.3

/*
* Funciones de arraque del sitio
*/ 
function RunSys(){
	jack('admin/','usr');
}


/* Validate contact form Fields */
function submitBTN() {
	document.forms[0].submit();
}

function form_contacto() {
	var validation_result;
	validation_result = validar_form_contacto();
	if(validation_result==''){
		document.forms[0].submit();
	}else{
		alert(validation_result);
	}
}

function validar_form_contacto(){
	var frm = document.forms[0];
	var sMessage = '';
	if(frm.contact_name.value==''){
		// nombre
		sMessage = 'Indicate your Name.';
	}else if(frm.contact_lastname.value==''){
		// apellido
		sMessage='Indicate your Last Name.';
	}else if(frm.contact_email.value==''){
		// email
		sMessage='Please, indicate your email.';
	}
	return sMessage;
}
/* End of contact validation */

/*  To launch any Pop up Windows    */
function openCenteredWindow(mypage,myname,w,h,features) {
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{winl = 0;wint =0;}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
marco = window.open(mypage,myname,settings);
marco.window.focus();
}

/* To launch Products PopUp in self window */
/**************************************************************/
function openCenteredWindowP(mypage,myname,w,h,features) {
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{winl = 0;wint =0;}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;

nuevo_win = window.open(mypage,myname,settings);
nuevo_win.ResizeToInner(w,h);

nuevo_win.focus();
}

function GetInnerSize () {
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return [x,y];
}
				

function ResizeToInner (w, h, x, y) {
	// make sure we have a final x/y value
	// pick one or the other windows value, not both
	if (x==undefined) x = window.screenLeft || window.screenX;
	if (y==undefined) y = window.screenTop || window.screenY;
	// for now, move the window to the top left
	// then resize to the maximum viewable dimension possible
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
	// now that we have set the browser to it's biggest possible size
	// get the inner dimensions.  the offset is the difference.
	var inner = GetInnerSize();
	var ox = screen.availWidth-inner[0];
	var oy = screen.availHeight-inner[1];
	// now that we have an offset value, size the browser
	// and position it
	window.resizeTo(Number(w)+Number(ox), Number(h)+Number(oy));
	window.moveTo(x,y);
}
/**************************************************************/



function openNonCenteredWindow(mypage,myname,w,h,features) {
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + 25 + ',';
settings += 'left=' + 25 + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}

function OpenPopup(url, winname,w,h){
	openCenteredWindow(url,winname,w,h,'toolbar=yes,location=no,locationbar=no,directories=no,status=no,statusbar=no,addressbar=no,menubar=no,scrollbars=no,copyhistory=yes,resizable=no,titlebar=no');
}

function OpenPopupP(url, winname,w,h){
	openCenteredWindowP(url,winname,w,h,'toolbar=no,location=no,locationbar=no,directories=no,status=no,statusbar=no,addressbar=no,menubar=no,scrollbars=no,copyhistory=yes,resizable=no,titlebar=no');
}


/*  To launch any Pop up Window  END  */
function OpenScrollPopup(url, winname,w,h){
	openCenteredWindow(url,winname,w,h,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
function OpenPositioned(url, winname,w,h){
	openNonCenteredWindow(url,winname,w,h,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=yes');
}


/* Simple OnMouseOver Menu, display block and none Div's */
function setVisible(status,IdDiv){
	document.getElementById(IdDiv).style.display = status;
	//document.getElementById('menudiv').style. = status;
}



//------------------------------------------------------------------------------------------------------------------------
function jack (url, id_contenedor)
{
    var pagina_requerida = false;
    if (window.XMLHttpRequest)
    {
        // Si es Mozilla, Safari etc
        pagina_requerida = new XMLHttpRequest ();
    } else if (window.ActiveXObject)  {
        // pero si es IE
        try 
        {
            pagina_requerida = new ActiveXObject ("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            // en caso que sea una versión antigua
            try
            {
                pagina_requerida = new ActiveXObject ("Microsoft.XMLHTTP");
            }
            catch (e)
            {
            }
        }
    } 
    else
    return false;
    pagina_requerida.onreadystatechange = function ()
    {
        // función de respuesta
        cargarpagina (pagina_requerida, id_contenedor);
    }
    pagina_requerida.open ('GET', url, true); // asignamos los métodos open y send
    pagina_requerida.send (null);
}
// todo es correcto y ha llegado el momento de poner la información requerida
// en su sitio en la pagina xhtml
function cargarpagina (pagina_requerida, id_contenedor)
{
    if (pagina_requerida.readyState == 4 && (pagina_requerida.status == 200 || window.location.href.indexOf ("http") == - 1))
    document.getElementById (id_contenedor).innerHTML = pagina_requerida.responseText;
}





/* Functions aba4s56 */
/* 
* Cross-browser event handling
*/
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}
/*
* Clear Default Text: functions for clearing and replacing default text in <input> elements.
*/
addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {  
            /* Add event handlers */          
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {	// Esta funcion limpia de caracteres el espacio input que se le detalle
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}

/*
* dataWindows /seacher & functions
*/
function SUBspl() { // Esta funcion realiza el procesamiento del buscador de la cabecera
	var frm = document.forms[0];
	var Sm = frm.busqueda.value;
	if(frm.busqueda.value==''){
		alert("Debe ingresar una palabra para realizar una búsqueda.\nEj. Disco Duro, Memoria RAM, DVD, CD, etc.");
	}else{
	var urlD = "dataProcess.php?busqueda="+Sm;
	jack(urlD,'data');
	setVisible('block','dataWindows');
	setTimeout("setVisible('none','CK'), setVisible('block','results');",3000);
	}
}

function selectorInSearch(item){ // Esta funcion permite al area de los anuncios realizar una busqueda en el catalogo
	itm = 'dataProcess.php?busqueda='+item;
	jack(itm,'data');
	//Effect.toggle('dataWindows','appear');
	setVisible('block','dataWindows');
	setTimeout("setVisible('none','CK'), setVisible('block','results');",3000);
	//Effect.toggle('searcher','appear');
}

function contactForm(){ // Esta funcion se encarga de realizara la validacion y el procesamiento del formulario de contacto
	var contactForm = document.forms[1];
	if(contactForm.nombre.value==''){
		alert("Por favor debe ingresar su nombre completo.");
	}else if(contactForm.email.value==''){
		alert("Por favor debe ingresar su correo electronico.");
	}else if(contactForm.telcel.value==''){
		alert("Por favor debe ingresar un número telefonico.");
	}else if(contactForm.txt.value==''){
		alert("Por favor debe ingresar su detalle antes de ser enviado el formulario.");
	}else{

	var nombre = "n="+contactForm.nombre.value;
	var email = "&e="+contactForm.email.value;
	var telcel = "&t="+contactForm.telcel.value;	
	var txt = "&txt="+contactForm.txt.value;
	var URLfrm = "contactFormProcess.php?"+nombre+email+telcel+txt;
	jack(URLfrm,'dataC');
	
	}

}

function regUsrFormed(){ // Valida el registro de un nuevo usuario
	var regUsrForm = document.forms[0];
	var string1=regUsrForm.email.value;
	var pass=regUsrForm.pass.value;
	var confirm=regUsrForm.confirm.value;
	
	if(regUsrForm.nombre.value==''){
		alert("Por favor debe ingresar su nombre completo.");
	}else if(regUsrForm.email.value==''){
		alert("Por favor debe ingresar en correo electrónico válido.");
	}
	else if(string1.indexOf("@")==-1){alert("Debe indicar un correo electrónico válido.");}
	else if(string1.indexOf(".")==-1){Alert("Debe indicar un correo electrónico válido.");}
	else if(regUsrForm.pass.value==''){
		alert("Compruebe la contraseña.");
	}
	else if(regUsrForm.confirm.value==''){
		alert("Compruebe la contraseña.");
	}
	else if(pass!=confirm){
		alert("Compruebe que la contraseña es la misma.");
	}else{
		document.forms[0].submit();
	}
	
}

function mainMarksTarget(keyword){ // Esta funcion le permite al flash de las marcas comerciales realizar la busqueda en el catalogo
	//var dat = "camino";
	var URM = "dataProcess.php?busqueda="+keyword;
	jack(URM,'data');
	//Effect.toggle('dataWindows','appear');
	setVisible('block','dataWindows');
	setTimeout("setVisible('none','CK'), setVisible('block','results');",3000);
	//Effect.toggle('searcher','appear');
}

function SH(){ // Esta funcion realizada un referescamiento de la pagina, utilizada la destruir la session en user o admin
	document.location.reload(true);
}
function SH2(){ //
	location.href = "main.php?c=ab";
	RefreshParent();
	window.close();
}


function edu(URL){ //Esta funcion aber y despliega los datos de la Informacion General
	setVisible('block','eduWindow');
	jack(URL,'dataE');
}

function regUserBTN(){
	OpenPopup('regUser.php','regUser','300','280');
	
}

function AdminWindow(w,h,features){
	//OpenPopup('AdminWindows.php','AdminWindows','450','340');
	features = 'toolbar=no,location=no,locationbar=no,directories=no,status=no,statusbar=no,addressbar=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no,titlebar=no';
	if(screen.width){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	}else{winl = 0;wint =0;}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;
	newWindow = window.open('AdminWindows.php', 'newWin', settings)
	newWindow.window.focus();
}
