/*interbusonline = {
	ver: 1.0
}*/

document.write("<SCR" + "IPT LANGUAGE='JavaScript'  SRC='/interfaz/js/window.js' TYPE='text/javascript'><\/SCR" + "IPT>");
document.write("<SCR" + "IPT LANGUAGE='JavaScript'  SRC='/interfaz/js/ajax/net.js' TYPE='text/javascript'><\/SCR" + "IPT>");

/*Ext.ns('interbusonline.general');
Ext.BLANK_IMAGE_URL = 'resources/images/default/s.gif';*/

interbusonline.general.entrar = function() {
    //Ext.QuickTips.init();

    // Create a variable to hold our EXT Form Panel.; 
    // Assign various config options as seen.;
    var login = new Ext.FormPanel({
        labelWidth: 80,
        url: '/usuarios/login/asp/login.asp',
        frame: true,
        title: 'Please Login',

        defaultType: 'textfield',
        monitorValid: true,
        // Specific attributes for the text fields for username / password.;
        // The "name" attribute defines the name of variables sent to the server.;
        items: [{
            fieldLabel: 'UserEmail',
            id: 'loginUserEmail',
            name: 'loginUserEmail',
            enableKeyEvents: true,
            allowBlank: false
        }, {
            fieldLabel: 'Password',
            name: 'loginPassword',
            inputType: 'password',
            allowBlank: false
		}],

            // All the magic happens after the user clicks the button ;    
            buttons: [{
                text: 'Login',
                formBind: true,
                // Function that fires when user clicks the button;
                handler: function() {
                    login.getForm().submit({
                        method: 'POST',
                        waitTitle: 'Connecting',
                        waitMsg: 'Connecting...',
                        success: function() {
                            Ext.Msg.alert('Status', 'WELCOME TO INTERBUS!', function(btn, text) {
                                if (btn == 'ok') {
                                    win.close();
                                    /*numeroOffer=getCookie("numeroOffer");
                                    if (numeroOffer!= null){
                                    	createCookie("numeroOffer", "", -1);
                                    	eraseCookies();
                                    }*/
                                    location.href = "../../../Reservaciones/servicios/asp/paso1.asp";
                                }
                            });
                        },

                        // Failure function, see comment above re: success and failure. ;
                        // You can see here, if login fails, it throws a messagebox;
                        // at the user telling him / her as much.;

                        failure: function(form, action) {
                            if (action.failureType == 'server') {
                                obj = Ext.util.JSON.decode(action.response.responseText);
                                Ext.Msg.alert('Login Error !', obj.errors.reason);
                            } else {
                                Ext.Msg.alert('Alert!', 'Authentication server is unreachable : ' + action.response.responseText);
                            }
                            login.getForm().reset();
                        }
                    });
                }
}]
            });

            // This just creates a window to wrap the login form. ;
            // The login object is passed to the items collection. ;      
            var win = new Ext.Window({
                layout: 'fit',
                width: 300,
                height: 150,
                modal: true,
                closable: true,
                resizable: false,
                plain: true,
                border: false,
                items: [login]
            });
            win.show();
            var f = Ext.get('loginUserEmail');
            f.focus.defer(100, f);
        }

interbusonline.general.entrar2 = function() {
    //Ext.QuickTips.init();

    // Create a variable to hold our EXT Form Panel.; 
    // Assign various config options as seen.;
    var login = new Ext.FormPanel({
        labelWidth: 80,
        url: '/usuarios/login/asp/login.asp',
        frame: true,
        title: 'Please Login',

        defaultType: 'textfield',
        monitorValid: true,
        // Specific attributes for the text fields for username / password.;
        // The "name" attribute defines the name of variables sent to the server.;
        items: [{
            fieldLabel: 'UserEmail',
            id: 'loginUserEmail',
            name: 'loginUserEmail',
            enableKeyEvents: true,
            allowBlank: false
        }, {
            fieldLabel: 'Password',
            name: 'loginPassword',
            inputType: 'password',
            allowBlank: false
		}],

            // All the magic happens after the user clicks the button ;    
            buttons: [{
                text: 'Login',
                formBind: true,
                // Function that fires when user clicks the button;
                handler: function() {
                    login.getForm().submit({
                        method: 'POST',
                        waitTitle: 'Connecting',
                        waitMsg: 'Connecting...',
                        success: function() {
                            Ext.Msg.alert('Status', 'WELCOME TO INTERBUS!', function(btn, text) {
                                if (btn == 'ok') {
                                    win.close();
                                    /*numeroOffer=getCookie("numeroOffer");
                                    if (numeroOffer!= null){
                                    	createCookie("numeroOffer", "", -1);
                                    	eraseCookies();
                                    }*/
									fCambiarLog1();
									Eps_Products()
									//interbusonline.general.entrar3 ();
                                    //location.href = "../../../Reservaciones/servicios/asp/paso1_a.asp";
                                }
                            });
                        },

                        // Failure function, see comment above re: success and failure. ;
                        // You can see here, if login fails, it throws a messagebox;
                        // at the user telling him / her as much.;

                        failure: function(form, action) {
                            if (action.failureType == 'server') {
                                obj = Ext.util.JSON.decode(action.response.responseText);
                                Ext.Msg.alert('Login Error !', obj.errors.reason);
                            } else {
                                Ext.Msg.alert('Alert!', 'Authentication server is unreachable : ' + action.response.responseText);
                            }
                            login.getForm().reset();
                        }
                    });
                }
}]
            });

            // This just creates a window to wrap the login form. ;
            // The login object is passed to the items collection. ;      
            var win = new Ext.Window({
                layout: 'fit',
                width: 300,
                height: 150,
                modal: true,
                closable: true,
                resizable: false,
                plain: true,
                border: false,
                items: [login]
            });
            win.show();
            var f = Ext.get('loginUserEmail');
            f.focus.defer(100, f);
        }
		
interbusonline.general.entrar3 = function() {		
	Ext.IframeWindow = Ext.extend(Ext.Window, {
	onRender: function() {
		this.bodyCfg = {
			tag: 'iframe',
			src: this.src,
			cls: this.bodyCls,
			style: {
				border: '0px none'
			}
		};
		Ext.IframeWindow.superclass.onRender.apply(this, arguments);
	}
	});
	
	var myWidth = 0, myHeight = 0;
	  
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	myWidth = myWidth -20;
	myHeight = myHeight -20;

	if (myWidth > 1166) {
		//myWidth = 1200;
		myWidth = 1166;
	}
	if (myHeight > 700){
		//myHeight = 800
		myHeight = 700
	}
	var w = new Ext.IframeWindow({
		id:id,
		width:myWidth,
		height:myHeight,
		title:"Knowledge Control Solutions Iframe Window Sample",
		//src:"https://www.interbusonline.com/Reservaciones/Servicios/asp/paso1.asp"
		src:"http://localhost/Reservaciones/Servicios/asp/paso1.asp"
		//src:"http://localhost/home/home.asp"
	})


	w.show();	
}
