﻿
/* _____________________________ ON ERROR ____________________________________________ */
function silenzia()  {return true}
// window.onerror=silenzia();
/* ___________________________________________________________________________________ */

////////////////////////////////////////////// INIZIO RICAVA COORDINATE DEL MOUSE
var IE = document.all?true:false;
// if (!IE) document.captureEvents(Event.MOUSEMOVE)
if (!IE) document.addEventListener('mousemove', getMouseXY, true);
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	// document.Show.MouseX.value = tempX;
	// document.Show.MouseY.value = tempY;
	return true;
}
////////////////////////////////////////////// FINE RICAVA COORDINATE DEL MOUSE


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function linkblank(src){
	MM_openBrWindow(src,'','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
}

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_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];}
}


/* INIZIO SCRIPT PER MAPPE GOOGLE ----------------------------------------------------------- */

//<![CDATA[

var map = null;
var geocoder = null;

var coordinate = "";

/*cerca un indirizzo*/
function showAddress(address,titolo) {

	// document.getElementById('daddr').value=address;

  if (GBrowserIsCompatible()) {
	geocoder = new GClientGeocoder();
  }

  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  // alert(address + " non trovato");
		} else {
		/*zoom*/

			coordinate = point;

			map = new GMap2(document.getElementById("map"));
			
			/*mappa - satellite - ibrida */
			map.addControl(new GMapTypeControl());
			
			/*controller con barra vert*/
			// map.addControl(new GSmallMapControl());
			map.addControl(new GLargeMapControl());
			
			/*zoom box, in basso a dx*/
			map.addControl(new GOverviewMapControl(),
			
			new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(9, 9)));
			
			/*COORDINATE DI PARTENZA DELLA MAPPA*/
			map.setCenter(point, 15);
			// map.setCenter(point, 12);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			if(titolo){
				marker.openInfoWindowHtml(titolo+"&nbsp;&nbsp;&nbsp;&nbsp;");
			} else {
				marker.openInfoWindowHtml(address+"&nbsp;&nbsp;&nbsp;&nbsp;");
			}
		}
	  }
	);
  }
}

//]]>

/* FINE SCRIPT PER MAPPE GOOGLE ----------------------------------------------------------- */

/* -------------- INIZIO FUNZIONE PER GESTIRE POST E GET IN AJAX --------------------------------------------- */

function xmlhttpPost(strURL, idBlock, idFormPost, azione) {
	/* INIZIO CUSTOMIZZAZIONE X OPERAWEB */
		setlivelli("loading",1);
	/* FINE CUSTOMIZZAZIONE X OPERAWEB */
	var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if(idFormPost && idFormPost!=""){
	    self.xmlHttpReq.open('POST', strURL, true);
	} else {
	    self.xmlHttpReq.open('GET', strURL, true);
	}
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText, idBlock);
			/* INIZIO CUSTOMIZZAZIONE X MANFROTTO INDIA */
				setlivelli("loading",0);
			/* FINE CUSTOMIZZAZIONE X MANFROTTO INDIA */
		}
    }
	if(self.xmlHttpReq && idFormPost && idFormPost!=""){
	    self.xmlHttpReq.send(getquerystring(idFormPost));
	} else {
	    self.xmlHttpReq.send(null);
	}
}

function getquerystring(idFormPost) {
	var qstr = "";
	var form = document.getElementById(idFormPost);
	for (keyVar in form) {
		if(form[keyVar] && form[keyVar].value!=undefined){
			qstr = qstr + keyVar + '=' + escape(form[keyVar].value) + "&";  // NOTE: no '?' before querystring
		}
	}
    return qstr;
}

function updatepage(str, idBlock){
	if(top.document.getElementById(idBlock)){ oggetto = top.document.getElementById(idBlock); }
	if(parent.document.getElementById(idBlock)){ oggetto = parent.document.getElementById(idBlock); }
	if(document.getElementById(idBlock)){ oggetto = document.getElementById(idBlock); }
	if(oggetto){
		oggetto.innerHTML = str;
	}
}

/* -------------- FINE FUNZIONE PER GESTIRE POST E GET IN AJAX --------------------------------------------- */


preUrl = "";
preBlock = "";
preFormPost = "";

var chiudiMS;

function ajaxWin(strURL, idBlock, idFormPost){
	// if(preUrl==strURL && preBlock==idBlock && preFormPost==idFormPost){
		// richiesta già eseguita	
	if(0){
	} else {
		preUrl = strURL;
		preBlock = idBlock;
		preFormPost = idFormPost;
		if(document.getElementById(idBlock)){
			xmlhttpPost(strURL,idBlock, idFormPost);
		} else {
			location.href=strURL;
		}
	}
}

function setOpacity(idDiv,value){
	if(prendiElementoDaId(idDiv)){
		oggetto=prendiElementoDaId(idDiv);
		oggetto.style.opacity = value/10;
		oggetto.style.filter = 'alpha(opacity=' + value*10 + ')';
	}
}

function setlivelli(nomediv,stato){
	if(prendiElementoDaId(nomediv)){
		oggetto=prendiElementoDaId(nomediv);
		var statoOra = 0;
		if(oggetto.style.visibility=='visible'){
			statoOra = 1;
		}
		if(stato==1){ // && statoOra==0
			oggetto.style.visibility='visible';
		}
		if(stato==0){ // && statoOra==1
			oggetto.style.visibility='hidden';
		}
	}

	/* INIZIO CUSTOMIZZAZIONE X OPERAWEB */

	/* FINE CUSTOMIZZAZIONE X OPERAWEB */
}

function valId(id){
	if(prendiElementoDaId(id)){
		oggetto=prendiElementoDaId(id);
		return oggetto.value;
	} else {
		return ("err");	
	}
}


/* ---------------------------------------------------------------------------- */
/* ---------------- INIZIO SCRIPT PER IL SITO --------------------------------- */
/* ---------------------------------------------------------------------------- */

function posizionaDiv(idDiv,cooX,cooY){
	oggetto=prendiElementoDaId(idDiv);
	oggetto.style.marginLeft=cooX+"px";
	oggetto.style.marginTop=cooY+"px";
}


function boxMouse(id, urltoload, idDiv, offX, offY, closeTimeOut){
	if(!(undefined===window.chiudiMS)){
		clearTimeout(chiudiMS);
	}
	var posiziona=posizionaDiv(idDiv,tempX+offX,tempY+offY);
	oggetto=prendiElementoDaId(idDiv);
	oggetto.innerHTML = "";
	var invia=ajaxWin(urltoload+id,idDiv);
	closeTxtPop(idDiv,closeTimeOut);
}

function closeTxtPop(idDiv,closeTimeOut){
	if(!(undefined===window.chiudiMS)){
		clearTimeout(chiudiMS);
	}
	chiudiMS = setTimeout("setlivelli('"+idDiv+"',0)",closeTimeOut);
}

var arrMenus=new Array();

function swappaDiv(livOn,livOff){
	setlivelli(livOn,1);
	setlivelli(livOff,0);
	if(livOff.substring(5,8)=="Off"){
		arrMenus[livOn]=setTimeout("swappaDiv('"+livOff+"','"+livOn+"');",5000);
	}
}

function modform(idCampo,valore){
	oggetto=prendiElementoDaId(idCampo);
	oggetto.value=valore;
}

function promptQuest(domanda, tipo, url, target){ // tipo=aj(ajax), ht(html)
	if(confirm(domanda)){
		if(tipo=="aj"){
			ajaxWin(url,target);
		}
		if(tipo=="ht"){
			window.location.href=y;
		}
	}
}

function vai(url){
	location.href=url;
}

function is_email(valore){
	indirizzo = valore;
	if (window.RegExp) {
		var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
		var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
		var regnv = new RegExp(nonvalido);
		var regv = new RegExp(valido);
		if (!regnv.test(indirizzo) && regv.test(indirizzo)){
			return false;
		}
		return true;
	} else {
		if(indirizzo.indexOf("@") >= 0){
			return false;
		}
		return true;
	}
}

function randNum(){
	return Math.round(100000*Math.random());	
}

function getElementsByClassName(classname) {
    var rl = new Array();
    var re = new RegExp('(^| )'+classname+'( |$)');
    var ael = document.getElementsByTagName('*');
    var op = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
    if (document.all && !op) ael = document.all;
    for(i=0, j=0 ; i<ael.length ; i++) {
        if(re.test(ael[i].className)) {
        	rl[j]=ael[i];
            j++;
        }
    }
    return rl;
}

function stessa_altezza(className) {
	cols = getElementsByClassName(className);

	var max = 0;
	
	for(var i=0; i<cols.length; i++) {
		if(cols[i].clientHeight > max) max = cols[i].clientHeight;
	}
	
	for(i=0; i<cols.length; i++) {
		cols[i].style.height = max + "px";
	}

	for(i=0; i<cols.length; i++) {
		if(cols[i].clientHeight > max) {
			offset = cols[i].clientHeight - max;
			cols[i].style.minHeight = (parseInt(cols[i].style.height)) - offset + "px";
		}
	}
}

function altezzeLiv2(){
	oggetto1=prendiElementoDaId('colsx_1');
	oggetto2=prendiElementoDaId('coldx_1');
	max=0;
	if(oggetto1.clientHeight > max) max = oggetto1.clientHeight;
	if((oggetto2.clientHeight+25) > max) max = oggetto2.clientHeight;
	oggetto1.style.minHeight = max+45+"px";
	oggetto2.style.minHeight = max-2+"px";

	oggetto1=prendiElementoDaId('colsx');
	oggetto2=prendiElementoDaId('coldx_sx');
	oggetto3=prendiElementoDaId('coldx_dx');
	max=0;
	if(oggetto1.clientHeight > max) max = oggetto1.clientHeight;
	if(oggetto2.clientHeight > max) max = oggetto2.clientHeight;
	if(oggetto3.clientHeight > max) max = oggetto3.clientHeight;
	oggetto1.style.minHeight = max+25+"px";
	oggetto2.style.minHeight = max+"px";
	oggetto3.style.minHeight = max+"px";
}

function swappaVis(idBlock, classOn, classOff){
	oggetto=prendiElementoDaId(idBlock);
	if(oggetto){
		if(oggetto.style.height=="0px"){
			oggetto.style.height="auto";
			oggetto.style.overflow="visible";
			oggetto=prendiElementoDaId('tit_'+idBlock);
			oggetto.className = 'blocco categ';
		} else {
			oggetto.style.height="0px";
			oggetto.style.overflow="hidden";
			oggetto=prendiElementoDaId('tit_'+idBlock);
			oggetto.className = 'blocco categ_off';
		}
	}
}

function prodDesc(){
	objDescr=prendiElementoDaId("infopdesc");
	objTech=prendiElementoDaId("infoptech");
	objDescr_tit=prendiElementoDaId("tit_infopdesc");
	objTech_tit=prendiElementoDaId("tit_infoptech");

	if(objDescr){
		objDescr.style.height="auto";
		objDescr.style.overflow="visible";
	}
	if(objTech){
		objTech.style.height="0px";
		objTech.style.overflow="hidden";
	}
	if(objDescr_tit){
		objDescr_tit.className="alignCenter nero";
		objDescr_tit.style.background="";
	}
	if(objTech_tit){
		objTech_tit.className="alignCenter";
		objTech_tit.style.background="url(img/div_orizz.gif) bottom left repeat-x";
	}
}

function prodTech(){
	objDescr=prendiElementoDaId("infopdesc");
	objTech=prendiElementoDaId("infoptech");
	objDescr_tit=prendiElementoDaId("tit_infopdesc");
	objTech_tit=prendiElementoDaId("tit_infoptech");
	if(objTech){
		objTech.style.height="auto";
		objTech.style.overflow="visible";
	}
	if(objDescr){
		objDescr.style.height="0px";
		objDescr.style.overflow="hidden";
	}
	if(objTech_tit){
		objTech_tit.className="alignCenter nero";
		objTech_tit.style.background="";
	}
	if(objDescr_tit){
		objDescr_tit.className="alignCenter";
		objDescr_tit.style.background="url(img/div_orizz.gif) bottom left repeat-x";
	}
}

function posizStores(){
	oggetto=prendiElementoDaId('contImg');
	altezza=Math.round(oggetto.clientHeight /2);
	oggetto=prendiElementoDaId('bottStores');
	oggetto.style.marginTop=altezza+"px";
}

/* ---------------------------------------------------------------------------- */
/* ---------------- FINE SCRIPT PER IL SITO ----------------------------------- */
/* ---------------------------------------------------------------------------- */


/* ---------------------------------------------------------------------------- */
/* ---------------- INIZIO SCRIPT PER I FORM ---------------------------------- */
/* ---------------------------------------------------------------------------- */


function contrContact(){
	invio=1;
	errors="";
	oggetto=document.getElementById("contactus");
	/*
	oggetto1=document.getElementById("photo");
	oggetto2=document.getElementById("video");
	oggetto3=document.getElementById("lighting");
	*/
	oggettocomments=document.getElementById("comments");
	oggettofirstName=document.getElementById("firstName");
	oggettolastName=document.getElementById("lastName");
	oggettoCountry=document.getElementById("country");
	oggettoemail=document.getElementById("email");

	/*
	if(!(oggetto1.checked) && !(oggetto2.checked) && !(oggetto2.checked)){ if(invio==1){ errors+="Select area of interest" }; invio=0; }
	*/
	if(oggettocomments.value==""){ if(invio==1){ oggettocomments.focus(); errors+="Please insert your message"; }; invio=0; }
	if(oggettofirstName.value==""){ if(invio==1){ oggettofirstName.focus(); errors+="Please insert your first name"; }; invio=0; }
	if(oggettolastName.value==""){ if(invio==1){ oggettolastName.focus(); errors+="Please insert your last name"; }; invio=0; }
	if(oggettoCountry.value==""){ if(invio==1){ oggettoCountry.focus(); errors+="Please insert your country"; }; invio=0; }

	if(oggettoemail.value==""){ if(invio==1){ oggettoemail.focus(); errors+="Please insert your E-mail"; }; invio=0; }
	if(oggettoemail.value.indexOf('@')<1 || oggettoemail.value.indexOf('@')==(oggettoemail.value.length-1)){ if(invio==1){ oggettoemail.focus(); errors+="Wrong E-mail"; }; invio=0; }

	if(invio==0){
		alert(errors);
		return (false);
	} else {
		oggetto.submit();
	}
}

/* ---------------------------------------------------------------------------- */
/* ---------------- FINE SCRIPT PER I FORM ------------------------------------ */
/* ---------------------------------------------------------------------------- */


