


window.onload = function(){
      
	   if(document.getElementById("Menu")){
		   
		   var menu = document.getElementById("Menu");
		   var ul = menu.getElementsByTagName("UL")[0];
		   var a =  menu.getElementsByTagName("A");
		   var page = window.location.toString();
		   var ss = false;
		   
		   for(var i=0; i<a.length; i++){
			   var href = a[i].href;
			   if((page.indexOf(href)>0) || (page==href)){
				ss = href;
				var li = a[i].parentNode;
				var ul = li.parentNode;
				break;
			   }
		   }
		   

	       
		   if(ss){
			   if(li.getElementsByTagName("UL").length>0){
			   var ulul = li.getElementsByTagName("UL")[0];
			   ulul.style.display = "block";
			   }
			   
			   if(ul){
				  ul.style.display = "block";
			   }
			   
		   }
		   
		   
		  // $('#Menu a').sifr({ font: 'helvetica_bold', fontSize: '12px', color: '#3976B5', textTransform: 'uppercase', hoverColor : '#FFCC00' });
		   
	   }
	
}




function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}





function ControlFormArea(t){
	   var theForm = document.forms["AccessReservedArea"];
	   var user = theForm.username.value;
	   var pass = theForm.password.value;
	   var lang = theForm.lingua.value.toUpperCase();
	   var win = theForm.win.value;
	   var control = true;
	   
	   if(user==""){
		   
			   if(lang=="IT"){
				   alert("Attenzione: il campo 'username' è obbligatorio.");
			   }else{
				   alert("Attenction: the field 'username' is required.");
			   }
			   
			   theForm.username.focus();
		       control = false;
			   return false;
	   }
		   
	   
	   if(pass==""){
		   if(lang=="IT"){
			   alert("Attenzione: il campo 'password' è obbligatorio.");
		   }else{
			   alert("Attenction: the field 'password' is required.");
		   }
			   theForm.password.focus();
		       control = false;
			   return false;
	   }   
	   
	   
	   
	   if(control){
		   
		   
		   if(win=="popup"){
		   theForm.action="../riservata/access.php?win="+win+"&lingua="+lang+"&";
		   window.open ('',t,'scrollbars=auto,status=no,resizable=yes,top=50,left=50,width=700,height=600');
		   return true;
		   
		   window.opener.document.theForm.username.value="";
		   window.opener.document.theForm.password.value="";
		   
		   }else{
		     theForm.action="access.php?win="+win+"&lingua="+lang+"&";
		     document.forms[0].submit();
		     //return true;
		   }
		   
		   
		  
		   
		   
	   }
	   
	   
}






//////////////////////////////////////////////////////////////////////////


browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;



	if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 4)) {
	document.write("<link rel='stylesheet' HREF='../2010/css/ossida_ie.css' TYPE='text/css'>");
	}
	
	else if (browser_type == "Netscape" && (browser_version >= 4)) {
	document.write("<link rel='stylesheet' HREF='../2010/css/ossida_ns.css' TYPE='text/css'>");
	} 



////////////////////////////////////////////
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

<!--
	var currentTimer;
	var currentMenu;	


//////////////////////////////////////////// POPUP MAGAZZINO //////////////////////////////////

function NewWindow(mypage,myname,w,h,scroll)
	{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
	if(win.window.focus){
		win.window.focus();
	}
	}
	
//////////////////////////////////////////// POPUP MAGAZZINO //////////////////////////////////

function ApriPopUp(mypage,myname,w,h)
	{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,resizable=no';
	win = window.open(mypage,myname,settings)
	if(win.window.focus){
		win.window.focus();
	}
	}
	
////////////////////////////////////// SCRIVI MENU DI NAVIGAZIONE IN SELECT ///////////////////

function scrivi_menu_navigazione(lang){
  arr_select = new Array();
  
  if(lang=='it'){
  arr_select[0]="Menu di navigazione,0";
  arr_select[1]="Azienda,azienda.html";
  arr_select[2]="Stabilimento produttivo,stabilimento.html";
  arr_select[3]="Certificazioni,certificazioni.html";
  arr_select[4]="Dove siamo,dove-siamo.html";
  arr_select[5]="Contatti,contatti.html";
  arr_select[6]="ossidazione,ossidazione.html";
  arr_select[7]="Processo di ossidazione,processo-di-ossidazione.html";
  arr_select[8]="Impianti di brillantatura,impianti-brillantatura.html";
  //arr_select[9]="Processo di brillantatura,processo-di-brillantatura.html";
  arr_select[9]="Impianti di pulitura,impianti-pulitura.html";
  arr_select[10]="Impegno ambientale,impegno-ambientale.html";
  arr_select[11]="Impianti di depurazione,impianti-depurazione.html";
  }else if(lang=='en'){

  arr_select[0]="Navigation menu,0";
  arr_select[1]="Company,company.html";
  arr_select[2]="Factory floor,factory-floor.html";
  arr_select[3]="Certifications,certifications.html";
  arr_select[4]="Where we are,where-we-are.html";
  arr_select[5]="Contact us,contact-us.html";
  arr_select[6]="Anodic oxidation,oxidation.html";
  arr_select[7]="Oxidation process,oxidation-process.html";
  arr_select[8]="Brightning system,brightning-system.html";
  //arr_select[9]="Brightning process,brightning-process.html";
  arr_select[9]="Cleaning system,cleaning-system.html";
  arr_select[10]="Enviromental care,environmental-care.html";
  arr_select[11]="Depuration systems,depuration-system.html";
	  
  }
  
  
  var new_select = '<select name="qmenu" class="campo_input_piccolo" onChange="javascript:vai_alla_pagina(this)">';
  
 for (var i=0; i<arr_select.length; i++) { 
	  var n = arr_select[i].substring(0, arr_select[i].indexOf(','));
	  var pag = arr_select[i].substring(arr_select[i].indexOf(',')+1);
	  var v = URLDecode('http%3A%2F%2Fwww.ossida.it%2F' + lang.toUpperCase() + '%2F' + pag);
	  //var v = URLDecode('http:%5C%5C127.0.0.1%5Cossida%5C' + lang.toUpperCase() + '%5C' + pag);
	  new_select +='<option value="'+ v  +'">&nbsp;'+ n + '&nbsp;</option>';
	  
  }


  return (new_select + '</select>');
}

/////////////////////////////////////////// POP UP CENTRO PAGINA CHE SI RIDIMENSIONA


	function getUrl(dato) {
	   var tmp = (location.search.substring(1));  // catturo i dati dopo il ?
	   blocco = tmp.split("&");   // divido le sezioni con &
	   for (i=0;i<blocco.length;i++) {
		  briciola=blocco[i].split("=");  // divido la variabile dal valore con =
		  if (briciola[0]==dato) return briciola[1];
	   }
	}
	
	

	function PopupPic(picURL, name, descURL) { 
	    if(picURL && (picURL!='')){
		 window.open( "popup.html?picURL=" + picURL + "&descURL=" + descURL, name, "resizable=1,HEIGHT=200,WIDTH=200"); 
		}
	} 
   

function adjust_popup()
{
        var w, h, fixedW, fixedH, diffW, diffH, marcoW, marcoH;

        if (document.all) {
                fixedW = document.body.clientWidth;
                fixedH = document.body.clientHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - document.body.clientWidth;
                diffH = fixedH - document.body.clientHeight;
				
        } else {
                fixedW = window.innerWidth;
                fixedH = window.innerHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - window.innerWidth;
                diffH = fixedH - window.innerHeight;
        }
        w = fixedW + diffW;
        h = fixedH + diffH;
        if (h >= screen.availHeight) w += 10;
        if (w >= screen.availWidth)  h += 10;
        w = Math.min(w,screen.availWidth);
        h = Math.min(h,screen.availHeight);
        window.resizeTo(w,h+50);
        window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}


////////////////////////// CONTROLLA DATI FORM CONTATTI /////////////////////////////////////

  avviso = new Array();
  avviso["IT"] = new Array();
  avviso["EN"] = new Array();
  
  avviso["IT"][1]="Attenzione, il campo 'Referente' è obbligatorio.";
  avviso["IT"][2]="Attenzione, il campo 'Telefono' è obbligatorio.";
  avviso["IT"][3]="Attenzione, il campo 'Email' è obbligatorio.";
  avviso["IT"][4]="Attenzione, senza consenso al trattamento dati la vostra richiesta non può essere inoltrata.";

  avviso["EN"][1]="Warning: the field 'Representative' is required. Please fill it.";
  avviso["EN"][2]="Warning: the field 'Telephone' is required. Please fill it..";
  avviso["EN"][3]="Warning: the field 'E-mail' is required. Please fill it.";
  avviso["EN"][4]="Warning: you cannot send us your request without accepting all the Terms and Conditions listed below.";

  function ControllaDati(lingua) {
	  
   if (check_referente(lingua) && check_email(lingua) && check_consenso(lingua)) {
   document.forms["FormContatti"].submit();
   } else return(false);

  }   



  function check_referente(lingua) {

    if (document.forms["FormContatti"].referente.value == "") {
      window.alert(avviso[lingua][1]);
      document.forms["FormContatti"].referente.focus();
      return(false);
    }
    else return(true);  

  }




  function check_telefono(lingua) {
    if ((document.forms["FormContatti"].telefono.value == "")
	  && (document.forms["FormContatti"].contatto[0].checked)){
      window.alert(avviso[lingua][2]);
	  var DIV_IMG = document.getElementById('OBBL_TEL');
	  if(DIV_IMG.style.display=="none"){
		DIV_IMG.style.display="";  
	  }
      document.forms["FormContatti"].telefono.focus();
      return(false);
    }

    else return(true);  

  }


  function check_email(lingua) {
   var MyEmail = document.forms["FormContatti"].email.value;
   if ((MyEmail.indexOf("@") == -1) |
		(MyEmail.indexOf(".") == -1) |
		(MyEmail.length < 7)) {
			window.alert(avviso[lingua][3]);
			document.forms["FormContatti"].email.focus();
        return(false);
	}
    else return(true);

   }
   
   
  function check_consenso(lingua) {

    if (document.forms["FormContatti"].consenso.checked == false) {
      window.alert(avviso[lingua][4]);
      return(false);
    }
    else return(true);  

  }
  
/////////////////////////////////////////////// ASSEGNA IL RESPONSABILE AL FORM CONTATTI /////////////////////////////

function check_responsabile(id){
	
	     var old_foto = new Array();
	     old_foto[1] = "resp1_bn.jpg";
		 old_foto[2] = "resp1_bn.jpg";
		 old_foto[3] = "resp1_bn.jpg";
		 old_foto[4] = "resp1_bn.jpg";
	
	     for(var i=1; i<=4; i++){
			var new_id = "foto"+i;
			var check_id = "check"+i;
			var path = document.getElementById(new_id).src.substr(0, document.getElementById(new_id).src.lastIndexOf("/")+1);
			
			if(document.getElementById(new_id) && (id==new_id)){
				document.getElementById(new_id).style.border = "5px solid #3399CC";
				document.getElementById(check_id).checked=true;
				var img = path + old_foto[i].substr(0, old_foto[i].lastIndexOf("_")) + ".jpg";
				MM_swapImage(new_id,'',img,1);
				
			}else if(document.getElementById(new_id) && (id!=new_id)){
				document.getElementById(new_id).style.border = "5px solid #E5E5E5";
				document.getElementById(check_id).checked=false;
				
				var img = path + old_foto[i];
				MM_swapImage(new_id,'',img,1);
			}
			 
		 }
		 
}
function change_style(id, color, img){
	     var new_style = "5px solid "+color;
		 var check = "check"+id.substr(4,1);
	     if(document.getElementById(id) && (color!="")){
	        var element = document.getElementById(id);
			if(document.getElementById(check).checked==false){
		    element.style.border = new_style;
			MM_swapImage(id,'',img,1);
			}
				
		 }
	
}

////////////////////////////////  PREDEFINITI DI DREAMWEAVER /////////////////////////////////



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_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];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


//////////////////////////////////// /////////////////////////////////////////////////////////////

function vai_alla_pagina(select){
    if(select.selectedIndex>0){
    document.location.href = select.options[select.selectedIndex].value;
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////

	
	function URLDecode(encoded) {
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while

   return plaintext;
};

