/* Cufon replacement */

Cufon.replace('h1', { fontFamily: 'ITC Avant Garde Gothic Std Bold' });
Cufon.replace('h2', { fontFamily: 'ITC Avant Garde Gothic Std' });
Cufon.replace('h3', { fontFamily: 'ITC Avant Garde Gothic Std' });
Cufon.replace('h4', { fontFamily: 'ITC Avant Garde Gothic Std' });
Cufon.replace('.cart h2', { fontFamily: 'ITC Avant Garde Gothic Std Bold' });

function BrowserName() {
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("chrome") != -1) return 'Chrome';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) 
	{
		if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
			return navigator.userAgent.substr(0,agt.indexOf('\/'));
	
		} else { 
			return 'Netscape';
		}
	} else if (agt.indexOf(' ') != -1) {
		return navigator.userAgent.substr(0,agt.indexOf(' '));
	} else { return navigator.userAgent;}
}


/* Jquery functions */
$(document).ready(function(){
	
	if (BrowserName() != "Internet Explorer") {
		$('#plus_white').rotate(45);
	}
	else
	{
		$('#plus_white').attr("src", "/images/plus_white.png");
	}
	
	/* Click su lista prodotti */
    $("#headLink").show();
    $("#cartheader").hide();

	 
	/* Caricamento su pagina prodotti */
	$("#prodotti .dett").show();
    $("#prodotti #productsList .notTheFirst").show();
	$("#prodotti #main").slideDown();
	
	$("#products .dett").show();
    $("#products #productsList .notTheFirst").show();
	$("#products #main").slideDown();

	
	/* Caricamento su pagina carrello */
	$("#carrello #cartheader").show();
	$("#cart #cartheader").show();
	$("#cart-en #cartheader").show();
	
	/* Caricamento su pagina registrazione */
	$("#registrationpage #cartheader").show();
	
	/* Caricamento su pagina checkout */
	$("#checkout #cartheader").show();
	 
});

function showHeadLink()
{
	
	     $("#cartheader").slideUp(800);
		 //$.scrollTo('#productsList', 800);
	     $(".dett").fadeIn();
	     $("#main").slideDown();
	     $("#productsList .notTheFirst").show();
	     $("#headLink").hide();

}

function showLogin ()
{
	if ($('#loginFormArea').css("display") == "none")
	{
		$('#loginFormArea').slideDown("slow");
		
		if (BrowserName() != "Internet Explorer") {
			$('#plus_white').rotate(0);
		}
		else
		{
			$('#plus_white').attr("src", "/images/per_white.png");
		}
	}
	else
	{
		$('#loginFormArea').slideUp("slow");
		if (BrowserName() != "Internet Explorer") {
			$('#plus_white').rotate(45);
		}
		else
		{
			$('#plus_white').attr("src", "/images/plus_white.png");
		}
	}	
}

function showCustomerData ()
{
	if ($('#customerData').css("display") == "none")
	{
		$('#customerData').slideDown("slow");
		
		if (BrowserName() != "Internet Explorer") {
			$('#plus_white').rotate(0);
		}
		else
		{
			$('#plus_white').attr("src", "/images/per_white.png");
		}
	}
	else
	{
		$('#customerData').slideUp("slow");
		if (BrowserName() != "Internet Explorer") {
			$('#plus_white').rotate(45);
		}
		else
		{
			$('#plus_white').attr("src", "/images/plus_white.png");
		}
	}
	$.scrollTo(0, 800);
	
}


function showRegistration (checkout)
{
	$('#loginFormArea').hide();
	$('#personalData').show();
	if (checkout == 1)
		$("#targetCheckout").val('1');
}

function hideRegistration ()
{
	$('#personalData').slideUp("slow");
	$.scrollTo(0, 800);
}

function hideCustomerData ()
{
	$('#customerData').slideUp("slow");
	if (BrowserName() != "Internet Explorer") {
		$('#plus_white').rotate(45);
	}
	else
	{
		$('#plus_white').attr("src", "/images/plus_white.png");
	}
	$.scrollTo(0, 800);
}


/* Increase - Decrease */
var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}





