﻿ua = navigator.userAgent.toLowerCase();
isIE7 = check(/msie 7/);
isIE8 = check(/msie 8/);
isIE6 = !isIE7 && !isIE8;

if (window.ActiveXObject) {
    var isIe = true;
	var dclase = "className";
	if (isIE8){
	    var dclase = "class";
	}
}
else {
    var isIe = false;
    var dclase = "class";
}
function check(r){
	return r.test(ua);
}

function direccionar(pagina) {
    window.location = pagina;
}

function numFormat(numero) {
    var original = parseFloat(numero);
    var result = original.toFixed(2);
    return result;
}

function IsNumeric(input) {
    var RE = /^-{0,1}\d*\.{0,1}\d+$/;
    return RE.test(input);
}

//valida string;
function IsString(input) {
    var RE = /^[a-zA-Z\n\r\t\&\á\é\í\ó\ú\ñ\\Á\É\Í\Ó\Ú\Ñ ]+$/;
    return RE.test(input);
}

//funcion que retorna la hora o el minuto;
function fHourMin(campo, fhc) {
    var fch = new Date(fhc);
    if (campo == "h") {
        var hour = fch.getHours();
        if (hour <= 9) {
            hour = "0" + hour;
        }
        return hour;
    }
    if (campo == "m") {
        var minute = fch.getMinutes();
        if (minute <= 9) {
            minute = "0" + minute;
        }
        return minute;
    }
    if (campo == "s") {
        var second = fch.getSeconds();
        if (second <= 9) {
            second = "0" + second;
        }
        return second;
    }
}

function fechaActual() {
    var ahora = new Date();
    var Mes = ahora.getMonth() + 1;
    var Dia = ahora.getDate();
    var Anio = ahora.getFullYear();
    fecha = Mes + "/" + Dia + "/" + Anio;
    return fecha;
}

function getfecha(fch) {
    var ahora = new Date(fch);
    var mes = ahora.getMonth() + 1;
    var dia = ahora.getDate();
    var anio = ahora.getFullYear();
    var fch = mes + "/" + dia + "/" + anio;
    return fch;
}

var aFinMes = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

function fechaDia(mes, anio) {
    return aFinMes[mes - 1] + (((mes == 2) && (anio % 4) == 0) ? 1 : 0);
}

function incFecha(fecha) {
    var ahora = new Date(fecha);
    var nDia = ahora.getDate();
    var nMes = ahora.getMonth() + 1;
    var nAnio = ahora.getFullYear();
    nDia += 1;
    if (nDia > fechaDia(nMes, nAnio)) {
        nDia = 1;
        nMes += 1;
        if (nMes == 13) {
            nMes = 1;
            nAnio += 1;
        }
    }
    fecha = nMes + "/" + nDia + "/" + nAnio;
    return fecha;
}
function fCambiarLog() {
    if (getSession("FullName") != "Interbusonline.com") {
        var usu = getSession("FullName");
        if (getSession("dUserType") != "1") {
            usu = usu + ", " + getSession("dChargee");
        }
        var elemento = document.getElementById("labelUser");

        var encabezadoUser = document.getElementById("encabezadoUser");
        encabezadoUser.style.display = 'inline';
        var labelUser = document.createElement("label");
        labelUser.setAttribute('id', 'labelUser');
        var txtUser = document.createTextNode(usu);
        labelUser.appendChild(txtUser);
        encabezadoUser.replaceChild(labelUser, elemento);
        
        //cambiar el log del menu
        document.getElementById("mLogIn").style.display = 'none';
        document.getElementById("mLogOut").style.display = 'inline';
        
        
    }
    /*if (getSession("dUserType") == 1) {
        var elemento = document.getElementById("discount");
        elemento.style.display = 'inline';
	    }
    else{
    	var elemento = document.getElementById("discount");
        elemento.style.display = 'none';
	}*/
}


function justificardocumento() {
    var lagoDocumento = document.getElementById("contenido").offsetHeight;
    if (lagoDocumento < 540) {
        document.getElementById("contenido").style.height = "70%";
    }
    else {
        document.getElementById("contenido").style.height = "";
    }
}

function getAppPath() {
    appPath = location.protocol + "//" + location.host;
    return appPath;
}

function getSession(name) {
    var url = getAppPath() + "/interfaz/asp/session/ajax_getSession.asp?session=" + name;
    var DatosSesion = new net.CargadorContenidos(url, nada, false);
    resultsSession = DatosSesion.req.responseText.split("|");
    return resultsSession[0];
}
function nada() { }
//********************************************************************************;
// Ventana del ext;
//********************************************************************************;
function createVentana(titlex, valor, w, h) {
    var ventanasEmergente = new Ext.Window({
        title: titlex,
        modal: true,
        width: w,
        height: h,
        html: valor,
        autoScroll: true,
        buttons: [
        	{ text: 'Close',
        	    listeners: {
        	        click: function() {
        	            ventanasEmergente.close();
        	        }
        	    }
        	}
            ],
        buttonAlign: 'center'
    });
    ventanasEmergente.show();
}

function msjChkPlace(chk) {
    var ele = "";
    var pos = "";
    var oriDes = "";
    if (paso == "Hotel") {
        pos = chk.split("-");
        pos = pos[1];
        pos = parseInt(pos.substring(5, pos.length));
        ele = eleSegm[pos];
        ele = ele.split("&");
        ele = ele[2];
        oriDes = " pick up or drop off or neither of them";
    }
    else {
        pos = chk.split("-");
        pos = pos[1];
        var obj = "";
        obj = pos.substring(0, 11);
        if (obj == "PlaceOrigen") {
            pos = parseInt(pos.substring(11, pos.length));
            oriDes = " pick up";
        }
        else {
            pos = parseInt(pos.substring(12, pos.length));
            oriDes = " drop off";
        }
        ele = eleSeg[pos];
        ele = ele.split("&");
        ele = ele[6];
    }
    msj = "<p style='margin:10px 10px 10px 10px'>You selected transportation from  <Strong>" + ele + "</Strong>. And you did not indicate a hotel for <Strong>" + oriDes + "</Strong>.";
    msj = msj + " Please remember to let us know with at least 72 hours prior to your travel which hotel you need to be picked up and dropped off,";
    msj = msj + " otherwise you might loose your reservation and no refund will be made. In order to modify your reservation:</p>";
    msj = msj + "<p style='margin:10px 10px 10px 10px'>1. Go to www.interbusonline.com.</p>";
    msj = msj + "<p style='margin:10px 10px 10px 10px'>2. At the menu bar click on LOG IN. Use the same email address and password used during reservation.</p>";
    msj = msj + "<p style='margin:10px 10px 10px 10px'>3. Click on SERVICES and then choose MY ITINERARIES.</p>";
    msj = msj + "<p style='margin:10px 10px 10px 10px'>4. Modify your itinerary following instruction and save it. You can also modify your reservation by email at";
    msj = msj + " support@interbusonline.com or by calling our customer service at (+506) 2283-5573 during office hours: Daily 07.00 – 20.00 Costa Rica time.</p>";
    msj = msj + "<p style='margin:10px 10px 10px 10px'> As you did not indicate a hotel for <Strong>" + oriDes + "</Strong>, at the end of this reservation you will have ";
    msj = msj + " the possibility to choose among a list of hotels we selected for you at a great balance between quality and price. Check out www.costaricadeluxe.com.";
    msj = msj + " You can also contact us at support@interbusonline.com  or by phone (+506) 2283 5573 for more information regarding lodging.</br></br></p>";
    var w = 400;
    var h = 300;

    createVentana('Confirm Need Hotel!', msj, w, h);
}
/*

Detalles de error de página web

Agente de usuario: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; FBSMTWB; GTB6.4; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)
Fecha: Mon, 24 May 2010 22:05:47 UTC


Mensaje: Se esperaba ')'
Línea: 1
Carácter: 79
Código: 0
URI: http://localhost/htgt/asp2/hoteles/user.asp?codContable=undefined&customer=undefined&callback=OX.AJAST.__callbacks__.callback1



*/


function createVtnHow(titlex, valor) {
    var ventanasEmergente = new Ext.Window({
        title: titlex,
        modal: true,
        width: 400,
        height: 300,
        html: valor,
        autoScroll: true,
        buttons: [{
        	text: 'Close',
    	    listeners: {
    	        click: function() {
    	            ventanasEmergente.close();
    	        }
    	    }
    	}],
        buttonAlign: 'center'
    });
    ventanasEmergente.show();
}

function WindowsPopup(titlex) {
    var windowPopup = new Ext.Window({
        title: titlex,
        id:'ventanaHTGT',
        closable: false,
        collapsible: true, //Se puede minimizar;
        modal: true,
        width: 850,
        border: true,
        height: 500,
        autoScroll: true,
        contentEl: 'booking',
        buttons: [{ 	
        	text: 'Close',
    	    listeners: {
    	        click: function() {
    	            if (item == "3") {
	                    closeAll();
	                }
	                else{
	                  	closeAll2();
	                }
	                var dir=location.href
	                location.href = dir;
    	        }
    	    }
    	},{ 	
    		id: 'Next',
        	text: 'Next',
            listeners: {
                click: function() {
                    if (item == "1") {
                        PayOnline();
                    }
                    else {
                    	this.disable();
        				this.hide();                    	
        				BuyOnline();
                    }
                }
            }
        }],
        buttonAlign: 'right'
    });
    windowPopup.show();

    //fire when the user clicks the minimize button;  
    windowPopup.on('minimize', function(w) {
        w.modal = false;
        w.setPosition(25, 25);
        w.collapse();
    });
}

function msjPsw() {
    var msj = "<p style='margin:10px 10px 10px 10px'>Email and password used at this time will be needed in case you want to ";
    msj = msj + "modify your itinerary. Email is your username.</p>";
    createVentana("Information Password!", msj, 400, 300);
}  