function formatText(index, panel) {
		  return index + "";
}
$(document).ready(function() {
$("a.boxes").fancybox({'zoomSpeedIn': 100, 'zoomSpeedOut': 100, 'overlayShow': false });
$("a.login").fancybox({'frameWidth': 130, 'frameHeight': 200});
$("a.garantie").fancybox({'frameWidth': 570, 'frameHeight': 335});
$("a.vid").fancybox({'frameWidth': 480, 'frameHeight': 256});
$('.anythingSlider').anythingSlider({easing: "easeInOutExpo",autoPlay: true,delay: 9000,startStopped: false,animationTime: 600,hashTags: true,buildNavigation: false,pauseOnHover: true,startText: "Go",stopText: "Stop",navigationFormatter: formatText});
$("#q_search").autocomplete('qsearch.php',{ minChars:3,width: 120 });
$("#login_form").submit(function()
	{
		$("#msgbox").removeClass().addClass('messagebox').text('').fadeIn(1000);
		
		$("#submitbutton").hide();
		$("#submitbutton_wait").show();
	
		$.post("qlogin.php",{ user_name:$('#username').val(),password:$('#password').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='1')
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()
			{ 
			  $(this).html('').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
				 top.location.href='go.php';
			  });
			  
			});
		  }
		  else 
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  $("#username").css("background-color", "#EF5959");
			  $("#password").css("background-color", "#EF5959");
			  $("#submitbutton").show();
		      $("#submitbutton_wait").hide();
			});		
          }
				
        });
 		return false; 
	});
	$("#password").blur(function()
	{
		$("#login_form").trigger('submit');
	});
});

function updatePrice(form) {
	 document.getElementById("r_a_v").style.display = "block";
    tempprice=products_price;
	u_val_1=int_kid;
	u_val_2=int_id;
	u_val_3=art_id;
    for (var i = 0; i < form.elements.length; i++)
    {
      var e = form.elements[i];
      if ( e.type == 'select-one' )
      {
        Item = e.selectedIndex;
        Price = optionprice[e.options[Item].value];
        tempprice=tempprice+Price; 
		u_val_2=u_val_2+Price;
      }  
    }  
	l_h(u_val_1,u_val_2,u_val_3,0);
	l_h(u_val_1,u_val_2,u_val_3,1);
    
    document.getElementById("kpreis").innerHTML=addCommas(tempprice.toFixed(2))+" &#8364;";
	document.getElementById("preis_adv").innerHTML="oder kaufen f&uuml;r: <span style=\"font-size:14px\">"+addCommas(tempprice.toFixed(2))+" &#8364;</span> <span class=\"stern\">*</span>";
}

function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? ',<sup>' + x[1] + '</sup>': '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + '.' + '$2');
    }
    return x1 + x2;
}

function l_h(val1,val2,val3,val4) {

$.post("rechner.php", { val_1: +val1, val_2: +val2, val_3: +val3, val_4: +val4 },

function(data){ 
if ( val4 == '1' )
 {
 $('.ratenanzeige_adv').html(data); 
 } 
 else{
 $('.ratenanzeige').html(data);
 }
}); 
}


function klick(aid) {if(document.images) {(new Image()).src="artikel.php?aid="+aid+"&what=setklick";}return true;}
