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 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() {
		
		new Ajax.Updater('C_0', 'INC/compare_detail.php', {
		encoding: 'iso-8859-1',
		asynchronous:false,
		evalScripts:true	
		});
		
 	 	//settaValori();	
		
}	

function Investor(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/investor1.php', {
		method: 'post',
		parameters: 'la=1',
		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(){
	
	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;
	 }
	
}	
	
function setCookie(sValore) {

  new Ajax.Updater('compara_block', 'INC/compare.php', {
		encoding: 'iso-8859-1',
		method: 'post',
		parameters: 'id='+sValore,
		asynchronous:false,
		evalScripts:true
		});
  
  document.getElementById("prod_"+sValore).style.backgroundImage = "url(IMG/check_ok.jpg)";
  
}
function recuperaCookie() {

  new Ajax.Updater('compara_block', 'INC/compare.php', {
		encoding: 'iso-8859-1',
		asynchronous:false,
		evalScripts:true
		});
  
}
function delCookie(sValore) {

  new Ajax.Updater('compara_block', 'INC/compare.php', {
		encoding: 'iso-8859-1',
		method: 'post',
		parameters: 'del='+sValore,
		asynchronous:false,
		evalScripts:true
		});
		
		document.getElementById("prod_"+sValore).style.backgroundImage = "url(IMG/check_no.jpg)";
		
		Compare_div();
  
}

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	
		});
	
}
