var temporizador;
var vTempo=100;
var idHistActual=0;
var idHistAnt=0;
var idHistAntIE=0;
function guardianUrl(){
	temporitzador=setTimeout("guardianUrl()",vTempo);
	var urlActual = window.location.toString();
	var bUrl = window.location.hash.substr(1);
	var urlActualIframe = document.location; 
	var bUrlIE = String(urlActualIframe.hash.substr(1)); 
	if((bUrlIE!= idHistAntIE && idHistAntIE !="" ) || bUrl!=idHistActual && bUrl!=idHistAnt && bUrl!="" && idHistActual!=""){
		navegar(urlVars(document.location));
	}
	if (bUrl!=""){
		idHistAnt=bUrl;
	}
	idHistAntIE= bUrlIE;
}
function sendHttpRequest(url,callbackFunc,respXml){
	cargando(true)
    var xmlobj=null;
    try{
        xmlobj=new XMLHttpRequest();
    }
    catch(e){
        try{
            xmlobj=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e){
            alert('Tu browser no soporta AJAX');
            return false;
        }
   }
	xmlobj.onreadystatechange=function(){
		if(xmlobj.readyState==4){
			if(xmlobj.status==200){
				cargando(false);
				respXml?eval(callbackFunc+'(xmlobj.responseXML)'):eval(callbackFunc+'(xmlobj.responseText)');
			}
		}
	}
    xmlobj.open('GET',url,true);
    xmlobj.setRequestHeader('Content-Type','text/xml; charset=UTF-8');
    xmlobj.send(null);
}
function loadHtml(url, div, dir){
	var dDiv=document.getElementById(div);
	var pageRequest = false;
	if (!pageRequest && typeof XMLHttpRequest != 'undefined'){
		pageRequest = new XMLHttpRequest();
	}	
	if (pageRequest){
		pageRequest.open('GET', dir+url, false);
		pageRequest.send(null);
		if (window.location.href.indexOf("http")==-1 || pageRequest.status==200){
			var page=pageRequest.responseText;
			dDiv.innerHTML=page;
		}
	}
}
function urlVars(Url){
	if(String(Url).indexOf('#')>=0){
		id= String(Url).split("#");
	}else{
		return(false);	
	}
	return(id[1]);
}
function setMenu(menu){
	document.location = "#"+menu;
	document.getElementById("menu_home").className = (menu == "home")? "active" : "";
	document.getElementById("menu_empresa").className = (menu == "empresa")? "active" : "";
	document.getElementById("menu_tecnologia").className = (menu == "tecnologia")? "active" : "";
	document.getElementById("menu_clientes").className = (menu == "clientes")? "active" : "";
	document.getElementById("menu_test").className = (menu == "test")? "active" : "";
}
function navegar(menu){
	if(menu=="empresa"){
		setMenu(menu)
		loadHtml("empresa.html", "contenido", "php/");
	}else if(menu=="tecnologia"){
		setMenu(menu)
		loadHtml("tecnologia.html", "contenido", "php/");
	}else if(menu=="clientes"){
		setMenu(menu)
		loadHtml("clientes.html", "contenido", "php/");
	}else if(menu=="test"){
		setMenu(menu)
		loadHtml("test.html", "contenido", "php/");
	}else{
		setMenu("home")
		loadHtml("home.html", "contenido", "php/");
		$(function() {
			$(".tabs").tabs(".images > div", {speed:"slow", effect: "default", rotate: true}).slideshow();
		});
	}
}

function WISEcontacto() {
}

function TSTenviar() {
    var xmlhttp;
    if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest();}
    else if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
    else { alert("Your browser does not support XMLHTTP!"); }
    xmlhttp.onreadystatechange=function() {
        if(xmlhttp.readyState==4) {
            respTST=xmlhttp.responseText;
            TSTrespuesta(); }
    }
    var wnsURL;
    wnsURL = wise_url + "TSTregistra.asp?NM=" + el("TSTnombre").value + " "
    + el("TSTapellido").value + "&EM=" + el("TSTempresa").value + "&CR="
    + el("TSTcargo").value + "&ML=" + el("TSTemail").value + "&FN="
    + el("TSTfono").value + "&CM=" + el("TSTcoment").value;
//    alert(wnsURL);
    xmlhttp.open("GET",wnsURL,true);
    xmlhttp.send(null);
}

function TSTrespuesta() {
    alert(respTST);

}

function inicio(){
	//PRELOAD IMAGENES
	preloadImages([
		'images/next-act.png',
		'images/prev-act.png'
	]);
	//INCLUDE DE ARCHIVOS
	loadHtml("header.html", "header", "php/");
	loadHtml("menu_principal.html", "menu_principal", "php/");
	navegar(urlVars(document.location));
	loadHtml("footer.html", "footer", "php/");
	//GUARDIAN DE HISTORIAL
	guardianUrl();
	//INIT FONT ESPECIAL
	_glowfont_js.initialize()
	_glowfont_js.configure({disableSelection: true});
    init();             // Llama la función estándar de WISEACCESS
}
