// JavaScript Document

window.dhtmlHistory.create();

var cambioHistorial = function (nuevaSeccion, metadatos) {
	//En nueva sección ya tenemos el nombre de la sección donde hay que ir
	Load(nuevaSeccion);
}

window.onload = function() {
	//Load login form
	//showLogin();
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(cambioHistorial);
	
	//Verifica si viene la página solicitada viene de un favorito o link pidiendo una sección específica
	var seccion = dhtmlHistory.getCurrentLocation();
		
	if (seccion != null) {
		//Inicio la sección deseada
		Load(seccion);
	} else { //Condición reconocida por SAFARI
		Load("home");
	}
	
}

//START LOAD LOGIN
/*function showLogin() {
	requestPage("Login.aspx", receivingPage);	
}

function receivingPage(value) {
	document.getElementById("login_form").innerHTML = value;
}*/
//END

// START NO POST BACK FUNCTION
function noPostBack(input1, input2, clickButton) {
    var input;
    
    if(!input2 && !clickButton) {
		if(!input1) {
			return false;
		} else {
			if(!clickButton) {
     			input = input1;
			}
		}
    } else {
		if(!input1 || !input2) {
			document.getElementById("LblMsg").innerText = "Ingrese sus datos";
			return false;
		} else {
        	input = input1 + "&" + input2;
		}
    }
    
    try {
        CallServer(input, null);
    } catch(e) {}
}

function ReceiveServerData(arg, context) {
     try {
        if(arg != "0"){
            Load(arg);
			document.getElementById("LblMsg").innerText = "";
			document.getElementById("TxtUser").value = "";
			document.getElementById("TxtPass").value = "";
        } else {
			document.getElementById("TxtUser").value = "";
			document.getElementById("TxtPass").value = "";
            document.getElementById("LblMsg").innerText = "Datos incorrectos";
        }
        } catch(e) {}
}
//END

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//Function for executing javascript code within an ajax response or within any string. It's like the Eval javascript's function.
function evalScript(scripts)
{ try
 { if(scripts != '') 
  { var script = "";
   scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
                                  if (scripts !== null) script += arguments[1] + '\n';
                                   return '';});
   if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
  }
  return false;
 }
 catch(e)
 { alert(e) 
 }
}