// JavaScript Document
function seleziona(stile) {
	switch (stile) {
		case 'N': document.getElementById('div_D').style.display = 'none';
				  document.getElementById('div_C').style.display = 'none';
				  document.getElementById('div_H').style.display = 'none';
				  document.getElementById('div_N').style.display = 'block';
				  document.getElementById('img_D').src = 'immagini/design_op.jpg';
				  document.getElementById('img_C').src = 'immagini/classic_op.jpg';
				  document.getElementById('img_H').src = 'immagini/chick_op.jpg';
				  document.getElementById('img_N').src = 'immagini/natural.jpg';
				  break;
		case 'D': document.getElementById('div_N').style.display = 'none';
				  document.getElementById('div_C').style.display = 'none';
				  document.getElementById('div_H').style.display = 'none';
				  document.getElementById('div_D').style.display = 'block';
				  document.getElementById('img_N').src = 'immagini/natural_op.jpg';
				  document.getElementById('img_C').src = 'immagini/classic_op.jpg';
				  document.getElementById('img_H').src = 'immagini/chick_op.jpg';
				  document.getElementById('img_D').src = 'immagini/design.jpg';
				  break;
		case 'C': document.getElementById('div_N').style.display = 'none';
				  document.getElementById('div_D').style.display = 'none';
				  document.getElementById('div_H').style.display = 'none';
				  document.getElementById('div_C').style.display = 'block';
				  document.getElementById('img_N').src = 'immagini/natural_op.jpg';
				  document.getElementById('img_D').src = 'immagini/design_op.jpg';
				  document.getElementById('img_H').src = 'immagini/chick_op.jpg';
				  document.getElementById('img_C').src = 'immagini/classic.jpg';
				  break;
		case 'H': document.getElementById('div_N').style.display = 'none';
				  document.getElementById('div_D').style.display = 'none';
				  document.getElementById('div_C').style.display = 'none';
				  document.getElementById('div_H').style.display = 'block';
				  document.getElementById('img_N').src = 'immagini/natural_op.jpg';
				  document.getElementById('img_D').src = 'immagini/design_op.jpg';
				  document.getElementById('img_C').src = 'immagini/classic_op.jpg';
				  document.getElementById('img_H').src = 'immagini/chick.jpg';
				  break;
	}
	document.getElementById('div_sel').style.display = 'block';
}

function carica_big(immagine) {
	document.getElementById('img_big').src = immagine;
}

function scopri_e_carica(immagine) {
	if (document.getElementById('div_extra').style.display != 'block') {
		document.getElementById('div_extra').style.display = 'block';
		document.getElementById('img_extra').src = immagine;
	} else {		
		var str = document.getElementById('img_extra').src;
		if (str.indexOf(immagine) != -1) {
			document.getElementById('div_extra').style.display = 'none';	
		} else {
			document.getElementById('img_extra').src = immagine;
		}
	}
}

//Mappa NOVI DI CARPI
function load_map() {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng(44.89394451921535,10.914251804351806), 14);
		function createMarker(point, number) {
		  var marker = new GMarker(point);
		  GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml("<strong>Ceramica Lord</strong><br /> - Stabilimento e Amministrazione - <br />Via Gazzoli , 85<br />41016 Novi di Modena (MO) - Italy");
		  });
		  return marker;
		}	
		 var point = new GLatLng(44.89394451921535,10.914251804351806);
		map.addOverlay(createMarker(point, 1));
  }
}

//Mappa SALVATERRA
function load_map_2() {
  if (GBrowserIsCompatible()) {
	var map2 = new GMap2(document.getElementById("map2"));
	map2.addControl(new GSmallMapControl());
	map2.addControl(new GMapTypeControl());
	map2.setCenter(new GLatLng(44.584002989337485,10.759198665618896), 14);
		function createMarker(point, number) {
		  var marker = new GMarker(point);
		  GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml("<strong>Ceramica Lord</strong><br />- Uffici Commerciali Italia/Estero -<br />Via Macina , 27<br />42010 Salvaterra (RE) - Italy");
		  });
		  return marker;
		}	
		 var point = new GLatLng(44.584002989337485,10.759198665618896);
		map2.addOverlay(createMarker(point, 1));
  }
}

function PopUPThis(img) {
	var fpop = window.open("","nome","width=100,height=100,menubar=no,toolbar=no,resizable=no,scrollbars=no");
	fpop.document.write('<html>\n');
	fpop.document.write('<head>\n');
	fpop.document.write('<title>PopUp</title>\n');  
	fpop.document.write('</head>\n');
	fpop.document.write('<script language=\'JavaScript\' type="text/javascript">\n');  
	fpop.document.write('function fitPic() {\n');  
	fpop.document.write('	var NS = (navigator.appName=="Netscape")?true:false;\n');
	fpop.document.write('	iWidth  = (NS)?window.innerWidth:document.body.clientWidth;\n');
	fpop.document.write('	iHeight = (NS)?window.innerHeight:document.body.clientHeight;\n');  
	fpop.document.write('\n');
	fpop.document.write('	var l = Math.floor((screen.availWidth  - document.images[0].width)/2);\n');
	fpop.document.write('	var a = Math.floor((screen.availHeight - document.images[0].height)/2);\n');
	fpop.document.write('\n');
	fpop.document.write('	iWidth  = document.images[0].width  - iWidth;\n');
	fpop.document.write('	iHeight = document.images[0].height - iHeight;\n');
	fpop.document.write('	window.resizeBy(iWidth, iHeight-1);\n');
	fpop.document.write('\n');
	fpop.document.write('	window.moveTo(l, a);\n');
	fpop.document.write('\n');
	fpop.document.write('	self.focus();\n');
	fpop.document.write('}\n');	
	fpop.document.write('</script>\n');
	fpop.document.write('<body style="margin:0px;" onLoad="fitPic();">\n');  
	fpop.document.write('<a href="javascript:self.close()"><img src="' + img + '" border="0" galleryimg="no" alt="Close" style="background:url(images/loader.gif) no-repeat center center;"></a>\n');  
	fpop.document.write('</body>\n');
	fpop.document.write('</html>\n');
	fpop.document.close();
}

function popupUti(tid) {
  window.open('visualizza_record_utente.php?ID='+tid,'CeramicaLordUti','scrollbars=yes,width=650,height=450');
}

function popupLoginClienti(str) {
  window.open(str,'netsyspopup','scrollbars=yes,width=500,height=500,resizable=yes');
}

function conferma(txt) {
var agree=confirm(txt);
if (agree)
	return true ;
else
	return false ;
}


// funzione per scopri copri pezzi di codice
function scopri(a) {
	if(document.getElementById(a).style.display != 'block') {
		document.getElementById(a).style.display = 'block';
	} else {
		document.getElementById(a).style.display = 'none';
	}
}

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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


