var $_T=new Array();
function iniciar() {
try {
	var er=/(autoTit)/;
	var f, e;
	var obj;
	adapBack();
	for (f=0; f<document.forms.length; f++) {
		for (e=0; e<document.forms[f].elements.length; e++) {
			obj=document.forms[f].elements[e];
			if (er.test(obj.className)) {
				if (obj.type=='password') {
					get(obj.id+'Tit').onfocus=function() { inpFocusPass(this); }
					obj.onblur=function() { inpBlurPass(this); }
				}
				else {
					obj.alt=obj.value;
					obj.onfocus=function() { inpFocus(this); }
					obj.onblur=function() { inpBlur(this); }
				}
			}
		}
	}
	//setTimeout("document.body.style.display='block'", 200);
} catch (err) { alert(err); }
}
function adapBack() {
	//alert(window.innerHeight+' && '+document.height);
	//if (window.innerHeight && document.height)
		//document.body.style.height=(Math.max(window.innerHeight, document.height)-40)+'px';
}
function inpFocus(obj) {
	if (obj.value==obj.alt)
		obj.value='';
}
function inpBlur(obj) {
	if (obj.value=='')
		obj.value=obj.alt;
}
function inpFocusPass(obj) {
	obj.style.display='none';
	get(obj.id.substr(0, obj.id.length-3)).style.display='inline';
	get(obj.id.substr(0, obj.id.length-3)).focus();
}
function inpBlurPass(obj) {
	if (obj.value=='') {
		obj.style.display='none';
		get(obj.id+'Tit').style.display='inline';
	}
}
function check(objId) {
	if (get(objId).value==get(objId).alt || get(objId).value=='') {
		get(objId).focus();
		return false;
	}
	else
		return true;
}
function checkMail(txt) {
	var er=/^[A-Za-z][A-Za-z0-9_\.\-]*@[A-Za-z0-9_\-]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	return er.test(txt);
}
function checkNick(txt) {
	var er=/^[A-Za-z0-9\-]{0,20}$/;
	return er.test(txt);
}
function checkImagen(txt) {
	var er=/\.(jpg|jpeg)$/i;
	return er.test(txt);
}
function checkAudio(txt) {
	var er=/\.(mp3|wma)$/i;
	return er.test(txt);
}
function checkVideo(txt) {
	var er=/^(http:\/\/)?(www\.|[a-z]{2}\.)?(youtube\.com|vimeo\.com)\/[a-z0-9_\/\-]+/i;
	return er.test(txt);
}
function mensaje(msg) {
	if (msg) alert(msg);
}
function chPerfil(obj, ver) {
	if (ver)
		get(obj).style.display='block';
	else
		get(obj).style.display='none';
}
function teamInfoEdit(s) {
	if (s) {
		get('teamInfo').style.display='none';
		get('teamInfoEdit').style.display='block';
	}
	else {
		get('teamInfoEdit').style.display='none';
		get('teamInfo').style.display='block';
	}
}

var estNum=0;
var estMax=0;
var estTxt=Array();
var estPorc=Array();
var timeout=null;
function userEstado() {
	
	get('userEstado').style.width=estNum*130/estMax+'px';
	if (estNum<4)
		get('userEstado').style.background='#FF0000';
	else if (estNum<9)
		get('userEstado').style.background='#FFFF00';
	else
		get('userEstado').style.background='#00FF00';
		
	get('userEstadoTxt').innerHTML=estTxt[estNum]+'&nbsp;';
}

function userEstadoMenos() {
	if (estNum>1) {
		estNum--;
		userEstado();
		if (timeout)
			clearTimeout(timeout);
		
		timeout=setTimeout('userEstadoEnvio()', 2000);
	}
}
function userEstadoMas() {
	if (estNum<estMax) {
		estNum++;
		userEstado();
		if (timeout)
			clearTimeout(timeout);
		
		timeout=setTimeout('userEstadoEnvio()', 2000);
	}
}
function userEstadoEnvio() {
	var ajax=nuevoAjax();
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4)	{
			
		}
	}
	ajax.open("POST", "user-estado.php", true);
	ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');	
	ajax.send('e='+estNum);
}
onunload=function() {
	if (timeout) {
		clearTimeout(timeout);
		userEstadoEnvio();
	}
}
function viewVideo(proveedorID, codigo) {
	gvVideo('viewVideo', proveedorID, codigo, 480, 360);
}
function gvVideo(objID, proveedorID, codigo, width, height) {
	if (proveedorID==1) {
		var so=new SWFObject('http://www.youtube.com/v/'+codigo+'&amp;hl=es&amp;fs=1&amp;autoplay=1', 'id', width, height, '9', '#FFFFFF');
		so.addParam('allowscriptaccess', 'always');
		so.addParam('allowfullscreen', 'true');
		so.write(objID);
	}
	else if (proveedorID==2) {
		var so=new SWFObject('http://vimeo.com/moogaloop.swf?clip_id='+codigo+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=1&amp;show_portrait=0&amp;color=000000&amp;fullscreen=1&amp;autoplay=1', 'id', width, height, '9', '#000000');
		so.addParam('allowscriptaccess', 'always');
		so.addParam('allowfullscreen', 'true');
		so.write(objID);
	}
}
function chPais(p) {
	if (p!=pID) {
		pID=p;
		var b, x, grupo, subgrupo;
		
		var sel=document.forms['registro'].regEquipoID;
		get('regEquipoID').options.length=1;
		count=1;
		
		opt=sel.getElementsByTagName('optgroup');
		//alert(opt.length);
		if (opt.length>0) {
		  	for (var i=opt.length-1; i>=0; i--) {
				sel.removeChild(opt[i]);
			}
		}
		
		var gr=0;
		
		for (var a=0; a<eqId.length; a++) {
			if (eqPa[a]==pID) {
				if (gr!=eqCa[a]) {
					if (gr!=0)
						sel.appendChild(grupo);
					
					gr=eqCa[a];
					b=getCat(gr);
					grupo=document.createElement('optgroup');
					grupo.label=catNo[b];
					x+=catNo[b]+'\n';
				}
				subgrupo=document.createElement('option');
				subgrupo.value=eqId[a];
				if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1)
					subgrupo.innerText=eqNo[a];
				else
					subgrupo.text=eqNo[a];
					
				grupo.appendChild(subgrupo);
			}
		}
		if (subgrupo)
			grupo.appendChild(subgrupo);
		
		if (grupo)
			sel.appendChild(grupo);
		
		subgrupo=document.createElement('option');
		subgrupo.value='-';
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1)
			subgrupo.innerText=eqOtro;
		else
			subgrupo.text=eqOtro;
		
		sel.appendChild(subgrupo);
	}
}
function getCat(id) {
	for (var a=0; a<catId.length; a++) {
		if (catId[a]==id) {
			return a;
			break;
		}
	}
	return null;
}
function addPlayer(id) {
	selOpen('addPlayer', id);
}
function chPlayer(id) {
	selOpen('chPlayer', id);
}

/* SELECTOR DE USUARIOS */
function selUser(obj, id) {
	get('selUs'+obj).value=id;
	get('form'+obj).submit();
}
function selUsers(obj) {
	get('form'+obj).submit();
}
function selOpen(obj, ref) {
	get('selUsRef'+obj).value=ref;
	get('selectorUser'+obj).style.top='-460px';
	get('selectorUser'+obj).style.left='20px';
	get('selectorUser'+obj).style.display='block';
}
function selClose(obj) {
	get('selectorUser'+obj).style.display='none';
	get('selUsRef'+obj).value='';
}
/* FIN SELECTOR DE USUARIOS */

function moreInfo() {
	get('InfoMin').style.display='none';
	get('InfoMax').style.display='block';
}

function get(obj) {	var r=null;	if (document.getElementById) { if (document.getElementById(obj)) r=document.getElementById(obj); } else if (document.all) {	if (document.all[obj]) r=document.all[obj];	} return r; }
function nuevoAjax(){var xmlhttp=false;try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttp=false;}}if(!xmlhttp&&typeof XMLHttpRequest!='undefined')xmlhttp=new XMLHttpRequest();return xmlhttp;}

