function inizio(){
ta = 1;
for (ta = 1; ta <= 5; ta++) { new Effect.Fade('box_'+ta, { duration: 0.1 }); }
Compare_div(1);
}

function OnChangeText()
		{
			
		var pattern = "Insert Product Code";
		var stringa = document.getElementById("txtproduct").value;
		var risultato = stringa.search(pattern);	
			
		if(risultato != -1){
         document.getElementById("txtproduct").value = "";} 
		}

function OnChangeText_mail()
		{
			
		var pattern = "E-Mail";
		var stringa = document.getElementById("subscribe_newsletter").value;
		var risultato = stringa.search(pattern);	
			
		if(risultato != -1){
         document.getElementById("subscribe_newsletter").value = "";} 
		}
		
function OnChangeText_username()
		{
			
		var pattern = "Username";
		var stringa = document.getElementById("username_form").value;
		var risultato = stringa.search(pattern);	
			
		if(risultato != -1){
         document.getElementById("username_form").value = ""; }
		}

function OnChangeText_password()
		{
         document.getElementById("password_form").value = "";
		}

function MorphEffect(i){
   	   if(i==1 || i == 4 || i == 5 || i == 8){
       new Effect.Morph('bar_1', 
       {style:'width:150px;',
         duration:0.8}); }
   	   if(i==1 || i == 3 || i == 4 || i == 6){	
       new Effect.Morph('bar_2', 
       {style:'width:190px;',
         duration:0.8}); }  
       if(i==1 || i == 2 || i == 5 || i == 7){	
       new Effect.Morph('bar_3', 
       {style:'width:350px;',
         duration:0.8}); }
       if(i==5 || i == 7 || i == 8 || i == 2){	
       new Effect.Morph('bar_4', 
       {style:'width:180px;',
         duration:0.8}); } 
   	   if(i==1 || i == 3 || i == 4 || i == 6 ){	
       new Effect.Morph('bar_5', 
       {style:'width:150px;',
         duration:0.8}); }         
   	   if(i==2 || i == 3 || i == 6 || i == 8){	
       new Effect.Morph('bar_6', 
       {style:'width:200px;',
         duration:0.8}); } 
   	   if( i == 4 || i==6 || i == 7 || i == 8){	
       new Effect.Morph('bar_7', 
       {style:'width:250px;',
         duration:0.8}); }  
   	   if(i==1 || i == 6 || i == 5){	
       new Effect.Morph('bar_8', 
       {style:'width:280px;',
         duration:0.8}); }  
       if(i==2 || i == 5 || i == 6 || i == 8){	
       new Effect.Morph('bar_9', 
       {style:'width:350px;',
         duration:0.8}); }
       if(i==1 || i == 3 || i == 6 || i == 8){	
       new Effect.Morph('bar_10', 
       {style:'width:260px;',
         duration:0.8}); }  
	   if(i==3 || i == 7 || i == 9 ){	
       new Effect.Morph('bar_10', 
       {style:'width:350px;',
         duration:0.8}); }  
       }

function BackMorph(){
       new Effect.Morph('bar_1', 
       {style:'width:100px;',
         duration:0.8});
       new Effect.Morph('bar_2', 
       {style:'width:60px;',
         duration:0.8});
       new Effect.Morph('bar_3', 
       {style:'width:200px;',
         duration:0.8});
       new Effect.Morph('bar_4', 
       {style:'width:150px;',
         duration:0.8});
       new Effect.Morph('bar_5', 
       {style:'width:210px;',
         duration:0.8});
       new Effect.Morph('bar_6', 
       {style:'width:50px;',
         duration:0.8});
       new Effect.Morph('bar_7', 
       {style:'width:200px;',
         duration:0.8});
       new Effect.Morph('bar_8', 
       {style:'width:150px;',
         duration:0.8});
       new Effect.Morph('bar_9', 
       {style:'width:220px;',
         duration:0.8});
       new Effect.Morph('bar_10', 
       {style:'width:210px;',
         duration:0.8}); 
	   new Effect.Morph('bar_11', 
       {style:'width:240px;',
         duration:0.8});
       }    

function submenuMorph(element){
	   colore = $(element).getStyle('color');
	   if (colore != "rgb(12, 12, 12)"){
       new Effect.Morph(element, 
       {style:'color:#000;',
         duration:0.5});
	   }                                     
       }

function BacksubmenuMorph(element){
	   colore = $(element).getStyle('color');
	   if (colore != "rgb(12, 12, 12)"){	
       new Effect.Morph(element, 
       {style:'color:#998675;',
         duration:0.5}); }                                     
       }
       


function Warrantyform() {
		
		new Ajax.Updater('warranty', 'INC/warranty.php', {
		method: 'post',
		parameters: 'id='+i,
		encoding: 'iso-8859-1',
		asynchronous:false,
		evalScripts:true,

		onSuccess : function (xmlHttp)
		{  },

		onComplete : function (xmlHttp)
		{ }
		
		});
}	

function Searchform(i, a) {

		if(a == 0){
		param= 'search='+i;
		}
		else{
		param='search='+i+'&selezione='+a;	
		}

		new Ajax.Updater('new_search_data', 'INC/search.php', {
		method: 'post',
		parameters: param,
		encoding: 'iso-8859-1',
		asynchronous:false,
		evalScripts:true,

		onSuccess : function (xmlHttp)
		{  },

		onComplete : function (xmlHttp)
		{ 
		}
		
		});
}

function Searchform_back(){
		new Ajax.Updater('new_search_data', 'INC/search_base.php', {
		encoding: 'iso-8859-1',
		asynchronous:false,
		evalScripts:true
		});
}


function Compare_div(a) {

		new Ajax.Updater('compara_block', 'INC/compare.php', {
		encoding: 'iso-8859-1',
		method: 'post',
		parameters: 'a='+a,
		asynchronous:true,
		evalScripts:true	
		});
		
		new Ajax.Updater('C_0', 'INC/compare_detail.php', {
		encoding: 'iso-8859-1',
		method: 'post',
		parameters: 'a='+a,
		asynchronous:true,
		evalScripts:true	
		});
		
			 
 	 	//settaValori();
		
		
}	

function FirstLevel(ida, i) {
		
		new Effect.Fade('centrale', { duration: 1.0});
		
		para = '3';
		
		for(t = 1; t <= 7; t++){			
		para2 = $('box_'+t).getStyle('zIndex');
		if(parseInt(para2) > parseInt(para)){ para = para2; }					
		}
		
		$('box_'+i).setStyle({
  			zIndex: parseInt(para) + 1
  			});
		
		new Ajax.Updater('box_'+i, 'INC/text1.php', {
		method: 'post',
		parameters: 'id='+ida,
		encoding: 'iso-8859-1',
		asynchronous:false,
		evalScripts:true,

		onSuccess : function (xmlHttp)
		{  },

		onComplete : function (xmlHttp)
		{ 
		new Effect.BlindDown('box_'+i, {duration: 1.0});
		for(t = 1; t <= 7; t++){
		if(t != i){new Effect.Fade('box_'+t, { duration: 1.0 });}
		}
		initialize();
		}
		});
}

function gotop(a)
{
	this.location.href="product.php?c="+a;
	
}

function search_re(){
	Effect.toggle('new_search', 'blind', { duration: 1.0 });
}

function compare_div(){
	Effect.toggle('C_0', 'blind', { duration: 1.0 });
	Effect.toggle('C_text', 'appear', { duration: 1.0 });
	
	
	if($("compara_puls_img")){
	stringa = $("compara_puls_img").getStyle('backgroundImage');
	var stringa_search = stringa.indexOf('compare_no.jpg');
	if(stringa_search != -1){
		
		
		$('compara_puls_img').setStyle({
  			background: 'url(IMG/compare_yes.jpg) top right no-repeat'
  			});		
  			
			}
	if(stringa_search == -1){
		
		$('compara_puls_img').setStyle({
  			background: 'url(IMG/compare_no.jpg) top right no-repeat'
  			});	
		}
	}	
		
}

function remove_element(sValore){
	delCookie(sValore);
	
		new Ajax.Updater('box_6', 'INC/text1.php', {
		encoding: 'iso-8859-1',
		method: 'post',
		parameters: 'id=14',
		asynchronous:false,
		evalScripts:true	
		});
	
}

function elaboraRMF(){	
	
	 err = 0;
	 testo = "";
	
	 var nome = document.warrantyform.name.value;
     var mail = document.warrantyform.mail.value;
	 var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;     
	
	 if(nome == ""){ 
	 	err = 1;
	 	testo = testo + "Please insert a customer name\n";
	 }	
	 if(!email_reg_exp.test(mail) || (mail == "") || (mail == "undefined")){ 
	 	err = 1;
	 	testo = testo + "Please insert a valid email\n";
	 }
	 
	 if(err == 0){
	 	document.warrantyform.action = "page.php?id=27";
   		document.warrantyform.submit();
	 }
	 else {
	 	alert(testo); 
	 	return false;
	 }
	
}	
	
