
// JavaScript Document


function checkNumTiquet(obj, obj2, obj3, obj4){
	sndReq('code='+obj.value+'&fecha='+obj3+'&clientID='+parseInt(obj2), 'codigoEan', obj4);
}



function registroOK(){
		
	if(myLightWindow == null)
	{
		setTimeout(registroOK, 100);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/registroOK.html', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}

function openErrorLogin(){
		
	if(myLightWindow == null)
	{
		setTimeout(openErrorLogin, 100);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/pop_errorLogIn.html', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}

function participacionOK(){
		
	if(myLightWindow == null)
	{
		setTimeout(participacionOK, 100);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/participacionOK.html', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}

function notLogged(){
		
	if(myLightWindow == null)
	{
		setTimeout(notLogged, 100);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/notLogged.asp', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}

function codigosRepetidos(){
		
	if(myLightWindow == null)
	{
		setTimeout(codigosRepetidos, 100);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/codigosRepetidos.html', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}

function codigoIncorrecto(){
		
	if(myLightWindow == null)
	{
		setTimeout(codigoIncorrecto, 100);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/codigoIncorrecto.html', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}

function fechaIncorrecta(){
		
	if(myLightWindow == null)
	{
		setTimeout(fechaIncorrecta, 100);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/fechaIncorrecta.html', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}

function faltacentro(){
		
	if(myLightWindow == null)
	{
		setTimeout(faltacentro, 100);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/faltacentro.html', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}



function openForgetPassword(){
if(myLightWindow == null)
	{
		setTimeout(openForgetPassword, 100);
	}
	else
	{
		myLightWindow.activateWindow({href:'popUps/pop_recordarPassword.html', title:'', caption:'', type:'external', width:'410', height:'203'});		
	}
}

function doWy(pag){
		
	if(myLightWindow == null)
	{
		setTimeout(doWy, 100, pag);
	}
	else
	{
myLightWindow.activateWindow({href:'popUps/'+pag+'.html', title:'', caption:'', type:'external', width:'410', height:'203'});
	}
}




function doEmailDuplicado(){
if(myLightWindow == null)
	{
		setTimeout(doEmailDuplicado, 100);
	}
	else
	{
		myLightWindow.activateWindow({href:'popUps/pop_email_duplicado.html', title:'', caption:'', type:'external', width:'410', height:'205'});	
	}
}

function doNIFDuplicado(){
	if(myLightWindow == null)
	{
		setTimeout(doNIFDuplicado, 100);
	}
	else
	{
	myLightWindow.activateWindow({href:'popUps/pop_nif_duplicado.html', title:'', caption:'', type:'external', width:'410', height:'205'});	
	}
	
}

function openLightWindow(pag, w, h){
	if(myLightWindow == null)
	{
		setTimeout(openLightWindow, 100);
	}
	else
	{
	myLightWindow.activateWindow({href:pag, title:'', caption:'', type:'external', width:w, height:h});		
	}
}
function openLightWindowGlobal(error){
	if(myLightWindow == null)
	{
		setTimeout(openLightWindowGlobal, 100);
	}
	else
	{
	myLightWindow.activateWindow({href:'popUps/pop_errorGenerico.asp?mensaje='+error, title:'', caption:'', type:'external', width:410, height:175});		
	}
}
function envioAmigoOK(error){
	if(myLightWindow == null)
	{
		setTimeout(envioAmigoOK, 100);
	}
	else
	{
		myLightWindow.activateWindow({href:'popUps/pop_envioAmigoOK.asp?mensaje='+error, title:'', caption:'', type:'external', width:410, height:250});	
	}
}
//Funcion para comprovar el email de invitación al amigo a medida que va tecleando.
var http = createRequestObject();

function sndReq(fvalue,page,base) {
	var contenedor;
	contenedor = document.getElementById(base);
	http.open('get', 'ajax/ajax_'+page+'.asp?'+fvalue);
	if (page=='codigoEan') http.onreadystatechange = function()	 {
							if(http.readyState == 4){
									var response = http.responseText;
									var update = new Array();
						
									if(response.indexOf('|' != -1)) {
										update = response.split('|');
										contenedor.innerHTML = update[0];			
									}
							}
	}
	http.send(null);
}
// cross-browser add-remove event to object
EventManager =
{
	addEvent: function(obj, e, func)
	{
		//W3C, Mozilla
		if(obj.addEventListener)
		{
			obj.addEventListener(e, func, false);
		}
		//IE
		else if(obj.attachEvent)
		{
			obj.attachEvent("on"+e, func);
		}
		//others
		else
		{
			obj["on"+e] = func;
		}
	},
	
	removeEvent: function(obj, e, func)
	{
		if(obj.removeEventListener)
		{
			obj.removeEventListener(e, func, false);
		}
		else if(obj.detachEvent)
		{
			obj.detachEvent("on"+e, func);
		}
		else
		{
			obj["on"+e] = null;
		}
	},
	
	delegate: function(o, f, inherit_args)
	{
		var a = new Array();
		for(var i=3; i<arguments.length; i++) a.push(arguments[i]);
		return function()
		{
			//se envían además los parámetros propios que el método devuelve
			if(inherit_args)
			{
				var ar = new Array();
				for(var i=0; i<arguments.length; i++) ar.push(arguments[i]); //arguments no se considera una array, por lo que no funciona 'concat'
				f.apply(o, ar.concat(a)); //suma a los valores retornados por la funcion por defecto los definidos por el usuario
			}
			else
			{
				f.apply(o, a);
			}
		}
	}
};

function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	return ro;
}


