var ajax=new Array();
function objetus(file) {
    xmlhttp=false;
    this.AjaxFailedAlert='Su navegador no soporta las funciónalidades de este sitio y podria experimentarlo de forma diferente a la que fue pensada.Por favor habilite javascript en su navegador para verlo normalmente.\n';
    this.requestFile = file;
    this.encodeURIString = true;
    this.execute = false;
    if (window.XMLHttpRequest) { 
        this.xmlhttp = new XMLHttpRequest();
        if (this.xmlhttp.overrideMimeType) {
            this.xmlhttp.overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) { // IE
        try {
            this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e) {
            try {
                this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                this.xmlhttp = null;
            }
        }
        if (!this.xmlhttp && typeof XMLHttpRequest!='undefined') {
            this.xmlhttp = new XMLHttpRequest();
            if (!this.xmlhttp){
                this.failed = true; 
            }
        } 
    }
    return this.xmlhttp ;
}
function recibeid(pPagina,pValorGet,pValorPost,pCapa,pPosicion,pValorCarga){
	if(pValorCarga=="")
		pValorCarga=1;
    ajax[pPosicion]=objetus(pPagina);
    if(pValorPost!=""){
        ajax[pPosicion].open("POST", pPagina+"?"+pValorGet+"&tiempo="+new Date().getTime(),true);
    } else {
        ajax[pPosicion].open("GET", pPagina+"?"+pValorGet+"&tiempo="+new Date().getTime(),true);
    }
    ajax[pPosicion].onreadystatechange=function() {
        if (ajax[pPosicion].readyState==1){
            document.getElementById(pCapa).innerHTML = "<div style='width:100%;padding:10px;text-align=center;'><img src='../imagenes/loading.gif' align='center'> Cargando...</div>";
			//document.getElementById("layForm").innerHTML="<div class='capaOculta'>qqqqqqqqqqqqqqqqq</div>";
        }
        if (ajax[pPosicion].readyState==4) {
            if(ajax[pPosicion].status==200)
            {	if(pValorCarga==1){
					document.getElementById(pCapa).innerHTML = ajax[pPosicion].responseText;
				}else{
					if((parseInt(ajax[pPosicion].responseText.indexOf('php'))>0)||(parseInt(ajax[pPosicion].responseText.indexOf('htm'))>0)||(parseInt(ajax[pPosicion].responseText.indexOf('html'))>0))
						document.location.href=ajax[pPosicion].responseText;
					else
						document.getElementById(pCapa).innerHTML = ajax[pPosicion].responseText;
				}
			}
            else if(ajax[pPosicion].status==404)
            {
                pCapa.innerHTML = "La direccion no existe";
            }
            else
            {
                pCapa.innerHTML = "Error: ".ajax[pPosicion].status;
            }
        }
    }
    if(pValorPost!=""){
        ajax[pPosicion].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax[pPosicion].send(pValorPost);
    } else {
        ajax[pPosicion].send(null);
    }
}
function recibeid2(pPagina,pValorGet,pValorPost,pCapa,pPosicion,pValorCarga,pLinkVolver){
	if(pValorCarga=="")
		pValorCarga=1;
    ajax[pPosicion]=objetus(pPagina);
    if(pValorPost!=""){
        ajax[pPosicion].open("POST", pPagina+"?"+pValorGet+"&tiempo="+new Date().getTime(),true);
    } else {
        ajax[pPosicion].open("GET", pPagina+"?"+pValorGet+"&tiempo="+new Date().getTime(),true);
    }
    ajax[pPosicion].onreadystatechange=function() {
        if (ajax[pPosicion].readyState==1){
            document.getElementById(pCapa).innerHTML = "<div style='width:100%;padding:10px;text-align=center;'><img src='../images/loading.gif' align='center'> Cargando...</div>";
        }
        if (ajax[pPosicion].readyState==4) {
            if(ajax[pPosicion].status==200)
            {	if(pValorCarga==1)
					document.getElementById(pCapa).innerHTML = ajax[pPosicion].responseText;
				else
				{	if(ajax[pPosicion].responseText=="ERROR")
						document.location.href=pLinkVolver;
					else
						document.getElementById(pCapa).innerHTML = ajax[pPosicion].responseText;
				}
			}
            else if(ajax[pPosicion].status==404)
            {
                pCapa.innerHTML = "La direccion no existe";
            }
            else
            {
                pCapa.innerHTML = "Error: ".ajax[pPosicion].status;
            }
        }
    }
    if(pValorPost!=""){
        ajax[pPosicion].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax[pPosicion].send(pValorPost);
    } else {
        ajax[pPosicion].send(null);
    }
}


function videosLista(parPagina,parPagAct,parCategoria,parCapa)
{	$.ajax({
		type: 'post',
		url: parPagina+"?ajx=1&pag="+parPagAct+"&itemC="+parCategoria,
		dataType: 'html',
		success: function(data){
			$("#"+parCapa).fadeIn(1000).html(data);
			$("ul.lst_video").ytplaylist({
				addThumbs:true, 
				autoPlay: false, 
				playerWidth: '72',
				playerHeight: '66',
				thumbSize: 'small',
				holderId: 'ytvideo2'
			});
		}
	});
}
function videosPreview(parPagina,parVideo,parCapa)
{	$.ajax({
		type: 'post',
		url: parPagina+"?ajx=1&acc=2&item="+parVideo,
		dataType: 'html',
		success: function(data){
			$(document).pngFix();
			$("#"+parCapa).html(data);
		}
	});
}


function IsMail(YourMail)
{	var Template = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; //Formato de direccion de correo electronico
	
	if(YourMail.value!="") 
	{
		if (Template.test(YourMail.value)) 
		{							}
		else
		{   alert("Ingrese un email correcto");
			YourMail.focus();
			YourMail.select();
		}		
	}
	return false;
}

