fletxaon=new Image();
fletxaoff=new Image();
fletxaon.src="/skins/tcterra/img/fletxaon.jpg";
fletxaoff.src="/skins/tcterra/img/fletxaoff.jpg";
actiucol="";

function win_popup(theURL,w,h,winName) 
{ 

var windowprops ="top=50,left=250,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no,width=" + w + ",height=" + h;
winName="";
window.open(theURL,winName,windowprops); 
//window.focus();

}


function win_popup_scroll(theURL,w,h,winName) 
{ 

var windowprops ="top=50,left=250,toolbar=no,location=no,status=no, menubar=no,scrollbars=yes, resizable=no,width=" + w + ",height=" + h;
winName="";

nova_fines= window.open(theURL,winName,windowprops); 
nova_fines.focus();

}


function doKeyDown(E)
{
	
	var myKeyCode = E.keyCode; 
	if (myKeyCode == 13) document.login_user.submit();
	
}

function checkvalor(camp){ 
	var i,error;
	error=1;
	i=0;
	
	while(i<camp.length && error==1){
	
		if(camp[i]=='email'){
		 if ((document.getELementById('email').value =="") || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getELementById('email').value))){
		 	alert("El mail es incorrecte");
		 }
		}else if(document.getElementById(camp[i]).value=="" || document.getElementById(camp[i]).value=="0"){
			alert("Has deixa't un camp obligatori sense omplir");
			document.getElementById(camp[i]).focus();
			error=0;
		}
		i++;
	}
	if(error) document.getElementById('form1').submit();
}	

function comprovarForm(dades){	
	camps=dades.split(",");
	
	for(i=0;i<camps.length;i++){
		if(camps[i]=='email'){
			if ((document.getElementById('email').value =="") || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email').value))){
      			alert("Email incorrecte.");
      			return (false);
    		}
		}else{
			text=document.getElementById(camps[i]).value;
			if (document.getElementById(camps[i]).value =="" || text.indexOf("(*)")>0){
      			alert(camps[i]+" incorrecte.");
      			return (false);
    		}
		}
	}
	
	return (true);
}

function textCounter(field, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
}

function input_on2(camp){
	document.getElementById(camp).className='input_on2';
}

function input_off2(camp){
	document.getElementById(camp).className='';
}

function input_on(camp){
	document.getElementById(camp).className='input_on';
}

function input_off(camp){
	document.getElementById(camp).className='input_off';
}
function canviFoto(camp,valor){
	document.getElementById(camp).src=document.getElementById(valor).value;
}

function respostes(num){
var txt='';
num++;
	for(i=1;i<num;i++){
		txt=txt+"Resposta "+i+":&nbsp;&nbsp;<input class='input_off' onfocus=\"input_on('resp"+i+"')\" onblur=\"input_off('resp"+i+"')\" type='text' id='resp"+i+"' name='resp"+i+"' value='' size=60><br>";
	}
	document.getElementById('resp').innerHTML=txt;
}

function veureObj(obj,val){
	if(document.getElementById(obj).style.visibility=='hidden'){
		document.getElementById(obj).style.visibility='visible';
		document.getElementById(obj).value=val;
	}else{
		document.getElementById(obj).style.visibility='hidden';
		document.getElementById(obj).value='';
	}
}

function afegirJug(num){
	opener.document.getElementById('jugadors').value='';
	txt="<table cellspacing=1 cellpadding=1><tr>";
	td=0;
	for(i=0;i<num;i++){
		if(document.getElementById('c'+i).checked){
			opener.document.getElementById('jugadors').value=opener.document.getElementById('jugadors').value+document.getElementById('c'+i).value+',';
			opener.document.getElementById('njugadors').value=opener.document.getElementById('njugadors').value+document.getElementById('n'+i).value+',';
			opener.document.getElementById('dorsal').value=opener.document.getElementById('dorsal').value+document.getElementById('dor'+i).value+',';
			opener.document.getElementById('posicio').value=opener.document.getElementById('posicio').value+document.getElementById('pos'+i).value+',';
			if(td>4){
				txt=txt+"</tr><tr>";
				td=0;
			}
			txt=txt+"<td>";
			txt=txt+"<a href=\"javascript:delJug("+document.getElementById('c'+i).value+",'"+document.getElementById('n'+i).value+"','"+document.getElementById('dor'+i).value+"','"+document.getElementById('pos'+i).value+"')\"><img src='http://www.entitatscatalanes.com/skins/tcterra/img/borrar.gif' border=0></a>";
			txt=txt+document.getElementById('n'+i).value;
			txt=txt+"</td>";
			td++;
		}
	}
	txt=txt+"</tr></table>";
	opener.document.getElementById('lljug').innerHTML=txt;
	window.close();
}

function delJug(id,nom,dorsal,posicio){
	
	itxt=document.getElementById('jugadors').value;
	itxt=itxt.replace(id+",","");
	document.getElementById('jugadors').value=itxt;
	
	ntxt=document.getElementById('njugadors').value;
	ntxt=ntxt.replace(nom+",","");
	document.getElementById('njugadors').value=ntxt;
	
	dtxt=document.getElementById('dorsal').value;
	dtxt=dtxt.replace(dorsal+",","");
	document.getElementById('dorsal').value=dtxt;
	
	ptxt=document.getElementById('posicio').value;
	ptxt=ptxt.replace(posicio+",","");
	document.getElementById('posicio').value=ptxt;
	
	ids=itxt.split(",");
	noms=ntxt.split(",");
	dorsal=dtxt.split(",");
	posicio=ptxt.split(",");
	
	td=0;
	txt="<table cellspacing=1 cellpadding=1><tr>";
	for(i=0;i<ids.length-1;i++){
		if(td>4){
			txt=txt+"</tr><tr>";
			td=0;
		}
		txt=txt+"<td>";
		txt=txt+"<a href=\"javascript:delJug("+ids[i]+",'"+noms[i]+"','"+dorsal[i]+"','"+posicio[i]+"')\"><img src='http://www.entitatscatalanes.com/skins/tcterra/img/borrar.gif' border=0></a>";
		txt=txt+noms[i];
		txt=txt+"</td>";
		td++;
	}
	txt=txt+"</tr></table>";
	document.getElementById('lljug').innerHTML=txt;
}

function volsborrar(link){
	if(confirm('Vols eliminar aquest registre?')){
		document.location.href='index.php?'+link;
	}
}

function ajudaOn(capa){
	x=event.x+20;
	y=event.y;
	
	if(screen.width<(x+200)){
		x=x-200;
		y=y+15;
	}
		
	tope=document.body.scrollTop;
	
	
	document.getElementById(capa).style.left=x;
	document.getElementById(capa).style.top=y+tope;
	if(document.getElementById(capa).style.visibility=='hidden')
		document.getElementById(capa).style.visibility='visible';
	else
		document.getElementById(capa).style.visibility='hidden';
}

function colorOn(color){
	document.getElementById(color).style.background='#cc9966';	
}
function colorOff(color){
	if(actiucol!=color)
		document.getElementById(color).style.background='#ffffff';	
}
function colorClick(key,model,td){
	document.getElementById('skin').value='ecp_'+model;
	document.getElementById('thumb'+key).src='/skins/ecp_'+model+'/img/pecp_'+model+'.jpg';
	document.getElementById(key+''+td).style.background='#cc9966';
	document.getElementById(actiucol).style.background='#ffffff';
	document.getElementById('link'+key).href="javascript:void(window.open('/skins/ecp_"+model+"/img/ecp_"+model+".jpg'))";
	actiucol=key+''+td;
}

var nav4 = window.Event ? true : false;
function acceptNum(evt){
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57));
}