// JavaScript Document
function view_child(obj) {
	var result = "";
	for (var i in obj) {
		result += 'obj' + "." + i + " = " + obj[i] + "<br>";
	}
	
	var w=window.open();
	w.document.write(result);
	return result;
}

function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function converti_in_array(obj) {
	var vRecord = new Array();
	if(typeof(obj) == 'object') {
		for(var item in obj) {
			var value = obj[item];
			if(typeof(value) == 'object') { 
				converti_in_array(value);
			} else {
				vRecord[item]=value;
			}
		}
	}
	return vRecord;
}

function FlagOnMouseOut(lan){
	if(lan!=languagecode){
		document.getElementById('language'+lan).src='images/flags/'+lan+'_off.png';	
	}
}
function FlagOnMouseOver(lan){
	if(lan!=languagecode){
		document.getElementById('language'+lan).src='images/flags/'+lan+'.png';	
	}
}
/*function setLanguage(lan){
	var qs = document.location.search;
	if(qs){
		var nqs = qs.replace(/&lang_code=\S+/,"");
		var nqs = nqs.replace(/lang_code=\S+/,"");
		var newqs = (nqs!='?')?nqs+"&lang_code="+lan:"?lang_code="+lan;
	}else{
		var newqs='?lang_code='+lan;	
	}
	var loc=document.location.href.replace(qs,"");
	document.location.href=loc+newqs;
}*/
function switchmenu(menu){
	if(menu!=menuselected && menuselected){
		document.getElementById(menuselected).className='';	
	}else{
		document.getElementById(menu).className='selected';	
	}
}
function switchtabhome(tab){
	//alert(tab);
	document.getElementById('newstab').style.display='none';
	document.getElementById('stampatab').style.display='none';
	document.getElementById('linktab').style.display='none';
	
	document.getElementById('newstabbt').className='';
	document.getElementById('stampatabbt').className='';
	document.getElementById('linktabbt').className='';
	
	document.getElementById(tab+'tab').style.display='inline';
	document.getElementById(tab+'tabbt').className='selected';
	document.getElementById('loadinghome').style.display='none';
}

function preloadImages(vImages) {
var arrayImmagini = vImages;
var imgLoad;
	for (i=0; i<= arrayImmagini.length; i++) {
		imgLoad = new Image();
		imgLoad.src = arrayImmagini[i];
	}
}
function categoriaOnMouseOver(id){
	defaultcategoriaimg=document.getElementById('categoriaimg').style.backgroundImage;
	document.getElementById('categoriaimg').style.backgroundImage='url(images.php?what=categoria&codice='+id+'&size=xs)';
}
function categoriaOnMouseOut(){
	document.getElementById('categoriaimg').style.backgroundImage=defaultcategoriaimg;
}

function resetricercapermodello(){
	document.getElementById('resetricercapermodello').style.display='none';
	document.getElementById('costruttorenome').value=DICTIONARY_selezionailcostruttore;
	Modelli(0);
	if(document.frmricercapermodello.idcostruttore.value!=""){
		document.frmricercapermodello.idcostruttore.value="";
		document.frmricercapermodello.idmodello.value="";
		ricercapermodello();
	}
	costruttore='';
}
function resetricercapercodice(){
	document.getElementById('resetricercapercodice').style.display='none';
	if(document.frmricercapercodice.codiceprodotto.value!=DICTIONARY_inserisciuncodice || codiceprodotto){
		document.frmricercapercodice.codiceprodotto.value="";
		ricercapercodice();
	}
	document.getElementById('codiceprodotto').value=DICTIONARY_inserisciuncodice;
	codiceprodotto='';
}
function switchimg(img){
	changeOpac(0, 'immagineprodotto');
	document.getElementById('immagineprodotto').style.backgroundImage='url(images.php?what=prodotto&img='+img+'&size=l)';
	document.getElementById('zoomprodotto').href='images.php?what=prodotto&img='+img+'&size=xl';
	FadeIn('immagineprodotto',1000);
}

function switchtabprodotto(tab){
	//alert(tab);
	document.getElementById('modellitabbt').className='';
	document.getElementById('prodottitabbt').className='';
	document.getElementById('downloadtabbt').className='';
	document.getElementById('videotabbt').className='';
	
	document.getElementById('modellitab').style.display='none';
	document.getElementById('prodottitab').style.display='none';
	document.getElementById('downloadtab').style.display='none';
	document.getElementById('videotab').style.display='none';
	
	document.getElementById(tab+'tab').style.display='inline';
	document.getElementById(tab+'tabbt').className='selected';
}
function switchtabdownload(tab){
	document.getElementById('manualitabbt').className='';
	document.getElementById('cataloghitabbt').className='';
	document.getElementById('softwaretabbt').className='';
	document.getElementById('comunicazionitabbt').className='';
	
	document.getElementById('manualitab').style.display='none';
	document.getElementById('cataloghitab').style.display='none';
	document.getElementById('softwaretab').style.display='none';
	document.getElementById('comunicazionitab').style.display='none';
	
	document.getElementById(tab+'tab').style.display='inline';
	document.getElementById(tab+'tabbt').className='selected';
}
function openWindow(nome, url, w, h, scorrimento, status, resizable) {
	var win = null;
	var pagina, nome, LeftPosition, TopPosition, settings;
	nome=nome;
	// scorrimento [yes | no]
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h-(screen.width*5/100))/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scorrimento+', resizable=' +resizable+', status=' +status;
	win = window.open(url,nome,settings);
}

function segnalaadunamico(id,url){
	openWindow('SEGNALA_PRODOTTO',url+'/segnalaadunamico.php?prodotto='+id,600,500,'yes','no','no');
}
var Utf8 = {
 
	// public method for url encoding
	encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// public method for url decoding
	decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

      function html_entity_decode(str)
      {
      try
      {
      var tarea=document.createElement('textarea');
      tarea.innerHTML = str; return tarea.value;
      tarea.parentNode.removeChild(tarea);
      }
      catch(e)
      {
      //for IE add <div id="htmlconverter" style="display:none;"></div> to the page
      document.getElementById("htmlconverter").innerHTML = '<textarea id="innerConverter">' + str + '</textarea>';
      var content = document.getElementById("innerConverter").value;
      document.getElementById("htmlconverter").innerHTML = "";
      return content;
      }
      }

function stampaordine(id){
	openWindow('STAMPA_ORDINE','include/ajax/stampaordine.php?ordine='+id,720,600,'yes','no','no');
}	  
function stampapreventivo(){
	openWindow('STAMPA_PREVENTIVO','include/ajax/preventivo.php',720,600,'yes','no','no');
}
<!--
var message="Funzione Disabilitata!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
//alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
//alert(message);
return false;
}
}
}

/*
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")
*///-->
-->


