function canviarZoom()
{
    if (document.getElementById('156-1-8').value != 619)
    {
        document.getElementById('159-1-0').value='NI';         
    } 
}

function activarZoom()
{
    if (document.getElementById('156-1-8').value != 619)
    {
        document.getElementById('159-1-0').value='NI';         
    } 
}

function onchangeZoom()
{
    if (document.getElementById('159-1-0').value != 'NI')
    {
        document.getElementById('156-1-8').value=619;         
    } 
}
    
/* Add bookmark */
function bookmark(url,title)
{
    if (document.all)
        window.external.AddFavorite(url, title);
    else if (window.sidebar)
        window.sidebar.addPanel(title, url, "");
}

/* Check valid email */
function checkemail(mail, msg) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))
	{
		return (true);
	}
	else
	{
		alert(msg);
		return (false)
	}
}

function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}


function checkopinion(formulatio, alerts)
{	
    if (trim(document.getElementById("idusuario").value) == "") {
		window.alert(alerts[0]);
		document.getElementById("idusuario").value = "";
		document.getElementById("idusuario").focus();						
		return false;
    }    
    if (trim(document.getElementById("titular").value) == "") {    
		window.alert(alerts[1]);
		document.getElementById("titular").value = "";
		document.getElementById("titular").focus();				
		return false;
    } 
    if (document.getElementById("camararelacionada") != null && document.getElementById("camararelacionada").value == "0") {
		window.alert(alerts[2]);		
		document.getElementById("camararelacionada").focus();				
		return false;
    }      
        
    if (trim(document.getElementById("pincode").value) == "") { 
		window.alert(alerts[4]);		
		document.getElementById("pincode").value = "";
		document.getElementById("pincode").focus();		
		return false;
	}     
	else if (trim(document.getElementById("pincode").value) != alerts[3]) {
		window.alert(alerts[5]);		
		document.getElementById("pincode").value = "";
		document.getElementById("pincode").focus();
		return false;	
	} 
}



function expandCollapse(element, img) {
	var elementdiv = document.getElementById(element);
	elementdiv.style.display = (elementdiv.style.display == "none") ? "block" : "none";
	
	var elementimg = document.getElementById(img);
	elementimg.src = (elementdiv.style.display == "none") ? "/images/open.gif" : "/images/close.gif";
}

/*var guia_open = new Image();
guia_open.src = '/images/guia_open.gif';

var guia_close = new Image();
guia_close.src = '/images/guia_close.gif';

var guia_help = new Image();
guia_help.src = '/images/guia_help.gif';

var guia_helpopen = new Image();
guia_helpopen.src = '/images/guia_helpopen.gif';*/


function abrir(name)
{
	var namedet = 'det_' + name;  
	var namegen = 'gen_' + name;
	var oNodegen = document.getElementById(namegen);
	var oNodedet = document.getElementById(namedet);
	if (oNodedet.style.display == 'none')
	{
		oNodedet.style.display = '';
		var oImgs = oNodegen.getElementsByTagName("IMG");
	  for (var i = 0; i < oImgs.length; i++)
   	{
			var oImg = oImgs.item(i);
			oImg.src = guia_close.src;
   	}		
	}
	else
	{
		oNodedet.style.display = 'none';
		var oImgs = oNodegen.getElementsByTagName("IMG");
	  for (var i = 0; i < oImgs.length; i++)
   	{
			var oImg = oImgs.item(i);
			oImg.src = guia_open.src;
   	}		
	}
}

function ayuda(sender, name)
{
	var oNode = document.getElementById(name);
	if (oNode.style.display == 'none')
	{
		oNode.style.display = '';
		sender.src = guia_helpopen.src;
	}
	else
	{
		oNode.style.display = 'none';
		sender.src = guia_help.src;
	}
}

function cerrartodos()
{
	var oNode = document.getElementById('options');
	var oChildren = oNode.getElementsByTagName('DIV');	
	//var oChildren = oNode.childNodes;
	for (var i = 0; i < oChildren.length; i++)
  {
     // store the name of the node and the value of the text node contained within the node
     var oChild = oChildren.item(i);
		 var name = oChild.id;
		 if (name.substr(0,4) == 'det_')
		 {
			 	oChild.style.display = 'none'
		 }
  }	
}


function tipo_obj_intercambiable(formulario,texto)
{
	if (document.getElementById("156-1-8").value == 619) {	
		document.getElementById("159-1-0").disabled="disabled";		
		document.getElementById("160-1-0").disabled="disabled";		
		document.getElementById("161-1-0").disabled="disabled";				
		document.getElementById("159-1-0").value="NI";		
		document.getElementById("160-1-0").value="NI";		
		document.getElementById("161-1-0").value="NI";		
		
	} else {	
		document.getElementById("159-1-0").disabled=false;
		document.getElementById("160-1-0").disabled=false;
		document.getElementById("161-1-0").disabled=false;
	}	
}


function valida_form_obj(formulario,texto){
	var encontrado = 0;
	var el = document.getElementById(formulario);

	for (i=0;i<el.elements.length;i++){ 
			if (el.elements[i].type == "select-one")
				if (el.elements[i].value != "NI") 
					encontrado = 1
	} 
	
	if (encontrado == 1)
		el.submit()
	else
		window.alert(texto)			
}

function ValidarIT() {
		isNS4 = (document.layers) ? true : false;
		isIE4 = (document.all && !document.getElementById) ? true : false;
		isIE5 = (document.all && document.getElementById) ? true : false;
		isNS6 = (!document.all && document.getElementById) ? true : false;
		var total;
		total = 0
		if (isIE5 || isIE4)
			{
			if (document.all.select1.value != 0)				
				total = total + 1
			if (document.all.select2.value != 0)
				total = total + 1
			if (document.all.select3.value != 0)
				total = total + 1
			if (total < 1)							
				window.alert("Devi selezionare almeno un prodotto per confrontare");
			else
				document.all.fCompara.submit();
    }
		if (isNS6)
			{
			if (document.getElementById("select1").value != 0)
				total = total + 1
			if (document.getElementById("select2").value != 0)
				total = total + 1
			if (document.getElementById("select3").value != 0)
				total = total + 1
			if (total < 1)							
				alert("Devi selezionare almeno un prodotto per confrontare");				
			else
				document.getElementById("fCompara").submit();
			}					
}

function pag_ayuda(el)
{
	var w = window.open('/info/ayuda.aspx?termino=' + el ,'Ayuda','width=500,height=500,dependent,alwaysRaised,resizable,scrollbars');
	w.focus();
}

function seleccionavideo(el)
{
	if (el.value != -1)
	{
		document.location.href = el.value;
	}
}

function seleccionaobjetivo(idproducto, urlobjetivo)
{
	if(urlobjetivo != '')
	{
		idobjetivo = urlobjetivo.substring(urlobjetivo.lastIndexOf(",")+1, urlobjetivo.lastIndexOf("."));
		objetivoaddclick(idproducto, idobjetivo);
		document.location.href = urlobjetivo;
	}
}

/* Cetc: borrar l'altre camp escollit (cp o població) */
function desactivar_input(txt1,txt2)
{
	document.getElementById(txt1).style.backgroundColor = "#FFFFCC";
	document.getElementById(txt2).style.backgroundColor = "#C0C0C0";
	document.getElementById(txt2).value = "";
}


/* Function */


