//GLOBALS
var w3c = (document.getElementById) ? 1:0
var ns4 = (document.layers) ? 1:0  //browser detect for NS4 & W3C standards

function getObject(sObj) {
	if (w3c)
		theObj = document.getElementById(sObj);
	else if (ns4)
		theObj = eval("document." + sObj);
	return theObj;
}

/*
function visual(aa) {
if (document.getElementById){
	if(document.getElementById(aa).style.display=='none'){
		document.getElementById(aa).style.display='';
	}else{
		document.getElementById(aa).style.display='none';
	}
}
}
*/

function visual(aa){
	obj=getObject(aa);
	if (obj){
		if(obj.style.display=='none'){
			obj.style.display='';
		}else{
			obj.style.display='none';
		}
	}
}

function visual_y(aa){
	obj=getObject(aa);
	obj.style.display='inline';
	return true;
}

function visual_n(aa){
	obj=getObject(aa);
	obj.style.display='none';
	return true;
}

function visual_evidenza(aa){
	if(aa=='video_evidenza'){
		visual_n('gallery_evidenza');
		visual_y('video_evidenza');
		btnvideo=getObject('bottone_video_evidenza');
		btnvideo.className="bottoneattivo";
		btnfoto=getObject('bottone_gallery_evidenza');
		btnfoto.className="bottone";
    }
	if(aa=='gallery_evidenza'){
		visual_n('video_evidenza');
		visual_y('gallery_evidenza');
		btnvideo=getObject('bottone_video_evidenza');
		btnvideo.className ="bottone";
		btnfoto=getObject('bottone_gallery_evidenza');
		btnfoto.className ="bottoneattivo";
    }
}

function visual_areamedia(aa){
	if(aa=='video_areamedia'){
		visual_n('gallery_areamedia');
		visual_y('video_areamedia');

		btnvideo=getObject('a_btnvideo');
		btnvideo.style.backgroundImage="url(http://www.arredamento.it/img/btn_video_on.gif)";
		btnfoto=getObject('a_btnfoto');
		btnfoto.style.backgroundImage="url(http://www.arredamento.it/img/btn_foto_off.gif)";
    }
	if(aa=='gallery_areamedia'){
		visual_n('video_areamedia');
		visual_y('gallery_areamedia');

		btnvideo=getObject('a_btnvideo');
		btnvideo.style.backgroundImage='url(http://www.arredamento.it/img/btn_video_off.gif)';
		btnfoto=getObject('a_btnfoto');
		btnfoto.style.backgroundImage='url(http://www.arredamento.it/img/btn_foto_on.gif)';
    }
}


function motorericerca()
  {
  var tro=document.motore.f_cerca;
  if(tro.value=="")
    {
    alert('Devi inserire un testo per la ricerca');
    tro.focus();
    return (false);
    }
  else
    {
    return(true);
    }
  }

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function gb_inner(aaa,bbb){

	obj=getObject(aaa);
	obj.innerHTML = bbb;

}

function SetAllCheckBoxes(FormName, FieldName, CheckValue){
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}



/*
funzione che assegna id del marchio nell'input hidden nel form ricerca negozi
*/    
function assegna_id(val_id){
  document.frm2.id_mark.value=val_id;
}


function window_open(theurl,w_width,w_height){
  window.open(theurl, '', 'width='+w_width+',height='+w_height+',left=0,top=0,resizable=yes,menubar=no,toolbar=no, scrollbars=yes,locations=no,status=no');
}
