function _SWFZoom(d) {
	obj = document.getElementById("seegame");
	if (d==0) {
		nw = obj.width*0.9;
		nh = obj.height*0.9;
	} else {
		nw = obj.width*1.1;
		nh = obj.height*1.1;
	}
	obj.width = nw+"px";
	obj.height = nh+"px";
	
}

function copy(text2copy) {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="/plantillas/includes/swf/_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
}

function share_im(){
	text=document.location.href;
	copy(text);
	alert('Se ha copiado el enlace del juego al portapapeles. Ahora pégalo en tu Messenger y compártelo con tus amigos!');
}

function ElmGetSafeElement(strId)
{
	if (null == strId || 0 >= strId.length)
		return null;

	var element = document.getElementById(strId);
	if (typeof(element) == 'undefined')
		return null;

	return element;
}

function Cambio(strCtrlId){
	x=1;
	i = true;
	while(i == true){
		if(x != strCtrlId) {
			var quePedo = ElmGetSafeElement(x);
			if (null != quePedo) {
					quePedo.className = "tabunsel";
			
					var ocultatCont = ElmGetSafeElement(x + "_cont");
					if (null != ocultatCont){ ocultatCont.className = "contunsel"; }
			}
			else { i = false;}
		}
		x++;
	}
	var selTab = ElmGetSafeElement(strCtrlId);
	if (null != selTab) { selTab.className = "tabsel"; }
	
	var verCont = ElmGetSafeElement(strCtrlId + "_cont");
	if (null != verCont) { verCont.className = "contsel"; }

}

function valFormAmigo(frm){
	if (frm.nombre.value == ""){
		alert("Debes informar tu nombre.");
		frm.nombre.focus();
		return false;
	}
	if (!validarEmail(frm.email.value)){
		alert("El formato de tu dirección de correo no es correcto.");
		frm.email.focus();
		return false;
	}
	if (frm.sunombre.value == ""){
		alert("Debes informar el nombre de tu amigo.");
		frm.sunombre.focus();
		return false;
	}
	if (!validarEmail(frm.suemail.value)){
		alert("El formato de la dirección de correo de tu amigo no es correcto.");
		frm.suemail.focus();
		return false;
	}
	
	var poststr = "email"+frm.email.value+"&suemail="+frm.suemail.value+"&nombre="+frm.nombre.value+"&sunombre="+frm.sunombre.value+"&gamename="+frm.gamename.value+"&gameuri="+frm.gameuri.value;
	makePostRequest("/plantillas/includes/proc/enviar_amigo.php", 'tra_msg', poststr);
}

function validarEmail(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){
		return true;
	} else {
		return false;
	}
}
