// JavaScript Document
function changeIdiom(idioma)
{
	url = window.location;
	url = url.toString();
	if (url.indexOf("?lang=") != -1)
		url = url.replace(url.substr(url.indexOf("?lang="),8),"?lang="+idioma)
	else if (url.indexOf("&lang=") != -1)
		url = url.replace(url.substr(url.indexOf("&lang="),8),"&lang="+idioma)	
	else{ 
		if (url.indexOf("?") != -1)
			url = url +"&lang=" + idioma
		else
			url = url +"?lang=" + idioma		
	}

window.location = url;
}

function idiomaIlumina(idioma){
	if (document.getElementById(idioma)!=null){
		document.getElementById(idioma).style.display = "none";
		if (document.getElementById("div_"+idioma)!=null)
			document.getElementById("div_"+idioma).style.display = "none";		
		else 
			document.getElementById("div_it").style.display = "none";		
	}
}

<!-- Canvia el color al fons del Menu de l`esquerra -->
function canvia(object,flag){
	color_defecte = '#FFFFFF';
	color_over = '#E5E5E5';
	if (flag){
		object.style.backgroundColor = color_over;
		object.style.cursor = "pointer";
	}
	else{
		object.style.backgroundColor = color_defecte;	
	}
}

function buscar(action){
	str = document.getElementById("txtbuscar").value;
	if ( str.length == 0 || str.length < 3 ){
		alert("[{915|Debe introducir 3 caracteres como mínimo}].");
	}
	else{
		document.fbuscar.action.value = action;
		document.fbuscar.texto = str;		
		document.fbuscar.submit();
	}
}

function uno(src,color_entrada) { 
    src.bgColor=color_entrada;
	src.style.cursor="pointer"; 
} 

function dos(src,color_default) { 
    src.bgColor=color_default;
	src.style.cursor="default"; 
}





//////////////////////////////////////////////////////////////////////
  
  function ves_pagina(num){
  	document.location="{_APPS_URL}?id={_ID_ITEM}&next="+num;
  }
  
  var valor =1;
  function comprova_email_form(obj){	
    obj=eval("document."+obj);
    if(obj.nom.value<1) alert('{_nom_obligatori}');
    if(!valida_email(obj.email.value))
    	{obj.submit();}
    	else
    	{alert("{_email_no_valid}");}
  }
  
  function comprova_dades_form(obj){	
    obj=eval("document."+obj);
    error="";
    if(valida_email(obj.email.value)){error+="{_email_no_valid}\n"}
    if(obj.nom.value.length<3){error+="{_escrigui_nom}\n"}
    if(obj.lopd.checked == false){error+="{_lopd_ch}\n"}
    if(obj.id.value == 0){error+="{_sel_idioma}\n"}
    
    	if(error)
    	{
    		alert(error);
    	}
    	else
    	{
    	obj.submit();
    	}
  	
  }
  
  function comprova_dades_form2(obj){	
    obj=eval("document."+obj);
    error="";
    if(obj.nom.value.length<3){error+="{_escrigui_nom}\n"}
    if(obj.observacions.value.length<3){error+="{_escrigui_obs}\n"}
    if(obj.lopd.checked == false){error+="{_lopd_ch}\n"}
    
    	if(error)
    	{
    		alert(error);
    	}
    	else
    	{
    	obj.submit();
    	}
  	
  }
  
  function preview(ruta,x,y){
    x=100;
    y=100;
    t=(screen.height-y)/2;
    l=(screen.width-x)/2;
    win=window.open('preview.php?src='+ruta,'preview','status=yes,scrollbars=no,left='+l+',top='+t+',width='+x+',height='+y);
  }
  
  function download(ruta){
    w=window.open(ruta,'download_win','width=300,height=10,top=20,left=20,status=yes,scrollbars=yes,resizable=yes,menubar=yes');
    w.focus();
  }
  
  function MM_reloadPage(init) {  //reloads the window if Nav4 resized
    if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
      document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  }
  
  MM_reloadPage(true);
  
  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_showHideLayers() { //v6.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 ocultarMenus(){
  	MM_showHideLayers('menu_4','','hide');
  	MM_showHideLayers('menu_5','','hide');
  	MM_showHideLayers('menu_6','','hide');
  	MM_showHideLayers('menu_7','','hide');	
  	MM_showHideLayers('menu_8','','hide');	
  	MM_showHideLayers('menu_9','','hide');	
  	MM_showHideLayers('menu_10','','hide');	
  	MM_showHideLayers('menu_11','','hide');	
  	MM_showHideLayers('menu_1314','','hide');			
  }
  
  function showMe(id){ 
    ocultarMenus();
    document.getElementById(id).style.visibility='visible' 
  } 
  
  timer=null 
  function hideMe(id){ 
    clearTimeout(timer) 
    timer=setTimeout("document.getElementById('"+id+"').style.visibility='hidden'",1500) 
  }
  
  function HideMenus(){
    clearTimeout(timer)
    timer=setTimeout("HideOpenMenus()",1000);
  } 
  
  
  function buscar(){
  //alert(action)
  	str = document.getElementById("txtbuscar").value;
  	if ( str.length == 0 || str.length < 3 ){
  		alert("Heu d’introduir 3 carŕcters com a mínim.");
  	}
  	else{
  		document.fbuscar.texto.value = str;
  		document.fbuscar.submit();
  	}
  }
  
  function pressKey(e){
  	if (checkEnter(e)) 
  		buscar();
  }
  
  function checkEnter(e){ //e is event object passed from function invocation
  	e = e || window.event;
  	var characterCode = e.keyCode;	
  
  	if(characterCode == 13) //if generated character code is equal to ascii 13 (if enter key)
  		return true;
  	else
  		return false; 
  }
