var defaultvar;
function elementExists(id) {
var elemento;
if(document.getElementById)
elemento = document.getElementById(id);
else
elemento = document.all[id_elemento];

if(elemento)
return true;
return false;
}
function axter(){defaultvar=true}

function showDetails(id){
	if(document.getElementById('dettagli_'+id).style.display=='none'){
		document.getElementById('dettagli_'+id).style.display='';
	}else{
		document.getElementById('dettagli_'+id).style.display='none';
	}
}
	
function ricerca_disabled(){
		if(document.getElementById('regione').value==''){
			document.getElementById('cerca').disabled=true;
		}else{
			document.getElementById('cerca').disabled=false;
		}
	}

function Mappa(indirizzo, riv){
	window.open('google.php?indirizzo='+indirizzo+'&rivenditore='+riv,'MappaGoogle','width=525,height=445,left=300,top=150, toolbar=0, menubar=0, scrollbar=0,resizable=1');
}

function Rivenditori(regione,provincia,citta){
	if(elementExists("rivenditori_container")){
		getRivenditori();
	}else{
		document.location.href='rivenditori.php?rivenditori=true&regione='+regione+'&provincia='+provincia+'&citta='+citta;
	}
}

var last_menu_open='';
function switchMenu(id){
	if(last_menu_open!=id){
		try{
		document.getElementById(last_menu_open+'_menu').className='menub';
		}catch(e){}
		document.getElementById(id+'_menu').className='menubON';
		last_menu_open=id;
	}
}

// JavaScript Document
	var last_id_clicked='';
	function SelImage(file,id,how, id_db_default){
		var obj=document.getElementById('img_'+ id);
		
		if (last_id_clicked==''){
			try{
				document.getElementById(id_db_default).className='img_not_selected';
			}catch(e){}
		}else{
		
			document.getElementById(last_id_clicked).className='img_not_selected';
			last_id_clicked='img_'+ id;
		}
		
		obj.className='img_selected';
		document.getElementById('image').value=file;
		if(how==1){
			document.getElementById('path_image').value='default_icons';
		}else{
			document.getElementById('path_image').value='';
		}
		
		last_id_clicked='img_'+ id;

	}
	
	function OverImage(id){
		var obj=document.getElementById('img_'+ id);
		if(last_id_clicked!='img_'+id){
		obj.className='img_onmouseover';
		}
	}
	
	function OutImage(id){
		var obj=document.getElementById('img_'+ id);
		if(last_id_clicked!='img_'+id){
		obj.className='img_not_selected';
		}
	}
	function set_last_id_clicked(id){
		last_id_clicked=id;
		alert(last_id_clicked);		
	}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
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;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
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 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;
}

<!--
var message="Funzione Disabilitata!";

function openonlinecatalog(){
	window.open('bomboniere-eco-solidali/index.html','onlinecatalog','toolbar=0, menubar=0, scrollbar=0,resizable=1');
}
///////////////////////////////////
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")//-->
-->
