/* header rollover functions */

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* END function rollover */


function EmptyField(fieldname)
{
	a=document.getElementById(fieldname);
	a.value="";
	//a.style.backgroundImage="none";
}

 function popWindow(openurl,w,h)
 {
  window.open(openurl,'Menu','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0, resizable=0,width=' + w + ',height=' + h + '');
 }
 

function showDiv( id, id2 ) {
    
    
    if(navigator.appName.indexOf("Microsoft") > -1){
		var canSee = 'block';
		} else {
		var canSee = 'table-row';
		}

		if ( id == 'A12' ) 			{
	    document.all.A01.style.visibility = 'hidden';
	    document.all.A01.style.display = 'none';
	    
	    document.all.A02.style.visibility = 'hidden';
	    document.all.A02.style.display = 'none';			
	   
	   	document.all.A12.style.visibility = 'visible';
	    document.all.A12.style.display = canSee;
		}
		else 	{	
	    document.all.A01.style.visibility = 'visible';
	    document.all.A01.style.display = canSee;
	    
	    document.all.A02.style.visibility = 'visible';
	    document.all.A02.style.display = canSee;
	    
	    document.all.A12.style.visibility = 'hidden';
	    document.all.A12.style.display = 'none';
	    
	    document.all.hid.style.visibility = 'hidden';
	    document.all.hid.style.display = canSee;
  	}
}

function showDivAddress( id, id2,v) {

    if(navigator.appName.indexOf("Microsoft") > -1){
		var canSee = 'block';
		} else {
		var canSee = 'table-row';
		}

		if ( v == 'IT')		{
	    document.all.hid.style.visibility = 'hidden';
	    document.all[ id ].style.visibility     = 'hidden';
	    document.all[ id2 ].style.visibility     = 'visible';
 	   	document.all.add1.style.visibility = 'hidden';
 	   	document.all.add1.style.display = canSee;
  	}
  	else		{
  		document.all.hid.style.visibility = 'visible';
	    document.all[ id ].style.visibility     = 'visible';
	    document.all[ id2 ].style.visibility     = 'hidden';
 	   	document.all.add1.style.visibility = 'visible';
 	   	document.all.add1.style.display = canSee;
  	}	
}


function showTipoPerson(tipopers) {
    
  
    if(navigator.appName.indexOf("Microsoft") > -1)		{
		var canSee = 'block';
		} else {
		var canSee = 'table-row';
		}
    
		
 var naz=document.getElementById('idNazione').value;
 
 if (tipopers =='A') {
     document.all.Nome.style.visibility = 'hidden';
     document.all.Nome.style.display = 'none';
 	   document.all.ragsoc.style.visibility = 'visible';
 	   document.all.ragsoc.style.display = canSee;
     if (naz =='IT') {
     					document.all.pIva.style.visibility = 'visible';
     					document.all.pIva.style.display = canSee;
 				      document.all.CF.style.visibility = 'visible';
     					document.all.CF.style.display = canSee;
     }
     document.all.ragsoc.focus();
  }
  else if ( tipopers == 'P') {
     document.all.Nome.style.visibility = 'visible';
     document.all.Nome.style.display = canSee;
     document.all.ragsoc.style.visibility = 'hidden';
     document.all.ragsoc.style.display = 'none';
     document.all.pIva.style.visibility = 'hidden';
     document.all.pIva.style.display = 'none';
 		 document.all.CF.style.visibility = 'hidden';
     document.all.CF.style.display = 'none';
  }
}


function showCampiItalia(naz) {
    
   if(navigator.appName.indexOf("Microsoft") > -1){
		var canSee = 'block';
		} else {
		var canSee = 'table-row';
		}

		/*
    document.all.pIva.style.visibility = 'hidden';
    document.all.pIva.style.display = 'none';
    document.all.CF.style.visibility = 'hidden';
    document.all.CF.style.display = 'none';
    document.all.ragsoc.style.visibility = 'hidden';
    document.all.ragsoc.style.display = 'none';  
    document.all.add1.style.visibility = 'hidden';
    document.all.add1.style.display = 'none';   
 		*/
 	
 if (naz =='IT' || naz =='') {
		 document.all.add1.style.visibility = 'hidden';
		 document.all.add1.style.display = 'none';
		 document.all.civ.style.visibility = 'visible';
		 document.all.civ.style.display = canSee;
  }
  else  {
 	   document.all.pIva.style.visibility = 'hidden';
     document.all.pIva.style.display = 'none';
     document.all.CF.style.visibility = 'hidden';
     document.all.CF.style.display = 'none';
 	   document.all.add1.style.visibility = 'visible';
 	   document.all.add1.style.display = canSee;
 	   document.all.civ.style.visibility = 'hidden';
 	   document.all.civ.style.display = 'none';
 	   document.all.ragsoc.style.visibility = 'visible';
 	   document.all.ragsoc.style.display = canSee;
  }
}







//////////////////////////////////////////////////////////////////////////



	var myRequest = null;	
	
	function CreateXmlHttpReq(handler)
	{
		var xmlhttp = null;
		
		try {
			xmlhttp = new XMLHttpRequest();
		} catch(e) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
		
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		
		xmlhttp.onreadystatechange = handler;
		return xmlhttp;
	}

	/*
		var xmlhttp = null;
		
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = handler;
		return xmlhttp;		
	}	*/

	function SwitchTipo(argc)
	{
		//var txt = document.example_form.txt.value;
		myRequest = CreateXmlHttpReq(myHandler);
		//alert ('/info/switch_contatti.php?tipoc=' + argc);
		myRequest.open("GET","/info/switch_contatti.php?tipoc="+argc);
		myRequest.send(null);
		
		var mioli = document.getElementById(argc);
		//alert (mioli.style.backgroundColor);
		//mioli.style.backgroundColor = "#f4f4f4";
		
		mioli.style.borderBottomColor = "#FFFFFF";
		mioli.style.borderBottomStyle = "solid";
		mioli.style.borderBottomWidth = "1px";
		mioli.style.borderTopColor = "#000000";
		mioli.style.borderTopStyle = "solid";
		mioli.style.borderTopWidth = "1px";
		mioli.style.borderLeftColor = "#000000";
		mioli.style.borderLeftStyle = "solid";
		mioli.style.borderLeftWidth = "1px";
		mioli.style.borderRightColor = "#000000";
		mioli.style.borderRightStyle = "solid";
		mioli.style.borderRightWidth = "1px";
		mioli.style.backgroundColor="#ffffff";	
		
		var d;
		ar_tabs=new Array();
		ar_tabs[1]="email";
		ar_tabs[2]="tel";
		ar_tabs[3]="fax";
		ar_tabs[4]="posta";
		
		for (d=1;d<=4;d++)		{
			if (ar_tabs[d]!=argc) 		{
				var curli = document.getElementById(ar_tabs[d]);
				curli.style.borderBottomColor = "#000000";
				curli.style.borderBottomStyle = "solid";
				curli.style.borderBottomWidth = "1px";		
				curli.style.borderTopColor = "#FFFFFF";
				curli.style.borderTopStyle = "solid";
				curli.style.borderTopWidth = "1px";
				curli.style.borderLeftColor = "#FFFFFF";
				curli.style.borderLeftStyle = "solid";
				curli.style.borderLeftWidth = "1px";
				curli.style.borderRightColor = "#FFFFFF";
				curli.style.borderRightStyle = "solid";
				curli.style.borderRightWidth = "1px";			
				curli.style.backgroundColor="#f1f1f1";										
			}	
		}
		
	}
	
	function myHandler() {
		//alert (myRequest.readyState + " " + myRequest.status);
		if (myRequest.readyState == 4 && myRequest.status == 200) 	{
			e = document.getElementById("strillorot1");
			//alert (myRequest.responseText);
			e.innerHTML = myRequest.responseText;
		}
	}	
	
	function SelCampo(argc)		{
		var a;
		 

		/////////////////////////////////
/*
ripulisco i campi ceh possono essere comparsi, altrimenti se si sceglie prodotto
e poi ordini restano i due campi
*/
		a = document.getElementById("no");
			a.style.visibility = 'hidden';
			a.style.display='none';	

			b = document.getElementById("cp");
			b.style.visibility = 'hidden';
			b.style.display='none';	
		////////////////////////////////////


		if(navigator.appName.indexOf("Microsoft") > -1){
		var canSee = 'block';
		} else {
		var canSee = 'table-row';
		}

		if (argc==1)		{
			a = document.getElementById("cp");
			a.style.visibility = 'visible';
			a.style.display=canSee;	
		}
		else if (argc==3)		{
			a = document.getElementById("no");
			a.style.visibility = 'visible';
			a.style.display=canSee;	
		}
		else 	{
			a = document.getElementById("no");
			a.style.visibility = 'hidden';
			a.style.display='none';	

			b = document.getElementById("cp");
			b.style.visibility = 'hidden';
			b.style.display='none';				
		}	
	}

function CheckForm()
{
	if ( document.myform.problema.value=='' )		
		alert ('Selezionare il tipo di richiesta.');

	if ( document.myform.testo.value=='' )	
		alert ('Inserire il testo della richiesta.');		

	if ( document.myform.email.value=='' )		
		alert ('Inserire il proprio indirizzo email.');			

		
		
}

function ShowDivConf(argv)
{
	var element = document.getElementById(argv);  

	element.style.display="block";
	element.style.visibility="visible";	
}

function HideDivConf(argv)
{
	var element = document.getElementById(argv);  
	
	element.style.display="none";
	element.style.visibility="hidden";	

}
function FadeDivConf(argv,timeout)
{
	$('#' + argv).fadeOut(timeout);
}
function FadeInDivConf(argv,timeout)
{
	$('#' + argv).fadeIn(timeout);
	/*
	alert(argv);
	$('#nanna').dialog();
	alert('nanna');
	*/
}

//for table rows in firefox
function ShowDivConfTr(argv)
{
	if(navigator.appName.indexOf("Microsoft") > -1){
		var canSee = 'block';
		} else {
		var canSee = 'table-row';
		}

	
	var element = document.getElementById(argv);  
	
	element.style.display=canSee;
	element.style.visibility="visible";
}


function ToggleLabel(divid)
{
	
	var obj = document.getElementById(divid);
	
	/* turn all labels off */
	/*document.getElementById('1').style.backgroundImage="url('https://secure.dmail.it/images/site/tab-off.gif')";*/
	document.getElementById('2').style.backgroundImage="url('https://secure.dmail.it/images/site/label_off.gif')";
	document.getElementById('3').style.backgroundImage="url('https://secure.dmail.it/images/site/label_off.gif')";
	document.getElementById('4').style.backgroundImage="url('https://secure.dmail.it/images/site/label_off.gif')";
	document.getElementById('5').style.backgroundImage="url('https://secure.dmail.it/images/site/label_off.gif')";
	
	document.getElementById(divid).style.backgroundImage="url('https://secure.dmail.it/images/site/label_on.gif')";
	

}

function ToggleLabel2(divid)
{
	
	var obj = document.getElementById(divid);
	//alert(divid);
	/* turn all labels off */

	if (document.getElementById('4')) {
		document.getElementById('4').style.backgroundImage="url('https://secure.dmail.it/images/site/label_off.gif')";
	}
	if (document.getElementById('5')) {
		document.getElementById('5').style.backgroundImage="url('https://secure.dmail.it/images/site/label_off.gif')";
	}

	/* turn clicked label on */
	if (document.getElementById(divid)) {
		document.getElementById(divid).style.backgroundImage="url('https://secure.dmail.it/images/site/label_on.gif')";
	}

}

function showhide(layer_ref) { 

var obj = document.getElementById(layer_ref);
var state = obj.style.display;
var visib = obj.style.visibility;

if (state == 'block') { 
state = 'none'; 
visib = 'hidden';
} 
else { 
state = 'block'; 
visib = 'visible'
} 
if (document.all) { //IS IE 4 or 5 (or 6 beta) 
eval( "document.all." + layer_ref + ".style.display = state"); 
eval( "document.all." + layer_ref + ".style.visibilty = visib"); 
} 
if (document.layers) { //IS NETSCAPE 4 or below 
document.layers[layer_ref].display = state; 
document.layers[layer_ref].visibility = visib; 
} 
if (document.getElementById &&!document.all) { 
hza = document.getElementById(layer_ref); 
hza.style.display = state; 
hza.style.visibility = visib; 
alert (hza.style.visibility);
} 
} 

function showRemoteCalendario() {
self.name = "main"; // names current window as "main"

var windowprops = "toolbar=0,location=0,left=10,top=10,directories=0,status=0, " +
"menubar=0,scrollbars=0,resizable=0,width=270,height=320";

OpenWindow = window.open("/servizi/calendario.php", "remote", windowprops); // opens remote control
}


 function AmicoWindow(url)
 {
  window.open(url,'Menu','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0, resizable=0,width=275,height=300');
 }


   function PopupPic(sPicURL) { 
     window.open( "/servizi/img_pop.php?"+sPicURL, "",  
     "resizable=1,HEIGHT=200,WIDTH=200"); 
   } 
   
      
function replace_criteo(criurl,div,tipo)
{
	var inputvar=document.getElementById(div).innerHTML;
	newinput = inputvar.replace(/www.dmail.it/g,criurl);

   var arlene = newinput.match(/COD \d+/g);
   if( arlene!=null )
   {
		var arr =[]
		for (var i=0; i<arlene.length; i++) 
		{
   		arr[i]=arlene[i].replace(/COD /g,'');
   		var res=get_critdivs(arr[i],tipo);
  		}
   }
   
   document.getElementById(div).innerHTML=newinput;
}


function get_critdivs(str,tipo)  
{  
	if(document.getElementsByTagName) 
	{
		var a = document.getElementsByTagName('div');
		for(var i = 0; i < a.length; i++) 
		{
		
		
			if(a[i].id && a[i].id.substring(0, 5).toLowerCase() == "crit_" ) 
			{
				var content=a[i].innerHTML;

				var reg = new RegExp(str);
				if (reg.test(content)) // Code has been found
				{
				  if (tipo==2)
				  {
				  	 var parentdiv='productcontent';
				  	 removeElement(parentdiv,a[i].id)
				  }
				  else
				  	{
					  var z=1;
					  var divresname='riserva_' + z;
					  var newcontent=document.getElementById(divresname).innerHTML;
					  a[i].innerHTML=newcontent;
					  var x =z+1;
					  nextdivname='riserva_' + x;
					  //copio il prossimo div nel div di riserva 1
					  if (document.getElementById(nextdivname))
					  {
					  	document.getElementById(divresname).innerHTML=document.getElementById(nextdivname).innerHTML;
					  }
					}
				}
			}
		
		}

	}
}
   
   
function removeElement(parentdiv,divNum) {
  var d = document.getElementById(parentdiv);
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}

function shorten(match, text1) {
  
  size=10;
  result=text1.substring(size);
  alert (result);
  
  /*
  amount = Number(amount) - 1;
  if (amount == 1) {
    unit = unit.slice(0, unit.length - 1);
  }
  else if (amount == 0) {
    unit = unit + "s";
    amount = "no";
  }
  */
  
 // return amount + " " + unit;
 return result;
}
function switch_product_img(divName, totalImgs,fotolink) {
			for (var i=1; i<=totalImgs; i++) {
				var showDivName = 'photo_' + i;
				var showObj = document.getElementById(showDivName);
				if (showDivName == divName) {
					showObj.style.display = 'block';
					if (fotolink!="") {
						document.getElementById('zoom').href=fotolink;
					}
				}
				else
					showObj.style.display = 'none';
				}
			}
			
function hide_all_show_one(container, show) {
	
var e = document.getElementsByTagName("div"); 

for (var i = 0; i < e.length; i++) { 
	e[i].style.display = 'none'; 
	if (e[i].id == show) e[i].style.display = 'block'; 
	} 
		
}

function carousel_on_off(container,divid) 
{

	var obj = document.getElementById(divid);
   var cont = document.getElementById(container);
	var all_divs = cont.getElementsByTagName("div");

	for (var i = 0; i < all_divs.length; i++) { 
		all_divs[i].innerHTML="<img src=\"/images/site/car_tabs_" + all_divs[i].id + "_OFF.png\" border=0 height=41>";
	} 
	obj.innerHTML="<img src=\"/images/site/car_tabs_" + obj.id + "_ON.png\" border=0 height=41>";


}

function add_div_carosello(container,macro,urlc,wh,hiddendiv) {
	
	var cardiv='carosellodiv';
	
	if (document.getElementById(cardiv)) {  
		 removeElement(container,cardiv);
		}

	getInfo('hp_macro=' + macro + '&hw='+ wh,urlc,hiddendiv,container);
}


function getInfo(pid,url2,hiddendiv,container)
{
	var qStr=pid;
	var element = document.getElementById(hiddendiv);  
	if (url2.length==0)
	{
	   element.innerHTML="";
	   return;
	}
	
	url2=url2+"?"+qStr;
	

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 alert ("Browser does not support HTTP Request");
	 return;
	}

	xmlHttp.open("GET", url2,true);   
	xmlHttp.onreadystatechange = function() {   
		//alert ('readyState'+xmlHttp.readyState + ' status' + xmlHttp.status);
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {   
		   var t  = document.getElementById(container);
		   var newdiv = document.createElement('div');
		   newdiv.id = "carosellodiv";
		   newdiv.name = "carosellodiv";
		   newdiv.style.zIndex="1";
		   newdiv.innerHTML=xmlHttp.responseText;  
		   t.appendChild(newdiv);	
		   
		   	var instanceOne = new ImageFlow();
	
	/* Create ImageFlow instances when the DOM structure has been loaded */
	//domReady(function()
	//{
		instanceOne.init({ ImageFlowID:'myImageFlow', 
						   circular: true, 
						   //reflectionPNG: true, 
						   xStep: 140, 
						   aspectRatio:2.264,
						   slider: true, 
						   buttons: true, 
						   captions: false, 
						   reflectionGET: '&bgc=eeeeee&fade_start=20%',
						   imageFocusMax: 2,
						   slideshowSpeed:1000,
						   imageCursor: 'pointer' });
		   
		}   
	}   
	
	xmlHttp.send(null);   
}

function willow() {
	alert('hello')
}

function Close_Omag_Div(omagarea,omagidv){
	
      var espressione  =  new RegExp(omagidv);
      var elems = document.getElementsByTagName("div"); 
      
      for (var i=0;i<elems.length;i++) {
				if (espressione.test(elems[i].id)) { 
			     elems[i].style.display="none";
			     elems[i].style.visibility="hidden";
   }  
 }
}

// per ajax
function showInfo(pid,div,url2)
{
	var qStr=pid;
	var element = document.getElementById(div);  
	
	if (url2.length==0)
	{
	   element.innerHTML="";
	   return;
	}
	
	url2=url2+"?"+qStr;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 alert ("Browser does not support HTTP Request");
	 return;
	}

	element.style.display="block";
	//alert (element.style.display)	;
	element.style.visibility="visible";
	element.innerHTML = '<center><img src=/images/dml/loading.gif></center>';  
	xmlHttp.open("GET", url2,true);   
	xmlHttp.onreadystatechange = function() {   
		//alert ('readyState'+xmlHttp.readyState + ' status' + xmlHttp.status);
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {   
		  element.innerHTML = xmlHttp.responseText;  
		}   
	}   
	
	xmlHttp.send(null);   
}


function showInfo2(pid,div,url2)
{
	var qStr=pid;
	var element = document.getElementById(div);  
	
	if (url2.length==0)
	{
	   element.innerHTML="";
	   return;
	}
	
	url2=url2+"?"+qStr;
	
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 alert ("Browser does not support HTTP Request");
	 return;
	}
	
	element.style.display="block";
	//alert (element.style.display)	;
	element.style.visibility="visible";
	element.innerHTML = '<center><img src=/images/dml/loading.gif></center>';  
	xmlHttp2.open("GET", url2,true);   
	xmlHttp2.onreadystatechange = function() {   
		//alert ('readyState'+xmlHttp.readyState + ' status' + xmlHttp.status);
		if (xmlHttp2.readyState == 4 && xmlHttp.status == 200) {   
		  element.innerHTML = xmlHttp2.responseText;   
		}   
	}   
	
	xmlHttp2.send(null);   

}

function showInfo3(pid,div,url2)
{
	var qStr=pid;
	var element = document.getElementById(div);  
	
	if (url2.length==0)
	{
	   element.innerHTML="";
	   return;
	}
	
	url2=url2+"?"+qStr;
	
	xmlHttp3=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 alert ("Browser does not support HTTP Request");
	 return;
	}
	
	element.style.display="block";
	//alert (element.style.display)	;
	element.style.visibility="visible";
	element.innerHTML = '<center><img src=/images/dml/loading.gif></center>';  
	xmlHttp3.open("GET", url2,true);   
	xmlHttp3.onreadystatechange = function() {   
		//alert ('readyState'+xmlHttp.readyState + ' status' + xmlHttp.status);
		if (xmlHttp3.readyState == 4 && xmlHttp.status == 200) {   
		  element.innerHTML = xmlHttp3.responseText;   
		}   
	}   
	
	xmlHttp3.send(null);   

}

// Script for ajax populating select fields
function GetXmlHttpObject(handler)
{
   var objXMLHttp=null
   if (window.XMLHttpRequest)
   {
       objXMLHttp=new XMLHttpRequest();
   }
   else if (window.ActiveXObject)
   {
       objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   return objXMLHttp
}
function replace_Html(div,content){

	document.getElementById(div).innerHTML=content;
	
}

function switch_divs(div1,div2) {
	//div1 viene "sostituito" da div2
	
	HideDivConf(div1);
	ShowDivConf(div2);

}

function ReverseContentDisplay(d) 		{
	if(d.length < 1) { 
		return; 
	}
	if(document.getElementById(d).style.display == "none") { 
		document.getElementById(d).style.display = "block"; 
	}
	else { 
		document.getElementById(d).style.display = "none"; 
	}
}

function reloadpayment(payment,page)	{
   
	 var sped = "";
   
   var f = document.getElementById('ordform');  // Step through the form elements  
   
	 for( var i = 0; i < document.forms['ordform'].elements.length; i++ )  {    
		if (document.forms['ordform'].elements[i].name=='X13' && document.forms['ordform'].elements[i].checked) {
			var sped=document.forms['ordform'].elements[i].value;
			//alert( f.elements[i].name + ' - ' + f.elements[i].value); 
			}
		 }

	 self.location=page + '?pos=3&pmt=' + payment + '&spd=' + sped + '#cc' ;

}

function popupWindow(url)
 {
  window.open(url,'Menu','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1, resizable=0,width=350,height=450');
 }
 
 function submitform()
 {
document.myForm.submit();
}

function reloadshipment(shipment,page,prezzoposta,prezzocor)
{
  var pay="";
  
   var f = document.getElementById( 'ordform' );  // Step through the form elements  
	 for( var i = 0; i < f.elements.length; i++ )  {    
		if (f.elements[i].name=='X14' && f.elements[i].checked) {
			var pay=f.elements[i].value;
			//alert( f.elements[i].name + ' - ' + f.elements[i].value); 
			}
		 }
  if (shipment=='2' && prezzoposta > prezzocor) {
  	if (confirm("Attenzione, hai scelto il servizio di recapito con Pacco Ordinario di Poste Italiane. Il costo è di Euro " + prezzoposta + " anziché Euro " + prezzocor + " utilizzando il Corriere espresso.")) {
	  self.location=page + '?pos=3&spd=' + shipment + '&pmt=' + pay + '#sped';
    }
     else {
	   return false;
   }
  }
  else {
    self.location=page + '?pos=3&spd=' + shipment + '&pmt=' + pay + '#sped' ;
  }
}


function Richiesta_Tel()
{
	if (confirm("Il numero di telefono è obbligatorio per spedizioni all'estero. Aggiorna i tuoi dati anagrafici.")) {
		return false;
	}
	else {
		return false;
	}
}

function Richiesta_Tel_eu()
{
	if (confirm("The phone number is mandatory for european shipping. Please update your personal information.")) {
		return false;
	}
	else {
		return false;
	}
}


function getformItems() 
{  if(!document.getElementById) 
	return;  
	var f = document.getElementById( 'ordform' );  // Step through the form elements  
	for( var i = 0; i < f.elements.length; i++ )  {    
		alert( f.elements[i].name );  
		alert( f.elements[i].value); 
		} 
} 

function showModalWindow(modal_window_id){
	//Get the A tag
	// var id = $(this).attr('href');
	
	var id = modal_window_id;

	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();

	//Set heigth and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	
	//transition effect		
	$('#mask').fadeIn(1000);	
	$('#mask').fadeTo("slow",0.8);	

	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();
	

	var docH = $(document).height();
	var docW = $(document).width();

	$(id).css('top',  (docH/2+winH/2)-$(id).height()/2);
	$(id).css('left', docW/2-$(id).width()/2);
	
	//transition effect
	$(id).fadeIn(2000); 

	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});

	$('#d-button-submit').click(function (e) {
		document.dati.submit();
		$('#mask').hide();
		$('.window').hide();
	});

	$('#d-button-cancel').click(function (e) {
		$('#mask').hide();
		$('.window').hide();
	});		
}

