// JavaScript Document

var ns4 = (document.layers); 
var ie4 = (document.all && !document.getElementById); 
var ie5 = (document.all && document.getElementById); 
var ns6 = (!document.all && document.getElementById); 
function attach(id)
{
 var obj
  if(ns4) obj = document.layers[id];
  else if(ie4) obj = document.all[id];
   else if(ie5 || ns6) obj = document.getElementById(id);
  return obj
} 

/*function validare_form(){
	var falta = "";
	var i,arg=validare_form.arguments; 
	for(i=2; i<arg.length; i=i+2){
		//alert(eval('document.toto.'+arg[i]+'.value'));
		temp_Obj = attach(arg[i+1]);
		if(arg[i]=='num'){
		//alert(eval('document.'+arg[0]+'.'+arg[i+1]+'.value'));
		//alert(!isNaN(eval('document.'+arg[0]+'.'+arg[i+1]+'.value')));
		
			if(isNaN(eval('document.'+arg[0]+'.'+arg[i+1]+'.value')) || eval('document.'+arg[0]+'.'+arg[i+1]+'.value') == '') {
				falta += "algo";
				if(ns4) { temp_Obj.color = 'red'; }
				else {temp_Obj.style.color = 'red'; }
			}
			else {
				if(ns4) { temp_Obj.color = 'black'; }
				else {temp_Obj.style.color = 'black'; }
			}
		}
		else if(arg[i]=='mail'){
			if(eval('document.'+arg[0]+'.'+arg[i+1]+'.value') == '') {
				falta += "algo";
				if(ns4) { temp_Obj.color = 'red'; }
				else {temp_Obj.style.color = 'red'; }
			}
			else {
				if(ns4) { temp_Obj.color = 'black'; }
				else {temp_Obj.style.color = 'black'; }
			}
		}
		else{
			if(eval('document.'+arg[0]+'.'+arg[i+1]+'.value') == arg[i]) {
				falta += "algo";
				if(ns4) { temp_Obj.color = 'red'; }
				else {temp_Obj.style.color = 'red'; }
			}
			else {
				if(ns4) { temp_Obj.color = 'black'; }
				else {temp_Obj.style.color = 'black'; }
			}
		}
	}
	if (falta != "") {
		falta =' '+arg[1]+' ';
		alert(falta);
		return false;
	}
	else {
		return true;
	}
}
*/

function validaDel(id,nombre,url){
	msg="¿Desea borrar "+ nombre +"?\n Los datos no se podran recuperar.";
	if (confirm(msg)){
		window.location=url+"?ac=borrar&id="+id;
		}
}

function act_idioma(nom_idioma,nom_desti,texte,lloc){
//alert(nom_idioma);
var camp=nom_idioma+nom_desti;
//alert(camp);
document.frm.elements[camp].value=texte.value;
XTCmsg(texte.value.length+" caracteres",lloc);
window.status=document.frm.elements[camp].value;
}

function idiomalang(nom_idioma2,idioma){
//alert(nom_idioma);
nom_idioma=idioma;
//alert(idioma);
//alert(nom_idioma);
}

function lnk(obj,clase){obj.className=clase;}

function XTCtrans(cur,which){
	strength=(which==0)? 0.70 : 1
		if (cur.style.MozOpacity)
			cur.style.MozOpacity=strength
		else if (cur.filters)
			cur.filters.alpha.opacity=strength*100
}

function XTCbgcolor(objNom,color){
document.getElementById(objNom).style.backgroundColor=color;
}

function XTClnktaula(obj,clase){obj.className=clase;}

function XTCmsg(msg,lloc){
	if (document.all||document.getElementById){
	      if (document.getElementById) {
			document.getElementById(lloc).innerHTML = ""+msg+"&nbsp;";
  			}
         else {
			lloc.innerHTML = ""+msg+"&nbsp;";	
			}
   } 
}


lang='es';
var promptOn = true;




function capturaTecla(frm) 
    {
        if(document.all)
            tecla=event.keyCode;
        else
        {
            tecla=e.which; 
        }
     if(tecla==13)
        {
            //alert("a");//
			frm.value+="<br>";
        }
    }  
   // if ()
	//document.onkeydown = capturaTecla;


function AddMessageCode(code, promptText, InsertText, NombreTextarea) {
	if (code != "") {
		if (promptOn == true){
			insertCode = prompt(promptText + "\n<" + code + ">xxx</" + code + ">", InsertText);
				if ((insertCode != null) && (insertCode != "")){
					cadena="document.frm."+ NombreTextarea +  ".value +=\"<" + code + ">" + insertCode + "</" + code + ">\"";
					//alert(cadena);
					eval(cadena);
				}
		}
		else{
			//document.frmNews.NombreTextarea.value += "<" + code + "></" + code + ">";
			
			cadena="document.frm."+ NombreTextarea +  ".value +=\"<" + code + "></" + code + ">\"";
			eval(cadena);
		}
	}
				
	//document.frmNews.NombreTextarea.focus();
	cadena="document.frm."+ NombreTextarea +  ".focus()";
	eval(cadena);
}


function AddCode(code, NombreTextarea) {

	//Añadir un link a la pagina
	if ((code != "") && (code == "URL")) {
		insertText = prompt("Introduzca el texto del enlace (texto que se pulsará)", "");
			
			if ((insertText != null) && (insertText != "") && (code == "URL")){
				insertCode = prompt("Introduzca la URL (direccion web) a la que llevará el enlace.", "http://");
					
					if ((insertCode != null) && (insertCode != "") && (insertCode != "http://")){					
						//document.frmNews.NombreTextarea.value += '<a href="' + insertCode + '">' + insertText + '</a>';
						cadena="document.frm."+ NombreTextarea +  ".value +=\"<a href='" + insertCode + "' target='_blank' class='texto_normal'>" + insertText + "</a>\"";
						eval(cadena);
					}
			}
	}
	
	//Añadir email a la pagina
	if ((code != "") && (code == "EMAIL")) {
		insertText = prompt("Introduzca el texto del email (texto que se pulsará)", "");
			
			if ((insertText != null) && (insertText != "")){
				insertCode = prompt("Introduzca el E-mail (xxxx@yyy.zz) al que llevará el enlace.", "");
					
					if ((insertCode != null) && (insertCode != "")){					
					//document.frmNews.NombreTextarea.value += '<a href="mailto:' + insertCode + '">' + insertText + '</a>';
					cadena="document.frm."+ NombreTextarea +  ".value +=\"<a href='mailto:" + insertCode + "' target='_blank' class='texto_normal'>" + insertText + "</a>\"";
					//cadena="document.frmNews."+ NombreTextarea +  ".value +=\"<a href=\"mailto:" + insertCode + "\">" + insertText + "</a>\"";
					eval(cadena);
				}
			}
	}
	
	//Comentarios en verde en las páginas
	if ((code != "") && (code == "BLOQUE")) {
		insertText = prompt("Introduzca el título del comentario", "");
			
			if ((insertText != null) && (insertText != "")){
				insertCode = prompt("Introduzca el texto del comentario.", "");
					
					if ((insertCode != null) && (insertCode != "")){					
					//document.frmNews.NombreTextarea.value += '<a href="mailto:' + insertCode + '">' + insertText + '</a>';
					cadena="document.frm."+ NombreTextarea +  ".value +=\"<br><br><span class='tverd'><b>" + insertText + "</b><br><br>" + insertCode + "</span><br>\"";
					//cadena="document.frmNews."+ NombreTextarea +  ".value +=\"<a href=\"mailto:" + insertCode + "\">" + insertText + "</a>\"";
					eval(cadena);
				}
			}
	}
}






/////////////////////////////

function damunt(Imatge,img,lay,w,h,step_h,step_v,count_lay,num_lay) { 
	if (document.images) {  
		document[Imatge].src=img; 
		//rttreterte/
		//alert(lay);
		temp_Obj = attach(lay);
		//step_h = 10;
		//step_v = 10;
		//temp_Obj = attach(id); 
		if(ns4) { temp_Obj.visibility = "hidden";temp_Obj.zIndex = parseInt(3);document.parent.zIndex = parseInt(15);temp_Obj.top = parseInt(temp_Obj.top) - step_v; temp_Obj.left = parseInt(temp_Obj.left) - step_h; temp_Obj.visibility = "visible";
		}
		else {temp_Obj.style.visibility = "hidden";temp_Obj.style.zIndex = parseInt(100);temp_Obj.style.top = parseInt(temp_Obj.style.top) - step_v; temp_Obj.style.left = parseInt(temp_Obj.style.left) - step_h; temp_Obj.style.visibility = "visible";
				//*****************************************
				for (x=0;x<count_lay;x++){
				if(x==num_lay){
				document.getElementById("parent_"+x).style.zIndex=100;
				document.getElementById("lay_"+x).style.zIndex=101;
				}else{
					document.getElementById("parent_"+x).style.zIndex=x;
					document.getElementById("lay_"+x).style.zIndex=x;
					}
				}
				//window.status=lay+"-"+parent_1.style.zIndex;
				//*******************************************
		}
		document[Imatge].width=w;  
		document[Imatge].height=h;  
		//alert(temp_Obj.style.zIndex);
	} 
return temp_Obj;} 

function fora(Imatge,lay,w,h,step_h,step_v,count_lay) {  
	if (document.images) { 
		temp_Obj = attach(lay);
		//step_h = 10;
		//step_v = 10;
		//temp_Obj = attach(id);
		if(ns4) {temp_Obj.zIndex = parseInt(1);temp_Obj.top = parseInt(temp_Obj.top) + step_v; temp_Obj.left = parseInt(temp_Obj.left) + step_h; }
		else {temp_Obj.style.zIndex = parseInt(1);temp_Obj.style.top = parseInt(temp_Obj.style.top) + step_v; temp_Obj.style.left = parseInt(temp_Obj.style.left) + step_h; }
				//*****************************************
				for (x=0;x<count_lay;x++){
				
					document.getElementById("parent_"+x).style.zIndex=x;
					document.getElementById("lay_"+x).style.zIndex=x;
					
				}
	 			//window.status=lay+"-"+parent_1.style.zIndex;
				//*******************************************
		document[Imatge].width=w;
		document[Imatge].height=h;    
	} 
 return temp_Obj;} 



function popUpWindow(imag, left, top, width, height)
{
  popUpWin = open("../imagen.php?imag="+imag+"&w="+width+"&h="+height, 'popUpWin', 'scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  popUpWin.focus();
}
function popUpWindow2(src, left, top, width, height)
{
  popUpWin2 = open(src, 'popUpWin2', 'scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  popUpWin2.focus();
}

function mapa(urlmapa){
var windowX = (screen.width/2)-(800/2);
var windowY = (screen.height/2)-(600/2);
var localitzar = window.open(urlmapa,"imatge","width=798,height=550,scrollbars=yes,resizable=yes");
localitzar.moveTo(windowX,windowY);
localitzar.focus();
}
