//sarisa.js starts 

/**
 * ====================================================================
 * About
 * ====================================================================
 * Sarissa is an ECMAScript library acting as a cross-browser wrapper for native XML APIs.
 * The library supports Gecko based browsers like Mozilla and Firefox,
 * Internet Explorer (5.5+ with MSXML3.0+), Konqueror, Safari and a little of Opera
 * @version 0.9.6.1
 * @author: Manos Batsis, mailto: mbatsis at users full stop sourceforge full stop net
 * ====================================================================
 * Licence
 * ====================================================================
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 or
 * the GNU Lesser General Public License version 2.1 as published by
 * the Free Software Foundation (your choice between the two).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License or GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * or GNU Lesser General Public License along with this program; if not,
 * write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 * or visit http://www.gnu.org
 *
 */
/**
 * <p>Sarissa is a utility class. Provides "static" methods for DOMDocument and 
 * XMLHTTP objects, DOM Node serializatrion to XML strings and other goodies.</p>
 * @constructor
 */
 //var browserType1;

var loadX=0;
var loadY=0;
var isMCS=false;
var travelInsuranceFlag=-1;
function setSafariXY(xf,yf,xs,ys)
{
	if(browserType=='Safari'){
		loadX=xs;
		loadY=ys;
		}else{
		loadX=xf;
		loadY=yf;
	}

}

function Sarissa(){};
/** @private */
Sarissa.PARSED_OK = "Document contains no parsing errors";
/**
 * Tells you whether transformNode and transformNodeToObject are available. This functionality
 * is contained in sarissa_ieemu_xslt.js and is deprecated. If you want to control XSLT transformations
 * use the XSLTProcessor
 * @deprecated
 * @type boolean
 */
Sarissa.IS_ENABLED_TRANSFORM_NODE = false;
/**
 * tells you whether XMLHttpRequest (or equivalent) is available
 * @type boolean
 */
Sarissa.IS_ENABLED_XMLHTTP = false;
/**
 * tells you whether selectNodes/selectSingleNode is available
 * @type boolean
 */
Sarissa.IS_ENABLED_SELECT_NODES = false;
var _sarissa_iNsCounter = 0;
var _SARISSA_IEPREFIX4XSLPARAM = "";
var _SARISSA_HAS_DOM_IMPLEMENTATION = document.implementation && true;
var _SARISSA_HAS_DOM_CREATE_DOCUMENT = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.createDocument;
var _SARISSA_HAS_DOM_FEATURE = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.hasFeature;
var _SARISSA_IS_MOZ = _SARISSA_HAS_DOM_CREATE_DOCUMENT && _SARISSA_HAS_DOM_FEATURE;
var _SARISSA_IS_SAFARI = (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1 || navigator.vendor.indexOf("Apple") != -1));
var _SARISSA_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1  && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
if(!window.Node || !window.Node.ELEMENT_NODE){
    var Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5,  ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12};
};

// IE initialization
if(_SARISSA_IS_IE){
    // for XSLT parameter names, prefix needed by IE
    _SARISSA_IEPREFIX4XSLPARAM = "xsl:";
    // used to store the most recent ProgID available out of the above
    var _SARISSA_DOM_PROGID = "";
    var _SARISSA_XMLHTTP_PROGID = "";
    /**
     * Called when the Sarissa_xx.js file is parsed, to pick most recent
     * ProgIDs for IE, then gets destroyed.
     * @param idList an array of MSXML PROGIDs from which the most recent will be picked for a given object
     * @param enabledList an array of arrays where each array has two items; the index of the PROGID for which a certain feature is enabled
     */
    pickRecentProgID = function (idList, enabledList){
        // found progID flag
        var bFound = false;
        for(var i=0; i < idList.length && !bFound; i++){
            try{
                var oDoc = new ActiveXObject(idList[i]);
                o2Store = idList[i];
                bFound = true;
                for(var j=0;j<enabledList.length;j++)
                    if(i <= enabledList[j][1])
                        Sarissa["IS_ENABLED_"+enabledList[j][0]] = true;
            }catch (objException){
                // trap; try next progID
            };
        };
        if (!bFound)
            throw "Could not retreive a valid progID of Class: " + idList[idList.length-1]+". (original exception: "+e+")";
        idList = null;
        return o2Store;
    };
    // pick best available MSXML progIDs
    _SARISSA_DOM_PROGID = pickRecentProgID(["Msxml2.DOMDocument.4.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"], [["SELECT_NODES", 2],["TRANSFORM_NODE", 2]]);
    _SARISSA_XMLHTTP_PROGID = pickRecentProgID(["Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"], [["XMLHTTP", 4]]);
    _SARISSA_THREADEDDOM_PROGID = pickRecentProgID(["MSXML2.FreeThreadedDOMDocument.4.0", "MSXML2.FreeThreadedDOMDocument.3.0"]);
    _SARISSA_XSLTEMPLATE_PROGID = pickRecentProgID(["Msxml2.XSLTemplate.4.0", "MSXML2.XSLTemplate.3.0"], [["XSLTPROC", 2]]);
    // we dont need this anymore
    pickRecentProgID = null;
    //============================================
    // Factory methods (IE)
    //============================================
    // see non-IE version
    Sarissa.getDomDocument = function(sUri, sName){
        
        var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
        // if a root tag name was provided, we need to load it in the DOM
        // object
        if (sName){
            // if needed, create an artifical namespace prefix the way Moz
            // does
            if (sUri){
                oDoc.loadXML("<a" + _sarissa_iNsCounter + ":" + sName + " xmlns:a" + _sarissa_iNsCounter + "=\"" + sUri + "\" />");
                // don't use the same prefix again
                ++_sarissa_iNsCounter;
            }
            else
                oDoc.loadXML("<" + sName + "/>");
        };
        return oDoc;
    };
    // see non-IE version   
    Sarissa.getParseErrorText = function (oDoc) {
        var parseErrorText = Sarissa.PARSED_OK;
        if(oDoc.parseError != 0){
            parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason + 
                "\nLocation: " + oDoc.parseError.url + 
                "\nLine Number " + oDoc.parseError.line + ", Column " + 
                oDoc.parseError.linepos + 
                ":\n" + oDoc.parseError.srcText +
                "\n";
            for(var i = 0;  i < oDoc.parseError.linepos;i++){
                parseErrorText += "-";
            };
            parseErrorText +=  "^\n";
        };
        return parseErrorText;
    };
    // see non-IE version
    Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
        oDoc.setProperty("SelectionLanguage", "XPath");
        oDoc.setProperty("SelectionNamespaces", sNsSet);
    };   
    /**
     * Basic implementation of Mozilla's XSLTProcessor for IE. 
     * Reuses the same XSLT stylesheet for multiple transforms
     * @constructor
     */
    XSLTProcessor = function(){
        this.template = new ActiveXObject(_SARISSA_XSLTEMPLATE_PROGID);
        this.processor = null;
    };
    /**
     * Impoprts the given XSLT DOM and compiles it to a reusable transform
     * @argument xslDoc The XSLT DOMDocument to import
     */
    XSLTProcessor.prototype.importStylesheet = function(xslDoc){
        // convert stylesheet to free threaded
        var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID); 
        converted.loadXML(xslDoc.xml);
        this.template.stylesheet = converted;
        this.processor = this.template.createProcessor();
        // (re)set default param values
        this.paramsSet = new Array();
    };
    /**
     * Transform the given XML DOM
     * @argument sourceDoc The XML DOMDocument to transform
     * @return The transformation result as a DOM Document
     */
    XSLTProcessor.prototype.transformToDocument = function(sourceDoc){
        this.processor.input = sourceDoc;
        var outDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
        this.processor.output = outDoc; 
        this.processor.transform();
        return outDoc;
    };
    /**
     * Set global XSLT parameter of the imported stylesheet
     * @argument nsURI The parameter namespace URI
     * @argument name The parameter base name
     * @argument value The new parameter value
     */
    XSLTProcessor.prototype.setParameter = function(nsURI, name, value){
        /* nsURI is optional but cannot be null */
        if(nsURI){
            this.processor.addParameter(name, value, nsURI);
        }else{
            this.processor.addParameter(name, value);
        };
        /* update updated params for getParameter */
        if(!this.paramsSet[""+nsURI]){
            this.paramsSet[""+nsURI] = new Array();
        };
        this.paramsSet[""+nsURI][name] = value;
    };
    /**
     * Gets a parameter if previously set by setParameter. Returns null
     * otherwise
     * @argument name The parameter base name
     * @argument value The new parameter value
     * @return The parameter value if reviously set by setParameter, null otherwise
     */
    XSLTProcessor.prototype.getParameter = function(nsURI, name){
        nsURI = nsURI || "";
        if(nsURI in this.paramsSet && name in this.paramsSet[nsURI]){
            return this.paramsSet[nsURI][name];
        }else{
            return null;
        };
    };
}
else{ /* end IE initialization, try to deal with real browsers now ;-) */
    if(_SARISSA_HAS_DOM_CREATE_DOCUMENT){
        /**
         * <p>Ensures the document was loaded correctly, otherwise sets the
         * parseError to -1 to indicate something went wrong. Internal use</p>
         * @private
         */
        Sarissa.__handleLoad__ = function(oDoc){
            if (!oDoc.documentElement || oDoc.documentElement.tagName == "parsererror")
                oDoc.parseError = -1;
            Sarissa.__setReadyState__(oDoc, 4);
        };
        /**
        * <p>Attached by an event handler to the load event. Internal use.</p>
        * @private
        */
        _sarissa_XMLDocument_onload = function(){
            Sarissa.__handleLoad__(this);
        };
        /**
         * <p>Sets the readyState property of the given DOM Document object.
         * Internal use.</p>
         * @private
         * @argument oDoc the DOM Document object to fire the
         *          readystatechange event
         * @argument iReadyState the number to change the readystate property to
         */
        Sarissa.__setReadyState__ = function(oDoc, iReadyState){
            oDoc.readyState = iReadyState;
            if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function")
                oDoc.onreadystatechange();
        };
        Sarissa.getDomDocument = function(sUri, sName){
            var oDoc = document.implementation.createDocument(sUri?sUri:"", sName?sName:"", null);
            oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
            return oDoc;
        };
        if(window.XMLDocument){
            /**
            * <p>Emulate IE's onreadystatechange attribute</p>
            */
            XMLDocument.prototype.onreadystatechange = null;
            /**
            * <p>Emulates IE's readyState property, which always gives an integer from 0 to 4:</p>
            * <ul><li>1 == LOADING,</li>
            * <li>2 == LOADED,</li>
            * <li>3 == INTERACTIVE,</li>
            * <li>4 == COMPLETED</li></ul>
            */
            // commented out to fix ie6 and firefox 3.6 home page hero rotator and clubhouse image rotator.
            // XMLDocument.prototype.readyState = 0;
            /**
            * <p>Emulate IE's parseError attribute</p>
            */
            XMLDocument.prototype.parseError = 0;

            // NOTE: setting async to false will only work with documents
            // called over HTTP (meaning a server), not the local file system,
            // unless you are using Moz 1.4+.
            // BTW the try>catch block is for 1.4; I haven't found a way to check if
            // the property is implemented without
            // causing an error and I dont want to use user agent stuff for that...
            var _SARISSA_SYNC_NON_IMPLEMENTED = false;// ("async" in XMLDocument.prototype) ? false: true;
            /**
            * <p>Keeps a handle to the original load() method. Internal use and only
            * if Mozilla version is lower than 1.4</p>
            * @private
            */
            XMLDocument.prototype._sarissa_load = XMLDocument.prototype.load;

            /**
            * <p>Overrides the original load method to provide synchronous loading for
            * Mozilla versions prior to 1.4, using an XMLHttpRequest object (if
            * async is set to false)</p>
            * @returns the DOM Object as it was before the load() call (may be  empty)
            */
            XMLDocument.prototype.load = function(sURI) {
                var oDoc = document.implementation.createDocument("", "", null);
                Sarissa.copyChildNodes(this, oDoc);
                this.parseError = 0;
                Sarissa.__setReadyState__(this, 1);
                try {
                    if(this.async == false && _SARISSA_SYNC_NON_IMPLEMENTED) {
                        var tmp = new XMLHttpRequest();
                        tmp.open("GET", sURI, false);
                        tmp.send(null);
                        Sarissa.__setReadyState__(this, 2);
                        Sarissa.copyChildNodes(tmp.responseXML, this);
                        Sarissa.__setReadyState__(this, 3);
                    }
                    else {
                        this._sarissa_load(sURI);
                    };
                }
                catch (objException) {
                    this.parseError = -1;
                }
                finally {
                    if(this.async == false){
                        Sarissa.__handleLoad__(this);
                    };
                };
                return oDoc;
            };
            
            
        }//if(window.XMLDocument)
        else if(document.implementation && document.implementation.hasFeature && document.implementation.hasFeature('LS', '3.0')){
            Document.prototype.async = true;
            Document.prototype.onreadystatechange = null;
            Document.prototype.parseError = 0;
            Document.prototype.load = function(sURI) {
                var parser = document.implementation.createLSParser(this.async ? document.implementation.MODE_ASYNCHRONOUS : document.implementation.MODE_SYNCHRONOUS, null);
                if(this.async){
                    var self = this;
                    parser.addEventListener("load", 
                        function(e) { 
                            self.readyState = 4;
                            Sarissa.copyChildNodes(e.newDocument, self.documentElement, false);
                            self.onreadystatechange.call(); 
                        }, 
                        false); 
                };
                try {
                    var oDoc = parser.parseURI(sURI);
                }
                catch(e){
                    this.parseError = -1;
                };
                if(!this.async)
                   Sarissa.copyChildNodes(oDoc, this.documentElement, false);
                return oDoc;
            };
            /**
            * <p>Factory method to obtain a new DOM Document object</p>
            * @argument sUri the namespace of the root node (if any)
            * @argument sUri the local name of the root node (if any)
            * @returns a new DOM Document
            */
            Sarissa.getDomDocument = function(sUri, sName){
                return document.implementation.createDocument(sUri?sUri:"", sName?sName:"", null);
            };        
        };
    };//if(_SARISSA_HAS_DOM_CREATE_DOCUMENT)
};
//==========================================
// Common stuff
//==========================================
if(!window.DOMParser){
    /*
    * DOMParser is a utility class, used to construct DOMDocuments from XML strings
    * @constructor
    */
    DOMParser = function() {
    };
    if(_SARISSA_IS_SAFARI){
        /** 
        * Construct a new DOM Document from the given XMLstring
        * @param sXml the given XML string
        * @param contentType the content type of the document the given string represents (one of text/xml, application/xml, application/xhtml+xml). 
        * @return a new DOM Document from the given XML string
        */
        DOMParser.prototype.parseFromString = function(sXml, contentType){
            if(contentType.toLowerCase() != "application/xml"){
                throw "Cannot handle content type: \"" + contentType + "\"";
            };
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(str), false);
            xmlhttp.send(null);
            return xmlhttp.responseXML;
        };
    }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && "loadXML" in Sarissa.getDomDocument()){
        DOMParser.prototype.parseFromString = function(sXml, contentType){
            var doc = Sarissa.getDomDocument();
            doc.loadXML(sXml);
            return doc;
        };
    };
};

if(window.XMLHttpRequest){
    Sarissa.IS_ENABLED_XMLHTTP = true;
}
else if(_SARISSA_IS_IE){
    /**
     * Emulate XMLHttpRequest
     * @constructor
     */
    XMLHttpRequest = function() {
        return new ActiveXObject(_SARISSA_XMLHTTP_PROGID);
    };
    Sarissa.IS_ENABLED_XMLHTTP = true;
};

if(!window.document.importNode && _SARISSA_IS_IE){
    try{
        /**
        * Implements importNode for the current window document in IE using innerHTML.
        * Testing showed that DOM was multiple times slower than innerHTML for this,
        * sorry folks. If you encounter trouble (who knows what IE does behind innerHTML)
        * please gimme a call.
        * @param oNode the Node to import
        * @param bChildren whether to include the children of oNode
        * @returns the imported node for further use
        */
        window.document.importNode = function(oNode, bChildren){
            var importNode = document.createElement("div");
            if(bChildren)
                importNode.innerHTML = Sarissa.serialize(oNode);
            else
                importNode.innerHTML = Sarissa.serialize(oNode.cloneNode(false));
            return importNode.firstChild;
        };
        }catch(e){};
};
if(!Sarissa.getParseErrorText){
    /**
     * <p>Returns a human readable description of the parsing error. Usefull
     * for debugging. Tip: append the returned error string in a &lt;pre&gt;
     * element if you want to render it.</p>
     * <p>Many thanks to Christian Stocker for the initial patch.</p>
     * @argument oDoc The target DOM document
     * @returns The parsing error description of the target Document in
     *          human readable form (preformated text)
     */
    Sarissa.getParseErrorText = function (oDoc){
        var parseErrorText = Sarissa.PARSED_OK;
        if(oDoc && oDoc.parseError && oDoc.parseError != 0){
            /*moz*/
            if(oDoc.documentElement.tagName == "parsererror"){
                parseErrorText = oDoc.documentElement.firstChild.data;
                parseErrorText += "\n" +  oDoc.documentElement.firstChild.nextSibling.firstChild.data;
            }/*konq*/
            else{
                parseErrorText = Sarissa.getText(oDoc.documentElement);
            };
        };
        return parseErrorText;
    };
};
Sarissa.getText = function(oNode, deep){
    var s = "";
    var nodes = oNode.childNodes;
    for(var i=0; i < nodes.length; i++){
        var node = nodes[i];
        var nodeType = node.nodeType;
        if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){
            s += node.data;
        }else if(deep == true
                    && (nodeType == Node.ELEMENT_NODE
                        || nodeType == Node.DOCUMENT_NODE
                        || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){
            s += Sarissa.getText(node, true);
        };
    };
    return s;
};
if(window.XMLSerializer){
    /**
     * <p>Factory method to obtain the serialization of a DOM Node</p>
     * @returns the serialized Node as an XML string
     */
    Sarissa.serialize = function(oDoc){
        var s = null;
        if(oDoc){
            s = oDoc.innerHTML?oDoc.innerHTML:(new XMLSerializer()).serializeToString(oDoc);
        };
        return s;
    };
}else{
    if(Sarissa.getDomDocument && (Sarissa.getDomDocument("","foo", null)).xml){
        // see non-IE version
        Sarissa.serialize = function(oDoc) {
            var s = null;
            if(oDoc){
                s = oDoc.innerHTML?oDoc.innerHTML:oDoc.xml;
            };
            return s;
        };
        /**
         * Utility class to serialize DOM Node objects to XML strings
         * @constructor
         */
        XMLSerializer = function(){};
        /**
         * Serialize the given DOM Node to an XML string
         * @param oNode the DOM Node to serialize
         */
        XMLSerializer.prototype.serializeToString = function(oNode) {
            return oNode.xml;
        };
    };
};

/**
 * strips tags from a markup string
 */
Sarissa.stripTags = function (s) {
    return s.replace(/<[^>]+>/g,"");
};
/**
 * <p>Deletes all child nodes of the given node</p>
 * @argument oNode the Node to empty
 */
Sarissa.clearChildNodes = function(oNode) {
    // need to check for firstChild due to opera 8 bug with hasChildNodes
    while(oNode.firstChild){
        oNode.removeChild(oNode.firstChild);
    };
};
/**
 * <p> Copies the childNodes of nodeFrom to nodeTo</p>
 * <p> <b>Note:</b> The second object's original content is deleted before 
 * the copy operation, unless you supply a true third parameter</p>
 * @argument nodeFrom the Node to copy the childNodes from
 * @argument nodeTo the Node to copy the childNodes to
 * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is false
 */
Sarissa.copyChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
    if((!nodeFrom) || (!nodeTo)){
        throw "Both source and destination nodes must be provided";
    };
    if(!bPreserveExisting){
        Sarissa.clearChildNodes(nodeTo);
    };
    var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
    var nodes = nodeFrom.childNodes;
    if(ownerDoc.importNode && (!_SARISSA_IS_IE)) {
        for(var i=0;i < nodes.length;i++) {
            nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
        };
    }
    else{
        for(var i=0;i < nodes.length;i++) {
            nodeTo.appendChild(nodes[i].cloneNode(true));
        };
    };
};

/**
 * <p> Moves the childNodes of nodeFrom to nodeTo</p>
 * <p> <b>Note:</b> The second object's original content is deleted before 
 * the move operation, unless you supply a true third parameter</p>
 * @argument nodeFrom the Node to copy the childNodes from
 * @argument nodeTo the Node to copy the childNodes to
 * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is
 */ 
Sarissa.moveChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
    if((!nodeFrom) || (!nodeTo)){
        throw "Both source and destination nodes must be provided";
    };
    if(!bPreserveExisting){
        Sarissa.clearChildNodes(nodeTo);
    };
    var nodes = nodeFrom.childNodes;
    // if within the same doc, just move, else copy and delete
    if(nodeFrom.ownerDocument == nodeTo.ownerDocument){
        while(nodeFrom.firstChild){
            nodeTo.appendChild(nodeFrom.firstChild);
        };
    }else{
        var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
        if(ownerDoc.importNode && (!_SARISSA_IS_IE)) {
           for(var i=0;i < nodes.length;i++) {
               nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
           };
        }else{
           for(var i=0;i < nodes.length;i++) {
               nodeTo.appendChild(nodes[i].cloneNode(true));
           };
        };
        Sarissa.clearChildNodes(nodeFrom);
    };
};

/** 
 * <p>Serialize any object to an XML string. All properties are serialized using the property name
 * as the XML element name. Array elements are rendered as <code>array-item</code> elements, 
 * using their index/key as the value of the <code>key</code> attribute.</p>
 * @argument anyObject the object to serialize
 * @argument objectName a name for that object
 * @return the XML serializationj of the given object as a string
 */
Sarissa.xmlize = function(anyObject, objectName, indentSpace){
    indentSpace = indentSpace?indentSpace:'';
    var s = indentSpace  + '<' + objectName + '>';
    var isLeaf = false;
    if(!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String 
        || anyObject instanceof Boolean || anyObject instanceof Date){
        s += Sarissa.escape(""+anyObject);
        isLeaf = true;
    }else{
        s += "\n";
        var itemKey = '';
        var isArrayItem = anyObject instanceof Array;
        for(var name in anyObject){
            s += Sarissa.xmlize(anyObject[name], (isArrayItem?"array-item key=\""+name+"\"":name), indentSpace + "   ");
        };
        s += indentSpace;
    };
    return s += (objectName.indexOf(' ')!=-1?"</array-item>\n":"</" + objectName + ">\n");
};

/** 
 * Escape the given string chacters that correspond to the five predefined XML entities
 * @param sXml the string to escape
 */
Sarissa.escape = function(sXml){
    return sXml.replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;")
        .replace(/'/g, "&apos;");
};

/** 
 * Unescape the given string. This turns the occurences of the predefined XML 
 * entities to become the characters they represent correspond to the five predefined XML entities
 * @param sXml the string to unescape
 */
Sarissa.unescape = function(sXml){
    return sXml.replace(/&apos;/g,"'")
        .replace(/&quot;/g,"\"")
        .replace(/&gt;/g,">")
        .replace(/&lt;/g,"<")
        .replace(/&amp;/g,"&");
};
//   EOF


//sarisa.js ends 


/*
@arg1 - formName
@arg2 - fieldId
	How to Use:  
	document.getElementById('thisId')== $get_JsElement('thisId')
	Created By- RoopVijay
*/

function $get_JsElement() {
	var element=null;
	  if(arguments.length==1){
	 	 element = document.getElementById(arguments[0]);
	  }else if(arguments.length==2){
	 	 element=eval("document."+arguments[0]+".elements['"+arguments[1]+"']")
	  }
	
    return element;
}


/*
@arg1 - forTextField or forSelect
@arg2 - formName
@arg3 - fieldId
	Created By- RoopVijay
*/
function $loadCookieValueOnPage(){

	if(getCookie(arguments[2])!=null)
	 {
			if(arguments[0]=='forTextField'){
				$get_JsElement(arguments[1],arguments[2]).value=getCookie(arguments[2])
			}else if(arguments[0]=='forSelect'){
				for(k=0;k<$get_JsElement(arguments[1],arguments[2]).options.length; k++)
				{
					if($get_JsElement(arguments[1],arguments[2]).options[k].value == getCookie(arguments[2]))
					{
						$get_JsElement(arguments[1],arguments[2]).options[k].selected=true;
						break;
					}
				}
			}
	}
}


//popdiv function start
function showHideDiv(divid,displayFlag,divType,divObj) {

	if(divType == 'p') {

		var posx = 0;
		var posy = 0;
		var xOffset = 0;
		var yOffset = 0;
		var obj = document.getElementById(divObj);

		// get mouse coordinates relative to icon image
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				posx += obj.offsetLeft;
				posy += obj.offsetTop;
				obj = obj.offsetParent;
			}
		} else if (obj.x) {
			posx += obj.x;
			posy += obj.y;
		}
		
		// set div offsets
		xOffset = 10;
		yOffset = 0;
		
		if(divid == 'wtRedress') {
			xOffset = 0;
		} else if(divid == 'privacyNotice') {
			xOffset = 130;
		}
		
		document.getElementById(divid).style.left = (posx+xOffset) ;
		document.getElementById(divid).style.top = (posy+yOffset) ;
		
	}
		
	if(displayFlag) {
		document.getElementById(divid).style.display = 'block';
	} else {
		document.getElementById(divid).style.display = 'none';
	}
		
}

// popdiv function end

// cal.js start 
var fixedConfiguratedDate="";
var calType="other";
var o_navigator = navigator.userAgent.toLowerCase();
var isMacIE = (o_navigator.indexOf("msie 5")>-1&&o_navigator.indexOf("mac")>-1) ? 1 : 0;
var isPCIE6 = (o_navigator.indexOf("msie 6")>-1) ? 1 : 0;
var isChrome = (o_navigator.indexOf("chrome")>-1) ? 1 : 0;
var isPCIE = (o_navigator.indexOf("msie")>-1&&!isMacIE&&o_navigator.indexOf("opera")==-1&&o_navigator.indexOf("msie 9")==-1) ? 1 : 0;
var isFF = (o_navigator.indexOf("mac")==-1 && o_navigator.indexOf("firefox")>-1) ? 1 : 0;
var isOpera = o_navigator.indexOf("opera")>-1 ? 1 : 0;
var isKHTML = o_navigator.indexOf("khtml")>-1 ? 1 : 0;
var isSafari = (o_navigator.indexOf("mac")>-1 && o_navigator.indexOf("safari")>-1) ? 1 : 0;
var isMacFF = (o_navigator.indexOf("mac")>-1 && o_navigator.indexOf("firefox")>-1) ? 1 : 0;
var mArray	= new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var dArray 	= new Array("S","M","T","W","T","F","S");
var datesArray 		= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var today='';
var yearShowFlg=false;
var showYear="";
if(typeof fixedateForAddPoints == 'undefined'){
today = new Date();			//todays date
}else{
var fixedateForAddPointsParse= Date.parse(fixedateForAddPoints)   // convert string to date
yearShowFlg = true;
today = new Date(fixedateForAddPointsParse); // get the configurate date
}
// today date is commened for temporary time 										
var cD 				= today.getDay();		//current day of week 0-6
var cT				= today.getDate();		//current day 1-31
var cM				= today.getMonth();		//current month 0-11
var cMDs 			= datesArray[cM];		//number of days in current month
var cY				= today.getFullYear();	//js method	not used here//current Year
var newT			= cT;					//cal selected date
var newM			= cM;					//cal selected month
var newY			= cY;					//cal selected year
var newDs			= cMDs;					//days for selected Month
var newD			= cD;					//day of week
var numCalendars	= 2;					//number of calendars you want to create
var calDirection	= "";	 				//put "horizontal" or "vertical"
var calopen 		= 0;					//boolean set state of iframe "0" closed "1" open;
var o_windowparent  = top;					//set parent frame
var o_input 		= 0;
var o_month = 0; var o_date = 0;
var o_iframecal = 0;
var o_from;var o_to;var v_from;var v_to;
var d_makefrom=0; var d_maketo=0;var s_lang="us";
var o_currentDate = false;
var i_firstMonth = cM;
var i_sfirstYear = cY; var i_sfirstMonth = cM;
var i_ofirstYear = cY; var i_ofirstMonth = cM;
var b_calinit = 0;
var o_row = null;
var i_numcal = 0;
var o_calbody = null; //where to write the calendar
var s_jscall = (isPCIE)? "parent." : "";
var s_closecal = "";
var b_date331 = 0;
var a_input = 0;
var o_parent;
var s_inputtype = "object"; //for text input or select list input
var a_v_input = null;
var FieldClicked = null;
var departDate = "";
var flgDorR="";
var flgRetName="";
var flgDateDisable="";
// cal.js end
//checkInBags.js start
var chk="";
var chkExccessbags='true';
var TOTALBAGSDEP=0;
var TotalSelectValue=0;
var TotalSelectValueRet=0;
var TotalSubDep=00;
var TotalSubRet=00;
var TotalDepRet=0;
var guestsize=0;
var chkAjaxDiv;
var chkAjaxDivSecond;
var secondDiv;
var pointsDivId;
var showPointsDivId;
var addFieldId="";
var discontinue=0;
var callErrorFun=0;
var excessBagsString="";
var excessBagsStringRet="";
var tempguestBag=0;
var guestHaveExcessBags=0;
var allowFree_Bags=0;
var xmlhttp = new XMLHttpRequest();
var chkxmlhttp = new XMLHttpRequest();
var formTripType=null;
//checkInbags.js end

//indexPageFunction.js start
var iswap=0;
var X=0;
var Y=0;	
var linkCnt = 0;
var maxheight = 240; //100 can be replaced with the desired height
var c1;
var c2;
//indexPageFunctions.js

//pnrResult.js start
var thisobj="undefined";
var checkval="undefined";
var depLeg1Guest="";
var depLeg2Guest="";
var retLeg1Guest="";
var retLeg2Guest="";
var depLeg1Seat="";
var depLeg2Seat="";
var retLeg1Seat="";
var retLeg2Seat="";
var guestArray=new Array();
var seatArray=new Array();
var seatDepConnectArray=new Array();
var guestArrayRet=new Array();
var seatArrayRet=new Array();
var seatRetConnectArray=new Array();
var gnum="";
var gnumRet="";
//var xmlhttp;
var ajaxDiv;
var alreadyCheckedInDep='false';
var alreadyCheckedInRet='false';
var mywindow;
var mywindowForHtml;
//pnrResult.js end


//searchPageFunctions.js start
var wichSelected;
var tabVal="";
//searchPageFunctions.js end


//signInAndProfile.js start
//var xmlhttp;
var ajaxDiv;
var seatMapAjaxDiv;
var activatedTab="";
var tabSelect="1";
var tbSelect="1";
var logInVal="Email or Elevate#";
var loginModuleOrRest="login";
var holdInnerHtml="";
//signInAndProfile.js end


//generalFunction.js start
var expiredays =0;
var FrmToSubmit="";
var buttonURL="";
var flgMsg=false;
var xAxis="";
var yAxis="";
var X1=0;
var Y1=0;
var disableIds=0;
var rUInRegistrationProcess="No";
var movex = 0;
var movey = 0;
var xdiff = 0;
var ydiff = 0;
var ystart= 0;
var xstart= 0;
var a=0;
var isScroll="Yes";
var positionDivFare;
var actualDiv;
var checkSearchTypeLink;
var imgObj;
//generalFunction.js end


//FlightStatusAjaxFunction.js start
var fltStatusErrorsRequired='To find the flight you need, we need a valid flight number or city pair.'
var fltStatusErrorsUnknown='Unknown error: Contact admin'
var fltStatusErrorsServiceRequired='No data matches your selection criteria.'
var fltStatusErrorsInValidFltNo='The flight number you have chosen does not fly on this date.  Please choose another day.' 
var fltStatusErrorsInValidFltNoNotNum='Flight numbers must be numeric only.'
var fltStatusErrorsInValidCityPair='The city pair you have selected does not match the correct flight number. Please double check them and try again.'
var fltStatusErrorsNoFltGivenDate='Sorry, there are not any flights for the date you have requested.'
var fltStatuserrorsnoData='No Data Available for this date or selected City Pair.'
var IsNumber=true;
//FlightStatusAjaxFunction.js end


function addElement(parentId, eleType, eleName, eleValue) {
	var parentObj = document.getElementById(parentId);
	//Create an input type dynamically.  
	var element = document.createElement("input");  
	//Assign different attributes to the element.  
	element.setAttribute("type", eleType);  
	element.setAttribute("value", eleValue);  
	element.setAttribute("name", eleName);  
	//Append the element in page (in FORM).  
	parentObj.appendChild(element);  
}

function createForm(frmName, frmAction){
	var formElement = document.createElement("form");
	formElement.setAttribute("name", frmName); 
	formElement.setAttribute("id", frmName); 
	formElement.setAttribute("method", "post");
	return formElement;
}


function joinElevate(fName, mName, lName, address1, address2, city, state, country, zipCode){
	var joinElevateReqForm = createForm("requestProfileForm", "joinElevate.do");
	var frmParentObj = document.getElementById("joinElevateDiv");
	frmParentObj.appendChild(joinElevateReqForm); 
	joinElevateReqForm.action="joinElevate.do";
	joinElevateReqForm.method="POST";
	addElement(joinElevateReqForm.id, "hidden", "method", "joinElevate");  
	addElement(joinElevateReqForm.id, "hidden", "fName", fName);  
	addElement(joinElevateReqForm.id, "hidden", "mName", mName);  
	addElement(joinElevateReqForm.id, "hidden", "lName", lName);  
	addElement(joinElevateReqForm.id, "hidden", "address1", address1);  
	addElement(joinElevateReqForm.id, "hidden", "address2", address2);  
	addElement(joinElevateReqForm.id, "hidden", "city", city);  
	addElement(joinElevateReqForm.id, "hidden", "state", state);  
	addElement(joinElevateReqForm.id, "hidden", "country", country);  
	addElement(joinElevateReqForm.id, "hidden", "zipCode", zipCode);
	
	joinElevateReqForm.submit();
}

// anchorPosition.js start
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}

// anchorPosition.js end

	
	
	
//  cal.js start
/* This function file returns the first day of a year */
function findFirstDay(){

	firstDay = new Date();
	firstDay.setDate(1);
	firstDay.setMonth(newM);
	firstDay.setFullYear(newY);
	return firstDay.getDay();
}

// this function will set default date from configuration File
function setDateLimit(DateLimit1) {
	fixedConfiguratedDate=DateLimit1;
}

// "fixedConfiguratedDate" this value is being come from project config.xml file.
 
function check331(d_date){
	var b_check331;
	ConParseDate = Date.parse(fixedConfiguratedDate)   // convert string to date
	
 	ConfiguratedDate = new Date(ConParseDate); // get the configurate date

	if (ConfiguratedDate>d_date){ 
	b_check331 = 0;
	}else{ 
	b_check331 = 1;
	}
	return b_check331;
}



function vm_setupCal(){
	i_numcal = 0;
	if(calType=='home'){
		makeCal(cM);
	}else{
		vm_makeCal(cM);
	}
}
function preventClose(evt){
	if(isKHTML||isOpera)evt.stopPropagation();
}

/*This creates the 'td' elements & sets the date into all tds */
function ty_makeDate(which){
	
	d_makedate = new Date(newY,newM,which);
	
	
	b_date331 = check331(d_makedate);

	if((flgDorR=="return_date.png" || flgDorR=="Return_date.gif" || flgRetName=="flightSearch.returnDateMC.MMDDYYYY")&& flgDateDisable!=""){
		var flgDateDisableDay =flgDateDisable.getDate();
		var flgDateDisableMonth =flgDateDisable.getMonth();
		var flgDateDisableYear =flgDateDisable.getFullYear();
			
		// Calander Issue Reported on Production - Abhay Gupta 1st Oct08			
		//if((flgDateDisableDay>which && flgDateDisableMonth == newM && flgDateDisableYear == newY)||b_date331 || (flgDateDisableMonth > newM)){
		if((flgDateDisableDay>which && flgDateDisableMonth == newM && flgDateDisableYear == newY)||b_date331){
			s_makeDate = "<td class='calDateOff' width='18' height='16'>&nbsp;";
			//s_makeDate= "<td class='calDateSel' width='18' height='16'>";
			s_makeDate+= which;
		
		}else{
		if(d_makefrom||d_maketo){
//			s_makeDate = ((d_makedate.toString()==d_makefrom.toString()) && flgDorR!= 'Return_date.gif') ? "<td class='calDateSel' width='18' height='16'>" : (d_makedate>d_makefrom&&d_makedate<d_maketo&&d_makefrom) ? "<td class='calDateOff' width='18' height='16'>" : "<td class='calDate' width='18' height='16'>"; // "<td class='calDateRng' width='18' height='16'>" has been changed to "<td class='calDateOff' width='18' height='16'>"//||(d_makedate.toString()==d_maketo.toString())
			if(flgDorR=="Return_date.gif" || flgDorR=="return_date.png" || flgRetName=="flightSearch.returnDateMC.MMDDYYYY"){
			d_makefrom=d_maketo;
			}
			
			if(d_makedate.toString()==d_makefrom.toString()){
				s_makeDate= "<td class='calDateSel' width='18' height='16'>";
			}
			else{
				if(d_makedate>d_makefrom&&d_makedate<d_maketo&&d_makefrom){
				 s_makeDate="<td class='calDateOff' width='18' height='16'>";}
				else{ 
				s_makeDate="<td class='calDate' width='18' height='16'>";}
				} // "<td class='calDateRng' width='18' height='16'>" has been changed to "<td class='calDateOff' width='18' height='16'>"//||(d_makedate.toString()==d_maketo.toString())

		}else{
			s_makeDate = "<td class='calDate' width='18' height='16'>";
		}
		
			if(d_makedate.toString()==d_makefrom.toString()){
				s_makeDate+= "<a href='#' id='idmake_Date' onclick='"+s_jscall+"ty_setDate("+newM+","+which+",this.parentNode,"+newY+");return false;' style='color:#FFFFFF;TEXT-DECORATION: none;'>";
			}
			else{
			s_makeDate+= "&nbsp;<a href='#' id='idmake_Date1' onclick='"+s_jscall+"ty_setDate("+newM+","+which+",this.parentNode,"+newY+");return false;' class='calDateA'>";
		
			}	
		
		
		s_makeDate+= which;
		s_makeDate+="</a>";
	}
	}else{
	if((cT>which && cM == newM && cY == newY)||b_date331){
			s_makeDate = "<td class='calDateOff' width='18' height='16'>&nbsp;";
		//s_makeDate= "<td class='calDateSel' width='18' height='16'>";
		s_makeDate+= which;
	}else{
		if(d_makefrom||d_maketo){
//			s_makeDate = ((d_makedate.toString()==d_makefrom.toString()) && flgDorR!= 'Return_date.gif') ? "<td class='calDateSel' width='18' height='16'>" : (d_makedate>d_makefrom&&d_makedate<d_maketo&&d_makefrom) ? "<td class='calDateOff' width='18' height='16'>" : "<td class='calDate' width='18' height='16'>"; // "<td class='calDateRng' width='18' height='16'>" has been changed to "<td class='calDateOff' width='18' height='16'>"//||(d_makedate.toString()==d_maketo.toString())
			if(flgDorR=="Return_date.gif" || flgDorR=="return_date.png" || flgRetName=="flightSearch.returnDateMC.MMDDYYYY"){
			d_makefrom=d_maketo;
			}
			
			if(d_makedate.toString()==d_makefrom.toString()){
				s_makeDate= "<td class='calDateSel' width='18' height='16'>";
			}
			else{
				if(d_makedate>d_makefrom&&d_makedate<d_maketo&&d_makefrom){
				 s_makeDate="<td class='calDateOff' width='18' height='16'>";}
				else{ 
				s_makeDate="<td class='calDate' width='18' height='16'>";}
				} // "<td class='calDateRng' width='18' height='16'>" has been changed to "<td class='calDateOff' width='18' height='16'>"//||(d_makedate.toString()==d_maketo.toString())

		}else{
			s_makeDate = "<td class='calDate' width='18' height='16'>";
		}
		
			if(d_makedate.toString()==d_makefrom.toString()){
				s_makeDate+= "<a href='#' id='idmake_Date2' onclick='"+s_jscall+"ty_setDate("+newM+","+which+",this.parentNode,"+newY+");return false;' style='color:#FFFFFF;TEXT-DECORATION: none;'>";
			}
			else{
			s_makeDate+= "&nbsp;<a href='#' id='idmake_Date3' onclick='"+s_jscall+"ty_setDate("+newM+","+which+",this.parentNode,"+newY+");return false;' class='calDateA'>";
		
			}	
		
		
		s_makeDate+= which;
		s_makeDate+="</a>";
	}
	} //end of else condition
	s_makeDate+="</td>";

	return s_makeDate;
}

/*This function creates the tr elements for a table*/
function ty_maketr(what){
	s_tr = "<tr>";
	s_tr+= what;
	s_tr+= "</tr>";
	return s_tr;
}


/*This function changes the month*/
function ty_changeMonths(which){
	calopen=0;
	i_numcal = 0;
	o_calbody.innerHTML ="";
	if(which < 0){
		which=11;
		newY--;
	}
	if(calType=='home'){
		makeCal(which);
	}else{
		vm_makeCal(which);
	}
	setTimeout("calopen = 1",100);
}

var o_cal1="", o_cal2="";
//Use for the top two tables

var calBaseWidth = 0;
if(isPCIE == 1 || isSafari) {
	calBaseWidth = '358';
} else {
	calBaseWidth = '357';
}

// body of calendar months is a background color of #f7f7f7
var tableOpen1 = "<tr><td colspan='3' align='center' valign='top'><table width='357' border='0' cellpadding='0' cellspacing='0'><tr><td width='13' rowspan='2' align='left' valign='top' background='https://static.virginamerica.com/images/calender_lt.png' style='background-repeat:repeat-y;'><img src='https://static.virginamerica.com/images/spacer.gif' width='13' height='8' /></td><td height='3' align='left' valign='top' bgcolor='#ffffff' ><img src='https://static.virginamerica.com/images/spacer.gif' width='15' height='3' /></td><td width='14' rowspan='2' align='left' valign='top' background='https://static.virginamerica.com/images/calender_rt.png' style='background-repeat:repeat-y;'><img src='https://static.virginamerica.com/images/spacer.gif' width='14' height='8' /></td></tr><tr><td align='left' valign='top' bgcolor='#e6e6e6'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td width='"+innerCalW+"' align='center' valign='top' bgcolor='#e6e6e6'>";
var tableClose1 = "</td></tr></table></td></tr><tr><td width='"+calBaseWidth+"' height='10' colspan='3' align='left' valign='top'><img src='https://static.virginamerica.com/images/calender_base.png' width='"+calBaseWidth+"' height='10' /></td></tr></table>";
var tdFor3rdTable = "</td><td width='7' height='19' align='left' valign='top'><img src='https://static.virginamerica.com/images/spacer.gif' width='7' height='96' /></td><td width='"+innerCalW+"' align='left' valign='top' >";

/*This function creates the structure for a table & sets the dates in 'tds' */
function vm_makeCal(whichMonth){
	
	o_calnext = "";
	//o_calprev = "";
	b_calinit = 1;
	o_cal= "";
	o_caltr="";o_caltd="";
	newM = whichMonth;
	
	if(newM < cM) newY = newY;
	if(newY<cY) newY=cY;
	if (newM>=12){
		newM=whichMonth-12;
		newY++;
	}
	if(i_numcal==0){
		i_firstMonth = newM
		switch(s_inputtype){
			case "object":
				i_ofirstMonth  = newM;
				i_ofirstYear = newY;
			break;
			default:
				i_sfirstMonth  = newM;
				i_sfirstYear = newY;
		}
	}
	
	newDs = datesArray[newM];
	isLeap 	= (newY % 4 == 0 && (newY % 100 !=0 || newY % 400 ==0 )) ? 1:0
	if (newM==1) newDs=newDs+isLeap;
	newD = findFirstDay();
	countDay = newD;
	
	s_calclass = (calDirection=="vertical")? "calTableH" : "calTableH";
	
	var changeTDTOTABLEValue = "";
	o_cal+="<table month='"+newM+"' year='"+newY+"' width='"+innerCalW+"' border='0' cellspacing='0' cellpadding='0' style='border:1px solid #f7f7f7;background-color:#ffffff;'>";
	o_caltr+= "<tr>";
	o_caltd+= "<td height='20' align='center' valign='top' class='calMon' background='https://static.virginamerica.com/images/month_bg.png' colspan=7>";
	
	changeTDTOTABLEValue = mArray[newM]; //+"&nbsp;"+newY;

	o_caltd+= "RWTCMT";
	o_caltd+= "</td>";
	o_caltr+=o_caltd;
	o_caltr+="</tr>";
	o_cal+=o_caltr;
	o_caltd = "";
	
	o_caltd+="<td height='14' align='left' valign='top' colspan=7 ><img src='https://static.virginamerica.com/images/day_name.png' width='"+innerCalW+"' height='14' /></td>";		
	
	o_caltd+="<tr><td ></td><td colspan=5><img src='https://static.virginamerica.com/images/spacer.gif'></td><td></td>";
	o_caltr = ty_maketr(o_caltd);
	o_cal+=o_caltr;
	o_caltd = "";
	i_calRows = 0;
	
	for (d=1;d<=newDs;d++){
		if(d==1)for(bd=0;bd < newD;bd++)o_caltd += "<td width='18' height='16' align='left' valign='top'><img src='https://static.virginamerica.com/images/spacer.gif' width='18' height='16' /></td>";
		o_caltd += ty_makeDate(d);
		countDay++;
		if(countDay==7){
			countDay=0;
			o_caltr = ty_maketr(o_caltd);
			o_cal+=o_caltr;
			o_caltd = "";
			i_calRows++
		}
		if(d==newDs && countDay!=0){
			for (bd=countDay;bd < 7;bd++) o_caltd += "<td width='18' height='16' align='left' valign='top'><img src='https://static.virginamerica.com/images/spacer.gif' width='18' height='16' /></td>";
			o_caltr = ty_maketr(o_caltd);
			o_cal+=o_caltr;			
			o_caltd ="";
			i_calRows++
		}
	}
	if(i_calRows < 6){
		o_caltd = "";
		for(bd=0;bd < 7;bd++) o_caltd += "<td width='18' height='16' align='left' valign='top'><img src='https://static.virginamerica.com/images/spacer.gif' width='18' height='16' /></td>";
		o_caltr = ty_maketr(o_caltd);
		o_cal+= o_caltr;
	}
	
	o_cal+="</table>";
	if (i_numcal==0) {
		if (newM==cM&&newY==cY) {
			o_cal1 = ""
		}
		else
		{
			o_cal1 = "<a href='#' id='idcal1' onclick='"+s_jscall+"ty_changeMonths("+i_firstMonth+"-1);"+s_jscall+"preventClose(event);return false;'><img src='https://static.virginamerica.com/images/calender_prev.png' border='0' /></a>" // SPECIFY IMAGE NAME INSTEAD OF <<
		}
		o_calprev = '<div style="float:left;">' + o_cal1 + '</div>';
	}
	else 
	{
		//o_cal1 = ""
	}
	
	o_calbody.innerHTML += o_cal;
	i_numcal++;
	
	//if(i_numcal==numCalendars&&!(newM==cM-1)&&!b_date331) {
	if(i_numcal==numCalendars &&!b_date331) {
		o_cal2 = "<a href='#' id='idcal2' onclick='"+s_jscall+"ty_changeMonths("+i_firstMonth+"+1);"+s_jscall+"preventClose(event);return false;'><img src='https://static.virginamerica.com/images/calender_nxt.png' border='0' /></a>"  // SPECIFY IMAGE NAME INSTEAD OF >>
	}else
	{
		o_cal2="";
	}
	
	
	o_calnext = '<div style="float:right;">' + o_cal2 + '</div>';
	
	// for the months
	var monthtable1 = "<table width='150' border='0' cellspacing='0' cellpadding='0'><tr><td align='left' valign='top' width='5' height='19'><img src='https://static.virginamerica.com/images/spacer.gif' width='5' height='19' border='0' /></td><td width='16' align='left' valign='top'>";
	var monthtable2 = "</td><td width='5' align='center' valign='middle' class='style9'><img src='https://static.virginamerica.com/images/spacer.gif' width='5' height='19' border='0' /></td></tr></table>";
	if(i_numcal < numCalendars)
	{	
		changeTDTOTABLEValue = monthtable1 + 
								"</td><td align='center' valign='middle' class='calMonthTitle'>" +
								changeTDTOTABLEValue + "</td><td width='16' align='center' valign='middle' class='style9'>&nbsp;" +
									monthtable2;
		
		o_cal1 = o_calbody.innerHTML;
		o_calbody.innerHTML = "";
		o_cal1 = o_cal1.replace("RWTCMT",changeTDTOTABLEValue);
	}
	else
	{
		// + o_cal2 
		changeTDTOTABLEValue = monthtable1 + 
								 "&nbsp;</td><td align='center' valign='middle' class='calMonthTitle'>" +
								changeTDTOTABLEValue + "</td><td width='16' align='center' valign='middle' class='style9'>"+ 
									monthtable2;
		

		
		o_cal2 =  o_calbody.innerHTML;
		o_cal2 = o_cal2 + "</td></tr></table>";
		o_calbody.innerHTML = "";
		o_cal2 = o_cal2.replace("RWTCMT",changeTDTOTABLEValue);
	}
	
	if(i_numcal < numCalendars)
	{	
		vm_makeCal(newM+1); 
		zzzz++;
		
	}
	else if (i_firstMonth > newM)
	{
		newY--;
	}
	// fill the calbody frame or div with actual calendar HTML
	if (zzzz%2 == 0) {
		//if(isPCIE == 1) {
	//	document.getElementById('calframe').style.height = '192px';
	//	}
		o_calbody.innerHTML = s_closecal + tableOpen1 + o_cal1 + tdFor3rdTable + o_cal2 + o_calprev + o_calnext + tableClose1; 
		zzzz = 1;
	}

}
var zzzz = 1;


function ty_setDate(whatMonth,whatDate,whatTD,whatYear){
	o_currentDate = whatTD;
	o_currentDate.className = "calDateSel";
	if(typeof(o_input)=="object"){
		o_input.value = (s_lang=="us") ? (whatMonth+1)+"/"+whatDate+"/"+whatYear : whatDate+"/"+(whatMonth+1)+"/"+whatYear;
	}else{
		document.getElementById(a_v_input[0]).selectedIndex = whatMonth;
		document.getElementById(a_v_input[1]).selectedIndex = whatDate-1;
	}
	closeCal();
}

/*This function hide the calendar*/
function hideCalendar(){
	o_caldiv.style.display = "none"
	if(o_parent && calType!='home') o_parent.className = "cbrow"
}


function splitDate(s_input, s_mode){
	this.delimitor = (s_input.indexOf("/")>-1) ? "/" : (s_input.indexOf(".")>-1) ? "." : (s_input.indexOf("-")>-1) ? "-" : (s_input.indexOf(",")>-1) ? "," : "/";
	a_input = s_input.split(this.delimitor);
	this.date = -1;this.month = -1;this.year = -1;
	if(a_input.length==3&&!isNaN(a_input[0])&&!isNaN(a_input[1])&&!isNaN(a_input[2])){
		this.month = (s_mode=="us") ? parseInt(a_input[0],10)-1 : parseInt(a_input[1],10)-1;
		this.date = (s_mode=="us") ? parseInt(a_input[1],10) : parseInt(a_input[0],10);
		this.year = a_input[2];
		if(this.month>11||this.month<0)this.month=-1;
		if(this.date>31||this.month<0)this.date=-1;
		i_yrlength = this.year.toString().length;
		if(i_yrlength==2)this.year = "20"+this.year;//fix this in the next 96 years...
		if(i_yrlength<1||i_yrlength==3||this.year<cY)this.year=-1;
	}
}
var o_caldiv=0;
var t_calcloser = null;


/*It creates the date of format mm/dd/yy for input field*/
function buildDate(s_monthdate){
	a_monthdate = s_monthdate.split("|");
	bd_oMonth = document.getElementById(a_monthdate[0]);
	bd_oDate = document.getElementById(a_monthdate[1]);
	i_month = bd_oMonth.selectedIndex+1;
	i_date = bd_oDate.selectedIndex+1;
	s_date = "";
	s_date = i_month+"/"+i_date+"/";
	s_date+= (i_month-1 < cM) ? cY+1 : cY;
	return s_date;
}
var s_lastinputtype = null;


/*it sets the style of the calendar either it will be vertical or horizontal*/
function makeCalendar(v_input,s_from,s_to,s_mode){
	
	o_input = v_input;
	// Start, coded by vinod sharma
	// date 22/02/2008
	// By default current date will be seleted by code
	if(document.getElementById(s_from).value=="" ||document.getElementById(s_from).value=="mm/dd/yyyy"){
		call_from_date_month= new Date().getMonth()+1;
		call_from_date_date= new Date().getDate();
		call_from_date_year= new Date().getFullYear();
	 	document.getElementById(s_from).value=call_from_date_month+'/'+call_from_date_date+'/'+call_from_date_year;
	}
	// End, coded by vinod sharma
	// date 22/02/2008
	// By default current date will be seleted by code
	var calCSS=null;
	if(calType=='home'){
		calCSS=document.getElementById("cssId");
	}else{
		calCSS=document.getElementById("calendarcss");	
	}
	
	// build of the iframe background in case of IE browsers
//	if(isPCIE == 1){		
//		s_iecalcss = "<link rel='STYLESHEET' type='text/css' href='"+calCSS.href+"' />";
		
//		o_califrame = document.getElementById("calframe")
//		calframe.document.open();
		
//		calframe.document.write("<html><head>"+s_iecalcss+"</head><body id='calbox' class='calendar'></body></html>");
//		calframe.document.close();
//	}
	i_numcal = 0;
	//if(isPCIE)document.getElementById("calframe").className="calframe";
	if(calType=='home'){
		//o_calbody = (isPCIE) ? document.getElementById("calbox") : document.getElementById("calbox");
		o_calbody = document.getElementById("calbox");
	}else{
//		o_calbody = (isPCIE) ? calframe.document.getElementById("calbox") : document.getElementById("calbox");
		o_calbody = document.getElementById("calbox");

	}
	o_calbody.innerHTML="";
	o_udate = (typeof(o_input)=="object") ? new splitDate(o_input.value,'us') : new splitDate(buildDate(o_input),'us') ;
	a_from = s_from.split("|");
	v_from = (a_from.length==1) ? new splitDate(document.getElementById(s_from).value,s_mode) : new splitDate(buildDate(s_from),s_mode);
	a_to = s_to.split("|");

	v_to = (a_to.length==2) ? new splitDate(buildDate(s_to),s_mode) : (document.getElementById(s_to)) ? new splitDate(document.getElementById(s_to).value,s_mode) : new splitDate("",s_mode);
	d_makefrom = (v_from.month!=-1) ? new Date(v_from.year,v_from.month,v_from.date) : 0;
	d_maketo = (v_to.month!=-1) ? new Date(v_to.year,v_to.month,v_to.date) : 0;

	
switch(b_calinit){
case 0:
	if(o_udate.month!=-1&&o_udate.year!=-1&&o_udate.date!=-1){
		newY=o_udate.year;
		newM=o_udate.month;
		newD=o_udate.date;
		if(calType=='home'){
			makeCal(o_udate.month);
		}else{
			vm_makeCal(o_udate.month);
		}
	}else if(o_udate!=document.getElementById(s_from)&&d_makefrom){
		newY=v_from.year;
		newM=v_from.month;
		newD=v_from.date;
		if(calType=='home'){
			makeCal(v_from.month);
		}else{
			vm_makeCal(v_from.month);
		}	
	}else if(o_udate!=document.getElementById(s_to)&&d_maketo){
		newY=v_to.year;
		newM=v_to.month;
		newD=v_to.date;
		if(calType=='home'){
			makeCal(v_to.month);
		}else{
			vm_makeCal(v_to.month);
		}	
	}else{
		newY=cY;newM=cM;newD=cD;
		if(calType=='home'){
			makeCal(cM);
		}else{
			vm_makeCal(cM);
		}
	}
break;
default:
		switch(s_inputtype){
			case "object":
				newM = i_ofirstMonth;
				newY = i_ofirstYear;
			break;
			default:
				newM = i_sfirstMonth;
				newY = i_sfirstYear;
		}
		if(calType=='home'){
			makeCal(newM);
		}else{
			vm_makeCal(newM);
		}
	}

	s_lastinputtype = typeof(o_input);
}
var p, EX1, EX2, EY1, EY2;


/*This function shows the calendar */
function openCal(v_input,s_from,s_to,s_cal,s_parent,s_mode,s_caldir, pos1, pos2, imageName){
	//calType="other";
	flgDorR=imageName;
	flgRetName=s_from;
	var retLocalVar=s_from;
	var dpDtStr="";
	cM= today.getMonth();	
	cY=today.getFullYear();
	if(document.flightSearchRTForm){
		for(i=0;i<document.flightSearchRTForm.elements.length;i++){
			if(document.flightSearchRTForm.elements[i].name=="flightSearch.depDate.MMDDYYYY")
				dpDtStr=document.flightSearchRTForm.elements[i].value;
		}
	}else if(document.flightSearchForm){
		for(i=0;i<document.flightSearchForm.elements.length;i++){
			if(document.flightSearchForm.elements[i].name=="flightSearch.depDate.MMDDYYYY")
				dpDtStr=document.flightSearchForm.elements[i].value;
	}
	}
	if(imageName=="Return_date.png" || (retLocalVar=="flightSearch.returnDateMC.MMDDYYYY") || imageName=="return_date.png" ){
	
		if(dpDtStr=="" ||dpDtStr=='mm/dd/yyyy'){
		
			i_ofirstMonth=new Date().getMonth();
	
			flgDateDisable=new Date();
			}else{
			flgDateDisable=new Date(dpDtStr);
			i_ofirstMonth=new Date(dpDtStr).getMonth();
			cM=i_ofirstMonth;
			cY=flgDateDisable.getFullYear();
		}
	}
	
	// section of the top of the calendar holding the left 'departing' or 'returning' image, close button and lt / rt corners
	s_closecal = "<table border='0' cellpadding='0' cellspacing='0'><tr><td width='280' height='22' align='left' valign='top' ><img src='https://static.virginamerica.com/images/" + imageName + "' /></td><td align='right' valign='top' style='background:url(https://static.virginamerica.com/images/cal-top-bg.png) repeat-x;' ><a href='#' id='idclose' onclick='"+s_jscall+"closeCal();return false;'><img src='https://static.virginamerica.com/images/view_cross_bt.png' border='0'/></a></td><td width='14' align='left' valign='top' ><img src='https://static.virginamerica.com/images/depart_date_rt.png' width='14' height='31' /></td></tr>";	
	
	FieldClicked=v_input.name;
	displayImage = imageName;
	if(o_parent) o_parent.className = "cbrow";
	clearTimeout(t_calcloser);
	s_inputtype = typeof(v_input);
	a_v_input = null;
	calopen = 0;
	o_caldiv = document.getElementById(s_cal);
	o_caldiv.style.display = "block";
	o_caldiv.className = "calboxon";
	
	makeCalendar(v_input,s_from,s_to,s_mode);
	
	o_inputright = v_input; 
	o_parent = document.getElementById(s_parent);
	o_cal = document.getElementById(s_cal);
	o_parent.className+=" cbrowon";
	i_calx = parseInt(o_inputright.offsetLeft)+parseInt(o_inputright.offsetWidth);
	i_caly = parseInt(o_parent.offsetTop)+(parseInt(o_parent.offsetHeight)/2)-(parseInt(o_cal.offsetHeight)/2);


	p = getXandY(v_input);
	EX1 = p.x;
	EX2 = (v_input.offsetWidth - pos1 + EX1)+'px';
	EY1 = p.y;
	EY2 = EY1;
	o_cal.style.left = EX2;
	o_cal.style.top = (EY2 + pos2 - 23)+'px';

	setTimeout("calopen = 1",100);

}

/*This function hide the calendar */
function closeCal(){
	if(o_caldiv&&calopen){
		t_calcloser = setTimeout("hideCalendar()",100);
		if(document.getElementById('BookFlightDiv') && document.getElementById('BookFlightDiv').style.display!='none' && document.flightSearchForm){
			if(FieldClicked=="flightSearch.depDate.MMDDYYYY" || FieldClicked=="flightSearch.depDateMC.MMDDYYYY"){
				updateDepDateInForm();
			}else{
				updateRetDateInForm();
			}
		}else{
			if(FieldClicked=="flightSearch.depDate.MMDDYYYY" && document.flightSearchOWForm!=null && document.flightSearchMCForm!=null){
				dateRT();
			}else if(FieldClicked=="flightSearch.returnDate.MMDDYYYY" && document.flightSearchMCForm!=null){
			dateReturnRT()
			}else if(FieldClicked=="flightSearch.depDateOW.MMDDYYYY" && document.flightSearchRTForm!=null && document.flightSearchMCForm!=null){
				dateOW();
			}else if(FieldClicked=="flightSearch.depDateMC.MMDDYYYY" && document.flightSearchRTForm!=null && document.flightSearchOWForm!=null){
				dateMC();
			}else if(FieldClicked=="flightSearch.depDateMC.MMDDYYYY" && document.flightSearchRTForm!=null && document.flightSearchOWForm!=null){
				dateMC();
			}else if(FieldClicked=="flightSearch.returnDateMC.MMDDYYYY" && document.flightSearchRTForm!=null){
			 dateReturnMC()
			}else{
			
			}
		}
	}

	calopen=0;
	
}

window.onclick=closeCal;
window.document.onclick=closeCal;

//  cal.js end


// checkInBags.js start
function chkBagsAction(chkBtn){

if(chk!='cancelAction')
{
ShowCheckBags()
}else{
onBackShowPnrHome()

}

document.getElementById('bagAddition').style.display='none';
}

function showPopUp(chkBtn){
	chk='cancelAction'
	document.getElementById('bagAddition').style.display='block';
	//showLoadingImageOpen('continue');
	showWaitImage();
}


function showPopUpContinue(thisId){
if(chkExccessbags=='true'){
		var X;var Y;
		var c = getAnchorPosition(thisId.id);
		X=c.x;
		Y=c.y-30;
		document.getElementById('bagAddition').style.left=X-150;
		document.getElementById('bagAddition').style.top=Y;
		document.getElementById('bagAddition').style.display='block';
		
	}else{
		ShowCheckBags();
	}
}


function disable(tabId)
{
				
		document.getElementById(tabId).innerHTML="<img src='https://static.virginamerica.com/images/Travel_mng_red.gif'>";
		
}
function hide(arg)
{document.getElementById(arg).style.display="none"}

function show(arg1)
{document.getElementById(arg1).style.display="block"}


String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
var ajaxDepTotal="";

function callCalCulateAmountURL(chkURL,totalGuests,OandDInd,cabinClass) {
	var guestNos;
	
	var guestBags="";
	var thetime=new Date(); 
	var dummy = "" + thetime.getHours() + thetime.getMinutes()
			+ thetime.getSeconds();
	
	
	
	if(chkURL=='depURL'){
		var guestNos = totalGuests;
		for (loop = 0; loop < totalGuests; loop++) {
				objname="checkInTotalBags1.totalBags"+"["+loop+"]"
				objvalue=document.checkInExtraPayForm.elements[objname].value;
				guestBags=guestBags+","+objvalue;
		}
	
	}	
	
	if(chkURL=='retURL'){
		var guestNos = totalGuests;
		for (loop = 0; loop < totalGuests; loop++) {
			objname = "checkInTotalBags1.bags[" + OandDInd +"].bagsName[" + loop + "]"
			objvalue=document.checkInExtraPayForm.elements[objname].value;
			guestBags=guestBags+","+objvalue;	
		}
	}		
	
	var myurl = "calulateTotalBagAmount.do?method=calCulateAmount&totalGuest="
			+ guestNos + "&totalBags=" + guestBags + "&chkUrl=" + chkURL
			+ "&cabinClass=" + cabinClass+ "&OandDInd=" + OandDInd;
		myurl=myurl+"&dummy="+dummy;
		
		xmlhttp.open("GET", myurl, true);
		xmlhttp.onreadystatechange = handleResponseForAmount;
		xmlhttp.send("");
		window.focus();
}


function handleResponseForAmount(){
	if (xmlhttp.readyState == 4) { // Complete
	      if (xmlhttp.status == 200) {
	     if((xmlhttp.responseText).trim()=='AjaxSessionTimeOut'){
   			window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut";
  		 }else if((xmlhttp.responseText).indexOf("esc-sign")==-1){
		      document.getElementById("loadingAnimationDiv").style.display="none";
		      document.getElementById('travelupdate').innerHTML=xmlhttp.responseText;
		      document.getElementById('errorOnChkInBags').style.display='none'
		      document.getElementById('conBtnShow').style.display='block';
   	          document.getElementById('conBtnHide').style.display='none';
		      
	     }else{
	     	document.getElementById("loadingAnimationDiv").style.display="none";
	     	 document.getElementById('errorOnChkInBags').innerHTML=xmlhttp.responseText;
	     	document.getElementById('errorOnChkInBags').style.display='block'
	     		 if(document.checkInExtraPayForm.elements['checkInTotalBags1.totalBags[0]']){
						for( loop=0 ;loop<10;loop++){
						   objname="checkInTotalBags1.totalBags"+"["+loop+"]"
           				   if(document.checkInExtraPayForm.elements[objname])
					       document.checkInExtraPayForm.elements[objname].options[0].selected="selected"
						}
					}	
	     		
	     			if(document.checkInExtraPayForm.elements['checkInTotalBags1.totalBags1[0]']){
						for( loop=0 ;loop<10;loop++){
						   objname="checkInTotalBags1.totalBags1"+"["+loop+"]"
           				   if(document.checkInExtraPayForm.elements[objname])
					       document.checkInExtraPayForm.elements[objname].options[0].selected="selected"
						}
					}
	     
	     			document.getElementById('conBtnShow').style.display='none';
					document.getElementById('conBtnHide').style.display='block';
				   
	     
	     
	     
	     }
	      }	
	}
}


var checkval="undefined";
function ShowCheckBags_updated(){
checkInExtraPayForm.submit();
document.getElementById('conBtnShow').style.display='none';
document.getElementById('conBtnHide').style.display='block';
}


function setDefaultTab(tabID){
	hide("divVI");
	hide("divCHF");
	hide("divCF");
	show(tabID);
}

var redid=""

function setDefTab(redid){
	if(redid=="tripid")
	{
	document.getElementById(redid).src="https://static.virginamerica.com/images/your_trip_red.gif";
	}
	 if(redid=="chid")
	{
	document.getElementById(redid).src="https://static.virginamerica.com/images/change_flight_red.gif";
	}
	 if(redid=="canid")
	{
	document.getElementById(redid).src="https://static.virginamerica.com/images/cancel_flight_red.gif";
	}
}


var tripid1=""
var chid1=""
var canid1=""
function changePIC(tripid1,chid1,canid1){
	if(typeof(currentTripType)!='undefined')
		currentTripType=tripid1;

	document.getElementById(tripid1).src="https://static.virginamerica.com/images/your_trip_grey.gif";
	document.getElementById(chid1).src="https://static.virginamerica.com/images/change_flight_grey.gif";
	document.getElementById(canid1).src="https://static.virginamerica.com/images/cancel_flight_grey.gif";
	
}

function setDiv(divID){
	document.getElementById('tripid').style.display="none";
	document.getElementById('chid').style.display="none";
	document.getElementById('canid').style.display="none";
	document.getElementById(divID).style.display="block";
}


function onBackShowPnrHome()
{
document.checkInExtraPayForm.method.value="managePnr";
document.checkInExtraPayForm.action="yourTrip.do";
document.checkInExtraPayForm.submit();
}
//checkInbags.js end

//clientValidation.js starts
/*	Author: Abhay Kumar Gupta
	
*/
	function originRT()
	{
		for (i = 0; i < document.flightSearchRTForm.elements.length; i++)
		{
			elementName = document.flightSearchRTForm.elements[i].name;
			if (elementName == "flightSearch.origin" )
			{
				for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
				{
					elementName2 = document.flightSearchOWForm.elements[j].name;
					if (elementName2 == "flightSearch.origin" )
					{
						document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					
					if (elementName3 == "flightSearch.origin" )
					{
						document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}

function DestinationRT(){
		for (i = 0; i < document.flightSearchRTForm.elements.length; i++)
		{
		
			elementName = document.flightSearchRTForm.elements[i].name;
			
		
			if (elementName == "flightSearch.destination" )
			{
				for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
				{
					elementName2 = document.flightSearchOWForm.elements[j].name;
					if (elementName2 == "flightSearch.destination" )
					{
						document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					if (elementName3 == "flightSearch.destination" )
					{
						document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}

	function originOW()
	{
		for (i = 0; i < document.flightSearchOWForm.elements.length; i++)
		{
		
			elementName = document.flightSearchOWForm.elements[i].name;
			
			if (elementName == "flightSearch.origin" )
			{
			
				for (j = 0; j < document.flightSearchRTForm.elements.length; j++)
				{
					elementName2 = document.flightSearchRTForm.elements[j].name;
					if (elementName2 == "flightSearch.origin" )
					{
						document.flightSearchRTForm.elements[j].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					
					if (elementName3 == "flightSearch.origin" )
					{
						document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}

	function DestinationOW()
	{
		for (i = 0; i < document.flightSearchOWForm.elements.length; i++)
		{
			elementName = document.flightSearchOWForm.elements[i].name;
			if (elementName == "flightSearch.destination" )
			{
				for (j = 0; j < document.flightSearchRTForm.elements.length; j++)
				{
					elementName2 = document.flightSearchRTForm.elements[j].name;
					if (elementName2 == "flightSearch.destination" )
					{
						document.flightSearchRTForm.elements[j].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					
					if (elementName3 == "flightSearch.destination" )
					{
						document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}
	
	function originMC()
	{
		for (i = 0; i < document.flightSearchMCForm.elements.length; i++)
		{
			elementName = document.flightSearchMCForm.elements[i].name;
			if (elementName == "flightSearch.origin" )
			{
				for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
				{
					elementName2 = document.flightSearchOWForm.elements[j].name;
					if (elementName2 == "flightSearch.origin" )
					{
						document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchRTForm.elements.length; k++)
				{
					elementName3 = document.flightSearchRTForm.elements[k].name;
					
					if (elementName3 == "flightSearch.origin" )
					{
						document.flightSearchRTForm.elements[k].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}

	function DestinationMC()
	{
		for (i = 0; i < document.flightSearchMCForm.elements.length; i++)
		{
			elementName = document.flightSearchMCForm.elements[i].name;
			if (elementName == "flightSearch.destination" )
			{
				for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
				{
					elementName2 = document.flightSearchOWForm.elements[j].name;
					if (elementName2 == "flightSearch.destination" )
					{
						document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchRTForm.elements.length; k++)
				{
					elementName3 = document.flightSearchRTForm.elements[k].name;
					
					if (elementName3 == "flightSearch.destination" )
					{
						document.flightSearchRTForm.elements[k].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}
	
	function dateRT()
	{
		for (i = 0; i < document.flightSearchRTForm.elements.length; i++)
		{

			elementName = document.flightSearchRTForm.elements[i].name;
			if (elementName == "flightSearch.depDate.MMDDYYYY" )
			{
			
				for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
				{
					elementName2 = document.flightSearchOWForm.elements[j].name;
					if (elementName2 == "flightSearch.depDateOW.MMDDYYYY" )
					{
						document.flightSearchOWForm.elements[j].value = document.flightSearchRTForm.elements[i].value;
						break;
					}
				}
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					
					if (elementName3 == "flightSearch.depDateMC.MMDDYYYY" )
					{
						document.flightSearchMCForm.elements[k].value = document.flightSearchRTForm.elements[i].value;
						break;
					}
				}
				break;
			}
		}
	}
	
	function dateReturnRT()
	{
		for (i = 0; i < document.flightSearchRTForm.elements.length; i++)
		{

			elementName = document.flightSearchRTForm.elements[i].name;
			if (elementName == "flightSearch.returnDate.MMDDYYYY" )
			{
			
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					
					if (elementName3 == "flightSearch.returnDateMC.MMDDYYYY" )
					{
						document.flightSearchMCForm.elements[k].value = document.flightSearchRTForm.elements[i].value;
						break;
					}
				}
				break;
			}
		}
	}
	
	
	function dateReturnMC()
	{
		for (i = 0; i < document.flightSearchRTForm.elements.length; i++)
		{
			elementName = document.flightSearchMCForm.elements[i].name;
			if (elementName == "flightSearch.returnDateMC.MMDDYYYY" )
			{
				for (k = 0; k < document.flightSearchRTForm.elements.length; k++)
				{
					elementName3 = document.flightSearchRTForm.elements[k].name;
					
					if (elementName3 == "flightSearch.returnDate.MMDDYYYY" )
					{
						document.flightSearchRTForm.elements[k].value = document.flightSearchMCForm.elements[i].value;
						break;
					}
				}
				break;
			}
		}
	}
	
	
	
	
		function dateOW()
	{
		for (i = 0; i < document.flightSearchOWForm.elements.length; i++)
		{

			elementName = document.flightSearchOWForm.elements[i].name;
			if (elementName == "flightSearch.depDateOW.MMDDYYYY" )
			{
			
				for (j = 0; j < document.flightSearchRTForm.elements.length; j++)
				{
					elementName2 = document.flightSearchRTForm.elements[j].name;
					if (elementName2 == "flightSearch.depDate.MMDDYYYY" )
					{
						document.flightSearchRTForm.elements[j].value = document.flightSearchOWForm.elements[i].value;
						break;
					}
				}
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					
					if (elementName3 == "flightSearch.depDateMC.MMDDYYYY" )
					{
						document.flightSearchMCForm.elements[k].value = document.flightSearchOWForm.elements[i].value;
						break;
					}
				}
				break;
			}
		}
	}
	
		function dateMC()
	{
		for (i = 0; i < document.flightSearchMCForm.elements.length; i++)
		{

			elementName = document.flightSearchMCForm.elements[i].name;
			if (elementName == "flightSearch.depDateMC.MMDDYYYY" )
			{
			
				for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
				{
					elementName2 = document.flightSearchOWForm.elements[j].name;
					if (elementName2 == "flightSearch.depDateOW.MMDDYYYY" )
					{
						document.flightSearchOWForm.elements[j].value = document.flightSearchMCForm.elements[i].value;
						break;
					}
				}
				for (k = 0; k < document.flightSearchRTForm.elements.length; k++)
				{
					elementName3 = document.flightSearchRTForm.elements[k].name;
					
					if (elementName3 == "flightSearch.depDate.MMDDYYYY" )
					{
						document.flightSearchRTForm.elements[k].value = document.flightSearchMCForm.elements[i].value;
						break;
					}
				}
				break;
			}
		}
	}
	
	
	function adultRT()
	{
		for (i = 0; i < document.flightSearchRTForm.elements.length; i++)
		{
			elementName = document.flightSearchRTForm.elements[i].name;
			if (elementName == "flightSearch.adults" )
			{
				for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
				{
					elementName2 = document.flightSearchOWForm.elements[j].name;
					if (elementName2 == "flightSearch.adults" )
					{
						document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					
					if (elementName3 == "flightSearch.adults" )
					{
						document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}

	function adultOW()
	{
		for (i = 0; i < document.flightSearchOWForm.elements.length; i++)
		{
		
			elementName = document.flightSearchOWForm.elements[i].name;
			
			if (elementName == "flightSearch.adults" )
			{
			
				for (j = 0; j < document.flightSearchRTForm.elements.length; j++)
				{
					elementName2 = document.flightSearchRTForm.elements[j].name;
					if (elementName2 == "flightSearch.adults" )
					{
						document.flightSearchRTForm.elements[j].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchMCForm.elements.length; k++)
				{
					elementName3 = document.flightSearchMCForm.elements[k].name;
					
					if (elementName3 == "flightSearch.adults" )
					{
						document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}

	function adultMC()
	{
		for (i = 0; i < document.flightSearchMCForm.elements.length; i++)
		{
			elementName = document.flightSearchMCForm.elements[i].name;
			if (elementName == "flightSearch.adults" )
			{
				for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
				{
					elementName2 = document.flightSearchOWForm.elements[j].name;
					if (elementName2 == "flightSearch.adults" )
					{
						document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
						break;
					}
				}
				for (k = 0; k < document.flightSearchRTForm.elements.length; k++)
				{
					elementName3 = document.flightSearchRTForm.elements[k].name;
					
					if (elementName3 == "flightSearch.adults" )
					{
						document.flightSearchRTForm.elements[k].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}

function childRT(){
	for (i = 0; i < document.flightSearchRTForm.elements.length; i++){
			elementName = document.flightSearchRTForm.elements[i].name;
		if (elementName == "flightSearch.kids" ){
			for (j = 0; j < document.flightSearchOWForm.elements.length; j++){
					elementName2 = document.flightSearchOWForm.elements[j].name;
				if (elementName2 == "flightSearch.kids" ){
						document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
						break;
					}
				}
			for (k = 0; k < document.flightSearchMCForm.elements.length; k++){
					elementName3 = document.flightSearchMCForm.elements[k].name;
				if (elementName3 == "flightSearch.kids" ){
						document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}

function childOW(){
	for (i = 0; i < document.flightSearchOWForm.elements.length; i++){
			elementName = document.flightSearchOWForm.elements[i].name;
		if (elementName == "flightSearch.kids" ){
			for (j = 0; j < document.flightSearchRTForm.elements.length; j++){
					elementName2 = document.flightSearchRTForm.elements[j].name;
				if (elementName2 == "flightSearch.kids" ){
						document.flightSearchRTForm.elements[j].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
						break;
					}
				}
			for (k = 0; k < document.flightSearchMCForm.elements.length; k++){
					elementName3 = document.flightSearchMCForm.elements[k].name;
				if (elementName3 == "flightSearch.kids" ){
						document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}
	
function childMC(){
	for (i = 0; i < document.flightSearchMCForm.elements.length; i++){
		elementName = document.flightSearchMCForm.elements[i].name;
		if (elementName == "flightSearch.kids" ){
			for (j = 0; j < document.flightSearchOWForm.elements.length; j++){
				elementName2 = document.flightSearchOWForm.elements[j].name;
				if (elementName2 == "flightSearch.kids" ){
					document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
					break;
				}
			}
			for (k = 0; k < document.flightSearchRTForm.elements.length; k++){
				elementName3 = document.flightSearchRTForm.elements[k].name;
				if (elementName3 == "flightSearch.kids" ){
					document.flightSearchRTForm.elements[k].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
					break;
				}
			}
			break;
		}
	}
}

function infantRT(){
	for (i = 0; i < document.flightSearchRTForm.elements.length; i++){
		elementName = document.flightSearchRTForm.elements[i].name;
		if (elementName == "flightSearch.infants" ){
			for (j = 0; j < document.flightSearchOWForm.elements.length; j++){
				elementName2 = document.flightSearchOWForm.elements[j].name;
				if (elementName2 == "flightSearch.infants" ){
					document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
					break;
				}
			}
			for (k = 0; k < document.flightSearchMCForm.elements.length; k++){
				elementName3 = document.flightSearchMCForm.elements[k].name;
				if (elementName3 == "flightSearch.infants" ){
					document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchRTForm.elements[i].selectedIndex;
					break;
				}
			}
			break;
		}
	}
}

function infantOW(){
	for (i = 0; i < document.flightSearchOWForm.elements.length; i++){
		elementName = document.flightSearchOWForm.elements[i].name;
		if (elementName == "flightSearch.infants" ){
			for (j = 0; j < document.flightSearchRTForm.elements.length; j++){
				elementName2 = document.flightSearchRTForm.elements[j].name;
				if (elementName2 == "flightSearch.infants" ){
					document.flightSearchRTForm.elements[j].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
					break;
				}
			}
			for (k = 0; k < document.flightSearchMCForm.elements.length; k++){
				elementName3 = document.flightSearchMCForm.elements[k].name;
				if (elementName3 == "flightSearch.infants" ){
					document.flightSearchMCForm.elements[k].selectedIndex = document.flightSearchOWForm.elements[i].selectedIndex;
					break;
				}
			}
			break;
		}
	}
}

function infantMC(){
	for (i = 0; i < document.flightSearchMCForm.elements.length; i++){
			elementName = document.flightSearchMCForm.elements[i].name;
		if (elementName == "flightSearch.infants" ){
			for (j = 0; j < document.flightSearchOWForm.elements.length; j++){
					elementName2 = document.flightSearchOWForm.elements[j].name;
				if (elementName2 == "flightSearch.infants" ){
						document.flightSearchOWForm.elements[j].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
						break;
					}
				}
			for (k = 0; k < document.flightSearchRTForm.elements.length; k++){
					elementName3 = document.flightSearchRTForm.elements[k].name;
				if (elementName3 == "flightSearch.infants" ){
						document.flightSearchRTForm.elements[k].selectedIndex = document.flightSearchMCForm.elements[i].selectedIndex;
						break;
					}
				}
				break;
			}
		}
	}
//clientValidation.js end

//cookiefunction.js starts
// JavaScript Document
function Get_Cookie( name ) {
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

/*
only the first 2 parameters are required, the cookie name, the cookie
value. Cookie time is in milliseconds, so the below expires will make the 
number you pass in the Set_Cookie function call the number of days the cookie
lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

Generally you don't need to worry about domain, path or secure for most applications
so unless you need that, leave those parameters blank in the function call.
*/
function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function discookie()
{

var gg=Get_Cookie( 'cv' )
}
// cookiefunction.js end


//indexPageFunction.js start



/*This function is used to restore the images*/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/*This function loads the images*/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/*This function swap the images*/
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




//pnrResult.js start

function submitFormForChangeSeat1(indxNum, segmentNum, whichFlow,firstClassCutOff){
	showWaitImage();
	window.location.href='showChangeSeatMap.do?method=showSeatMapForChange&tabSelected='+indxNum+'&activeSegmentIndex='+segmentNum+'&whichFlow='+whichFlow+'&firstClassCutOff='+firstClassCutOff;
}
function submitFormForChangeSeat(indxNum, segmentNum, whichFlow,firstClassCutOff){
	showWaitImage();
	window.location.href='showChangeSeatMap.do?method=showSeatMapForChange&tabSelected='+indxNum+'&activeSegmentIndex='+segmentNum+'&whichFlow='+whichFlow+'&firstClassCutOff='+firstClassCutOff;
}



function replaceAll(st){
var i=st.length;
for(var m=0;m<i;m++){
if(st.indexOf("/")!=-1){
	st=st.replace("/","'");
}

if(st.indexOf('?')!=-1){
	st=st.replace('?','"');
}

}
return st
}



function showPrintWindow(){

var p=self.print();

return p

}
var OSDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function callPBPassForHTML(btnId, oandDId, whichlegNo, flightNo, ffNumber,
		numberInParty,onHome) {
var top=10;
var left=180;
var width=845;
var height=700;
OSDetect.init();
var guestname;
var urls="";

if(btnId.indexOf("/")!=-1){
	guestname=replaceAll(btnId);
}else if(btnId.indexOf("?")!=-1){
	guestname=replaceAll(btnId);
	
}else{
	guestname=btnId;
}

var osdetect = OSDetect.OS;  
var browserdetect=OSDetect.browser;
	if(onHome=='onHome'){
		urls = "checkInPrintBoardingPassForHtml.do?method=printBoardingPassForSingleGuest&indexNum="
	}else{
		urls = "checkInPrintBoardingPassForHtmlSSL.do?method=printBoardingPassForSingleGuest&indexNum="
	}
	
		urls=urls+ guestname
			+ "&oandDId="
			+ oandDId
			+ "&legNo="
			+ whichlegNo
			+ "&flightNo="
			+ flightNo
			+ "&ffNumber="
			+ ffNumber
			+ "&numberInParty="
			+ numberInParty
			+ "&OSDetect="
			+ osdetect + "&browserdetect=" + browserdetect;
	
	mywindowForHtml = window.open("/html/Virgin_America_Boarding_Pass.html",
			"BoardingPass",
			"toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,top="
					+ top + ", left=" + left + ", width=" + width + ",height="
					+ height);
ajaxToGeneratePdfHTML(urls);

}

function printAllBoardingPassInHTMLView(){
var top=10;
var left=180;
var width=845;
var height=700;
OSDetect.init();
var osdetect = OSDetect.OS;  
var browserdetect=OSDetect.browser;
	var urls = "checkInPrintBoardingPassSSL.do?method=printAllBoardingPassInHTMLView&indexNum="
			+ "forAllGuest"
			+ "&OSDetect="
			+ osdetect
			+ "&browserdetect="
			+ browserdetect;

	mywindowForHtml = window.open("/html/Virgin_America_Boarding_Pass.html",
			"BoardingPass",
			"toolbar=no,status=yes,menubar=yes,scrollbars=yes,resizable=no, top="
					+ top + ", left=" + left + ", width=" + width + ",height="
					+ height);
ajaxToGeneratePdfHTML(urls);

}


function ajaxToGeneratePdfHTML(myurl)
{
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange = handleResponsePrintBoardingPassForHTML;
	xmlhttp.send("");

}

function handleResponsePrintBoardingPassForHTML() {    
if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) {
            var resText=xmlhttp.responseText;
     
            if(resText.trim()=='AjaxSessionTimeOut'){
            mywindowForHtml.close();
            window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut";
            }else if(resText.trim()=='PrintBoardingPassError'){
                mywindowForHtml.close();
                if(document.getElementById('PDF_ERROR_MESSAGE_POPUP')){
                    document.getElementById('PDF_ERROR_MESSAGE_POPUP').style.display='block';
                }
            }else{  
                var topSSL=10;
                var leftSSL=180;
                var widthSSL=845;
                var heightSSL=700;
                var fileNameUpdated = resText.replace(/[\r\n]/g, "");
                var ua = navigator.userAgent.toLowerCase(); 
                if ( ua.indexOf( "msie" ) != -1 ) { 
                    var statusX = '';
                    do
                    {
	                    //get the child window document loading status
	                    statusX = mywindowForHtml.document.readyState;
                    }
                    while (statusX !="complete") //continue detect the status if it is not completed yet
                    mywindowForHtml.document.getElementById('pdfhtml').innerHTML=fileNameUpdated;
                }
                else
                {
                    mywindowForHtml.document.getElementById('pdfhtml').innerHTML=fileNameUpdated;
                }
            }
        }
    }
}


function showPrintItinerary(){
	
	var pageId = 'viewItinerary';
	if(s.pageName) {
		if(s.pageName.indexOf('View Itinerary') != -1) {
			pageId = 'viewItinerary';
		} else if(s.pageName.indexOf('Check-in') != -1) {
			pageId = 'checkIn';
		} else if(s.pageName.indexOf('Change Flight') != -1) {
			pageId = 'changeFlight';
		} else if(s.pageName.indexOf('Cancel Flight') != -1) {
			pageId = 'cancelFlight';
		}
	}
	var disp_setting="toolbar=no,location=no,directories=no,menubar=yes,"; 
    disp_setting+="scrollbars=yes,width=736, height=670, left=0, top=0";

	var urls="checkInPrintItinerary.do?method=printItinerary&pageId="+pageId;

	window.open(urls,"",disp_setting);
}


function insertGuestSeat(num,gu,ss){
	gnum=num;
	var ind=num;
	var guest=gu;
	var seat=ss;
	guestArray[ind]=guest;
	seatArray[ind]=seat;
}

function insertGuestSeat1(num,gu,ss)
{
	gnumRet=num;
	var ind=num;
	var guest=gu;
	var seat=ss;
	guestArrayRet[ind]=guest;
	seatArrayRet[ind]=seat;
}

function insertDepConnectGuestSeat(num, ss)
{
	seatDepConnectArray[num] = ss;
}
function insertRetConnectGuestSeat(num, ss)
{
	seatRetConnectArray[num] = ss;
}

function ShowCheckBags1(e)
{
	checkInBagForm.submit();
}

var thisId;
function CheckInInfoPopUp(buttonId){
	thisId=buttonId;
	
	var X;var Y;

var c = getAnchorPosition(thisId.id);
	X=c.x;
	Y=c.y+25;
	
	document.getElementById('CheckInInFo').style.left=X-50
	document.getElementById('CheckInInFo').style.top=Y-30
	document.getElementById('CheckInInFo').style.display='block';

}

function showElevateExpPopUp(buttonId,popupId){
	getAnchorXY(buttonId);
	
	document.getElementById(popupId).style.left=X1-50
	document.getElementById(popupId).style.top=Y1-30
	document.getElementById(popupId).style.display='block';

}



function ShowCheckBags(thisId){
document.getElementById('CheckInInFo').style.display='none'
var X;var Y;

var c = getAnchorPosition(thisId.id);
	X=c.x;
	Y=c.y+25;

	if(alreadyCheckedInDep=='false'){
		if(checkval=="undefined") {
			document.checkInBagForm.checkChange.value="no";
		}
		checkInBagForm.submit();
	}else{
		
	
		document.getElementById('alreadyCheckedIn').style.left=X-100
		document.getElementById('alreadyCheckedIn').style.top=Y-30
		document.getElementById('alreadyCheckedIn').style.display='block';
	}
}
var guestTypeArr=new Array();
var gFNameArr=new Array();
var gLNameArr=new Array();

var ins=0;
var rins=0;
var guestNumberInParty="";
var guestRetNumberInParty="";
var OandDSize=0;
function checkInClickIt(thisobj,whichLeg,OandDInd,flightNo,num,numberInParty,guestStatus) {	

if(guestStatus=='checkInRestricted'){
setPosition(thisobj, document.getElementById("petSSRMsgId"),-20,20);
document.getElementById("petSSRMsgId").style.display="block";

if(thisobj.checked){
thisobj.checked=false
}

}else{


var s=new Array();
	var checkBoxId="";
	var checkBox=""

	var guestId=""
	var guestObj="";
	var selGuestsId=""
	var selGuests="";


	var seatId=""
	var seatObj="";
	var selSeatsId=""
	var selSeats="";

	var connSeatId=""
	var connSeatObj="";
	var selConnSeatsId=""
	var selConnSeats="";
	var selNumInParId="";
				
	var selRewNoId="";
	var selEleVAId="";
	var eleVAIdObj="";
	var selRewardNos="";
	
	var RowNum="Row"+OandDInd
	var RowNumRet="Row#"+OandDInd
	var x = document.checkInBagForm;
						
	var guestNumberInParty="";
	var numInPartyId="";
			
	var guestseqno="";	
		
	var selGTId="";
	var selGTId="";
	var eleGTObj="";
	var guestType="";
	
	
	for(i=0;i<guestSize;i++){
		
		if(whichLeg=='Depart')
			checkBoxId="DepRow"+i;
		else
			checkBoxId="Ret"+RowNum+i;
		
				
		
		checkBox=document.getElementById(checkBoxId);
		if(checkBox!=null){
		if(checkBox.checked){
			checkval=checkBox
			if(whichLeg=='Depart'){
				guestId="depRow#"+i;
				seatId="depSeatRow"+i;
				connSeatId="depSeatConnRow"+i;
				selEleVAId="depEleVARow"+i;
				}else{
				guestId="ret"+RowNumRet+i;
				seatId="seat"+RowNum+i;
				connSeatId="seatConn"+RowNum+i;
				selEleVAId="retEleVARow"+OandDInd+i;
			}
			
			guestNumberInParty=guestNumberInParty + ";" + numInPartyArray[OandDInd].split(";")[i];
			//guestObj=document.getElementById(guestId).innerHTML;
				
			var selGname=gFNameArr[i]+"_"+gLNameArr[i];
			
			selGuests=selGuests+";"+selGname;
			//selGuests=selGuests+";"+guestObj
		
			seatObj=document.getElementById(seatId).innerHTML;
			selSeats=selSeats+";"+seatObj;
						
			
			if(document.getElementById(connSeatId)){
			connSeatObj=document.getElementById(connSeatId).innerHTML;
			selConnSeats=selConnSeats+";"+connSeatObj
			}
			
			
			if(document.getElementById(selEleVAId)){
				eleVAIdObj=document.getElementById(selEleVAId).innerHTML;
				selRewardNos=selRewardNos+";"+eleVAIdObj;
			}else{
				selRewardNos=selRewardNos+";"+" ";
			}
			
			
			guestType=guestType+";"+guestTypeArr[i];
			
			
			document.checkInBagForm.checkChange.value="checked";
			
			
			
			
			}
		}
	}//end of For
			if(whichLeg=='Depart'){
				selGuestsId="checkInTotalBags.depLeg1";
				selSeatsId="checkInTotalBags.depLeg1Seat";
				selConnSeatsId="checkInTotalBags.depLeg2Seat";
				numInPartyId='checkInTotalBags.strDepNumberInParty';
				selRewNoId="checkInTotalBags.rewNumDep";
				selGTId="checkInTotalBags.depGuestType"
				
				x.elements[selGTId].value=guestType;	
				x.elements[numInPartyId].value=guestNumberInParty;	
			}else{
				selGuestsId="checkInTotalBags.selGuests["+(OandDInd-1)+"]";
				selSeatsId="checkInTotalBags.selSeats["+(OandDInd-1)+"]";
				selConnSeatsId="checkInTotalBags.selConnSeats["+(OandDInd-1)+"]";
				selNumInParId="checkInTotalBags.selNumInParty["+(OandDInd-1)+"]";
				selRewNoId	="checkInTotalBags.selRewNos["+(OandDInd-1)+"]";
				selGTId="checkInTotalBags.selGuestType["+(OandDInd-1)+"]"
				
				x.elements[selGTId].value=guestType;	
				x.elements[selNumInParId].value = guestNumberInParty;
			}
		
		
			
			
			x.elements[selGuestsId].value = selGuests;
			x.elements[selSeatsId].value = selSeats;
		

			if(document.getElementById(connSeatId))
			x.elements[selConnSeatsId].value = selConnSeats;
				
			x.elements['checkInTotalBags.depSelect'].value='notSelect';
					
			if(whichLeg!='Depart')
			x.elements['checkInTotalBags.retSelect'].value='notSelect';
					
			x.elements[selRewNoId].value = selRewardNos;
			
			for(i=0;i<OandDSize;i++){
					for(k=0;k<guestSize;k++){
							if(i==0)
								checkBoxId="DepRow"+k;
							else
								checkBoxId="RetRow"+i+k;
								
							checkBox=document.getElementById(checkBoxId);
							if(checkBox!=null)
							if(checkBox.checked){
								if(i==0)
									x.elements['checkInTotalBags.depSelect'].value='select'
								else
									x.elements['checkInTotalBags.retSelect'].value='select'
							
								break;	
					}
				}
			}	
			
		if(x.elements['checkInTotalBags.depSelect'].value=='notSelect' && 
		(x.elements['checkInTotalBags.retSelect'].value=='notSelect' || x.elements['checkInTotalBags.retSelect'].value==''))
			checkval='undefined';
				
}				
}

function disable(tabId)
{
				
		document.getElementById(tabId).innerHTML="<img src='https://static.virginamerica.com/images/Travel_mng_red.gif'/>";
		
}
function hide(arg)
{document.getElementById(arg).style.display="none"}

function show(arg1)
{document.getElementById(arg1).style.display="block"}

function setDefaultTab(tabID)
{

	hide("divVI");
	hide("divCHF");
	hide("divCF");
	show(tabID);
}
var redid=""
function setDefTab(redid){
	
	if(redid=="tripid")
	{
	document.getElementById(redid).src="https://static.virginamerica.com/images/your_trip_red.gif";
	}
	 if(redid=="chid")
	{
	document.getElementById(redid).src="https://static.virginamerica.com/images/change_flight_red.gif";
	}
	 if(redid=="canid")
	{
	document.getElementById(redid).src="https://static.virginamerica.com/images/cancel_flight_red.gif";
	}
}


var tripid1=""
var chid1=""
var canid1=""
function changePIC(tripid1,chid1,canid1){
	
	document.getElementById(tripid1).src="https://static.virginamerica.com/images/your_trip_grey.gif";
	document.getElementById(chid1).src="https://static.virginamerica.com/images/change_flight_grey.gif";
	document.getElementById(canid1).src="https://static.virginamerica.com/images/cancel_flight_grey.gif";
	
}

function setDiv(divID){
	document.getElementById('tripid').style.display="none";
	document.getElementById('chid').style.display="none";
	document.getElementById('canid').style.display="none";
	document.getElementById(divID).style.display="block";
}


// Start Function is created for issue 1020
function ajaxPnrDisplay(myurl, div,id){
	ajaxDiv = div;
	if(ajaxDiv=="body"){
		/*setPosition(id, document.getElementById("loadingDiv"),50,50);
		document.getElementById("loadingDiv").style.display="block";*/
		showWaitImage();
	}
	
	//document.getElementById("loadingDiv").style.display="block";
	showWaitImage();
	
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div;
	xmlhttp.open("POST", myurl, true);

	xmlhttp.onreadystatechange = handleResponsePnrDisplay;
	xmlhttp.send("");
}

function handleResponsePnrDisplay() {
var ind=-1;
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) {
     	var PNRResponseText=xmlhttp.responseText;
      	document.getElementById("loadingAnimationDiv").style.display="none";
	  	if(PNRResponseText.trim()=='AjaxSessionTimeOut'){
   		window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut";
  		}else if(PNRResponseText.search("btn_find_flight.gif")==-1){
  				document.getElementById(ajaxDiv).innerHTML=PNRResponseText;
		if(ajaxDiv=="chkInRightBarError"){
				document.getElementById(ajaxDiv).innerHTML=PNRResponseText;
				ajaxPnrDisplay("upadteRightBarWithAjax.do?method=updateRightBarAjax","chkInRightBarError");
		}else if(ajaxDiv=="body"){
			ajaxPnrDisplay("postUpdateTitleBar.do?method=updateTitleBar","postTitleBarDiv");
				
		}
	}else{
			document.getElementById("chkInRightBarError").innerHTML=PNRResponseText;
	}
	  
	  
	  }
	}
}
// End Function is created for issue 1020
/*
*Created By vinod Sharma
* for set the date in wanna book flight from flight schedule result page.
* start
*/
function ajaxPnrDisplayForPoints(myurl, div,id){
	
	if(div=="body"){
		/*setPosition(id, document.getElementById("loadingDiv"),50,50);
		document.getElementById("loadingDiv").style.display="block";*/
		showWaitImage();
	}

	$('#'+div).load(myurl,'',done);
	function done()
	{
		document.getElementById("loadingAnimationDiv").style.display="none";
		if(div=="body"){
				ajaxPnrDisplayPoints("postUpdateTitleBar.do?method=updateTitleBar","postTitleBarDiv");
		}
		
	}

	
}

var windowObject="";

function sendEmailPNRResult(pnrNumber,linkId){

	ajaxEmailPNRResult(pnrNumber,linkId);
	linkId=linkId
		
	/*setPosition(document.getElementById(linkId),document.getElementById("loadingDiv"),200 ,20);
	document.getElementById("loadingDiv").style.display="block";*/
	showWaitImage();

}

var email;
function sendEmail(){
	showWaitImage();
	var pnrNumber = document.getElementById("pnrNumber").value;
	var includeBillingInfo = document.getElementById("viewItineraryEmailBilling").checked;
	var linkId = "sendEmilId";
	ajaxEmailPNRResult(pnrNumber,'',linkId,includeBillingInfo);
	
}

function closeSendEmailPopUp(arg)
{
document.getElementById(arg).style.display="none"

}

function ajaxEmailPNRResult(pnrNumber,email,linkId,includeBillingInfo){
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	var myUrl="sendEmailItinerary.do?method=sendEmailItinerary&pnrNumber="+ pnrNumber+"&emailId="+email+"&includeBillingInfo="+includeBillingInfo;
	myUrl=myUrl+"&dummy="+dummy;
	ajaxDiv = linkId;
	xmlhttp.open("POST", myUrl, true);
	xmlhttp.onreadystatechange = handleResponseEmailPNRResult;
	xmlhttp.send("");

}

function handleResponseEmailPNRResult() {

   if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) {
      	if((xmlhttp.responseText).trim()=='Success'){
      		
      		popupOverlay('popup-emailItinerary-confirm.jsp','Email Itinerary &amp; Receipt',350,this,false,0,0,false,email);
      
  		}else {
  			popupOverlay('popup-emailItinerary-error.jsp','Email Itinerary &amp; Receipt',350,this,false,0,0,false);
  		}
      	closeWaitImage();
    }
 }
}
//pnrResult.js end

//print_sections.js start
/*

This script was created by Ian Lloyd (http://lloydi.com/). I'd appreciate it 
if you could keep this comment in the script if you choose to use it (albeit 
in an amended form.

The original blog entry relating to this can be found here: http://tinyurl.com/p9tqb.

The addEvent function comes courtesy of Scott Andrew: http://tinyurl.com/qcmrd

*/
function addEvent(elm, evType, fn, useCapture)
{
		if(elm.addEventListener)
		{
			elm.addEventListener(evType, fn, useCapture);
			return true;
		}
		else if (elm.attachEvent)
		{
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		}
		else
		{
			elm['on' + evType] = fn;
		}
}



//searchPageFunctions.js start
function setFocusOnBtn(){

if(document.getElementById('divRT').style.display=='block'){
	document.getElementById('RoundWaySearch').focus();
}

}

function setFocusOnBtnForOW(){

if(document.getElementById('divOW').style.display=='block'){
	document.getElementById('OneWaySearch').focus();
}


}


function setFocusOnBtnForMC(){

if(document.getElementById('divMC').style.display=='block'){
	document.getElementById('MultiSearch').focus();
}

}
/*This function checks the value of a cookie & sets the tab*/
function loadDivForCookie(){
    

      if (getCookie("TT") == "rt" || getCookie("TT") == null)
      {
            //changePIC("rt",'flightOptionRTSelected');
            changeTabImg("rt");
            wichSelected="divRT";
            setDefaultTab('divRT');
      }
      else if (getCookie("TT") == "ow")
      {
            //changePIC("ow",'flightOptionOWSelected');
            changeTabImg("ow");
            wichSelected="divOW";
            setDefaultTab('divOW');
      }
      else if (getCookie("TT") == "mc")
      {
            //changePIC("mc",'flightOptionMCSelected');
            changeTabImg("mc");
            wichSelected="divMC";
            setDefaultTab('divMC');
      }
}

/*It checks the date*/
function checkDate(datevalue)
{
	var date = "";
		for (j = 0; j < document.flightSearchRTForm.elements.length; j++)
		{
			if (document.flightSearchRTForm.elements[j].name == datevalue)
			{
				date = document.flightSearchRTForm.elements[j].value;
				break;
			}
		}
		var index = j;s
		if((date.length == 2) || (date.length == 5) ){
			var separator = "/";
			date = date.concat(separator); 
			document.flightSearchRTForm.elements[index].value = date;
			
		}
}

/*It changes the image of a td*/
function changeContent()
{document.getElementById("BF_collopse").background="https://static.virginamerica.com/images/Title_book_flights_expanded.gif"

var x=document.getElementById('BF_table').rows[1].cells

x[0].innerHTML="<img src='https://static.virginamerica.com/images/title_bookflight_footer.gif'/>"
}




var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}

/*checks the browser & hide a element*/
function hide(arg2) {
  if (browserType == "gecko" )
  {
     document.poppedLayer = eval('document.getElementById(arg2)');
  }
  else if (browserType == "ie")
  {
     document.poppedLayer = eval('document.all[arg2]');
  }
  else
  {
     document.poppedLayer = eval('document.layers[arg2]');
  	
  }
  document.poppedLayer.style.display = "none";
}

/*checks the browser & show a element*/
function show(arg2) {
  if (browserType == "gecko" )
     document.poppedLayer = eval('document.getElementById(arg2)');
  else if (browserType == "ie")
     document.poppedLayer = eval('document.all[arg2]');
  else
  {
      document.poppedLayer = eval('document.layers[arg2]');
  }
  document.poppedLayer.style.display = "block";
}

/*This function implements the 'hide()' & 'show()' function*/
function setDefaultTab(tabID){
tabVal=tabID;
if(document.getElementById('homeErrorMessageDiv')){
	if(wichSelected!=tabID){
		document.getElementById('homeErrorMessageDiv').style.display='none';

	}else{

		document.getElementById('homeErrorMessageDiv').style.display='block';
		}
}
	hide("divRT");
	hide("divOW");
	hide("divMC");
	show(tabID);


			
}

function setFormFareType(tabID){
var thisForm=null;
if(formTripType=='rt')thisForm="flightSearchRTForm";
if(formTripType=='ow')thisForm="flightSearchOWForm";
if(formTripType=='mc')thisForm="flightSearchMCForm";
if(eval("document."+thisForm)){
var formVal=eval("document."+thisForm+".elements['flightSearch.fareFormatType'].value");


if(tabID=='rt')thisForm="flightSearchRTForm";
if(tabID=='ow')thisForm="flightSearchOWForm";
if(tabID=='mc')thisForm="flightSearchMCForm";

var obj=eval("document."+thisForm+".elements['flightSearch.fareFormatType']");
	obj.value=formVal
}
}

/*This function changes the images of the elements*/
/*This function changes the images of the elements*/
function changePIC(tabID,nameIMG){
if(typeof(currentTripType)!='undefined')
	currentTripType=tabID;
var obj;
	document.getElementById('rt').className="flightOptionRTDefault";
	document.getElementById('ow').className="flightOptionOWDefault";
	document.getElementById('mc').className="flightOptionMCDefault";
	obj=document.getElementById("rta");
	obj.disabled=false;
	obj.style.cursor='pointer';
	obj=document.getElementById("owa");
	obj.disabled=false;
	obj.style.cursor='pointer';
	obj=document.getElementById("mca");
	obj.disabled=false;
	obj.style.cursor='pointer';
	document.getElementById(tabID).className=nameIMG;
	obj=document.getElementById(tabID+"a");
	
	obj.style.cursor='text';
	obj.disabled = true;
	if(formTripType)
	setFormFareType(tabID);
	if(document.getElementById('searchPromoCode')){
	if(document.getElementById('searchPromoCode').style.display='block'){
		document.getElementById('searchPromoCode').style.display='none'
	}}
}

function changePICT(tabID,nameIMG){
var obj;
	document.getElementById('rt').src="https://static.virginamerica.com/images/tab_rt1_default.gif";
	document.getElementById('ow').src="https://static.virginamerica.com/images/tab_ow1_default.gif";
	document.getElementById('mc').src="https://static.virginamerica.com/images/tab_mc1_default.gif";
	obj=document.getElementById("rt").parentNode;
	obj.disabled=false;
	obj.style.cursor='pointer';
	obj=document.getElementById("ow").parentNode;
	obj.disabled=false;
	obj.style.cursor='pointer';
	obj=document.getElementById("mc").parentNode;
	obj.disabled=false;
	obj.style.cursor='pointer';
	document.getElementById(tabID).src=nameIMG;
	obj=document.getElementById(tabID).parentNode;

	obj.style.cursor='text';
	obj.disabled = true;

	
	if(document.getElementById('searchPromoCode')){
	if(document.getElementById('searchPromoCode').style.display='block'){
		document.getElementById('searchPromoCode').style.display='none'
	}}
}

/*This function changes the image of a element*/
function changeImageOnMouseOverOrOut(obj, IMG){
	obj.src=IMG;
}

/*This function is used to hide & show the 'div' elements*/
function resetDiv(divID){
	document.getElementById('divRT').style.display="none";
	document.getElementById('divOW').style.display="none";
	document.getElementById('divMC').style.display="none";
	document.getElementById(divID).style.display="block";
}

/*This function implements the 'getCookie()' function*/
function loadDataFromCookies() {
		
		for (j = 0; j < document.flightSearchRTForm.elements.length; j++)
		{
			var obj = document.flightSearchRTForm.elements[j];
			
			if (obj.name == "flightSearch.origin" )
			{	obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.destination" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.depDate.MMDDYYYY" )
			{
				obj.value = ((getCookie(obj.name) != null) && (Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie(obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.returnDate.MMDDYYYY" )
			{
				obj.value = ((getCookie(obj.name) != null) && (Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie(obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.adults" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.kids" )
			{
				obj.value = (getCookie (obj.name ) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.infants" )
			{
				obj.value = (getCookie (obj.name ) != null)?getCookie (obj.name):(obj.value);
			}
		}	
		for (j = 0; j < document.flightSearchOWForm.elements.length; j++)
		{
			var obj = document.flightSearchOWForm.elements[j];
			if (obj.name == "flightSearch.origin" )
			{
				obj.value = (getCookie (obj.name ) != null)?getCookie (obj.name ):(obj.value);
			}
			else if(obj.name == "flightSearch.destination" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.depDateOW.MMDDYYYY" )
			{
				obj.value = ((getCookie(obj.name) != null) &&(Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie(obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.adults" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.kids" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.infants" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
		}	
		for (j = 0; j < document.flightSearchMCForm.elements.length; j++)
		{
			var obj = document.flightSearchMCForm.elements[j];
			if (obj.name == "flightSearch.origin" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.destination" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.depDateMC.MMDDYYYY" )
			{
				obj.value = ((getCookie(obj.name) != null) && (Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie(obj.name):(obj.value);
			}
			else if (obj.name == "flightSearch.originMC" )
			{	obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.destinationMC" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.returnDateMC.MMDDYYYY" )
			{
				obj.value = ((getCookie(obj.name) != null) && (Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie("flightSearch.returnDate.MMDDYYYY"):(obj.value);
			}
			else if(obj.name == "flightSearch.adults" ){
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.kids" ){
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
			else if(obj.name == "flightSearch.infants" ){
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
		}	
	}
	
	
function loadFlightStatusDataFromCookies() {
	for (j = 0; j < document.flightStatusForm.elements.length; j++)
		{
			var obj = document.flightStatusForm.elements[j];
			
			if (obj.name == "flightStatus.flightDate" )
			{
			
				if(getCookie (obj.name) != null)
				{
					obj.selectedIndex=getCookie (obj.name);
				}
				
			}				
			else 
		 if(obj.name == "flightStatus.flightNumber" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
		else if (obj.name == "flightStatus.origin" )
			{	obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}
		else if(obj.name == "flightStatus.destination" )
			{
				obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			}			
		}			
	}


/*This function returns the values of all cookies*/
function getCookie (name) {

	var dcookie = document.cookie; 
	var cname = name + "=";
	var clen = dcookie.length;
	var cbegin = 0;
	        while (cbegin < clen) {
	        var vbegin = cbegin + cname.length;
	                if (dcookie.substring(cbegin, vbegin) == cname) { 
	                var vend = dcookie.indexOf (";", vbegin);
	                        if (vend == -1) vend = clen;
	                return unescape(dcookie.substring(vbegin, vend));
	                }
	        cbegin = dcookie.indexOf(" ", cbegin) + 1;
	                if (cbegin == 0) break;
	        }
	return null;
	
}


function checkformRail(o_form) {
			s_action = "";
			a_radio = o_form.railoption;
			for(var i=0;i<a_radio.length;i++)if(a_radio[i].checked)s_action=a_radio[i].value;
			window.location=s_action;
		}
		
//searchPageFunctions.js end

//siginandProfile.js start


// To close a open div
function closeDivSign(divIdForClose){

	if(document.getElementById(divIdForClose)){
		document.getElementById(divIdForClose).style.display="none";
		
	}
	if(loginModuleOrRest=="restLogin"){
		if(document.getElementById("submitForgot")){
			document.getElementById("submitForgot").href="javascript:createURLandSubmit('forgetPasswordRestModule');";
		}
	}
	if(divIdForClose=="editForm")
		closeDivSign("deleteFromDBMsgBox");
}

function openWindowForReViewItinerary(openUrl){
var top=50;
var left=200;
var width=770;
var height=680;

	window.open(openUrl, "", "toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no, top=" + top + ", left=" + left + ", width=" + width + ",height=" + height);

}

function onChangeLogin(tObj){
	logInVal=tObj.value;

}


function logOut(){
document.goProfileHome.action="/logOut.do";
document.goProfileHome.method.value="logOut";
document.goProfileHome.submit();
}



// It will create URL and will call AJAX.
function createURLandSubmit(method,fltMethod){
	var url="";
	var i=0;
	if(method=="forgetPassword"){
		url="/forgetPassword.do?divNo=1&fltMethod="+fltMethod+"&";
		setObjOffset(document.getElementById("placeToOpenDiv"),document.getElementById("SignIn"),0,0);
		for (i = 0; i < document.forgetPasswordForm.elements.length; i++) {
			url=url+document.forgetPasswordForm.elements[i].name+"="+document.forgetPasswordForm.elements[i].value;
			if(i!=(document.forgetPasswordForm.elements.length-1))
				url=url+"&";
		}
		url=url+"&loginId="+document.getElementById("EmailAddress").value;
	
		/*document.getElementById("SignIn").innerHTML="<img src='https://static.virginamerica.com/images/loading.gif'/>";*/
		showWaitImage();
		ajaxProfile(url, "SignIn");
	}
	if(method=="forgetPasswordRestModule"){
		url="/forgetPassword.do?divNo=1&fltMethod="+fltMethod+"&";
		setObjOffset(document.getElementById("openForgotPassword"),document.getElementById("SignIn"),0,0);
		for (i = 0; i < document.forgetPasswordForm.elements.length; i++) {
			url=url+document.forgetPasswordForm.elements[i].name+"="+document.forgetPasswordForm.elements[i].value;
			if(i!=(document.forgetPasswordForm.elements.length-1))
				url=url+"&";
		}
		url=url+"&loginId="+document.getElementById("EmailAddress").value;
		/*document.getElementById("SignIn").innerHTML="<img src='https://static.virginamerica.com/images/loading.gif'/>";*/
		showWaitImage();
		ajaxProfileInRestModules(url, "SignIn");
	}
	if(method=="changePassword"){
		url="/changePassword.do?divNo=2&fltMethod="+fltMethod+"&";
		for (i = 0; i < document.changePasswordForm.elements.length; i++) {
			url=url+document.changePasswordForm.elements[i].name+"="+document.changePasswordForm.elements[i].value;
			if(i!=(document.changePasswordForm.elements.length-1))
				url=url+"&";
		}
		/*document.getElementById("SignIn").innerHTML="<img src='https://static.virginamerica.com/images/loading.gif'/>";*/
		showWaitImage();
		ajaxProfile(url, "SignIn");
	}
}

function goToRegisterPageFromCompanion(){
	document.goProfileHome.action="goForCompanionRegister.do";
	document.goProfileHome.method.value="logOut";
	document.goProfileHome.submit();
}
var isOk=false;
var isAnswered=false;
var funcName="";
var divId2Delete="";
var indexVal="";
function confirmationBeforeDelete(whereOpen,whichData,funcname,divid2Delete,indexval){
	
	funcName=funcname;
	divId2Delete=divid2Delete;
	indexVal=indexval;
	var wObj=document.getElementById("deleteFromDBMsgBox");
	
	
	setPosition(whereOpen,wObj,160,0);
	wObj.style.display="block";
}
function retOkVal(){
	isOk=true;
	deleteVal();
	closeDivSign('deleteFromDBMsgBox');
	return isOk;
}
function deleteVal(){
	if(isOk){
 		str=funcName+"('"+divId2Delete+"','"+indexVal+"')";
		eval(str);
	}
}
function openPreAndNext(responseDiv, moveType){
var url="";
	url="nextAndPreviousAccountAction.do?method=nextAndPreviousAccountInfo&moveType="+moveType;
	ajaxProfile(url, responseDiv);
}
function openPreAndNextPoints(responseDiv, moveType){
var url="";
	url="nextAndPreviousAccountActionPoints.do?method=nextAndPreviousAccountInfoPoints&moveType="+moveType;
	ajaxProfile(url, responseDiv);
}
function openPreAndNextFF(responseDiv, moveType,currentNo){
var url="";
	if(responseDiv=='futureFltDiv'){
		url="nextAndPreviousFutureFlightAction.do?method=nextAndPreviousFutureFlightInfo&moveType="+moveType+"&currentPageNo="+currentNo+"&divId="+responseDiv;
	}else{
		url="nextAndPreviousFutureFlightAction.do?method=nextAndPreviousFutureFlightInfo&moveType="+moveType+"&currentPageNo="+currentNo+"&divId=";
	}
	ajaxProfile(url, responseDiv);
}

var activityFirstDataInd;
var activitySecDataInd;
var activityPastDataInd;

function openPreAndNextActivity(responseDiv,moveType, currentNo){
var url="";
	
	url="nextAndPreviousElevateActivityAction.do?method=nextAndPreviousElevateActivityInfo&moveType="+moveType+"&currentPageNo="+currentNo;
	
	ajaxProfile(url, responseDiv);
}


function populateActivityData(sortBtnId,responseDiv){
 activityFirstDataInd=document.signInForm.activityFirstData.selectedIndex;
 activitySecDataInd=document.signInForm.activitySecData.selectedIndex;
 activityPastDataInd=document.signInForm.activityPastData.selectedIndex;
 
var activityFirstData=document.signInForm.activityFirstData.value;
var activitySecData=document.signInForm.activitySecData.value;
var activityPastData=document.signInForm.activityPastData.value;
//var lodingObj=document.getElementById('loadingDiv');
	//getAnchorXY(sortBtnId);
	//lodingObj.style.left=X1;
	//lodingObj.style.top=Y1;
	//lodingObj.style.display='block';
	showWaitImage();
	url="nextAndPreviousElevateActivityAction.do?method=populateSelectedData&activityFirstData="+activityFirstData+"&activitySecData="+activitySecData+"&activityPastData="+activityPastData;
	ajaxProfile(url, responseDiv);

}

// It will Call AJAX and will paint response in perticular DIV
function openDivForSignIn(obj1, divNo,fltMethod){
	
	var myUrl="";
	obj1=document.getElementById("placeToOpenDiv");
	loginModuleOrRest="login";
	
	setPosition(obj1,document.getElementById("SignIn"),5,20);
	if(document.getElementById("trSignIn").style.display!="none"){
		document.getElementById("trSignIn").style.display="none";
	}
	if(document.getElementById("SignIn").style.display!="none"){
		document.getElementById("SignIn").style.display="none";
	}
	myUrl="signIn.jsp?divNo="+divNo+"&fltMethod="+fltMethod+"&loginName="+logInVal;
	if(fltMethod !='undefined'){
		ajaxProfile(myUrl, "SignIn");}
}

// It will Call AJAX and will paint response in perticular DIV
function openDivForSignInInRestModules(obj1, divNo){
	var myUrl="";
	loginModuleOrRest="restLogin";
	if(obj1.id=='CheckInopenForgotPassword' || obj1.id=='ChangeFlightopenForgotPassword' || obj1.id=='CancelFlightopenForgotPassword'){
		document.getElementById("SignIn").style.top=$('#forgotpass').offset().top+"px";
		document.getElementById("SignIn").style.left=$('#forgotpass').offset().left+"px";
	}else{
		setObjOffset(obj1,document.getElementById("SignIn"),0,0);
	}
	myUrl="signIn.jsp?divNo="+divNo+"&loginName="+logInVal;
	if(document.getElementById("SignIn").style.display!="none"){
		document.getElementById("SignIn").style.display="none";
	}
	ajaxProfileInRestModules(myUrl, "SignIn");
}

// Calling AJAX
function ajaxProfileInRestModules(myurl, div1){
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div1;
	xmlhttp.open("POST", myurl, true);
	chkURL=myurl;
	xmlhttp.onreadystatechange = handleResponseInRestModules;
	xmlhttp.send("");
}
var chkURL="";
// wait for response and write it in div
function handleResponseInRestModules() {

    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
		document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
	
		if(document.getElementById("submitForgot")!=null)
			document.getElementById("submitForgot").href="javascript:createURLandSubmit('forgetPasswordRestModule');";
		
		document.getElementById(ajaxDiv).style.display="block";
		
		if(document.getElementById("submitForgot")!=null && document.getElementById("closeHref"))
		document.getElementById("closeHref").href="javascript:closeDivSign('SignIn');";
			
		if(document.getElementById("submitForgot")!=null)
			document.getElementById("cancleHref").href="javascript:closeDivSign('SignIn');";
		
		if(document.getElementById("submitForgot")!=null)
			document.getElementById("changeImage").style.backgroundImage="";
			//url('https://static.virginamerica.com/images/ForgotPassword.gif')
		closeWaitImage();
	  }
	}
}


// It will Call AJAX and will paint response in perticular DIV
function openDivForEdit(objEditId, idObjID, urlToOpen){
	var myUrl;
	var divN=objEditId;
	var idObj=document.getElementById(idObjID);
	var objEdit=document.getElementById(objEditId);
	if(!(divN=="divPI" || divN=="divTD" || divN=="divPass" || divN=="divAdd" || divN=="divCCI" || divN=="divFP" || divN=="divTC" || divN=="divIT")){
		closeDivSign("deleteFromDBMsgBox");
		//objEdit.innerHTML="<img src='https://static.virginamerica.com/images/loading.gif'/>";
		showWaitImage();
	} else {
		//objEdit.innerHTML="";
		closeWaitImage();
	}
	
	getAnchorXY(idObjID);
	objEdit.style.left=X1-250;
	objEdit.style.top=Y1+10;
	if(objEdit.id=="accountDivDisplay"){
		setPosition(idObj,objEdit,0,200);
	}
	objEdit.style.display="block";
	myUrl=urlToOpen
	
	ajaxProfile(myUrl, objEdit.id);

}	
function openDivForEditUpdated(objEdit, idObj, urlToOpen){
	
	var myUrl;
	var divN=objEdit.id;
	
	if(!(divN=="divPI" || divN=="divPass" || divN=="divAdd" || divN=="divCCI" || divN=="divFP" || divN=="divTC" || divN=="divIT" || divN=="OptIn")){
		closeDivSign("deleteFromDBMsgBox");
		objEdit.innerHTML="";
	}else
	{
		document.getElementById("editForm").innerHTML="";
	}
	
	if(objEdit.id=="accountDivDisplay"){
		setPosition(idObj,objEdit,0,200);
	}
	objEdit.style.display="block";
	myUrl=urlToOpen
	showWaitImage();
	ajaxProfileUpdated(myUrl, objEdit.id);
	
}



function ajaxProfileForPassword(myurl, div1){
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div1; 
	xmlhttp.open("POST", myurl, true);
	chkURL=myurl;
	
	xmlhttp.onreadystatechange = handleResponseForPassword;
	xmlhttp.send("");
	
	
	
}


function handleResponseForPassword(){

if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
      	document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
      	document.getElementById(ajaxDiv).style.display="block";
      	enablePage();
      	if((ajaxDiv=="divPI" || ajaxDiv=="divPass" || ajaxDiv=="divAdd" || ajaxDiv=="divCCI" || ajaxDiv=="divFP" || ajaxDiv=="divTC" || ajaxDiv=="divIT" || ajaxDiv=="OptIn"))
		document.getElementById("editForm").style.display='none';
      }
}

}


function disablePage(){
	document.getElementById("disableTotalPage").style.top=0;
	document.getElementById("disableTotalPage").style.left=0;
	document.getElementById("disableTotalPage").style.height=getXandY($get_JsElement('ContainerFooter')).y;
	document.getElementById("disableTotalPage").style.width=1050;
	document.getElementById("disableTotalPage").style.display="block";
}
function enablePage(){
	if(document.getElementById("disableTotalPage"))
		document.getElementById("disableTotalPage").style.display="none";
}

function clearCheckBox(){
	for(i=0;i<document.modifyProfileForm.elements.length;i++){
		var chkObj=document.modifyProfileForm.elements[i];
		if(chkObj.name=="interestVal"){
			chkObj.checked=false;
		}
	}
}

// Calling AJAX
function ajaxProfile(myurl, div1){
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div1; 
	xmlhttp.open("POST", myurl, true);
	chkURL=myurl;

	xmlhttp.onreadystatechange = handleResponse;
	xmlhttp.send("");
}
function ajaxProfileUpdated(myurl, div1){

myurl=encodeURI(myurl);

	$('#'+div1).load(myurl,'',done);				
	enablePage();
	function done(){
		if((div1=="divPI" || div1=="divPass" || div1=="divAdd" || div1=="divCCI" || div1=="divFP" || div1=="divTC" || div1=="divIT" || div1=="OptIn")){
		document.getElementById("editForm").style.display='none';
	}
		closeWaitImage();

	}
	
	
}

function ajaxProfileAlt(myurl, div1){

	$('#'+div1).load(myurl,'',done);				
	enablePage();

	function done()
	{
	}
}

var chkURL="";
// wait for response and write it in div
function handleResponse() {
   var h=0;
   var ind=0; 
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
		
		if((xmlhttp.responseText).trim()=='AjaxSessionTimeOut'){
   		window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut";
  		}else if((xmlhttp.responseText).search("bg_ForgetPassword")!=-1){
			ind=(xmlhttp.responseText).search("bg_ForgetPassword");
		}else if((xmlhttp.responseText).search("bg_Sign-in")!=-1){
			ind=(xmlhttp.responseText).search("bg_Sign-in");
		}
		
		if((xmlhttp.responseText).substring(ind,ind+10)=="bg_Sign-in"){
			h=104
		}else if((xmlhttp.responseText).substring(ind,ind+17)=="bg_ForgetPassword"){
			h=142
		}
		
		/** code for forgot password Omniture event **/
		if((xmlhttp.responseText).search('PasswordResetEmailSent') !=-1){
			var s=s_gi(setOmnitureEnv());
			s.linkTrackVars='events';
			s.linkTrackEvents='event27';
			s.events='event27';
			s.tl(true,'o','Forgot Password');
		}
		/** code for forgot password Omniture event end **/
		
		if(loginModuleOrRest=="restLogin"){
			h=0;
			
		}
		document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
		document.getElementById(ajaxDiv).style.display="block";
		enablePage();
	
			if(loginModuleOrRest=="restLogin"){
			if(document.getElementById("changeImage")){
				document.getElementById("closeHref").href="javascript:closeDivSign('SignIn');";
				document.getElementById("changeImage").style.backgroundImage="url('https://static.virginamerica.com/images/bg_ForgetPasswordWithoutSignIn.gif')";
				
			}
		}	
		
		if(ajaxDiv=='elevateActivitiesDiv'){
			if(document.getElementById('activityFirstData')){
			document.signInForm.activityFirstData.selectedIndex=activityFirstDataInd;
			document.signInForm.activitySecData.selectedIndex=activitySecDataInd;
			document.signInForm.activityPastData.selectedIndex=activityPastDataInd;
			}
		}
		
		
	if(document.getElementById("loadingAnimationDiv"))document.getElementById("loadingAnimationDiv").style.display="none";		
		
		xmlhttp=null;	
	  }
	}
}

// submit login form after change password
function submitFormLogAfterChangePassword(URLParameters){
	var loginURL="";
	loginURL="/signInLogin.do"+URLParameters+"&reDirect=no";
	
	ajaxProfileSignIn(loginURL, "loginWindowDiv");
}

// submit login form
function submitFormLog(formName, statusBooking){
	var loginURL="";
	var signLoginId=document.signInForm.loginId.value;
	for (i = 0; i < document.signInForm.elements.length; i++) {
			if(document.signInForm.elements[i].name=="password"){
				var signPassword=document.signInForm.elements[i].value;
				break;
			}
		}
	if(rUInRegistrationProcess=="Yes"){
		document.signInForm.action="/signInFromRegister.do";
		document.signInForm.submit();
	}else{
		if(statusBooking=="booking"){
		
			loginURL="/signInLogin.do?method=signIn&loginId="+signLoginId+"&password="+signPassword+"&reDirect=no";
		}else{
			loginURL="/signInLogin.do?method=signIn&loginId="+signLoginId+"&password="+signPassword+"&reDirect=yes";
		}
	
		//document.getElementById("submitID").innerHTML='<img src="https://static.virginamerica.com/images/btn_sign-in.gif" height="20" width="63" alt="Sign In" title="Sign In" border="0" />';
		ajaxProfileSignIn(loginURL, "loginWindowDiv");
	}
	//document.getElementById("SignIn").innerHTML="<img src='https://static.virginamerica.com/images/loading.gif'/>";
	showWaitImage();
}


// Calling AJAX
function ajaxProfileSignIn(myurl, div1){

	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div1;
	xmlhttp.open("POST", myurl, true);
	
	xmlhttp.onreadystatechange = handleResponseSignIn;
	xmlhttp.send("");
}

// wait for response and write it in div
function handleResponseSignIn() {
	
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
		document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
		document.getElementById(ajaxDiv).style.display="block";
		closeWaitImage();
	  }
	}
}



// Function for rollover image
function showRolloverImage(imgId,imgName){
	if(imgId.src.indexOf("cl") == -1)
		imgId.src= "https://static.virginamerica.com/images/"+imgName+"_roll.gif";
	else
		imgId.src= "https://static.virginamerica.com/images/"+imgName+"_roll_cl.gif";
}

// restore roll over image
function restoreImage(imgId,imgName){
	if(imgId.src.indexOf("cl") == -1)
			imgId.src= "https://static.virginamerica.com/images/"+imgName+".gif";
	else
	imgId.src= "https://static.virginamerica.com/images/"+imgName+"_cl.gif";	
}

// This function is for toggel among four (The basic, future flights,
//	account information and preference page under profile) pages.

function showElevatePointsDivArea(divId,activeImg,tbSelect){
	document.getElementById("elevateActivities").src="https://static.virginamerica.com/images/btn_the_basics.gif";
	document.getElementById("elevateContact").src="https://static.virginamerica.com/images/btn_account_activitty.gif";
	document.getElementById('elevatePreferences').src="https://static.virginamerica.com/images/btn_preferences.gif";
	
	document.getElementById("elevateActivitiesDiv").style.display="none";
	document.getElementById("elevateContactDiv").style.display="none";
	document.getElementById("elevatePreferencesDiv").style.display="none";
	
	document.getElementById("showNeedPointsDiv").style.display="none";
	document.getElementById("needPointsResultDiv").style.display="none";
	document.getElementById("upComingFlightImageId").style.display="none";
	document.getElementById("forGotPointImageId").style.display="none";
	document.getElementById("elevatePointsExplainDivId").style.display="none";
	document.getElementById("requestElevatePointsImageId").style.display="block";
	document.getElementById("elevateExpandHtmlId").style.display="block";
	divId.src=activeImg;
	tbSelect=tabSelect;
	document.getElementById("pointHistoryDiv").style.display="block";
}



var elevatePointsActiveImage;

function showFullActivity(){
showLoadingImageonPopUp('pointHistoryFromTheBasic');
window.location="/signIn.do?method=homeProfileWithPagination&showActivity=true"
}

function showDivArea(divId,activeImg, tbSelect){
if(tbSelect==1){
	myUrl="showPreferences.do?method=showPrefrences&forwardPage=elevateActivity";
	if(divId!="pointHistoryFromTheBasic")
	showLoadingImageonPopUp(divId);
	showElevatePointDetailsAjax(myUrl, divId,activeImg);
}else if(tbSelect==3){
	myUrl="showPreferences.do?method=showPrefrences&forwardPage=contactInfo";
	showLoadingImageonPopUp(divId);
	showElevatePointDetailsAjax(myUrl, divId,activeImg);
}else if(tbSelect==5){
	myUrl="showPreferences.do?method=showPrefrences&forwardPage=preferences";
	showLoadingImageonPopUp(divId);
	showElevatePointDetailsAjax(myUrl, divId,activeImg);
}else if(tbSelect==4){
	myUrl="showPreferences.do?method=showPrefrences&forwardPage=pointsExpSummary";
	showLoadingImageonPopUp(divId);
	showElevatePointDetailsAjax(myUrl, divId,activeImg);
}else{
	document.getElementById("elevateActivities").src="https://static.virginamerica.com/images/btn_the_basics.gif";
	document.getElementById("elevateContact").src="https://static.virginamerica.com/images/btn_account_activitty.gif";
	document.getElementById('elevatePreferences').src="https://static.virginamerica.com/images/btn_preferences.gif";
	// First set vigibility to false for all four pages
	document.getElementById("elevateActivitiesDiv").style.display="none";
	document.getElementById("elevateContactDiv").style.display="none";
	document.getElementById("elevatePreferencesDiv").style.display="none";
	
	document.getElementById("showNeedPointsDiv").style.display="none";
	document.getElementById("needPointsResultDiv").style.display="none";
	// Set the clicked div/page to display
	divId.src=activeImg;
	divAreaId=divId.id+"Div";
	tbSelect=tabSelect;
	
	
	if(divAreaId=='elevateActivitiesDiv'){
		
	document.getElementById("upComingFlightImageId").style.display="none";
	document.getElementById("forGotPointImageId").style.display="block";
	document.getElementById("elevateExpandHtmlId").style.display="block";	
	document.getElementById("requestElevatePointsImageId").style.display="none";
	document.getElementById("elevatePointsExplainDivId").style.display="none";
		document.getElementById("elevateExpandHtmlIdPref").style.display="none";
	}else if(divAreaId=='elevatePreferencesDiv'){
		s.event12="Elevate Preferences";
	document.getElementById("upComingFlightImageId").style.display="none";
	document.getElementById("forGotPointImageId").style.display="none";
	document.getElementById("elevateExpandHtmlId").style.display="none";	
	document.getElementById("elevatePointsExplainDivId").style.display="none";
	document.getElementById("requestElevatePointsImageId").style.display="none";
	document.getElementById("elevateExpandHtmlIdPref").style.display="block";
	}else if(divAreaId=='elevateContactDiv'){
		s.event15="Past Flights";
	document.getElementById("upComingFlightImageId").style.display="none";
	document.getElementById("forGotPointImageId").style.display="none";
	document.getElementById("elevateExpandHtmlId").style.display="block";	
	document.getElementById("elevatePointsExplainDivId").style.display="none";
	document.getElementById("requestElevatePointsImageId").style.display="block";
	document.getElementById("elevateExpandHtmlIdPref").style.display="none";
	}
	document.getElementById(divAreaId).style.display="block";
	
	showLoadingImageClose();
}
	var s_code=s.t();if(s_code)document.write(s_code);
}

/**
	 * This function will use for call the fare details in travel exp page with Ajax
	 * Name ajax 
	 * @param myurl
	 * @param Div
	 */
function showElevatePointDetailsAjax(myurl, div,activeImg){
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div;
	elevatePointsActiveImage=activeImg;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange=handleResponseElevatePointDetails;
	xmlhttp.send("");
}

/**
	* This function will use for call the fare details in travel exp page with Ajax
	* Name handleResponse
	* 

*/

function handleResponseElevatePointDetails(){
 
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
    	 var ElevatePointResponseText =xmlhttp.responseText;
     if(ElevatePointResponseText.trim()=='AjaxSessionTimeOut'){
  		window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut";
  		}else if(ajaxDiv=="elevateActivities" || ajaxDiv=="expPointsLinkDivId" || ajaxDiv=="pointHistoryFromTheBasic"){
  		document.getElementById("elevateActivitiesDiv").style.display="none";
		document.getElementById("elevateContactDiv").style.display="none";
		document.getElementById("elevatePreferencesDiv").style.display="none";
		document.getElementById("elevateActivitiesDiv").style.display="block";
		document.getElementById("elevateActivitiesDiv").innerHTML=xmlhttp.responseText;
  		document.getElementById('elevateActivities').className="current"
  		document.getElementById('elevateContact').className=""
  		document.getElementById('elevatePreferences').className=""
  		document.getElementById("eleActivityRightContantDivId").style.display="";
  		document.getElementById("myContactInfoRightContentDivId").style.display="none";
  		document.getElementById("preferencesRightContentDivId").style.display="none";
  		document.getElementById("myAccountRightContentDivId").style.display="none";
  		if(typeof(activityFirstDataInd)!='undefined' && typeof(activitySecDataInd)!='undefined' && typeof(activityPastDataInd)!='undefined' ){
  		   if(document.signInForm){
  			document.signInForm.activityFirstData.selectedIndex=activityFirstDataInd;
			document.signInForm.activitySecData.selectedIndex=activitySecDataInd;
			document.signInForm.activityPastData.selectedIndex=activityPastDataInd;
		}
		}
  		showLoadingImageClose();
  		
  		}else if(ajaxDiv=="elevateContact"){
  		document.getElementById("elevateActivitiesDiv").style.display="none";
		document.getElementById("elevateContactDiv").style.display="none";
		document.getElementById("elevatePreferencesDiv").style.display="none";
		document.getElementById("elevateContactDiv").style.display="block";
		document.getElementById("elevateContactDiv").innerHTML=xmlhttp.responseText;
		document.getElementById('elevateActivities').className=""
  		document.getElementById('elevateContact').className="current"
  		document.getElementById('elevatePreferences').className=""
  		document.getElementById("eleActivityRightContantDivId").style.display="none";
  		document.getElementById("myContactInfoRightContentDivId").style.display="";
  		document.getElementById("preferencesRightContentDivId").style.display="none";
  		document.getElementById("myAccountRightContentDivId").style.display="none";
  		
		showLoadingImageClose();
  		}else if(ajaxDiv=="elevatePreferences"){
  	
  		document.getElementById("elevateActivitiesDiv").style.display="none";
		document.getElementById("elevateContactDiv").style.display="none";
		document.getElementById("elevatePreferencesDiv").style.display="none";
		
  		
  		document.getElementById("elevatePreferencesDiv").style.display="block";
		document.getElementById("elevatePreferencesDiv").innerHTML=xmlhttp.responseText;
  		
  		document.getElementById('elevateActivities').className=""
  		document.getElementById('elevateContact').className=""
  		document.getElementById('elevatePreferences').className="current"
  		
  		document.getElementById("eleActivityRightContantDivId").style.display="none";
  		document.getElementById("myContactInfoRightContentDivId").style.display="none";
  		document.getElementById("preferencesRightContentDivId").style.display="";
  		document.getElementById("myAccountRightContentDivId").style.display="none";
  		
  		showLoadingImageClose();
  		} 
  	 	} 
	}
}
//ankur changes start
var chkAccountDetailsRS='false';
var chkPointActivityDetailsRS='false';
var arrowImgId;

function callAjaxFunction(objDivId,imgId){
imgObj= document.getElementById(imgId);
arrowImgId=imgId;
if(chkAccountDetailsRS=='false' && objDivId=='messageDisplay' && document.getElementById(objDivId).style.display=='none'){
	//showLoadingImageOpen(imgId.replace('Img', 'Td'));
	showWaitImage();
	myUrl="elevateAccountDetails.do?method=elevateBookingDetails";
	retreiveAccountDetails(myUrl,objDivId);
	chkAccountDetailsRS='false';
}else if(chkPointActivityDetailsRS=='false' && objDivId=='messageActivity' && document.getElementById(objDivId).style.display=='none'){
	//showLoadingImageOpen(imgId.replace('Img', 'Td'));
	showWaitImage();
	myUrl="elevateAccountDetails.do?method=elevatePointsActivity";
	retreiveAccountDetails(myUrl,objDivId);
	chkPointActivityDetailsRS='false';
}else{
	if(document.getElementById(objDivId).style.display=='none'){
		imgObj.setAttribute("src", "https://static.virginamerica.com/images/arrowDown.gif");
		document.getElementById(objDivId).style.display='';
		if(objDivId=='messageDisplay'){
			document.getElementById('messageActivity').style.display='none';
			document.getElementById('ptDivImgId').setAttribute("src", "https://static.virginamerica.com/images/arrowRight.gif");
		}
		if(objDivId=='messageActivity'){
			document.getElementById('messageDisplay').style.display='none';
			document.getElementById('msgDivImgId').setAttribute("src", "https://static.virginamerica.com/images/arrowRight.gif");
		}		
		
	}else{
		imgObj.setAttribute("src", "https://static.virginamerica.com/images/arrowRight.gif");
		document.getElementById(objDivId).style.display='none';
	}
	
}
}



function retreiveAccountDetails(myurl, divId){
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = divId;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange=handleResponseAccountDetails;
	xmlhttp.send("");
}


function handleResponseAccountDetails(){
    if (xmlhttp.readyState == 4) { // Complete
	      if (xmlhttp.status == 200) { // OK response
		    	 var responseText =xmlhttp.responseText;
	
			if(responseText.trim()=='AjaxSessionTimeOut'){
   				window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut";
  			}else{
	  	
	  		  		document.getElementById('loginWindowDiv').innerHTML=xmlhttp.responseText;
	  				document.getElementById('loginWindowDiv').style.display='';
	  				document.getElementById(ajaxDiv).style.display='block';
					var img= document.getElementById(arrowImgId);
		  			img.setAttribute("src", "https://static.virginamerica.com/images/arrowDown.gif");
					if(ajaxDiv=='messageActivity' && document.getElementById('messageDisplay').style.display!='none'){
						document.getElementById('messageDisplay').style.display='none';
						document.getElementById('msgDivImgId').setAttribute("src", "https://static.virginamerica.com/images/arrowRight.gif");
					}
	  			 
	  			 if(ajaxDiv=='messageDisplay'){
					if(document.getElementById('messageActivity').style.display!='none'){
					document.getElementById('messageActivity').style.display='none';
					document.getElementById('ptDivImgId').setAttribute("src", "https://static.virginamerica.com/images/arrowRight.gif");	  		
	  				}
	  			}
	  		
	  			 
	  			 
	  			    showLoadingImageClose();
	  		}	   
			
	  	}
	}
}






function isNumeric(value) {
	  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
	  return true;
	}

function validateLength(limit, str) {
    if (str.length != limit) {
    return false;
    }
    return true;
  }


function isalphaNumericValidate(valuetocheck)
{
	var tempval = valuetocheck;
	for(var j=0; j<tempval.length; j++)
		{
		  var tempchar = tempval.charAt(j);
		  var hh = tempchar.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
                        
			 return false;
		  }
 		}
 
 return true;
}

function vxTrim(value) {
	  value = value.replace(/^\s+/,'');
	  value = value.replace(/\s+$/,'');
	  return value;
}

function showCkInHome(pnr,forId,lastName,tickNo){
	
	// Trim the left and right blank spaces from PNR.
	
	if (pnr != null && pnr != "" && pnr!="Confirmation Code"){
		pnr = vxTrim(pnr);
	}
	
	if(!isalphaNumericValidate(pnr)){
		if(pnr!="Confirmation Code"){
			alert("Confirmation Code must be alphanumeric six characters only");            

		return false;
		}
	}
	if(!validateLength(6,pnr)){
		if(pnr!="Confirmation Code"){
		alert("Confirmation Code does not contain six characters.");
		return false;
		}
	}
	
	if((pnr=="Confirmation Code") && (!isNumeric(tickNo))){
		if(tickNo!="Ticket Number"){
		alert("Ticket Number must be numeric thirteen digits only");
		return false;
		}
	}
	if((pnr=="Confirmation Code") && (!validateLength(13,tickNo))){
		if(tickNo!="Ticket Number"){
		alert("Ticket Number does not contain thirteen digits.");
		return false;
		}
	}
	


	//arguments[0] = Confirmation code
	//arguments[1] = Id
	//arguments[2] = Last name
	//arguments[3] = Ticket number
	//arguments[4] = method


	var method = document.pnrDetailForm.elements['method'].value;

	var x=document.pnrDetailForm.elements['pnrDetail.pnrNo'];
	x.value=pnr;
	
	// Added for Search by E-Ticket Functionality -Start //
	var y=document.pnrDetailForm.elements['pnrDetail.tickNo'];
	y.value=tickNo;
	// Added for Search by E-Ticket Functionality -End //
	
	if(arguments[4] !== null && arguments[4] !=="") {
		method = arguments[4];
	}
	
	
	if((arguments[0]=="Confirmation Code" || arguments[0]=="")&&(arguments[3]=="Ticket Number" || arguments[3]==""))
	{
		alert("Please provide the Confirmation Code or Ticket Number");
    return false;
	}
	
	
	if((arguments[2]=="Last Name" || arguments[2]=="") && method!=="viewItinerary")
	{
		alert("Please provide your last name");
	return false;
	}
	
	if(arguments[2]!=null){
	document.pnrDetailForm.elements['pnrDetail.lastName'].value=arguments[2];
	var iChars = "!@#$%^&*()+=[]\\\;,./{}|\":<>?";
	for (var i = 0; i < document.pnrDetailForm.elements['pnrDetail.lastName'].value.length; i++) {
		if (iChars.indexOf(document.pnrDetailForm.elements['pnrDetail.lastName'].value.charAt(i)) != -1) {
			alert ("Your lastname has special characters. \nThese are not allowed.\n Please remove them and try again.");
			return false;
		}
	}
	}
	
	if(forId!=null && forId==''){
	document.pnrDetailForm.fromManageTravel.value='no';
	}

	if(method != null){
		if(method=='viewItinerary'){
		document.pnrDetailForm.elements['method'].value="viewItinerary";
	}else{

		document.pnrDetailForm.elements['method'].value="getItineraryForGuest";
	}
	}
	document.pnrDetailForm.submit();	
	showWaitImage();
	}

function submitElevateUpcomingFlights(pnr,forId,lastName,tickNo,elevateFlightIndex){
	document.pnrDetailForm.elements['method'].value = "viewItinerary";
	document.pnrDetailForm.elements['pnrDetail.pnrNo'].value = pnr;
	document.pnrDetailForm.elements['pnrDetail.lastName'].value = lastName;
	document.pnrDetailForm.submit();
	showWaitImage();
}

// calculates the total page size with scroll area
function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight + document.body.offsetTop;
		xWithScroll = document.body.offsetWidth + document.body.offsetLeft;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	return arrayPageSizeWithScroll;
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function closeFareRulDiv(divId){

document.getElementById(divId).style.display='none';
}

function toggleTaxesAnFee(objId){
var imgObj=document.getElementById(objId);
if(document.getElementById("passengerChargeId").style.display!="none"){
imgObj.src='https://static.virginamerica.com/images/taxFeesExpand.gif';
document.getElementById("passengerChargeId").style.display="none";
document.getElementById("securityFeeId").style.display="none";
document.getElementById("segmentFeeId").style.display="none";
if(document.getElementById("travelInsurenceId")!=null)
document.getElementById("travelInsurenceId").style.display="none";
}else{
imgObj.src='https://static.virginamerica.com/images/taxFeesCollapse.gif';
document.getElementById("passengerChargeId").style.display="";
document.getElementById("securityFeeId").style.display="";
document.getElementById("segmentFeeId").style.display="";
if(document.getElementById("travelInsurenceId")!=null)
document.getElementById("travelInsurenceId").style.display="";

}

}

//ankur changes end


function showRolloverImageNor(imgId,imgName){
	imgId.src= "https://static.virginamerica.com/images/"+imgName+"_roll.gif";
}

function restoreImageNor(imgId,imgName){
	imgId.src= "https://static.virginamerica.com/images/"+imgName+".gif";
}
	
// To add new email addresses on edit window under profile/preference
function addEvent(){
	var ni = document.getElementById('myDiv');
	var numi = document.getElementById('theValue');
	var num = (document.getElementById("theValue").value -1)+ 2;
	numi.value = num;
	var divIdName = "my"+num+"DivEMail";
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName);
	newdiv.innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=416><tr><td width=31></td><td width=110 class=pageBody9><strong>Email Address:</strong></td><td width=110><input name=modifyProfileModel.emailaddress["+num+"] type=text class=pageBody9 size=25 ></td><td><img src=https://static.virginamerica.com/images/spacer.gif width=3 /></td><td><img src=https://static.virginamerica.com/images/btn_delete.gif onmouseover=\"showRolloverImage(this,'btn_delete');MakeCursor(this);\" onmouseout=restoreImage(this,\'btn_delete\') alt=Delete title=Delete onclick=\"removeEvent(\'"+divIdName+"\',\'myDiv\',\'mail\');resetMailElementName();\"></td><td></td></tr><tr><td colspan=4><img src=https://static.virginamerica.com/images/spacer.gif width=1 height=3></td></tr></table>";
	CntAddElements("cntMailElements");
	ni.appendChild(newdiv);
}

//	To add phone numbers on edit window under profile/preference
function addEventForPhone(){
	var ni = document.getElementById('myDivPhone');
	var numi = document.getElementById('theValuePhone');
	var num = (document.getElementById("theValuePhone").value -1)+ 2;
	numi.value = num;
	var divIdName = "my"+num+"Div4Phone";
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName);
	newdiv.innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=416><tr><td width=31><input type=radio value=phone"+num+" name=phonePrimary  onclick=setRadioVal(this.value,\'personalInfo\',0);></td><td width=110 class=pageBody9><select name=modifyProfileModel.phonetypenew["+num+"] class=pageBody9 style=\'width:100px;\'><option selected=selected value=\'\'>Select Type</option><option value=office>Business</option><option value=Home>Home</option><option value=Mobile>Mobile</option></select></td><td width=110><input id=phonenumbernewID"+num+" onblur=\"filterValue(\'phonenumbernewID"+num+"\');\" name=modifyProfileModel.phonenumbernew["+num+"] type=text value='' class=pageBody9 size=25 ></td><td><img src=https://static.virginamerica.com/images/spacer.gif width=3 /></td><td><img src=https://static.virginamerica.com/images/btn_delete.gif onmouseover=\"showRolloverImage(this,'btn_delete');MakeCursor(this);\" onmouseout=restoreImage(this,\'btn_delete\') alt=Delete title=Delete onclick=\"removeEvent(\'"+divIdName+"\',\'myDivPhone\',\'phone\');resetElementName("+num+");\"></td><td></td></tr><tr><td colspan=4><img src=https://static.virginamerica.com/images/spacer.gif width=1 height=3></td></tr></table>";
	CntAddElements("cntMailElements");
	ni.appendChild(newdiv);
}

// Remove element from page
function removeEvent(divNum, myDivID, whichEl){
	var d = document.getElementById(myDivID);
	var olddiv = document.getElementById(divNum);
	if(whichEl=="mail")
		CntRemoveElements("theValue");
	else if(whichEl=="phone")
		CntRemoveElements("theValuePhone");
	d.removeChild(olddiv);
}

// Add new credit card information div to edit page under profile/preference/credit card-edit section
function addEventForCreditCard(){
	var ni = document.getElementById('myDivCard');
	var i=0;
	var numi = document.getElementById('theValueCard');
	var num = (parseInt(numi.value) -1)+ 2;
	numi.value = num;
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		if(document.modifyProfileForm.elements[i].name=="modifyProfileModel.cardCount")
			document.modifyProfileForm.elements[i].value=num;
	}
	
	var divIdName = "myDivCreditCard"+num;
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName);
	ni.appendChild(newdiv);
	// Call AJAX for modify/Add
	openDivForEdit(divIdName,divIdName, 'editCreditCardInfoInProfileIterateAdd.jsp?divNum='+num);
}

// Add new companion information div to edit page under profile/preference/credit card-edit section
function addEventForCompanion(){
	var ni = document.getElementById('myDivCompanion');
	var i=0;
	var numi = document.getElementById('theValueCompanion');
	var num = (parseInt(numi.value) -1)+ 2;
	numi.value = num;

	var divIdName = "nameDivParent"+num;
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName);
	ni.appendChild(newdiv);
	// Call AJAX for modify/Add
	openDivForEdit(divIdName, divIdName, 'editTravelCompanionsInProfileAdd.jsp?divNum='+num);
}

function CntAddElements(elementId){
	var cntAdd=0;
	cntAdd=document.getElementById(elementId).value;
	document.getElementById(elementId).value= (cntAdd)- (-1);
}

function CntRemoveElements(elementId){
	var cntRem=0;
	cntRem=document.getElementById(elementId).value;
	document.getElementById(elementId).value=cntRem-1;
}

function showHideLayer(anchorObj, divID,imgName,divIDSpace){
	divId =document.getElementById(divID);
	if(divIDSpace!='no'){
		divIDSpace=document.getElementById(divIDSpace);
	}

	if(divId.style.display!="none"){
		anchorObj.className="collapseBtn";
		divId.style.display = "none";
		if(divIDSpace!='no'){
			divIDSpace.style.display = "block";
		}
		if(document.getElementById("toggleTrigger"))
		document.getElementById("toggleTrigger").innerHTML ="Show Details";            
	}
	else{
		anchorObj.className="collapsed";
		divId.style.display = "block";
		if(divIDSpace!='no'){
			divIDSpace.style.display = "none";
		}
		if(document.getElementById("toggleTrigger"))
		document.getElementById("toggleTrigger").innerHTML ="Hide Details";              
	}
}


function showHideLayerOnLoad(){

var divId;
var activeImg;
	if(tabSelect==1){
		divId="theBasics";
		activeImg="https://static.virginamerica.com/images/btn_the_basics_sel.gif";
	}else if(tabSelect==2){
		divId="accountActivity";
		activeImg="https://static.virginamerica.com/images/btn_account_activitty_sel.gif";
	}else if(tabSelect==3){
		divId="futureFlights";
		activeImg="https://static.virginamerica.com/images/btn_future_flights_sel.gif";
	}else if(tabSelect==4){
		divId="preferences";
		activeImg="https://static.virginamerica.com/images/btn_preferences_sel.gif";
	}else{
		divId="theBasics";
		activeImg="https://static.virginamerica.com/images/btn_the_basics_sel.gif";
	}
	showDivArea(document.getElementById(divId),activeImg,tabSelect);
}

function resetElementName(num){
	var elcnt=0;
	var dlNum=parseInt(num);
	var radioDelNum;
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		if(document.modifyProfileForm.elements[i].name.length>32){
			if(document.modifyProfileForm.elements[i].name.substring(0,33)=="modifyProfileModel.phonenumbernew"){
				document.modifyProfileForm.elements[i].name="modifyProfileModel.phonenumbernew["+elcnt+"]";	
				elcnt=elcnt+1;
		
			}
		}
	}
	elcnt=0;
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		if(document.modifyProfileForm.elements[i].name.length>30){
			if(document.modifyProfileForm.elements[i].name.substring(0,31)=="modifyProfileModel.phonetypenew"){
				document.modifyProfileForm.elements[i].name="modifyProfileModel.phonetypenew["+elcnt+"]";	
				elcnt=elcnt+1;
			}
		}
	}
	elcnt=0;
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		if(document.modifyProfileForm.elements[i].name=="phonePrimary"){
			document.modifyProfileForm.elements[i].value="phone"+elcnt;	
			elcnt=elcnt+1;
		}
	}
}

function resetMailElementName(){
	var elcnt=0;
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		if(document.modifyProfileForm.elements[i].name.length>30){
			if(document.modifyProfileForm.elements[i].name.substring(0,31)=="modifyProfileModel.emailaddress"){
				document.modifyProfileForm.elements[i].name="modifyProfileModel.emailaddress["+elcnt+"]";	
				elcnt=elcnt+1;
		
			}
		}
	}
}

function resetElementNamePhoneRun(num){

	var elcnt=0;
	var hiddCnt=parseInt(num);
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		if(document.modifyProfileForm.elements[i].name.length>32){
			if(document.modifyProfileForm.elements[i].name.substring(0,33)=="modifyProfileModel.phonenumbernew"){
				if(i>=num && elcnt>num){
					document.modifyProfileForm.elements[i].name="modifyProfileModel.phonenumbernew["+(elcnt-1)+"]";	
					document.modifyProfileForm.elements[i].value=document.modifyProfileForm.elements[i].name;	
					if(parseInt(document.getElementById("theValuePhone").value)>=(hiddCnt+1)){
						document.getElementById('positionDiv'+hiddCnt+"").value=hiddCnt-1;
						hiddCnt=hiddCnt+1;
					}
				}
				elcnt=elcnt+1;
			}
		}
	}
	document.getElementById("theValuePhone").value=parseInt(document.getElementById("theValuePhone").value)-1;
}


function deleteLayer(id) {
	if (document.layers && document.layers[id]){
		document.layers[id].visibility='hide'
		delete document.layers[id]
	}
}

function setAliasValue(val){
	for (i = 0; i < document.requestProfileForm.elements.length; i++) {
		if(document.requestProfileForm.elements[i].name=="createProfile.emailSecond")
			document.requestProfileForm.elements[i].value=val;
	}
}

function setAliasModifyValue(val){
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		if(document.modifyProfileForm.elements[i].name=="modifyProfileModel.alias")
			document.modifyProfileForm.elements[i].value=val;
	}
}

function resetElementNameAddress(num){
var elcnt=0;
var name;
var elPosition;
var elIntPosition;
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		name=document.modifyProfileForm.elements[i].name;
		name=name.split("[");
		if(!(name[1]==null || name[i]=="")){
			elPosition=name[1].split("]");
			if(!(elPosition[0]==null || elPosition[0]=="")){
				elIntPosition=parseInt(elPosition[0]);
				if(i>=num && elIntPosition>num){
					document.modifyProfileForm.elements[i].name=name[0]+"["+(elIntPosition-1)+"]";
				}
			}
		}
	}
	document.getElementById("theValueAddress").value=document.getElementById("theValueAddress").value-1;
}

function addEventForAddress(){
var i=0;
var ni = document.getElementById('myDivAddress');
var i=0;
var numi = document.getElementById('theValueAddress');
var num = (parseInt(numi.value) -1)+ 2;
	numi.value = num;
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
			if(document.modifyProfileForm.elements[i].name=="modifyProfileModel.addressCnt")
				document.modifyProfileForm.elements[i].value=num;
	}
	var divIdName = "myDivAddress"+num;
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName);
	ni.appendChild(newdiv);
		openDivForEdit(divIdName,'editBtnAddress', 'editAddressInProfileIterateAdd.jsp?divNum='+num);
}

function removeEventForAddress(divNum, myDivID, whichEl){
	document.getElementById(divNum).style.display="none";
	var olddiv = olddiv.parentNode;
	var d = document.getElementById(myDivID);
	d.removeChild(olddiv);
}
function populateOmnitureVariable(modify)
{
	
	s.events="event9";
	if(modify=="personal"){
	s.eVar24='Edit Personal Information';
	}
	else if(modify=="creditCard"){
	s.eVar24='Edit Credit Card Information';
	}
	else if(modify=="password"){
	s.eVar24='Edit Password';
	}
	else if(modify=="address"){
	s.eVar24='Edit Address Information';
	}
	else if(modify=="companion"){
	s.eVar24='Edit Companion';
	}else if(modify=="attribute"){
	s.eVar24='Edit Attribute';
	}else if(modify=="interest"){
	s.eVar24='Edit Interest';
	}
	var s_code=s.t();if(s_code)document.write(s_code);
}
function createUrlPersonalInfo(place, frm){
	
closeDivSign("deleteFromDBMsgBox");
disablePage();
populateOmnitureVariable(frm);
var url=null;
var postionDiv="testPosition";
	// It will create url for modification/Addition in personal information
	if(frm=="personal"){
		url="modifyProfile.do?div=11";
		document.modifyProfileForm.elements["modifyProfileModel.cntPhone"].value=document.getElementById("theValuePhone").value;
		document.modifyProfileForm.elements["modifyProfileModel.cntEMail"].value=document.getElementById("theValue").value;

		for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
			if(document.modifyProfileForm.elements[i].name!="phonePrimary")
				url=url+"&"+document.modifyProfileForm.elements[i].name+"="+document.modifyProfileForm.elements[i].value;
		}
		openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("editPersonalOpen"), url);
	}
	
	// It will create url for modification/Addition in credit card information
	if(frm=="creditCard"){
		url="modifyCreditCardProfile.do?div=11";
		var t=0;
		for(i=0; i<document.modifyProfileForm.elements.length; i++){
			if(document.modifyProfileForm.elements[i].name=="modifyProfileModel.cardCount"){
				document.modifyProfileForm.elements[i].value=document.getElementById("theValueCard").value;
			}
		
			if(document.modifyProfileForm.elements[i].type!="radio"){
				url=url+"&"+document.modifyProfileForm.elements[i].name+"="+document.modifyProfileForm.elements[i].value
				//t=t+1;
			}
		}
		openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("editCreditCOpen"), url);
	}
	
	// It will create url for modification of account information
	if(frm=="password"){
		url="modifyPasswordProfile.do?div=11";
		var val='';
		for (i = 0; i <  document.modifyProfileForm.elements.length; i++) {
			val=document.modifyProfileForm.elements[i].value;
			val=val.replace('+', 'PLUS');
			//url=url+"&"+document.modifyProfileForm.elements[i].name+"="+escape(val);
			url=url+"&"+document.modifyProfileForm.elements[i].name+"="+document.modifyProfileForm.elements[i].value;
		}
		url=url.replace(/PLUS/g, '%2B');
		openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("editPasswordOpen"), url);
	}
	
	// It will create url for modification/Addition in address information
	if(frm=="address"){
		url="modifyAddressProfile.do?div=11";
		for(i=0; i<document.modifyProfileForm.elements.length; i++){
			if(document.modifyProfileForm.elements[i].name=="modifyProfileModel.addressCnt"){
				document.modifyProfileForm.elements[i].value=document.getElementById("theValueAddress").value;
			}
		}
		var totalElement=((parseInt(document.getElementById("theValueAddress").value)+1)*11)+3;
		var nameVal;
		for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
			nameVal=document.modifyProfileForm.elements[i].name.split("_");
			if(nameVal[0]!="radioAddress"){
				url=url+"&"+document.modifyProfileForm.elements[i].name+"="+document.modifyProfileForm.elements[i].value;
			}
		}
		openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("editBtnAddress"), url);
	}
	
	// It will create url for modification/Addition for Companion
	if(frm=="companion"){
		url="modifyCompanionProfile.do?div=11";
		for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		if(document.modifyProfileForm.elements[i].name=="modifyProfileModel.companionTotal"){
			document.modifyProfileForm.elements[i].value=document.getElementById("theValueCompanion").value;
		}
		if(document.modifyProfileForm.elements[i].name!=""){
			url=url+"&"+document.modifyProfileForm.elements[i].name+"="+document.modifyProfileForm.elements[i].value;
			}
		}
		openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("companion"), url);
	}
	
	// It will create url for modification/Addition for attribute
	if(frm=="attribute"){
		url="modifyAttributeProfile.do?div=11";
		for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
			url=url+"&"+document.modifyProfileForm.elements[i].name+"="+document.modifyProfileForm.elements[i].value;
		}
		openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("editFightPOpen"), url);
	}
	
	// It will create url for modification/Addition for interest attribute
	if(frm=="interest"){
		url="modifyAttributeProfile.do?div=11&method=modifyInterest";
		var selectedString="";
		var chkcnt=0;
		for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
			if(document.modifyProfileForm.elements[i].name=="interestVal"){
			if(document.modifyProfileForm.elements[i].checked){
				if(chkcnt>0)
					selectedString=selectedString+",";
				selectedString=selectedString+document.modifyProfileForm.elements[i].value;
				chkcnt=chkcnt+1;
			}
		}}url=url+"&modifyProfileModel.interestVal="+selectedString;
		openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("editInterestOpen"), url);
	}
}	

function goToPrefrence(){
	showDivArea(document.getElementById('preferences'),'https://static.virginamerica.com/images/btn_preferences_sel.gif');
}

// For validation page
function divhideFunctionError(divID){
	var x=document.getElementById(divID);
	if(x.style.display == "block" || x.style.display == "inline"){
		x.style.display = "none"
		iswap=0;
	}else if(x.style.display == "none" || x.style.display == ""){	
		x.style.display = "inline"
	}
}

function setRadioVal(RdVal, editType, cntPos){

	var icnt=0;
	if(editType=="personalInfo"){
		for (i = 0; icnt < document.modifyProfileForm.elements.length; icnt++) {
			if(document.modifyProfileForm.elements[icnt].name=="modifyProfileModel.phonePrimary"){
				document.modifyProfileForm.elements[icnt].value=RdVal;}
		}
	}
	if(editType=="personalInfoEmail"){
	
		for (i = 0; icnt < document.modifyProfileForm.elements.length; icnt++) {
			if(document.modifyProfileForm.elements[icnt].name=="modifyProfileModel.emailtype"){
				document.modifyProfileForm.elements[icnt].value=RdVal;}
		}
	}
	if(editType=="addressInfo"){
		for (i = 0; icnt < document.modifyProfileForm.elements.length; icnt++) {
			if(document.modifyProfileForm.elements[icnt].name=="modifyProfileModel.addressPrimary["+cntPos+"]"){
				document.modifyProfileForm.elements[icnt].value=RdVal;}
		}
	}
	if(editType=="addressInfoPrimary"){
		for (i = 0; icnt < document.modifyProfileForm.elements.length; icnt++) {
			if(document.modifyProfileForm.elements[icnt].name=="modifyProfileModel.whichPrimary"){
				document.modifyProfileForm.elements[icnt].value=RdVal;}
		}
	}
	if(editType=="cardInfoPrimary"){
		for (i = 0; icnt < document.modifyProfileForm.elements.length; icnt++) {
			if(document.modifyProfileForm.elements[icnt].name=="modifyProfileModel.whichPrimaryCard"){
				document.modifyProfileForm.elements[icnt].value=RdVal;}
		}
	}
}

function deleteCreditCard(divId2Delete, blockNum){
	document.getElementById(divId2Delete).innerHTML='';
	resetElementNameCard(blockNum);
}

function deleteCreditCardSession(divId2Delete, blockNum){
var delct=0;
var i1=0;
	delct=parseInt(document.getElementById("sessionDelCard").value);
	
	for (i1 = 0; i1 < document.modifyProfileForm.elements.length; i1++) {
		if(document.modifyProfileForm.elements[i1].name=="modifyProfileModel.delCardArry"){
			if(document.modifyProfileForm.elements[i1].value==null || document.modifyProfileForm.elements[i1].value==""){
				document.modifyProfileForm.elements[i1].value=blockNum;
			}else{
				document.modifyProfileForm.elements[i1].value=document.modifyProfileForm.elements[i1].value+"|"+blockNum;
			}
		}
		if(document.modifyProfileForm.elements[i1].name=="modifyProfileModel.delCardcount"){
			document.modifyProfileForm.elements[i1].value=parseInt(document.modifyProfileForm.elements[i1].value)+1;
		}
	}
	resetElementNameCard(blockNum);
	document.getElementById("theValueCard").value=(parseInt(document.getElementById("theValueCard").value)-1);
	document.getElementById("sessionDelCard").value=delct+1;

}



function resetElementNameCard(div2Delete, numDiv){
var cnt=document.getElementById("theValueCard").value;
var obj=document.getElementById(div2Delete);
var	num=parseInt(numDiv);
obj.outerHTML="";
var i=0;
	for(i=num+1; i<=cnt; i++){
		document.getElementById("myDivCreditCard"+i).id="myDivCreditCard"+(i-1);
		document.getElementById("divRelVal"+i).id=(i-1);
		document.getElementById("divRelVal"+(i-1)).value="divRelVal"+(i-1);
		document.getElementById("myDivCreditCard"+(i-1)).id="myDivCreditCard"+(i-1);
	}
}

function deletePhoneSession(divId2Delete, blockNum){
var url="modifyProfile.do?method=deletePhoneInfo&delCardInfo="+blockNum;
	openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("testPosition"), url);
}

function deleteEmailSession(divId2Delete, blockNum){
var url="modifyCreditCardProfile.do?method=deleteEmailInfo&delCardInfo="+blockNum;
	openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("testPosition"), url);
}

function deleteAddressSession(divId2Delete, blockNum){
var url="modifyCreditCardProfile.do?method=deleteAddressInfo&delCardInfo="+blockNum;
	openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("testPosition"), url);
}

function deleteCreditCardSession(divId2Delete, blockNum){
var url="modifyCreditCardProfile.do?method=deleteCardInfo&delCardInfo="+blockNum;
	openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("testPosition"), url);
}

function deleteCompanionSession(divId2Delete, blockNum){
var url="modifyCreditCardProfile.do?method=deleteCompanionInfo&delCardInfo="+blockNum;
	openDivForEditUpdated(document.getElementById('editForm'), document.getElementById("companion"), url);
}

function divResetGeneralFunction(DivName, TotalTxt, parentDiv, FunctionIn ){
var cnt;
var nameDiv;
var tempDivName=DivName.split("myBtn");
	DivName="myDivCreditCard"+tempDivName[1];
	if(FunctionIn=="CCard"){
		nameDiv="myDivCreditCard";}
	
	cnt=parseInt(document.getElementById(TotalTxt).value);
	var obj=document.getElementById(DivName);
	num1=obj.id.split(nameDiv);
	num=parseInt(num1[1]);
	var a1=document.getElementById(parentDiv);
	a1.removeChild(obj);
	var i=0; 
	for(i=num+1; i<=cnt; i++){
		document.getElementById(nameDiv+i).id=nameDiv+(i-1);
		document.getElementById("myBtn"+i).id="myBtn"+(i-1);
		document.getElementById("divAddress"+i).id="divAddress"+(i-1);
		for (i1 = 0; i1 < document.modifyProfileForm.elements.length; i1++) {
			if(document.modifyProfileForm.elements[i1].name=="rdoCCType"+i){
				document.modifyProfileForm.elements[i1].name="rdoCCType"+(i-1);
			}
			if(document.modifyProfileForm.elements[i1].name=="radioAddress_"+i){
				document.modifyProfileForm.elements[i1].name="radioAddress_"+(i-1);
			}
			
		}
		
	}
	resetCreditCard(tempDivName[1]);
	cnt=cnt-1;
	document.getElementById(TotalTxt).value=cnt;
}

function divResetGeneralFunctionForCompanion(DivName, TotalTxt, parentDiv, FunctionIndx ){
var cnt;
var nameDiv;
	nameDiv="companionDiv";
	nameDivParent="nameDivParent";
	cnt=parseInt(document.getElementById(TotalTxt).value);
	var obj=document.getElementById(DivName);
	num1=FunctionIndx;
	num=parseInt(num1);
	var a1=obj.parentNode;
	a1.removeChild(obj);
	var i=0;
	for(i=num+1; i<=cnt; i++){
		document.getElementById(nameDiv+i).id=nameDiv+(i-1);
		document.getElementById(nameDivParent+i).id=nameDivParent+(i-1);
		document.getElementById(i).id=""+(i-1);
	}
	resetCompanion(num);
	cnt=cnt-1;
	document.getElementById(TotalTxt).value=cnt;
}

function divResetGeneralFunctionAddress(DivName, TotalTxt, parentDiv, FunctionIn ){
var cnt;
var nameDiv;
var tempDivName=DivName.split("myBtn");
	DivName="myDivAddress"+tempDivName[1];
	if(FunctionIn=="Address"){
		nameDiv="myDivAddress";
	}
	cnt=parseInt(document.getElementById(TotalTxt).value);
	var obj=document.getElementById(DivName);
	num1=obj.id.split(nameDiv);
	num=parseInt(num1[1]);
	var a1=document.getElementById(parentDiv);
	a1.removeChild(obj);
	var i=0; 
	for(i=num+1; i<=cnt; i++){
		document.getElementById(nameDiv+i).id=nameDiv+(i-1);
		document.getElementById("myBtn"+i).id="myBtn"+(i-1);
	}
	resetAddress(tempDivName[1]);
	cnt=cnt-1;
	document.getElementById(TotalTxt).value=cnt;
}


function resetCreditCard(num){
var i1=0;
var i=0;
var name="";
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		name=document.modifyProfileForm.elements[i].name;
		name=name.split("[");
		if(!(name[0]==null || name[0]=="")){
			if(name[0]!="modifyProfileModel.delCard"){
				if(!(name[1]==null || name[i]=="")){
					elPosition=name[1].split("]");
					if(!(elPosition[0]==null || elPosition[0]=="")){
						elIntPosition=parseInt(elPosition[0]);
						if(i>=num && elIntPosition>num){
							document.modifyProfileForm.elements[i].name=name[0]+"["+(elIntPosition-1)+"]";
						}
					}
				}
			}
		}
	}
}

function resetAddress(num){
var i1=0;
var i=0;
var name="";
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		name=document.modifyProfileForm.elements[i].name;
		name=name.split("[");
		if(!(name[0]==null || name[0]=="")){
			if(name[0]!="modifyProfileModel.delCard"){
				if(!(name[1]==null || name[i]=="")){
					elPosition=name[1].split("]");
					if(!(elPosition[0]==null || elPosition[0]=="")){
						elIntPosition=parseInt(elPosition[0]);
						if(i>=num && elIntPosition>num){
						document.modifyProfileForm.elements[i].name=name[0]+"["+(elIntPosition-1)+"]";
						}
					}
				}
			}
		}
	}
}

function resetCompanion(num){
var i1=0;
var i=0;
var name="";
	for (i = 0; i < document.modifyProfileForm.elements.length; i++) {
		name=document.modifyProfileForm.elements[i].name;
		name=name.split("[");
		if(!(name[0]==null || name[0]=="")){
			if(name[0]!="modifyProfileModel.companionTotal"){
				if(!(name[1]==null || name[i]=="")){
					elPosition=name[1].split("]");
					if(!(elPosition[0]==null || elPosition[0]=="")){
						elIntPosition=parseInt(elPosition[0]);
						if(i>=num && elIntPosition>num){
							document.modifyProfileForm.elements[i].name=name[0]+"["+(elIntPosition-1)+"]";
						}
					}
				}
			}
		}
	}
}


function showNormalPasswordGuest(thisobj){
	
	if(thisobj.value==""){
		var obj=document.getElementById("divpassnewGuest");
			thisobj.name="pass*"
			document.getElementById("passwordGuestDiv").style.display = "block";
			document.getElementById("divpassnewGuest").style.display = "none";
			for (i = 0; i < document.signInGuestForm.elements.length; i++) {
				if(document.signInGuestForm.elements[i].name=="password"){
					
					document.signInGuestForm.elements[i].value="Password"
					document.signInGuestForm.elements[i].focus();
					break;
				}
			}
	}
}


function showPasswordInNewPass(nameVal, hideDiv, showDiv){
var obj=document.getElementById(hideDiv);
	obj.innerHTML='';
	document.getElementById(hideDiv).style.display = "none";
	document.getElementById(showDiv).style.display = "block";
	for (i = 0; i < document.changePasswordForm.elements.length; i++) {
		if(document.changePasswordForm.elements[i].name==nameVal){
			document.changePasswordForm.elements[i].focus();
			break;
		}
	}
}


function showAddress(divName, rdoIndex, indx){
	var newYesOrNo="No";
	var txtVal="modifyProfileModel.useAddress["+indx+"]";
	if(rdoIndex == '0'){
		document.getElementById(divName).style.display= "none";
	}
	else{
		document.getElementById(divName).style.display= "inline";
		newYesOrNo="Yes";
	}
	for(i=0; i<document.modifyProfileForm.elements.length; i++){
		if(document.modifyProfileForm.elements[i].name==txtVal){
			document.modifyProfileForm.elements[i].value=newYesOrNo;
		}
	}
}

function managePnrOnFlightHistoryPage(pnrValue,isBooker,linkId){
	document.getElementById("pnrValue").value=pnrValue;
	document.getElementById("isbookre").value=isBooker;
	document.pnrDetailForm.submit();
	//showLoadingImageOpen(linkId);
	showWaitImage();
}

// this function is called from login window for next flight link
function managePnrOnLoginWindow(pnrValue,isBooker){
	document.getElementById("pnrValueLoginWindow").value=pnrValue;
	document.getElementById("isbookreLoginWindow").value=isBooker;
	document.managePnrOnLoginWindow.submit();
	//showLoadingImageOpen("managePnrOnLoginWindowId");
	showWaitImage();
}



function checkOptOptions(ajaxDiv){
	var optionString="";
	var chkBoxCnt=0;
	while(eval('document.getElementById'+'("'+'optcheck'+chkBoxCnt+'")')){
		var x=eval('document.getElementById'+'("'+'optcheck'+chkBoxCnt+'")');
		if(x.checked==true)
			optionString=optionString+x.value+"-true,";
		else
			optionString=optionString+x.value+"-false,";
		chkBoxCnt++;
	}
	disablePage();
	showWaitImage();
	setPosition(document.getElementById(ajaxDiv), document.getElementById("editForm"),-200, 30);
	
	var myUrl="updateOptIn.do?method=modifyOptInOptions&optInFlag="+optionString;
		$('#editForm').load(myUrl,'',done);				
	enablePage();
	function done(){
		closeWaitImage();
	}
}
function closeOpenAjax(divName){
	if(document.getElementById(divName)){
		if(document.getElementById(divName).style.display=='block'){
			document.getElementById(divName).style.display='none'
			
		}else{
			document.getElementById(divName).style.display='block'
		}
	}
}
//-------------------------End: For Showing Error-------------------------//

//-------------------------Start :close Div Window by Vinod 15/02/2007-------------------------//

function closeDivWindow(divName){
	if(document.getElementById(divName)){
			document.getElementById(divName).style.display='none';
	}
}


// this is method will be used on manage Addresss.
function openPreAndNextAddress(responseDiv, moveType){
var url="";
	url="nextAndPreviousAdressesInfo.do?method=nextAndPreviousAdressesInfo&moveType="+moveType;
	ajaxProfile(url, responseDiv);
}


/**
	 * This function will use for showManageAddresses  with Ajax
	 * Name showManageAddresses
	 * @param imageId
	 * @param OandDetailsNumber
	 *
	 * 
*/
	function showManageAddressesSubmit(ImageId , divName) {
	var positionObj=ImageId;
	myUrl="showManageAddressesAction.do?method=showManageAddresses";
	ajaxShow(myUrl, divName);
	//showLoadingImageOpen(ImageId);
	showWaitImage();
	setPosition(document.getElementById(positionObj), document.getElementById(divName), 100, -20);
	}
	
	/**
	 * This function will use for showManageAddresses  with Ajax
	 * Name showManageAddresses
	 * @param imageId
	 * @param OandDetailsNumber
	 *
	 * 
*/
	function addManageAddressesSubmit(ImageId , divName) {
	var positionObj=ImageId;
	myUrl="showManageAddressesAction.do?method=addManageAddresses";
	ajaxUpdate(myUrl, divName,'no');
	}
	
	
	/**
	 * This function will use for update the old addresses  with Ajax
	 * Name updateManageAddressesSubmit
	 * @param imageId
	 * @param OandDetailsNumber
	 *
	 * 
*/
	function deleteManageAddressesSubmit(divName,addressId) {
	myUrl="updateManageAddressesAction.do?method=deleteManageAddresses&addressId="+addressId;
		if(document.getElementById("viewPricingAllDiv")){
		holdInnerHtml=document.getElementById("viewPricingAllDiv").innerHTML;
		}

	ajaxUpdate(myUrl, divName,'no');
	}

	/**
	 * This function will use for update the old addresses  with Ajax
	 * Name updateManageAddressesSubmit
	 * @param imageId
	 * @param OandDetailsNumber
	 *
	 * 
*/
	function updateManageAddressesSubmit(ImageId , divName) {
	var updateAddressUrl=null;
	var positionObj=ImageId;
	updateAddressUrl="updateManageAddressesAction.do?method=modifyManageAddresses";
	for(i=0; i<document.modifyAddressForm.elements.length; i++)
	{
	updateAddressUrl=updateAddressUrl+"&"+document.modifyAddressForm.elements[i].name+"="+document.modifyAddressForm.elements[i].value
	}
	if(document.getElementById("viewPricingAllDiv")){
	holdInnerHtml=document.getElementById("viewPricingAllDiv").innerHTML;
	}
	ajaxUpdate(updateAddressUrl, divName,'no');
}
/**
	 * This function will use for update the main guest page with Ajax
	 * Name updateManageAddressesSubmit
	 * @param imageId
	 * @param OandDetailsNumber
	 *
	 * 
*/

	function updateGuestPage() {

	if(document.getElementById("viewPricingAllDiv")){
	document.getElementById("viewPricingAllDiv").innerHTML=holdInnerHtml;
	}
	if(document.getElementById('showManageAddressesDiv')){
		document.getElementById('showManageAddressesDiv').style.display="none";
	 }
	 if(document.getElementById('showEditContactInfoDiv')){
	 	document.getElementById('showEditContactInfoDiv').style.display='none';
	}
	}

/**
	 * This function will use for call the fare details in travel exp page with Ajax
	 * Name ajax 
	 * @param myurl
	 * @param Div
	 */
	function ajaxShow(myurl, div){
	document.getElementById(div).style.display="none";
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange =handleResponseShow;
	xmlhttp.send("");
	}

/**
	* This function will use for call the fare details in travel exp page with Ajax
	* Name handleResponse
	* 

*/

function handleResponseShow() {
     if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
     	    	if(ajaxDiv=='showManageAddressesDiv'){
     		document.getElementById(ajaxDiv).innerHTML='<div style="position: relative;">'+xmlhttp.responseText+'</div>';
  		}else{
  		document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
  		}
  		document.getElementById('loadingAnimationDiv').style.display="none";
		document.getElementById(ajaxDiv).style.display="block";
  	  	
  	  } 
	}



}

/**
 * This function will use for call the fare details in travel exp page with Ajax
 * Name ajax 
 * @param myurl
 * @param Div
 */
function ajaxUpdate(myurl, div,modeType){
	document.getElementById(div).style.display="none";
	/*setPosition(document.getElementById('manageAddressesId'),document.getElementById('loadingDiv'),-20,-20);
	document.getElementById('loadingDiv').style.display="block";*/
	showWaitImage();
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange =handleResponseUpdate;
	xmlhttp.send("");
}


/**
	* This function will use for call the fare details in travel exp page with Ajax
	* Name handleResponse
	* 

*/

function handleResponseUpdate() {
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
     	document.getElementById('loadingAnimationDiv').style.display="none";
		document.getElementById(ajaxDiv).style.display="block";
		var resTxt =xmlhttp.responseText;
		if(resTxt.indexOf("https://static.virginamerica.com/images/travel_text_bg.gif")!=-1){
		document.getElementById("viewPricingAllDiv").innerHTML=xmlhttp.responseText;
  		document.getElementById("showNewAddressWindow").style.display="none";
		document.getElementById('loadingAnimationDiv').style.display="none";
		document.getElementById("divAddress0").style.display ="block";
		}else if(resTxt.indexOf("https://static.virginamerica.com/images/VA_Purchase_BuyTicket_heade.gif")!=-1){
  			document.getElementById("sect").innerHTML=xmlhttp.responseText;
  		}else{
  		document.getElementById(ajaxDiv).innerHTML='<div style="position: relative;">'+xmlhttp.responseText+'</div>';
  		if(document.getElementById("showNewAddressWindow")){
  			document.getElementById("showNewAddressWindow").style.display="none";
  		}
		document.getElementById('loadingAnimationDiv').style.display="none";
		if(document.getElementById("divAddress0")){
			document.getElementById("divAddress0").style.display ="block";
		}
		}
  	
  	  } 
	}
}

function signInFromTravellerAndPurchaseSubmit(pageValue){
if(pageValue=='changeFlight'||pageValue=='cancelFlight'||pageValue=='CheckIn'||pageValue=='manageTravel'){
	document.signInForm.method.value="signInPnr";
	document.signInForm.action="signInPnr.do";
}else if(pageValue=='secureFlight'){
	document.signInForm.method.value="signInFromTravellerAndPurchase";	
	document.signInForm.action="signIn.do";
}else{
document.signInForm.method.value="signInFromTravellerAndPurchase";
document.signInForm.action="signInTravellerAndPurchase.do";
}
document.signInForm.fltMethod.value=pageValue;
document.signInForm.submit();
document.getElementById("submitID").innerHTML='<img src="https://static.virginamerica.com/images/btn_sign-in.gif" height="20" width="63" alt="Sign In" title="Sign In" border="0" />';
	//document.getElementById("SignIn").innerHTML="<img src='https://static.virginamerica.com/images/loading.gif'/>";
	showWaitImage();
}

function signInElevateHome(pageValue){

document.signInForm.method.value="signInFromHome";
document.signInForm.fltMethod.value=pageValue;
document.signInForm.action="signInTravellerAndPurchase.do";
document.signInForm.submit();
document.getElementById("submitID").innerHTML='<img src="https://static.virginamerica.com/images/btn_sign-in.gif" height="20" width="63" alt="Sign In" title="Sign In" border="0" />';
	//document.getElementById("SignIn").innerHTML="<img src='https://static.virginamerica.com/images/loading.gif'/>";
	showWaitImage();
}

//signInAndProfile.js end


//titlebarFunctions.js

function MakeCursor(abh)
{
	abh.style.cursor="pointer";
}
//titleBarFunctions.js end

//generalfunction.js start


function enterSignInlogin(thisobj)
{
var TestVar2 = thisobj.value;
TestVar2=TestVar2.replace(/^\s+/, '');
	if(TestVar2=="")
	{
		TestVar2="Email or Elevate#";
		thisobj.value=TestVar2
	}
}

function enterSignloginclk(thisobj)
{
TestVar2="Email or Elevate#";
	if(thisobj.value==TestVar2){
		thisobj.value=TestVar2;
		thisobj.focus(); 
		thisobj.select();
	}
}


function signInAnswerclk(thisobj)
{
	TestVar2="Answer";
	if(thisobj.value==TestVar2){
		thisobj.value=TestVar2;
		thisobj.focus(); 
		thisobj.select();
	}
}


function signInAnswer(thisobj){
	var TestVar2 = thisobj.value;
	TestVar2=TestVar2.replace(/^\s+/, '');
	if(TestVar2=="")
	{
		TestVar2="Answer";
		thisobj.value=TestVar2
	}
}

function enterEmailAddress(thisobj)
{
var TestVar4 = thisobj.value;
TestVar4=TestVar4.replace(/^\s+/, '');
	if(TestVar4=="")
	{
		TestVar4="Email Address";
		thisobj.value=TestVar4
	}
}

function enterEmailAddressclk(thisobj)
{
	TestVar4="Email Address";
	if(thisobj.value==TestVar4){
		thisobj.value=TestVar4;
		thisobj.focus(); 
		thisobj.select();
	}
}

function entername(thisobj)
{
var TestVar = thisobj.value;
TestVar=TestVar.replace(/^\s+/, '');
	if(TestVar=="")
	{
		TestVar="Last Name";
		thisobj.value=TestVar
	}
}

function enternameclk(thisobj)
{
	TestVar="Last Name";
	if(thisobj.value==TestVar){
		thisobj.value=TestVar;
		thisobj.focus(); 
		thisobj.select();
	}
}


function enterpnr(thisobj)
{
var TestVar1 = thisobj.value;
TestVar1=TestVar1.replace(/^\s+/, '');
	if(TestVar1=="")
	{
		TestVar1="Confirmation Code";
		thisobj.value=TestVar1
	}
}



function enterpnrclk(thisobj)
{
	TestVar1="Confirmation Code";
	if(thisobj.value==TestVar1){
		thisobj.value=TestVar1;
		thisobj.focus(); 
		thisobj.select();
	}
}


function enterticket(thisobj)
{
var TestVar5 = thisobj.value;
TestVar5=TestVar5.replace(/^\s+/, '');
	if(TestVar5=="")
	{
		TestVar5="Ticket Number";
		thisobj.value=TestVar5
	}
}


function enterticketclk(thisobj)
{
	TestVar5="Ticket Number";
	if(thisobj.value==TestVar5){
		thisobj.value=TestVar5;
		thisobj.focus(); 
		thisobj.select();
	}
}


function enterlogin(thisobj)
{
	var TestVar2 = thisobj.value;
	TestVar2=TestVar2.replace(/^\s+/, '');
	if(TestVar2=="")
	{
		TestVar2="Email or Elevate#";
		thisobj.value=TestVar2
	}
}


function enterloginclk(thisobj)
{
	
	TestVar2="Email or Elevate#";
	if(thisobj.value==TestVar2){
		thisobj.value=TestVar2;
		thisobj.focus(); 
		thisobj.select();
	}
}


function enterpassword(thisobj)
{
	var TestVar3 = thisobj.value;
	TestVar3=TestVar3.replace(/^\s+/, '');
		if(TestVar3=="")
		{
			TestVar3="Password";
			thisobj.value=TestVar3;
		}
}


function enterpasswordclk(thisobj)
{
	TestVar3="Password";
	thisobj.value=TestVar3;
	thisobj.focus(); 
	thisobj.select();




}

function enterpassclk(thisobj)
{
	TestVar3="Password";
	thisobj.value=TestVar3;
	thisobj.focus(); 
	thisobj.select();

}


function setCss(frm,id,cssName){$get_JsElement(frm,id).className=cssName}
function setCss(obj,cssName){obj.className=cssName}

function toggleFields(thisobj){

if(thisobj.parentNode.id=='nor_FieldDivId'){

	thisobj.parentNode.style.display='none';
	$get_JsElement('pass_FieldDivId').style.display='block';
	$get_JsElement('pass_FieldDivId').firstChild.value="";
	$get_JsElement('pass_FieldDivId').firstChild.focus();

}else if(thisobj.parentNode.id=='pass_FieldDivId' && thisobj.value==""){

	thisobj.parentNode.style.display='none';
	$get_JsElement('nor_FieldDivId').style.display='block';
	$get_JsElement('nor_FieldDivId').firstChild.value="Password";
	$get_JsElement('nor_FieldDivId').firstChild.focus();

}
}

function toggleFieldsDisplay(id1,id2){
$get_JsElement(id1).style.display='none';
if(id2=='corp1'){
	$get_JsElement('corp1').style.display='block';
	$get_JsElement('sustHrefId').className='selected';
	
	$get_JsElement('corp2').style.display='none';
	$get_JsElement('commHrefId').className='';
}


if(id2=='corp2'){
	$get_JsElement('corp2').style.display='block';
	$get_JsElement('commHrefId').className='selected';
	
	$get_JsElement('corp1').style.display='none';
	$get_JsElement('sustHrefId').className='';
}

		$get_JsElement('aboutusCorporate').href='aboutus.do?pageName=aboutusCorporate'
}

var character;
var browserAgent;
function returnChar(e){
var n=navigator;
browserAgent=n.userAgent

var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;

var char1 = String.fromCharCode(code);
character=char1;

}

function showPassword(thisobj,passwordFirstDiv,passwordSecondDiv,formName,eventProcedure){
returnChar(eventProcedure);
var obj=document.getElementById(passwordFirstDiv);

	thisobj.name="pass1"
	var documentForm=eval("document."+formName)
	
	document.getElementById(passwordFirstDiv).style.display = "none";
	document.getElementById(passwordSecondDiv).style.display = "block";
	for (i = 0; i < documentForm.elements.length; i++) {
		if(documentForm.elements[i].name=="password"){
			if(browserAgent.indexOf("MSIE")!=-1){
			documentForm.elements[i].value="";
			}else{
				documentForm.elements[i].value="";
			}
			documentForm.elements[i].focus();
			break;
		}
	}
}

function showPasswordOnRightClick(thisobj,passwordFirstDiv,passwordSecondDiv,formName,eventProcedure){

if(eventProcedure.button==2){
returnChar(eventProcedure);

var obj=document.getElementById(passwordFirstDiv);

	thisobj.name="pass1"
	var documentForm=eval("document."+formName)
	
	document.getElementById(passwordFirstDiv).style.display = "none";
	document.getElementById(passwordSecondDiv).style.display = "block";
	for (i = 0; i < documentForm.elements.length; i++) {
		if(documentForm.elements[i].name=="password"){
			if(browserAgent.indexOf("MSIE")!=-1){
			documentForm.elements[i].value="";
			}else{
				documentForm.elements[i].value="";
			}
			documentForm.elements[i].focus();
			break;
		}
	}
	}
}

function showMessageForUsers(linkId,popUpId)
{

setPosition(document.getElementById(linkId), document.getElementById(popUpId), 180, -45);
document.getElementById(popUpId).style.display="block";
}

function closeMsgWinForUsers(){
document.getElementById("MessageForUsers").style.display="none";

document.showNeedPointsForm.submit();

}


function showNormalPasswordGenView(thisobj){
	
	if(thisobj.value==""){
		var obj=document.getElementById("divpassnewGuest");
		
			thisobj.name="pass*"
			document.getElementById("passwordGuestDiv").style.display = "block";
			document.getElementById("divpassnewGuest").style.display = "none";
			for (i = 0; i < document.signInForm.elements.length; i++) {
				if(document.signInForm.elements[i].name=="password"){
					
					document.signInForm.elements[i].value="Password"
					document.signInForm.elements[i].focus();
					break;
				}
			}
	}
}

function showNormalPasswordGen(thisobj){
	
	if(thisobj.value==""){
		var obj=document.getElementById("divpassnewGuest");
			thisobj.name="pass*"
			document.getElementById("passwordGuestDiv").style.display = "block";
			document.getElementById("divpassnewGuest").style.display = "none";
			for (i = 0; i < document.signInPnrForm.elements.length; i++) {
				if(document.signInPnrForm.elements[i].name=="password"){
					
					document.signInPnrForm.elements[i].value="Password"
					document.signInPnrForm.elements[i].focus();
					break;
				}
			}
	}
}

function showNormalPassword(thisobj){


	if(thisobj.value==""){
	var obj=document.getElementById("divpassnew");
		thisobj.name="pass*"
		document.getElementById("passwordDiv").style.display = "block";
		document.getElementById("divpassnew").style.display = "none";
		for (i = 0; i < document.signInForm.elements.length; i++) {
			
			if(document.signInForm.elements[i].name=="password"){
				document.signInForm.elements[i].focus();
				break;
			}
		}
	}

}

function enterflight(thisobj)
{
var TestVar2 = thisobj.value;
	if(TestVar2=="")
	{
		TestVar2="Flight Number";
		thisobj.value=TestVar2
	}
}


function enterflightclk(thisobj)
{
	TestVar2="Flight Number";
	if(thisobj.value=="Flight Number"){
		thisobj.value=TestVar2;
		thisobj.focus(); 
		thisobj.select();
	}
}

//----------Functions for scrolling YTS------------//					
function setVariables(){
	if(document.getElementById("bottomMove")) {
		if (navigator.appName == "Netscape") {
			v = ".top=";
			h = ".left=";
			dS = "document.";
			sD = "";
			y = "window.pageYOffset";
			x = 0;
			iW = "window.innerWidth";
			iH = "window.innerHeight";
		}else {
			h = ".pixelLeft=";
			v = ".pixelTop=";
			dS = "";
			sD = ".style";
			y = "document.body.scrollTop";
			x = 0;
			iW = "document.body.clientWidth";
			iH = "document.body.clientHeight";
		}
		object = "scrollYTS";
		checkLocationA();
	}
}
function showHideNewAddressDiv(beanValue,loopId)
{
	if(beanValue=='newCard')
	{
		document.getElementById('newCardDivOnPopUp'+loopId).style.display='block';
		document.getElementById('div123'+loopId).style.overflow='auto';
		}
	if(beanValue=='savedCard')
	{
		document.getElementById('newCardDivOnPopUp'+loopId).style.display='none';
		document.getElementById('div123'+loopId).style.overflow='auto';
		}
}
function changeAddress(addressSize)
{
	
	
	for(i=0; i <addressSize; i++ )
	{
		if(document.getElementById("dynamicAddressDiv"+i))
		{
			document.getElementById("dynamicAddressDiv"+i).style.display = 'none';
		}
	}
	if(document.getElementsByName("viewPurchaseModel.savedAddressName"))
	{
		if(document.getElementsByName("viewPurchaseModel.savedAddressName")[0])
		{
			var addressIndex = document.getElementsByName("viewPurchaseModel.savedAddressName")[0].selectedIndex;
		}
	}
	var divName="dynamicAddressDiv"+addressIndex;
	if(document.getElementById(divName))
	{
		document.getElementById(divName).style.display = 'block';
	}
}

var divToOpenByAjax;
var refDiv;
var addNewAddress=new Array(2);
function openDivForManageCreditCard(divToOpen,posDiv)
{
	var ajaxUrl="";
	ajaxUrl="manageCreditCard.do?method=manageCreditCard"
	refDiv=posDiv;
	ajaxToOpenDiv(ajaxUrl,divToOpen)
	
}

function openCloseNewCardDiv(beanValue, isReset){
	if(beanValue=="savedCard" || beanValue=="VirginAmericaSignatureCard"){
		if(document.getElementById("newCardDiv")){
			document.getElementById("newCardDiv").style.display="none";
		}
	}
	if(beanValue=="newCard"){
		if(document.getElementById("newCardDiv")){
			if(document.getElementById("newCardDiv").style.display=="none"){
				var form;
				if(document.purchaseForm)
					form=document.purchaseForm;
				else if(document.checkInDetailForm)
					form=document.checkInDetailForm;
				else
					form=document.purchaseForm;
				if(isReset!='no'){
				form.elements['viewPurchaseModel.cardNo'].value='';
					if(form.elements['viewPurchaseModel.nameOnCard'])
				form.elements['viewPurchaseModel.nameOnCard'].value='';
					else if(form.elements['viewPurchaseModel.firstName'])
						form.elements['viewPurchaseModel.firstName'].value='';
				form.elements['viewPurchaseModel.cardType'].selectedIndex=0;
					form.elements['viewPurchaseModel.date'].value='00';
				form.elements['viewPurchaseModel.year'].value='1';
				if(form.elements['viewPurchaseModel.cardNickName'])
					form.elements['viewPurchaseModel.cardNickName'].value='';
					//document.getElementById("securityCodeTd").style.visibility='visible';
				}
	    		var els = document.getElementById('newCardDiv').getElementsByTagName("*");
	    		for(var i=0,j=els.length; i<j; i++){
	    			if(els[i].className=='style8_error')
	    				els[i].className='style8';
	    			else if(els[i].className=='Guest_input_TextType_error')
	    				els[i].className='Guest_input_TextType';
	    			else if(els[i].tagName=='IMG' && els[i].getAttribute('src').indexOf('Error_logo_horizontal.gif')!=-1)
	    				els[i].setAttribute("src", "https://static.virginamerica.com/images/spacer.gif")
	    		}
				
			}
			document.getElementById("newCardDiv").style.display="block";
		}
	}
}

function openCloseNewAddresssDiv(beanValue){
	if(beanValue=="savedAddress"){
		if(document.getElementById("newAddressDiv")){
			document.getElementById("newAddressDiv").style.display="none";
		}
	}
	if(beanValue=="newAddress"){
		if(document.getElementById("newAddressDiv")){
			document.getElementById("newAddressDiv").style.display="block";
		}
	
	}
}
// open and close Address window in traveler page
function openCloseNewAddressDiv(beanValue)
{
	
	if(beanValue=="useOldAddress")
	{
		if(document.getElementById("showNewAddressWindow"))
		{
			document.getElementById("showNewAddressWindow").style.display="none";
		}
	}
	if(beanValue=="useNewAddress")
	{
		if(document.getElementById("showNewAddressWindow"))
		{
			document.getElementById("showNewAddressWindow").style.display="block";
		}
	}
}
function updateCreditCardUrl()
{
	var updateCreditUrl=null;
	
	var loop=0;
	updateCreditUrl="editCreditCardPurchase.do?method=editCreditCardPurchase";
	for(i=0; i<document.modifyProfileForm.elements.length; i++)
	{
		if(document.modifyProfileForm.elements[i].type=="radio")
		{
				if(document.modifyProfileForm.elements[i].checked)
			{
				if(document.modifyProfileForm.elements[i].value=='new')
				{
					addNewAddress[loop]='new';
					loop++
				}
				if(document.modifyProfileForm.elements[i].value=='stored')
				{
					addNewAddress[loop]='stored';
					loop++
				}
				updateCreditUrl=updateCreditUrl+"&"+document.modifyProfileForm.elements[i].name+"="+document.modifyProfileForm.elements[i].value
			}
		}
		else
		{
			updateCreditUrl=updateCreditUrl+"&"+document.modifyProfileForm.elements[i].name+"="+document.modifyProfileForm.elements[i].value
		}
	}
	
	ajaxToOpenDiv(updateCreditUrl,'sect');
	
}
function addCreditCardPurchase()
{
	var addCardUrl=null;
	addCardUrl="addCreditCardPurchase.do?method=addCreditCard"
	ajaxToOpenDiv(addCardUrl,'manageCreditCardDiv');
}
function moveCreditCardPurchase(movetype)
{
	var addCardUrl=null;
	addCardUrl="moveCreditCardPurchase.do?method=moveCreditCard&moveType="+movetype
	ajaxToOpenDiv(addCardUrl,'manageCreditCardDiv');
}
function deleteCreditCardPurchase(cardId)
{
	var addCardUrl=null;
	addCardUrl="deleteCreditCardPurchase.do?method=deleteCreditCard&cardId="+cardId
	if(cardId==0)
	{
	ajaxToOpenDiv(addCardUrl,'manageCreditCardDiv');
}
	else
	{
		ajaxToOpenDiv(addCardUrl,'sect');
	}
}
function updatePurchasePage(eId)
{
	var updateUrl=null;
	updateUrl="updatePurchasePage.do?method=homeProfileWithPagination&entity="+eId
	
	ajaxToOpenDiv(updateUrl,'sect');
}
function ajaxToOpenDiv(myurl, div1){
	
	if(div1!='sect')
	{
		
		document.getElementById(div1).style.display="none";
		//document.getElementById('loadingDiv').style.display="block";
		//setPosition(document.getElementById(refDiv),document.getElementById('loadingDiv'),75,-20);
		showWaitImage();
		disableTotalpage();
	}
	else
	{
		document.getElementById('manageCreditCardDiv').style.display="none";
		if(document.getElementById('showManageAddressesDiv'))
		{
			document.getElementById('showManageAddressesDiv').style.display="none";
		}
				
		disableTotalpage();
		/*document.getElementById('loadingDiv').style.display="block";
		setPosition(document.getElementById(refDiv),document.getElementById('loadingDiv'),75,-20);*/
		showWaitImage();
	}
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	divToOpenByAjax = div1;
	
	xmlhttp.open("POST", myurl, true);
	chkURL=myurl;
	
	xmlhttp.onreadystatechange = handleResponseEditCreditCard;
	xmlhttp.send("");
}
function handleResponseEditCreditCard() {
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) {
      	if(xmlhttp.responseText.indexOf('https://static.virginamerica.com/images/manageCreditCard.gif')!=-1)
      	{
      		document.getElementById('manageCreditCardDiv').innerHTML='<div style="position: relative;">'+xmlhttp.responseText+'</div>';
      		divToOpenByAjax='manageCreditCardDiv';
      	}
      	else
      	{
      		document.getElementById(divToOpenByAjax).innerHTML=xmlhttp.responseText;
      	}
		
		document.getElementById('loadingAnimationDiv').style.display="none";
		document.getElementById(divToOpenByAjax).style.display="block";
		document.getElementById("disableTotalPage").style.display="none";
		if((document.getElementById('manageCreditCardDiv').innerHTML).indexOf('Your Information has not been successfully updated')!=-1)
		{
			document.getElementById('manageCreditCardDiv').style.display="block";
			setPosition(document.getElementById(refDiv),document.getElementById('manageCreditCardDiv'),215,-20);
		}
		
		if(divToOpenByAjax!='sect')
		{
			setPosition(document.getElementById(refDiv),document.getElementById(divToOpenByAjax),215,-20);
			for(k=0;k<addNewAddress.length;k++)
			{
				if(addNewAddress[k]=='new')
				{
					showHideNewAddressDiv('newCard',k)
					addNewAddress[k]='';
				}
			}
			
		}
		
		
		
	  }
	}
}
/* For position of travel exp added by tarun kathpal*/
function setPositionTravelExp(){
	
	var toplength="";
	
	toplength=document.getElementById("scrollYTS").style.top;
	if(toplength==''){document.getElementById("scrollYTS").style.top='0pt'}
	
	var length=document.getElementById("scrollYTS").style.top.split("p");
	var totalLength=eval(document.getElementById('bottomMove').offsetTop)+eval(length[0])+250;
	
	if(totalLength>getXandY(document.getElementById("ContainerFooter")).y) {
		var difference=totalLength-document.getElementById('bottomLimitForScroll').offsetTop-60;
		var YtsTop=eval(length[0]-difference);
		
		if(YtsTop<4){
			if(document.getElementById("upperLimitForScroll")) {
				document.getElementById("scrollYTS").style.top=document.getElementById("upperLimitForScroll").style.top;
			}
		}else{
			document.getElementById("scrollYTS").style.top=YtsTop;
		}
		if(document.getElementById("upperLimitForScroll")) {
			checkLocation();
		}
	}
}

function checkLocation() {
	
	if(document.getElementById("bottomMove")) {
		yy = eval(y);
		ydiff = ystart - yy;
		
		if(isScroll=="Yes") {
			if ((ydiff < (-1)) || (ydiff > (1))) {
				movey = Math.round(ydiff / 10), ystart -= movey;
			}
			varEndPoint=ystart;
			
			if(document.getElementById("bodyEnd").offsetTop<document.getElementById("bottomLimitForScroll").offsetTop){}
			if(document.getElementById('bottomLimitForScroll').offsetTop<varEndPoint+(document.getElementById('bottomMove').offsetTop-document.getElementById('topMove').offsetTop)+150) {} else {
				if(document.getElementById("upperLimitForScroll").offsetTop<0) {} else {
					document.getElementById("scrollYTS").style.top=ystart;
				}
			}
		}
		setTimeout("checkLocation()",1);
	}
}
						
function checkLocationA(){
	ystart = eval(y);
	xstart=eval(x);
}
						
function delayLogo() {
	eval(dS + object + sD + v + 0);
	eval(dS + object + sD + h + (-200));
	object = 'scrollYTS';
}

//----------End: Functions for scrolling YTS------------//	

function closeFareRulDiv(divName){
	document.getElementById(positionDivFare).style.display='none';
	document.getElementById("disableTotalPage").style.display="none";
	isScroll='Yes';
}



function showPromoCodeDiv(LinkId)
{
	document.getElementById('promoCodeErrTxt').innerHTML = 'If you happen to have a Virgin America promo code, enter it here and click the "Apply" button to cash in for a lower fare or special offer.';
	document.getElementById('searchWinFrm').style.height=118;
	// promo code window position is set
	setSafariXY(200,120,140,100);
	setPosition(LinkId, document.getElementById("searchPromoCode"),loadX,loadY);
	document.getElementById('searchPromoCode').style.display='block';
	document.getElementById('promoCodeText').value='';
	document.getElementById('promoCodeText').focus();
	checkSearchTypeLink=LinkId
}
function removePromoCode(pageName){
	if(document.getElementById('loadingAnimationDiv')){
		//showHomeLoader('BookFlightDiv');
		showWaitImage();
	}else{
		//showWaitImage(document.getElementById('promoCodeText'));
		showWaitImage();
	}
	var removePromoUrl='promoCodeRemove.do?method=removePromoCode&pageName='+pageName;
	promoCodeRemoveAjax(removePromoUrl);
	
}
var removePromoCodeXmlhttp = new XMLHttpRequest();
function promoCodeRemoveAjax(url){
	removePromoCodeXmlhttp.open("POST", url, true);
	removePromoCodeXmlhttp.onreadystatechange = handleResponseRemovePromoCode;
	removePromoCodeXmlhttp.send("");

}
function handleResponseRemovePromoCode()
{
	if (removePromoCodeXmlhttp.readyState == 4) 
	{ // Complete
      if (removePromoCodeXmlhttp.status == 200) 
      { // OK response
    	  var resTxt = removePromoCodeXmlhttp.responseText;
    	  ajax("updateTitleBar.do?method=updateTitleBar","titleBarDiv");
    	  document.getElementById('PromoCodeDetail').innerHTML=resTxt;
    	  enableDisablePointOption(false);
    	  if(document.getElementById('loadingAnimationDiv')){
    		  $get_JsElement('loadingAnimationDiv').style.display='none'
    	  }
	  }
	}
}
function ajax(myurl, div){
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	xmlhttp.open("POST", myurl, true);
	ajaxDiv=div;
	xmlhttp.onreadystatechange = handleResponseSelectUpdateTitleBar;
	xmlhttp.send("");
}
function handleResponseSelectUpdateTitleBar() {
    String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
   				if((xmlhttp.responseText).trim()=='AjaxSessionTimeOut'){
  			window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut"
  		}else if((xmlhttp.responseText).trim()=='AjaxError')
  		{
  			window.location="/home.do?method=virginAmerica&fromErrorPage=fromErrorPage"
  		}
  		else{  
  			
  			if(document.getElementById(ajaxDiv))
  				document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
			 showLoadingImageClose();
	  	}
	  
	  }
	}
}
function searchPromoCodeVal()
{
	
	var tripType="other";
	if(document.getElementById('divOW').style.display=='block')
		{
			tripType="OW";
		}
	if(document.getElementById('promoCodeText').value!=""){
			document.flightSearchOWForm.elements['flightSearch.searchPromoCode'].value=document.getElementById('promoCodeText').value
			document.flightSearchRTForm.elements['flightSearch.searchPromoCode'].value=document.getElementById('promoCodeText').value
			document.flightSearchMCForm.elements['flightSearch.searchPromoCode'].value=document.getElementById('promoCodeText').value
			document.getElementById('promoCodeText').focus();
		}else{
			document.flightSearchOWForm.elements['flightSearch.searchPromoCode'].value="";
			document.flightSearchRTForm.elements['flightSearch.searchPromoCode'].value="";
			document.flightSearchMCForm.elements['flightSearch.searchPromoCode'].value="";
		}
	var promoUrl='promoCodeApply.do?method=applyPromoCode&certCode='+document.getElementById('promoCodeText').value+'&tripType='+tripType;
	showWaitImage(checkSearchTypeLink);
	promoCodeAjax(promoUrl);
	
}
var promoCodeXmlhttp = new XMLHttpRequest();
function promoCodeAjax(url){
	promoCodeXmlhttp.open("POST", url, true);
	promoCodeXmlhttp.onreadystatechange = handleResponsePromoCode;
	promoCodeXmlhttp.send("");

}
function handleResponsePromoCode()
{
	if (promoCodeXmlhttp.readyState == 4) 
	{ // Complete
      if (promoCodeXmlhttp.status == 200) 
      { // OK response
	      var resTxt = promoCodeXmlhttp.responseText;
	    
	    	var errorElements=getElementsByClassName('errorLabel');
	    	if(errorElements){
		    	for(i=0;i<errorElements.length;i++){
		    		errorElements[i].className=errorElements[i].className.replace('errorLabel','');
		    	}
	    	}
	    	if(document.getElementById('BookFlightDiv')){
	    		var els = document.getElementById('BookFlightDiv').getElementsByTagName("*");
	    		for(var i=0,j=els.length; i<j; i++){
	    			if(els[i].className=='error')
	    				els[i].className='';
	    			else if(els[i].className!='ErrorMessage' && els[i].className.indexOf('Error')!=-1)
	    				els[i].className=els[i].className.substring(0,els[i].className.indexOf('Error'));
	    		}
	    	}
	      if(resTxt.indexOf('esc-sign')==-1 && resTxt.indexOf('escSignImg')==-1){
	    	document.getElementById('PromoCodeDetail').innerHTML=resTxt;
	    	//document.getElementById('promoCodeText').readOnly=true;
	    	$get_JsElement('ErrorMessage').style.display='none';
	      	enableDisablePointOption(true);
	      	ajax("updateTitleBar.do?method=updateTitleBar","titleBarDiv");
	      }else{
	    	$get_JsElement('ErrorMessage').style.display='block';
	    	$get_JsElement('promoCodeText').className='promocode_error';
	    	if(document.getElementById('homeErrorMessageDiv')){
	    		document.getElementById('homeErrorMessageDiv').style.display='block';
	    	}
	    	if(typeof(wichSelected)!='undefined' && typeof(currentTripType)!='undefined'){
	    		if(currentTripType=='ow')
	    			wichSelected='divOW';
	    		else if(currentTripType=='rt')
	    			wichSelected='divRT';
	    		else
	    			wichSelected='divMC';
        	}
	    	errorPresent=true;
	      	$get_JsElement('ErrorMessage').innerHTML=resTxt;
	      	increaseErrorCount('promoCode',document.estara_form);
	      	//$get_JsElement('promoLabel').className='errorLabel'+" "+$get_JsElement('promoLabel').className;
	      }
    	}
      // close the loading image after data come
      showLoadingImageClose();
      if(document.getElementById('loadingAnimationDiv')){
    	  prvTripType=currentTripType;
    	  $get_JsElement('loadingAnimationDiv').style.display='none'
      }
    }
}

// This function used for enabling/disabling of point option on search page
// In case of promocode it should be disabled - Abhay
function enableDisablePointOption(optionFlg){
	flg=false;
	for(frmCnt=0; frmCnt<document.forms.length; frmCnt++){
		for(eleCnt=0; eleCnt<document.forms[frmCnt].elements.length; eleCnt++){
	    	ele=document.forms[frmCnt].elements[eleCnt];
	      	if((ele.name=="fareFormatType" || ele.name=="flightSearch.fareFormatType") && ele.value=="Points"){
	      		if(optionFlg){
	      			ele.disabled="disabled";
	      			ele.checked=false;
	      		}else{
	      			ele.disabled=false;
				}
				flg=true;
				break;
	      	}
	    }
   		if(flg)
   			break;
   	}
}



function callWantPromoCode()
{	
	document.MeetVaForm.method.value="showWantMeetVa";
	document.MeetVaForm.action="wantPromoCode.do"
	document.MeetVaForm.submit();
}

function closeDiv(divID){
		document.getElementById(divID).style.display='none';
	}

/** This function is used for enable element**/
function chVarDisable()
{
disableIds=0

}

/** This function is used for changing cursor
    if element is disable then default cursor is used
    if element is enable then pointer cursor is used
**/
function SS_MakeCursor(arg,btnIds){


 if(disableIds==1){
        arg.style.cursor="default";
 }

 if(disableIds==0){
	    arg.style.cursor="pointer";
		if(btnIds=="continue"){
			MM_swapImage('continue','','https://static.virginamerica.com/images/btn_GoOn_roll.gif',1)
	 	}
	 	if(btnIds=="previous"){
			MM_swapImage('previous','','https://static.virginamerica.com/images/btn_GoBack_roll.gif',1)
	    }
	}

}


/** This function is used for getting X & Y co-ordinates of a element**/
function getAnchorXY(VF_id) {
	
	
	var c = getAnchorPosition(VF_id);
	
	X1=c.x;
	Y1=c.y;
}	



/** This function is used for setting a pointer cursor**/
function MakeCursor(arg){
	arg.style.cursor="pointer";
}





/** This function is used for Date validation

	Checks for the following valid date formats:
	MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
	Also separates date into month, day, and year variables

**/
function isValidDate(dateStr) {
	
	var bool = true;


if (dateStr != "" && dateStr != "----------------------------")
{
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

	// To require a 4 digit year entry, use this line instead:
	// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	
	var matchArray = dateStr.match(datePat); // is the format ok?

	if(dateStr == "mm/dd/yyyy" || dateStr=="")
	{
		dateStr="";
		return true;
		
	}
	
	if (matchArray != null) {
	
		month = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[4];
		if (month < 1 || month > 12) { // check month range
			document.getElementById("textMessage").innerHTML="Month must be between 1 and 12.";
			document.getElementById("formatMessage").style.display="block";
			bool = false;
		}
		if (day < 1 || day > 31) {
			document.getElementById("textMessage").innerHTML="Day must be between 1 and 31.";
			document.getElementById("formatMessage").style.display="block";
			bool = false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			document.getElementById("textMessage").innerHTML="Month "+month+" doesn't have 31 days!";
			document.getElementById("formatMessage").style.display="block";
			bool = false;
		}
		if (month == 2) { // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) {
				document.getElementById("textMessage").innerHTML="February " + year + " doesn't have " + day + " days!";
				document.getElementById("formatMessage").style.display="block";
				bool = false;
		   }
		}
		if(year.length != 4){
			document.getElementById("textMessage").innerHTML="Year format should be in 'yyyy'.";
			document.getElementById("formatMessage").style.display="block";
			bool = false;
			}
		   
		
		
	}else {
		document.getElementById("textMessage").innerHTML="Please provide proper date format (mm/dd/yyyy)";
		document.getElementById("formatMessage").style.display="block";
		bool = false;
	}
}
	
	return bool;  // date is valid
}//  End -->

/** This function is used for implementing the 'isValidDate()' function & setCookie() function**/
function checkDateAndSubmit(date1, date2, frm,buttonName,searchPage){
	if(document.getElementById('titleBarDiv'))
	updateTitileBar("updateTitleBar.do?method=updateTitleBar&atHome=atHome","titleBarDiv");
	if(searchPage){
		if(searchPage=='true'){
			if(document.getElementById('divRT').style.display=='block')
			{
				date1=document.flightSearchRTForm.elements['flightSearch.depDate.MMDDYYYY'].value;
				date2=document.flightSearchRTForm.elements['flightSearch.returnDate.MMDDYYYY'].value
				frm=document.flightSearchRTForm
			}else if(document.getElementById('divOW').style.display=='block'){
				date1=document.flightSearchOWForm.elements['flightSearch.depDateOW.MMDDYYYY'].value;
				date2='mm/dd/yyyy';
				frm=document.flightSearchOWForm;
			}else{
				date1=document.flightSearchMCForm.elements['flightSearch.depDateMC.MMDDYYYY'].value;
				date2=document.flightSearchMCForm.elements['flightSearch.returnDateMC.MMDDYYYY'].value;
				frm=document.flightSearchMCForm;
			}
		}
	}
	var dt=(new Date().getMonth()+1)+"/"+new Date().getDate()+"/"+(new Date().getYear()+1900);
	var dt1=(new Date().getMonth()+1)+"/"+new Date().getDate()+"/"+(new Date().getYear());
	var date11=new Date(date1);
	var date22=new Date(date2);
	
	//for cookie.
	var expiredays =30;
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	
	     

      if(frm.name=="flightSearchRTForm"){
            setCookie ("TT", "rt", exdate);
            
      }else if(frm.name=="flightSearchOWForm"){
            setCookie ("TT", "ow", exdate);
      }else {
            setCookie ("TT", "mc", exdate);
      }
      
	 if(frm.action.indexOf('ScheduleResult')!=-1){
		frm.elements['flightSearch.adults'].value="1"
		frm.elements['flightSearch.kids'].value="0"
	 }

	
	setCookies();//call function for setting cookies.
	
	if (isValidDate(date1) && isValidDate(date2)) {

		if((((date1+"")==(dt+"") && (date2+"")==(dt+"")) || ((date1+"")==(dt1+"") && (date2+"")==(dt1+"")))&& (date1+"")!="mm/dd/yyyy" && (date1+"")!=""){
			//This block will be changed by the popup window not message alert;
			FrmToSubmit=frm;
			buttonURL=buttonName;
			flgMsg=false;
			// for same Day flight message show
			if(arguments[5]!=null){
				sameDayFlightsMessageOpen('false',arguments[5]);
			}else{
				sameDayFlightsMessageOpen('false');
			}
			//decision("a",frm);
		}else if(((date1+"")==(date2+"")) && (date2+"")!=(dt+"") && (date1+"")!="mm/dd/yyyy" && (date1+"")!=""){
			//This block will be changed by the popup window not message alert;
			flgMsg=true;
			FrmToSubmit=frm;
			buttonURL=buttonName;
			// same Day flight message show
			if(arguments[5]!=null){
				sameDayFlightsMessageOpen('false',arguments[5]);
			}else{
				sameDayFlightsMessageOpen('false');
			}
			//decision("a",frm);
		}else if((((date1+"")==(dt+"") && (date2+"")!=(dt+"")) || ((date1+"")==(dt1+"") && (date2+"")!=(dt1+"")))&& (date1+"")!="mm/dd/yyyy" && (date1+"")!=""){
			//This block will be changed by the popup window not message alert;
			FrmToSubmit=frm;
			flgMsg=false;
			buttonURL=buttonName;
			if(arguments[5]!=null){
				setSafariXY(450,375,300,90);
			}else{
				setSafariXY(150,100,150,90);
			}
			setPosition(buttonURL, document.getElementById('message'),loadX,loadY);
			document.getElementById("message").style.left = '46%';
			document.getElementById("message").style.display="block";
			document.getElementById('timePopUp').focus();
		}else if((((date1+"")!=(dt+"") && (date2+"")==(dt+"")) || ((date1+"")!=(dt1+"") && (date2+"")==(dt1+"")))&& (date1+"")!="mm/dd/yyyy" && (date1+"")!=""){
			//This block will be changed by the popup window not message alert;
			FrmToSubmit=frm;
			flgMsg=false;
			buttonURL=buttonName;
			if(arguments[5]!=null){
				setSafariXY(450,375,300,90);
			}else{
				setSafariXY(450,100,150,90);
			}
			setPosition(buttonURL, document.getElementById('message'),loadX,loadY);
			document.getElementById("message").style.left = '46%';
			document.getElementById('message').style.display="block";
			document.getElementById('timePopUp').focus();
			
		}else{
			/*if(arguments[5]!=null){
				showWaitImage(buttonName,arguments[5]);
			}else{
				showWaitImage(buttonName);
			}*/
			showWaitImage();
		frm.submit();
	}
	}

	
	

}


/**
	 * This function will use for call the fare details in travel exp page with Ajax
	 * Name updateTitileBar 
	 * @param myurl
	 * @param Div
	 */
function updateTitileBar(myurl, div){
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange = handleResponseofTitleBar;
	xmlhttp.send("");
}

	/**
	 * This function will use for call the fare details in travel exp page with Ajax
	 * Name handleResponseSelect
	 * 
	 */

function handleResponseofTitleBar() {
    String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
   			if((xmlhttp.responseText).trim()=='AjaxSessionTimeOut'){
  			window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut"
  			}else{
   			document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
	  		}
	  	}
	  }
}



function changeFlightStatusDestinationFields(x,desValue, pageId){
	var temp1=document.flightStatusForm.elements["flightStatus.destination"];
	var selInd=0;
	
	if(x!=0)
	{
			for (m=temp1.options.length-1;m>0;m--)
			{
				temp1.options[m]=null;	
			}
	}	
		
	for (i=0;i<group[x].length;i++)
	{
		temp1.options[i]=new Option(group[x][i].text,group[x][i].value);
			if(group[x][i].value==desValue)
			{
				selInd=i;
			}

	}	
	if(desValue=='To'){
	temp1.options[0].selected=true;
	}else{
		
		temp1.options[selInd].selected=true;
	}
if(pageId){
	fltStsloadComboBox();
}
}

function fltStsloadComboBox(){
	$('#fltStsDesDiv a').remove();
	$('#fltStsDesDiv div').remove();
	$('#fltStsDesDiv select').selectbox({debug: false});
}


   //  check for valid numeric strings	
function IsNumeric(strString)
{
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;
   

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}



/** This function is used for getting X & Y co-ordinates of a element & its sub-elements**/
function getXandY( oElement ){
if(oElement){
if(oElement!=null){	
	var r=0;
	r = { x: oElement.offsetLeft, y: oElement.offsetTop};
	while( oElement != null ) {
		r.x += oElement.offsetLeft;
		r.y += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return r;
}
}
}

/** This function is used for getting X & Y co-ordinates of a element 
 *	and set it to given element. lftDis, topDis will decide if you want some margin **/
function setObjOffset(oElement, divObj, lftDis, topDis){
	if(oElement){
		var offsetParent = oElement.offsetParent; 
	    var parent       = oElement.parentNode;
	    var r = { x: oElement.offsetLeft, y: oElement.offsetTop};
	    while(offsetParent) {
	    	r.x += offsetParent.offsetLeft;
	        r.y += offsetParent.offsetTop;
	        offsetParent = offsetParent.offsetParent;
	    }
	    divObj.style.left=(r.x + lftDis) +'px';
	    divObj.style.top=(r.y + topDis) +'px';
	}
}


function showLoading(oElement){
	
	var loadingObj = document.getElementById("loadingAnimationDiv");
	if(oElement){
		var offsetParent = oElement.offsetParent; 
	    var parent       = oElement.parentNode;
	    var r = { x: oElement.offsetLeft, y: oElement.offsetTop};
	    while(offsetParent) {
	    	r.x += offsetParent.offsetLeft;
	        r.y += offsetParent.offsetTop;
	        offsetParent = offsetParent.offsetParent;
	    }
	    loadingObj.style.left=(r.x - 10) +'px';
	    loadingObj.style.top=(r.y - 50) +'px';
	}
	loadingObj.style.display = "block";
}

/** This function sets the left & top position of a element **/
function setPosition(oElement, divObj, lftDis, topDis){
  if(oElement){
	divObj.style.left=(getXandY( oElement ).x-lftDis)+'px';
	divObj.style.top=(getXandY( oElement ).y-topDis)+'px';
  }
}


/** This function implements the 'setCookie()' function & creates the cookies **/
function setCookies(){
	
	var i=0;
	var expiredays =30;
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	var mcDepDate2="";
	     

     
		for (j = 0; j < document.flightSearchRTForm.elements.length; j++)
		{
			var obj = document.flightSearchRTForm.elements[j];
			if (obj.name == "flightSearch.origin" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.destination" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.depDate.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.returnDate.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.adults" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.kids" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.infants" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}
		}

		for (j = 0; j < document.flightSearchOWForm.elements.length; j++){
			var obj = document.flightSearchOWForm.elements[j];
			if (obj.name == "flightSearch.origin" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.destination" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.depDateOW.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.adults" ){
				setCookie (obj.name, escape(obj.value), exdate);	
			}else if(obj.name == "flightSearch.kids" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.infants" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}
		}	
		for (j = 0; j < document.flightSearchMCForm.elements.length; j++){
			var obj = document.flightSearchMCForm.elements[j];
			if (obj.name == "flightSearch.origin" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.destination" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.depDateMC.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if (obj.name == "flightSearch.originMC" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.destinationMC" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.returnDateMC.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.adults" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.kids" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.infants" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}
		}	
}

function setFlightStatusCookies(){
	
	var i=0;
	var expiredays =30;
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	var mcDepDate2="";
	
	for (j = 0; j < document.flightStatusForm.elements.length; j++)
	{
		var obj = document.flightStatusForm.elements[j];
		if (obj.name == "flightStatus.flightDate" )
		{
			setCookie (obj.name, escape(obj.selectedIndex), exdate);
		}
		else if(obj.name == "flightStatus.flightNumber" ){			
			setCookie (obj.name, obj.value, exdate);
		}
		else if(obj.name == "flightStatus.origin" ){
			setCookie (obj.name, escape(obj.value), exdate);
		}
		else if(obj.name == "flightStatus.destination" ){
			setCookie (obj.name, escape(obj.value), exdate);
		}						
	}	     
}

/** This function creates a array of all cookies**/
function setCookieArray(name){
		this.length = setCookieArray.arguments.length - 1;
        for (var i = 0; i < this.length; i++) {
        	this[i + 1] = setCookieArray.arguments[i + 1]
        	setCookie (name + i, this[i + 1], expdate);
        }        
}

/** This function creates the cookies with name-pair value**/
function setCookie (name, value, expires) {
        if (!expires) expires = new Date();
document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() +  "; path=/";
}



/** This function show the confirmation box**/
function decision(message, submitFrm){
	FrmToSubmit = submitFrm;
	decisionYes();
	
}

/** This function is used to show a 'div' element which has the id 'message' 
	as well as it is used to hide a 'div' element which has the id 'messageShortjourney'**/
function decisionYes(){
	
	document.getElementById('messageShortjourney').style.display="none";
	if(flgMsg){
		FrmToSubmit.submit();
		showWaitImage(buttonURL);
	}else{
		
		setPosition(buttonURL, document.getElementById('message'), 150,100);
		document.getElementById('message').style.display="block";
	}
}

/**This is used to hide a 'div' element**/
function decisionNo(divIDForHide){
	document.getElementById(divIDForHide).style.display="none";
}

/**This is used to submit a form & hide a 'div' element**/
function shrtFrmSubmit(divIDForHide){
	FrmToSubmit.submit();
	/*if(arguments[1]!=null){
		if(document.flightSearchForm && document.getElementById('btnModifySearch')){
			$('#loadingDiv').css({top:($('#btnModifySearch').offset().top-30)+'px',left:(($('#btnModifySearch').offset().left+10))+'px'});
			document.getElementById("loadingDiv").style.display="block";
			showWaitImage();
		}else{
			showWaitImage();
		}
	}else{
		showWaitImage();
	}*/
	showWaitImage();
	document.getElementById('message').style.display="none";

}

// created By Vinod :: this function will call for same day flights 
function sameDayFlightsMessageOpen(checkFlag){
	if(checkFlag=='false'){
		if(arguments[1]!=null){
			setSafariXY(435,375,300,90);
		}else{
			setSafariXY(150,100,150,90);
		}
		setPosition(buttonURL, document.getElementById('SameDayFlightsMessageId'),loadX,loadY);
		document.getElementById('SameDayFlightsMessageId').style.left = '45%';
		document.getElementById('SameDayFlightsMessageId').style.display="block";
	}
}


function sameDayFlightsMessageClose(closeType){
	if(closeType=='true'){
		if(flgMsg){
			FrmToSubmit.submit();
			if(arguments[1]!=null){
				showWaitImage(buttonURL,arguments[1]);
			}else{
				showWaitImage(buttonURL);
			}
		} else {
			document.getElementById('SameDayFlightsMessageId').style.display="none";
			if(arguments[1]!=null){
				setSafariXY(435,375,300,90);
			}else{
				setSafariXY(150,100,150,90);
			}
			if(document.flightSearchForm && document.getElementById('btnModifySearch')){
				$('#message').css({top:($('#btnModifySearch').offset().top)+'px',left:($('#btnModifySearch').offset().left-60)+'px'});
			}else{
				setPosition(buttonURL, document.getElementById('message'), loadX,loadY);
				document.getElementById('message').style.left = '45%';
			}
			
			document.getElementById('message').style.display="block";
		}
		document.getElementById('SameDayFlightsMessageId').style.display="none";
	} else {
		document.getElementById('message').style.display="none";
		document.getElementById('SameDayFlightsMessageId').style.display="none";
	}
	
}




/**This function validates a Fax Number**/
function  checkFax(faxType,event)
{
		
		var faxNo = "";
		 var key="";
		 var type=false;
		
	type = CheckNumeric(event);
	if(type)
	{
	for (j = 0; j < document.purchaseForm.elements.length; j++)
		{   
			if (document.purchaseForm.elements[j].name == faxType)
			{   
				faxNo = document.purchaseForm.elements[j].value;
				
				break;
			}
		}
		var index = j; 
		
		if((faxNo.length == 3) || (faxNo.length == 7) )
		{
			var separator = "-";
			faxNo = faxNo.concat(separator); 
			document.purchaseForm.elements[index].value = faxNo;
			
		}
		if((faxNo.length == 13) && (faxNo.search(/-/) >= 0 ))
		{
			var str1 = faxNo.slice(0,3);
			var str2 = faxNo.slice(4,7);
			var str3 = faxNo.slice(8);
			faxNo = str1 + str2 + str3;
			document.purchaseForm.elements[index].value = faxNo;
			
		}// otherwise, discard character
	}
		
}

/**This function checks a keyID **/
function CheckNumeric(e)
{
   var KeyID = (window.event) ? event.keyCode : e.keyCode;
   if ( KeyID == 8 )
	 {
	    return false; // if so, do nothing
	 }
	 else 
	 {
	 	return true;
	 	
	 }
}


/**This function changes a image & cursor on a img element **/

/* change Satus
* 20/07/2006
* Amit/Roop
*/
function changeImageOnMouseOverOrOut(obj, IMG){
	obj.src=IMG;
	obj.style.cursor="pointer";
	
}
/* change Satus
* 20/07/2006
* Amit/Roop
*/
/**This function changes a image & cursor on a img element **/
function divhideFunctionTravel2(divID, clickedObject, toChangeIMG, toChangeIMGCol)
	{  
		var x=document.getElementById(divID);

		if(x.style.display == "block")
			{
				x.style.display = "none"
				clickedObject.src=toChangeIMGCol;
				
			}else if(x.style.display == "none" || x.style.display == ""){	
				x.style.display = "block"
				clickedObject.src=toChangeIMG;
				
			}
}

/** This function is used for sets the left & top of a 'div' element 
	& display that div **/
function viewFare(viewFare_id)
{
	var x="";
	getAnchorXY(viewFare_id)
	document.getElementById('viewFare').style.left=X1-412
	document.getElementById('viewFare').style.top=Y1+15
	document.getElementById('viewFare').style.position="absolute"
	document.getElementById('viewFare').style.display="block";

}




/* this function is used for the profile page*/
function CreateProfileForm()
{
	document.createProfileForm.method.value="createProfile";
	document.createProfileForm.submit();
}
//this is method is use for FareRule Description 

/* this function is used to show fare rules pop up */
function fareRulesDescriptionPopUp(fareBaseCode,fareBaseCodeS,route,routeS,clickObjId,pnrNumber){
	showWaitImage();
	var thisXoffset = 0;
	var thisYoffset = 0;
	var URL='fareRuleDescription.do?method=fareRuleDescription&fareBaseCode='+fareBaseCode+'&fareBaseCodeS='+fareBaseCodeS+'&route='+route+'&routeS='+routeS;
	if(pnrNumber)
		URL=URL+'&pnrNumber='+pnrNumber;
	var xmlHttp= $.ajax({
			 	   type: "GET",
			 	   url: URL,
			 	   dataType:"html",
			 	   success: function(html){
						$(xmlHttp.responseText).find('#fareRulesText').html()
						$('#popupMsgArea').html($(xmlHttp.responseText).find('#fareRulesText').html());
						$('#popupMsgArea').find('table').width(525)
						$('#AcceptId').show();
						$('#popupTitle').html('Fare Rules');
						$('#popupTitle').html('Fare Rules');
						$('#popupTable').width(525);
						$('#popupFrame').width(525);
						$('#popupFrame').height($('#popupId').height());
						// start addition for fare rules display on manage travel / future flights page
						if(clickObjId.indexOf('ffReviewFareRules') != -1) {
							thisXoffset = -350;
							thisYoffset = -200;
							document.getElementById('fareRulesBodyTable').style.width = '450';
							document.getElementById('fareRulesBodyTable').style.marginLeft = '0px';
						}
						// end addition for fare rules display on manage travel / future flights page
						$('#popupId').css({top:($('#'+clickObjId).offset().top-($('#popupId').height())-thisYoffset)+'px',left:($('#'+clickObjId).offset().left-($('#popupId').width()/2)-thisXoffset)+'px'});
						$('#popupId').show();
						closeWaitImage();
					}
				});
}

function callFareRulesDescription(fareBaseCode,fareBaseCodeS,route,routeS,psDiv,actDiv)
{
	/*document.getElementById("disableTotalPage").style.top=0;
	document.getElementById("disableTotalPage").style.left=0;
	document.getElementById("disableTotalPage").style.height=getXandY(document.getElementById("ContainerFooter")).y;
	document.getElementById("disableTotalPage").style.width=950;
	document.getElementById("disableTotalPage").style.display="block";*/
	positionDivFare=psDiv;
	actualDiv=actDiv;
	NewMyUrl='fareRuleDescription.do?method=fareRuleDescription&fareBaseCode='+fareBaseCode+'&fareBaseCodeS='+fareBaseCodeS+'&route='+route+'&routeS='+routeS;
	FareRulesAjax(NewMyUrl, "viewFareRuleDes");
}
function disableTotalpage()
{

	document.getElementById("disableTotalPage").style.top=0;
	document.getElementById("disableTotalPage").style.left=0;
	document.getElementById("disableTotalPage").style.height=getXandY(document.getElementById("ContainerFooter")).y;
	document.getElementById("disableTotalPage").style.width=950;
	document.getElementById("disableTotalPage").style.display="block";
	
}
function enableTotalPage()
{

	document.getElementById("disableTotalPage").style.display="none";
}
var FareRulesXmlhttp = new XMLHttpRequest();
var FareRulesAjaxDiv = null;

function FareRulesAjax(myurl2, div){

	var thetime1=new Date(); 
	var dummy=""+thetime1.getHours()+thetime1.getMinutes()+thetime1.getSeconds();
	myurl2=myurl2+"&dummy="+dummy;
	FareRulesAjaxDiv = div;
	FareRulesXmlhttp.open("GET", myurl2, true);
	FareRulesXmlhttp.onreadystatechange = handleResponseFareRules;
	FareRulesXmlhttp.send(null);
}

function handleResponseFareRules() {
    if (FareRulesXmlhttp.readyState == 4) { // Complete
      if (FareRulesXmlhttp.status == 200) { // OK response
    	document.getElementById(positionDivFare).style.display="block";
		if(positionDivFare == 'viewFareRuleDiv') {
			document.getElementById("viewFareRuleInnerDiv").innerHTML=FareRulesXmlhttp.responseText;
		}
		if(positionDivFare=='viewFareRuleDesT')
		{
			document.getElementById("viewFareRuleDesInnerT").innerHTML=FareRulesXmlhttp.responseText;
		}
		if(positionDivFare=='viewFareRuleDesR')
		{
			document.getElementById("viewFareRuleDesInnerR").innerHTML=FareRulesXmlhttp.responseText;
		}
		if(positionDivFare=='viewFareRuleDesB')
		{
			document.getElementById("viewFareRuleDesInnerB").innerHTML=FareRulesXmlhttp.responseText;
		}
		if(positionDivFare=='viewFareRuleDesTB')
		{
			document.getElementById("viewFareRuleDesInnerTB").innerHTML=FareRulesXmlhttp.responseText;
		}
		if(positionDivFare=='viewFareRuleDesTBS')
		{
			document.getElementById("viewFareRuleDesInnerTBS").innerHTML=FareRulesXmlhttp.responseText;
		}
			if (document.all) {
			
			if(actualDiv!='fareRuleDescription_cancel' && actualDiv!='fareRuleDescription_R'){
			document.getElementById(positionDivFare).style.left=document.getElementById(actualDiv).offsetLeft-300;
			}
		}
		//Code Added By Vishal Mahajan For Debugging on MAC
		if(navigator.userAgent.indexOf("Safari")!=-1)
		{
			if(actualDiv!='fareRuleDescription_cancel')
			document.getElementById(positionDivFare).style.left=document.getElementById(actualDiv).offsetLeft-300;
		}
		
		var posx = 0;
		var posy = 0;
		var xOffset = 0;
		var yOffset = 0;
		var obj = document.getElementById(actualDiv);

		// get mouse coordinates relative to icon image
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				posx += obj.offsetLeft;
				posy += obj.offsetTop;
				obj = obj.offsetParent;
			}
		} else if (obj.x) {
			posx += obj.x;
			posy += obj.y;
		}
		
		// set div offsets
		xOffset = -300;
		yOffset = 0;
		
		if(actualDiv.indexOf('two')!= -1 || actualDiv.indexOf('mid')!= -1) {
			yOffset = -200;
		}
		
		if(actualDiv.indexOf('two')!= -1 && isPCIE6 == 1) {
			yOffset = -200;
		}
		
		if(actualDiv.indexOf('two')!= -1 && isFF == 1) {
			yOffset = -250;
		}
		
		document.getElementById(positionDivFare).style.left = (posx+xOffset) ;
		document.getElementById(positionDivFare).style.top = (posy+yOffset) ;
	
		isScroll="No";

		}
	}
}


	
// Functions for va team page

var vision="";
var people="";
var press="";
var navthisid="";
function changeNavTitleBarImage()
{
document.getElementById('Vision').src='https://static.virginamerica.com/images/btn_what_we_about_off.gif';
document.getElementById('People').src='https://static.virginamerica.com/images/btn_people_off.gif';
document.getElementById('Press').src='https://static.virginamerica.com/images/btn_press_off.gif'
}

function navmouseover(imgCurrObj,thisid)
{
	   if(thisid=="Vision"){ 
		    if(vision==""){
	 			MakeCursor(imgCurrObj);
	 			MM_swapImage('Vision','','https://static.virginamerica.com/images/btn_what_we_about_on.gif',1)
			}
		}
		
		if(thisid=="People"){
			if(people==""){
				MakeCursor(imgCurrObj);
				MM_swapImage('People','','https://static.virginamerica.com/images/btn_people_on.gif',1)
			}
		}
		
		if(thisid=="Press"){
			if(press==""){
				MakeCursor(imgCurrObj);
				MM_swapImage('Press','','https://static.virginamerica.com/images/btn_press_on.gif',1)
			}
		}

}



/*Changed By mohit 
* for Static content
* Start
*/
function callMeetVaPages(thisid)
{	
	navthisid=thisid;
	document.MeetVaForm.method.value="showMeetVa";
	if(thisid=="Vision"){
		if(vision==""){
	
			document.MeetVaForm.NavChImage.value="Vision";
			document.MeetVaForm.action="meetVa.do"
		}
	}
	
	if(thisid=="People"){
		if(people==""){
		
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam.do"
		}
	}
	
	if(thisid=="People1"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam1.do"
		}
	}
	
	if(thisid=="People2"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam2.do"
		}
	}
	
	if(thisid=="People3"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam3.do"
		}
	}
	
	if(thisid=="People4"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam4.do"
		}
	}
	
	if(thisid=="People5"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam5.do"
		}
	}
	
	if(thisid=="People6"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam6.do"
		}
	}
	
	if(thisid=="People7"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam7.do"
		}
	}
	
	if(thisid=="People8"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam8.do"
		}
	}
	
	if(thisid=="People9"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam9.do"
		}
	}
	
	if(thisid=="People10"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam10.do"
		}
	}
	
	if(thisid=="People11"){
		if(people==""){
			document.MeetVaForm.NavChImage.value="People";
			document.MeetVaForm.action="meetVaTeam11.do"
		}
	}
	
	if(thisid=="Press"){
		if(press==""){
		
			document.MeetVaForm.NavChImage.value="Press";
			document.MeetVaForm.action="meetVaPress.do"
		}
	}
	
	document.MeetVaForm.submit();
}
/*Changed By mohit 
* for Static content
* End
*/
//End of Functions for va team page



function openWinPrintItinerary(actionUrl){
	var disp_setting="toolbar=no,location=no,directories=no,menubar=yes,"; 
	    disp_setting+="scrollbars=yes,width=762, height=670, left=0, top=0";
	var urls=actionUrl
	window.open(urls,"",disp_setting)
}


function openChangeSeatPrintItinerary(actionUrl){
var disp_setting="toolbar=no,location=no,directories=no,menubar=yes,"; 
    disp_setting+="scrollbars=yes,width=650, height=670, left=0, top=0";

var urls=actionUrl

window.open(urls,"",disp_setting)

}


function closeWindow(){

self.close();
}
function CallElevate(){

location.href='whatIseleVAte.do?method=showwhatIseleVAte';

}

function hidePopUp(){
document.getElementById('Hrefmessage').style.display='none'
}


//********purpose enter the form with enter key
	function sumitSearchWithEnterKey(enterId,evt) {
	if (window.event){ 
	Key = window.event.keyCode;
	}else if(evt){ 
	Key = evt.which;
	}
	if(Key == 13){

	document.getElementById(enterId).onclick();
	return false;
	}else{

	 return true;
	}

}

/* This is generic function for displaying popup message. 
 * Parameters->
 * 	pageName:	Name of HTML/JSP
 *  title:		Title need to display on popup
 *  popupWidth:	Width of popup
 *  clkObj:		Clicked element object 
 *  showBtn:	Need to show OK button or not (options true/false)
 *  lftMrg:		Left margin
 *  rgtMrg:		Right margin
 *  decision:	show as decision box (true/false) - OPTIONAL
 *  openParameter: send through any type of parameter desired in this open field.
 *  functionCalled: If decision selected as true pass function here with parameters
 */
 
var clearPopupInterval;
var counter = 20;

function updatePopup(pageName, title, popupWidth, clkObj, showBtn, lftMrg, rgtMrg, decision,openParameter,functionCalled){
			
	if(clearPopupInterval) {
		clearInterval(clearPopupInterval);
		counter = 20;
	}
	
	$('#popupMsgArea').load(pageName,'cache:false',done);
	function done(){
		
		document.getElementById("AcceptId").style.display = 'none';	
			
		document.getElementById("popupTitle").innerHTML = title;
		var popupElement = document.getElementById("popupTable");
		popupElement.style.width = eval(popupWidth);
		
		var popupFrame = document.getElementById("popupFrame");
		setObjOffset(clkObj, document.getElementById("popupId"), lftMrg, rgtMrg)

		if(eval(showBtn))
			document.getElementById("AcceptId").style.display = 'block';
		
		if(eval(decision)){
            var el = document.getElementById('AcceptId');
            document.getElementById('declinedId').style.display='block';
            el.setAttribute("onclick",functionCalled+";closePopup('popupId');");
        }
		var popupDiv = document.getElementById("popupId");
		document.getElementById("popupId").style.display='block';
		popupFrame.style.width=eval(popupWidth)-20;
		//popupFrame.style.height=popupDiv.offsetHeight-20;
		
		if(openParameter) {
			document.getElementById("popUpOpenParameter").innerHTML = openParameter;
		}
		
		if(document.getElementById("loadingAnimationDiv"))
			closeWaitImage();
    }
    
    /*if(pageName != 'html/popup-travelInsuranceInfo.html') {
        clearPopupInterval = window.setInterval('checkPopupInterval()',1000);
    }

    if(pageName == 'popup-fareselect-seatview.jsp') {
    	document.getElementById("popupCloseBtn").style.display = 'block';
    } else {
    	if(document.getElementById("popupCloseBtn"))
    		document.getElementById("popupCloseBtn").style.display = 'none';
    }*/
    	
}

function closePopup(divId){

if(clearPopupInterval) {
		clearInterval(clearPopupInterval);
		counter = 20;
	}

document.getElementById(divId).style.display='none';
}

// This function will be used to submit given form
function goBackToTravelManager(formName){
	frmObj = eval("document."+formName);
	frmObj.submit();
}

/*Changed By mohit 
* for Static content
* Start
*/
function callJobsPages(thisid)
{
	if(thisid=="jobsWhyVA"){	
		   document.privacyPolicy.method.value="showjobs";
		   document.privacyPolicy.action="jobsWhyVA.do"
		   document.privacyPolicy.submit();
	}
	if(thisid=="jobsAlex"){	
		   document.privacyPolicy.method.value="showjobs";
		   document.privacyPolicy.action="jobsAlex.do"
		   document.privacyPolicy.submit();
	}
	if(thisid=="jobsDiversity"){	
		   document.privacyPolicy.method.value="showjobs";
		   document.privacyPolicy.action="jobsDiversity.do"
		   document.privacyPolicy.submit();
	}
	if(thisid=="jobsGetToKnowUs"){	
		   document.privacyPolicy.method.value="showjobs";
		   document.privacyPolicy.action="jobsGetToKnowUs.do"
		   document.privacyPolicy.submit();
	}
	if(thisid=="jobsGetToKnowUsJessica"){	
		   document.privacyPolicy.method.value="showjobs";
		   document.privacyPolicy.action="jobsGetToKnowUsJessica.do"
		   document.privacyPolicy.submit();
	}
	if(thisid=="jobsJoinTheTeam"){	
		   document.privacyPolicy.method.value="showjobs";
		   document.privacyPolicy.action="jobsJoinTheTeam.do"
		   document.privacyPolicy.submit();
	}
	if(thisid=="jobsBenefits"){	
		   document.privacyPolicy.method.value="showjobs";
		   document.privacyPolicy.action="jobsBenefits.do"
		   document.privacyPolicy.submit();
	}
}
/*Changed By mohit 
* for Static content
* end
*/


/*
* for open and close show wiat image Div
* start
*/

function showLoadingImageonPopUp(buttonName) {
	var cPopup=getAnchorPosition(buttonName);
	var xp=cPopup.x
	var yp=cPopup.y-10
	if (document.getElementById("loadingAnimationDiv")){
		/*document.getElementById("loadingAnimationDiv").style.left=xp+'px';
		document.getElementById("loadingAnimationDiv").style.top=yp+'px';
		document.getElementById("loadingAnimationDiv").style.display="block";*/
showWaitImage();
	}

}


// This function will work for show loading image with all parameters.
function showLoadingImageOpenWithAllValues(buttonName,first,second) {
	//setPosition(buttonName, document.getElementById("loadingAnimationDiv"), first, second);
	//document.getElementById("loadingAnimationDiv").style.display="block";
	showWaitImage();
}

// This function will work for show loading imageon search page.
function showLoadingImageOpen(buttonName) {
	//setPosition(document.getElementById(buttonName), document.getElementById("loadingAnimationDiv"), 50, 50);
	//document.getElementById("loadingAnimationDiv").style.display="block";
	showWaitImage();

}

function showLoadingImageClose(){
if(document.getElementById("loadingAnimationDiv")){
	document.getElementById("loadingAnimationDiv").style.display="none";
}
}


function _showLoadingImageOpen(buttonName) {

	//setPosition(document.getElementById(buttonName), document.getElementById("loadingAnimationDiv"), 450, 50);
	//document.getElementById("loadingAnimationDiv").style.display="block";
	showWaitImage();

}


function showPopUp(positionId,tarGetId,setX,setY){
setPosition($get_JsElement(positionId), $get_JsElement(tarGetId), setX, setY);
$get_JsElement(tarGetId).style.display="block";
}
 
function _showLoadingImageClose(){
if(document.getElementById("loadingAnimationDiv")){
	document.getElementById("loadingAnimationDiv").style.display="none";
}
}
/*
* for open and close show wiat image Div
* End
*/

/*
* for set the date in wanna book flight from flight schedule result page.
* start
*/

function setDateInWannaBookFlightWindow(tripType,currentDate,segmentNumber)
{
if(tripType=='rt'){
	if(segmentNumber==0){
	document.flightSearchRTForm.elements['flightSearch.depDate.MMDDYYYY'].value=currentDate;
	}else{
	document.flightSearchRTForm.elements['flightSearch.returnDate.MMDDYYYY'].value=currentDate;
	}
}else if(tripType=='mc'){
	if(segmentNumber==0){
	document.flightSearchMCForm.elements['flightSearch.depDateMC.MMDDYYYY'].value=currentDate;
	}else{
	document.flightSearchMCForm.elements['flightSearch.returnDateMC.MMDDYYYY'].value=currentDate;
	}
}else if(tripType=='ow'){
	if(segmentNumber==0){
	document.flightSearchOWForm.elements['flightSearch.depDateOW.MMDDYYYY'].value=currentDate;
	}
}

}

// This funtion will open the flightSchedule information div.
function showScheduleDetials(obj,flightNumber,aircarftType,airPort,journeyTime)
{
document.getElementById("flightNumberSpanId").innerHTML=flightNumber;
document.getElementById("aircarftSpanId").innerHTML=aircarftType;
document.getElementById("airPortSpanId").innerHTML=airPort;
document.getElementById("journeTimeSpanId").innerHTML=journeyTime;
document.getElementById("totalJourneTimeSpanId").innerHTML=journeyTime;

var positionObj="loadImgCenter1";
setPosition(obj, document.getElementById("flightScheduleDetialsDiv"), 50, 30);
document.getElementById("flightScheduleDetialsDiv").style.display="block";
}


/*
* for set the date in wanna book flight from flight schedule result page.
* end
*/

//This function will change the Guest Type combo box value in purchase page based on the salutation
function ChangeGuestType(optval, obj)
{
	var option = obj.options;

	if(optval=='Mr')
		option.selectedIndex = 0;
	if(optval=='Mrs')
		option.selectedIndex = 0;
	if(optval=='Miss (Adult)')
		option.selectedIndex = 0;
	if(optval=='Miss (Child)')
		option.selectedIndex = 2;
	if(optval=='Ms')
		option.selectedIndex = 0;
	if(optval=='Mstr (Child)')
		option.selectedIndex = 2;
}
//generalFunction.js end



function fltErrorMessages(error1,error2,error3,error4,error5,error6,error7,error8){

fltStatusErrorsRequired=error1
fltStatusErrorsUnknown=error2
fltStatusErrorsServiceRequired=error3
fltStatusErrorsInValidFltNo=error4
fltStatusErrorsInValidFltNoNotNum=error5
fltStatusErrorsInValidCityPair=error6
fltStatusErrorsNoFltGivenDate=error7
fltStatuserrorsnoData=error8
}



// function for show div on exit seat by roop starts//
var img_ID="";
var idArray=new Array("1A","2A","1C","2C","1D","2D","1F","2F","1B","2B");
var firstClass="false";
function ShowExitRowDiv(img_id){
		img_ID=img_id;
		for(var i=0;i<idArray.length;i++){
			if(idArray[i]==img_ID){
				img_ID="firstClass";
			}
		}
		if((!isMCS) || (img_ID=="firstClass")){
			if(img_ID=="firstClass"){
		 		x=document.getElementById('FirstClassInformation');
		 	}else{
					x=document.getElementById('PremiumSeatInformation');
			}
			getAnchorXY(img_id)
			x.style.left=X1+14;
			x.style.top=Y1+14;
			x.style.position="absolute";
			x.style.display="block";
		}
}

var checkX=0;
var checkY=0;

function ShowExitRowDivOnSelect(img_id){
img_ID=img_id;
for(var i=0;i<idArray.length;i++){
      if(idArray[i]==img_ID){
            img_ID="firstClass";
      }
}
if(img_ID=="firstClass"){
 x=document.getElementById('FirstClassInformation');}
else
x=document.getElementById('PremiumSeatInformation');

getAnchorXY(img_id)
            x.style.left=X1-checkX+8;
            x.style.top=Y1-checkY+8;
            x.style.position="absolute";
            x.style.display="block";
}



function HideExitRowDiv(){
	if(img_ID!=""){  
		if(img_ID=="firstClass"){
			 document.getElementById('FirstClassInformation').style.display='none';}
		else
			document.getElementById('ExitSeatInformation').style.display='none';
	  		document.getElementById('PremiumSeatInformation').style.display='none';
		img_ID="";	
	}
}

/////////////////////////////////////////////////

//new function for phase 1
var elevateIdValidated="";
var elevateLabelId="";
function showTestField(elevateDivId,addDivId){
document.getElementById(addDivId).style.display='none';
document.getElementById(elevateDivId).style.display='block';
}

var guestFFProg;
var elevateIdValidated;
var guestIndex;
var ffprogramlist;
var selectedFFPProgram;
function addElevateIdAction(guestFirstName,guestLastName,guestInd,pnrNo,guestID){
	guestIndex=	guestInd;
	var guestFirstLastName=guestFirstName+"_"+guestLastName;
	ffprogramlist=document.getElementById("ffProgram"+guestInd);
	guestFFProg = ffprogramlist.options[ffprogramlist.selectedIndex].value;
	selectedFFPProgram=ffprogramlist.options[ffprogramlist.selectedIndex].text;
	elevateIdValidated=document.getElementById("ffpNumber"+guestInd).value
	if(elevateIdValidated=='Add #'){elevateIdValidated="";}
	var urls="addElevateId.do?method=addelevateId&elevateIdParam="+elevateIdValidated+"&guestFirstLastName="+guestFirstLastName+"&guestInd="+guestInd+"&guestFFProg="+guestFFProg+"&pnrNo="+pnrNo+"&guestID="+guestID;
	ajaxToaddElevateId(urls);
	showWaitImage();
	
}

function ajaxToaddElevateId(myurl){
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange = handleResponseForAddElevateId;
	xmlhttp.send("");

}

function handleResponseForAddElevateId() {
    if (xmlhttp.readyState == 4) { 
      if (xmlhttp.status == 200) {
        if(xmlhttp.responseText.trim()=='AjaxSessionTimeOut'){
	  		window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut";
  		}else if(xmlhttp.responseText.trim()=='success'){
	  		if(guestIndex.length==2){	  			
	  			guestIndex='0'+guestIndex.substring(1,2);
	  			while(document.getElementById('ajaxRefreshDiv1'+guestIndex)){
	  				document.getElementById('ffProgram1'+guestIndex).value = guestFFProg;
	  				document.getElementById('ajaxRefreshDiv1'+guestIndex).innerHTML = selectedFFPProgram;
	  		  	  	document.getElementById('ffpNumber1'+guestIndex).value = elevateIdValidated;
	  				document.getElementById('ajaxRefreshDiv2'+guestIndex).innerHTML = elevateIdValidated;
		  		  		if(document.getElementById('points'+guestIndex))
	  		  			document.getElementById('points'+guestIndex).style.display="block";
	  		  		if(document.getElementById('addBtn'+guestIndex))
	  		  			document.getElementById('addBtn'+guestIndex).innerHTML="";
		  		  	if(document.getElementById('ajaxRefreshDiv1'+guestIndex).innerHTML){
				  		if(document.getElementById('ajaxRefreshDiv1'+guestIndex).innerHTML.indexOf('America')<0){
				  			if(document.getElementById('points'+guestIndex)){
				  				document.getElementById('points'+guestIndex).style.display='none';
				  				document.getElementById('points'+guestIndex).innerHTML='';
				  			}
				  		}
			  		}
	  		  	  	guestIndex=eval(eval(guestIndex)+10);
	  			}
	  		}else{
	  			document.getElementById('ffProgram1'+guestIndex).value = guestFFProg;
  				document.getElementById('ajaxRefreshDiv1'+guestIndex).innerHTML = selectedFFPProgram;
  		  	  	document.getElementById('ffpNumber1'+guestIndex).value = elevateIdValidated;
  				document.getElementById('ajaxRefreshDiv2'+guestIndex).innerHTML = elevateIdValidated;
		  		if(document.getElementById('points'+guestIndex))
		  			document.getElementById('points'+guestIndex).style.display="block";
		  		if(document.getElementById('addBtn'+guestIndex))
		  			document.getElementById('addBtn'+guestIndex).innerHTML="";
		  		if(document.getElementById('ajaxRefreshDiv1'+guestIndex).innerHTML){
			  		if(document.getElementById('ajaxRefreshDiv1'+guestIndex).innerHTML.indexOf('America')<0){
			  			if(document.getElementById('points'+guestIndex)){
			  				document.getElementById('points'+guestIndex).style.display='none';
			  				document.getElementById('points'+guestIndex).innerHTML='';
			  			}
			  		}
		  		}
	  		}
	  		if(document.getElementById('btnJoinElevate'+guestIndex)){
	  		document.getElementById('btnJoinElevate'+guestIndex).innerHTML='';
	  		document.getElementById('btnJoinElevate'+guestIndex).className='';
	  		}
	  		if(document.getElementById('validationMessageDiv')){
	  			document.getElementById('validationMessageDiv').innerHTML="";
	  		}
  		}else{  
  			document.getElementById('validationMessageDiv').innerHTML=xmlhttp.responseText;
		}
  		showLoadingImageClose();
	   }
	}
}

function showPopupWithGrayBG(ancorObj){
stopIt='false';
var x=document.getElementById('PopoupOnGrayDiv')

var c1=getAnchorPosition('HowItWorks');

x.style.left=c1.x;
x.style.top=c1.y;
x.style.display="block";
if(document.getElementById('prem_hint')){
document.getElementById('prem_hint').style.background="#FFB2B5"
}
}

function popUpHowWorks(divId){

var x=document.getElementById('PopoupOnGrayDiv')

var c1=getAnchorPosition(divId);

x.style.left=c1.x;
x.style.top=c1.y;
x.style.display="block";
stopIt='true';
}

function showTermsCondition(divId){

var x=document.getElementById('tirmsDiv')

var c1=getAnchorPosition(divId);

x.style.left=c1.x;
x.style.top=c1.y-50;
x.style.display="block";

}

function closeDivs(){

if(document.getElementById('PopoupPointBetaAlert')!=null){
document.getElementById('PopoupPointBetaAlert').style.display="none";
}


if(document.getElementById('PopoupOnGrayDiv')!=null){
document.getElementById('PopoupOnGrayDiv').style.display="none"

}


if(document.getElementById('prem_hint')!=null){
document.getElementById('prem_hint').style.background="#ffffff"

}
}

function showPrintableView(firstname,lastname,elevateNo){
	var disp_setting="toolbar=no,location=no,directories=no,menubar=no,status=no,"; 
     disp_setting+="scrollbars=yes,width=650, height=670, left=0, top=0"; 
	var url="html/elevate_card_print.html?&fn="+firstname+"&ln="+lastname+"&eN="+elevateNo
	window.open(url,"",disp_setting);
}

function passwordStrength(password)
{
	var desc = new Array();
	desc[0] = "Very Weak";
	desc[1] = "Weak";
	desc[2] = "Better";
	desc[3] = "Medium";
	desc[4] = "Strong";
	desc[5] = "Strongest";

	var score   = 0;
	//if password bigger than 6 give 1 point
	if (password.length > 6) score++;
	//if password has both lower and uppercase characters give 1 point	
	if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
	//if password has at least one number give 1 point
	if (password.match(/\d+/)) score++;
	//if password has at least one special caracther give 1 point
	if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) )	score++;
	//if password bigger than 12 give another 1 point
	if (password.length > 12) score++;
 	document.getElementById("passwordDescription").innerHTML = desc[score];
	document.getElementById("passwordStrength").className = "strength" + score;
}

function logIntoTB() {
	
	$( "#travelBankLogin" ).toggleClass("hidden",false);
	$( "#travelBankBalance" ).toggleClass("hidden",false);
	return false;

}


// For Credit File Redemption //

function applyCreditFile(id,div)
{
	/*setPosition(document.getElementById(id), document.getElementById("loadingDiv"),475,50);
	document.getElementById("loadingDiv").style.display="block";*/
	saveTravelInsurance();
	showWaitImage();
	var travelInsuranceFlagRetain=travelInsuranceFlag;
	var size=document.getElementsByName('checkBoxCreditFile').length;
	
	var creditFile="";
	
	for(creditLoop=0;creditLoop<size;creditLoop++)
	{
		if(document.getElementsByName('checkBoxCreditFile')[creditLoop].checked)
		{
			creditFile=creditFile+document.getElementsByName('checkBoxCreditFile')[creditLoop].id+"-";
		}
		
	}
	
	var URL="applyCreditFile.do?method=apply&creditFiles="+creditFile;
	$.ajax({
	 	   type: "POST",
	 	   url: URL,
	 	   cache: false,
	 	   dataType:"html",
	 	   success: function(html){
				$("#"+div).html(html.trim());
				travelInsuranceFlag=travelInsuranceFlagRetain;
			    showLoadingImageClose();
			    if(html.trim().indexOf('errormessage_hold')!=-1){
			    	window.scrollTo(0,0);
			    }
			    retainTravelInsurance();
			}
	 });
}

function removeCreditFile(creditFile,id,div)
{
	
	/*setPosition(document.getElementById(id), document.getElementById("loadingDiv"),50,50);
	document.getElementById("loadingDiv").style.display="block";*/
	showWaitImage();
	saveTravelInsurance();
	var travelInsuranceFlagRetain=travelInsuranceFlag;
	var URL="removeCreditFile.do?method=remove&creditFiles="+creditFile;
	$.ajax({
	 	   type: "POST",
	 	   url: URL,
	 	   cache: false,
	 	   dataType:"html",
	 	   success: function(html){
				travelInsuranceFlag=travelInsuranceFlagRetain;
				$("#"+div).html(html.trim());
			    showLoadingImageClose();
			    retainTravelInsurance();
			}
	 });
}
function showHideAddCreditFile()
{
	
	if(document.getElementsByName('checkBoxAddCreditFile')[0].checked)
	{
		document.getElementById('addCreditFileDiv').style.display="block";
	}
	else
	{
		document.getElementById('addCreditFileDiv').style.display="none";
	}
	
}
function addCreditFile(id,div)
{
	/*setPosition(document.getElementById(id), document.getElementById("loadingDiv"),0,50);
	document.getElementById("loadingDiv").style.display="block";*/
	showWaitImage();
	var fileNumber=document.getElementById("creditFileNumber").value;
	var firstName=document.getElementById("firstName").value;
	var lastName=document.getElementById("lastName").value;
	saveTravelInsurance();
	var travelInsuranceFlagRetain=travelInsuranceFlag;
	var URL="addCreditFile.do?method=add&creditFileNumber="+fileNumber+"&firstName="+firstName+"&lastName="+lastName;
	$.ajax({
	 	   type: "POST",
	 	   url: URL,
	 	   cache: false,
	 	   dataType:"html",
	 	   success: function(html){
				travelInsuranceFlag=travelInsuranceFlagRetain;
				$("#"+div).html(html.trim());
			    showLoadingImageClose();
			    if(html.indexOf('errormessage_hold')!=-1){
			    	window.scrollTo(0,0);
			    }
			     retainTravelInsurance();
			}
	 });
}
function addCreditFilePostBooking(id,div,module)
{
	/*setPosition(document.getElementById(id), document.getElementById("loadingDiv"),0,50);
	document.getElementById("loadingDiv").style.display="block";*/
	showWaitImage();
	var fileNumber=document.getElementById("creditFileNumber").value;
	var firstName=document.getElementById("firstName").value;
	var lastName=document.getElementById("lastName").value;
	if(module=='changeSeat')
	{
		
		var URL="addCreditFileChangeSeat.do?method=add&creditFileNumber="+fileNumber+"&firstName="+firstName+"&lastName="+lastName;
	}
	
	else if(module=='changeFlight')
	{
		var URL="addCreditFileChangeFlight.do?method=add&creditFileNumber="+fileNumber+"&firstName="+firstName+"&lastName="+lastName;
	}

	$('#'+div).load(URL,'',showLoadingImageClose);
}


function setFareFarmatType(fareFormatValue,windowPositionId)
{
if(fareFormatValue=="Points"){

//setPosition(document.getElementById(windowPositionId), document.getElementById("PopoupPointBetaAlert"),50,-20);
//document.getElementById("PopoupPointBetaAlert").style.display="block";
	if(document.getElementById('promoDetailRT')){
document.getElementById('promoDetailRT').style.display="none";
document.getElementById('promoDetailOW').style.display="none";
document.getElementById('promoDetailMC').style.display="none";
	}
	if(document.getElementById('promoDetails')){
		document.getElementById('promoDetails').style.display="none";
		if(document.getElementById('promoDetailDivider'))
		document.getElementById('promoDetailDivider').style.display="none";
	}if(document.getElementById('PromoCodeDiv')){
		document.getElementById('PromoCodeDiv').style.display="none";
		if(document.getElementById('promoDetailDivider'))
		document.getElementById('promoDetailDivider').style.display="none";
	}
}else{
	if(document.getElementById('promoDetailRT')){
document.getElementById('promoDetailRT').style.display="block";
document.getElementById('promoDetailOW').style.display="block";
document.getElementById('promoDetailMC').style.display="block";
	}
	if(document.getElementById('promoDetails')){
		document.getElementById('promoDetails').style.display="block";
		if(document.getElementById('promoDetailDivider'))
		document.getElementById('promoDetailDivider').style.display="";
		
	}if(document.getElementById('PromoCodeDiv')){
		document.getElementById('PromoCodeDiv').style.display="block";
		if(document.getElementById('promoDetailDivider'))
		document.getElementById('promoDetailDivider').style.display="";
		
	}
document.getElementById("PopoupPointBetaAlert").style.display="none";

}

if(document.flightSearchRTForm){
	document.flightSearchRTForm.elements['flightSearch.fareFormatType'].value=fareFormatValue;
}if(document.flightSearchMCForm){
	document.flightSearchMCForm.elements['flightSearch.fareFormatType'].value=fareFormatValue;
}if(document.flightSearchOWForm){
	document.flightSearchOWForm.elements['flightSearch.fareFormatType'].value=fareFormatValue;
}

}


// travel Insurance//
function addTravelInsurance(checkbox, pageName){
	if(document.getElementById("totalTop")){
		var divObjs=document.getElementById("totalTop").getElementsByTagName("div");
		for(i=0;i<divObjs.length;i++){
			if(divObjs[i].getAttribute('id') && divObjs[i].style.display!='none'){				
				if(divObjs[i].getAttribute('id').indexOf('travelExpWithTotal')>=0 && checkbox.value=='on'){
					//return;
				}else if(checkbox.value=='off'){
					//return;
				}
			}
		}
	}
	var addressCheckBoxStat='false';
	if(document.purchaseForm.elements['viewPurchaseModel.info']){
		addressCheckBoxStat=document.purchaseForm.elements['viewPurchaseModel.info'].checked;
	}
	
	var addNewAddressStatus=false;
	if(document.getElementById('newAddressDiv') && document.getElementById('newAddressDiv').style.display!='none'){
		addNewAddressStatus=true;
	}
	var addNewCardStatus=false;
	var cardHolderNameBeforeAjax;
	var cardTypeBeforeAjax;
	var cardNoBeforeAjax;
	var cardExpMonthBeforeAjax;
	var cardExpYearBeforeAjax;
	var cardSecurityCodeBeforeAjax;
	if(document.getElementById('newCardDiv') && document.getElementById('newCardDiv').style.display!='none'){
		addNewCardStatus=true;
		cardHolderNameBeforeAjax=document.getElementById("id_cardHolderName").value;
		cardTypeBeforeAjax=document.getElementById("id_cardType").value;
		cardNoBeforeAjax=document.getElementById("id_cardNumber").value;
		cardExpMonthBeforeAjax=document.getElementById("id_cardExpMonth").value;
		cardExpYearBeforeAjax=document.getElementById("id_cardExpYear").value;
		cardSecurityCodeBeforeAjax=document.getElementById("id_cardSecurityCode").value;
	}
                var URL = "";
                if(pageName == 'payment')
                                URL="addRemoveTravelInsurance.do?method=travelInsurance&checked="+checkbox.value+"&addressCheckBox="+addressCheckBoxStat;
             
                if(pageName == 'review')
                                URL="addRemoveTravelInsuranceReview.do?method=travelInsurance&checked="+checkbox.value;
                var parms='';
                if(document.purchaseForm){
	                for (var i=0; i < document.purchaseForm.elements.length; i++) {
                	   var element = document.purchaseForm.elements[i];
                	   if(i==0){
                		   parms=parms+element.name+'='+element.value;
                	   }else{
                		   if(element.name=='viewPurchaseModel.wanaSaveCard' && element.checked!=true){
                			   continue;
                		   }
                		   parms=parms+'&'+element.name+'='+element.value;
                	   }
	                }
                }
        		$.ajax({
        	    	   type: "POST",
        	    	   url: URL,
		   data: parms,
        	    	   dataType:"html",
		   cache: false,
        	    	   complete: function(){
			    	   	document.getElementById("loadingAnimationDiv").style.display="none";
		                    if(checkbox.value=='on'){
		                    	if(document.getElementById("travelExpWithInsurance"))
		                            document.getElementById("travelExpWithInsurance").style.display="block";
		                    	if(document.getElementById("travelExpWithInsurance1"))
		                    		document.getElementById("travelExpWithInsurance1").style.display="block";
		                    	if(document.getElementById("travelExpWithTotal"))
		                    		document.getElementById("travelExpWithTotal").style.display="block";
		                    	if(document.getElementById("travelExpWithoutTotal"))
		                    		document.getElementById("travelExpWithoutTotal").style.display="none";
		                    	if(document.getElementById("totalBottom"))
		                    		document.getElementById("totalBottom").innerHTML=document.getElementById("totalTop").innerHTML;
		                    }else{
		                    	if(document.getElementById("travelExpWithInsurance"))
			                		   document.getElementById("travelExpWithInsurance").style.display="none";
			                	   if(document.getElementById("travelExpWithInsurance1"))
			                		   document.getElementById("travelExpWithInsurance1").style.display="none";
			                	   if(document.getElementById("travelExpWithoutTotal"))
			                		   document.getElementById("travelExpWithoutTotal").style.display="block";
			                	   if(document.getElementById("travelExpWithTotal"))
			                		   document.getElementById("travelExpWithTotal").style.display="none";
			                	   if(document.getElementById("totalBottom"))
			                		   document.getElementById("totalBottom").innerHTML=document.getElementById("totalTop").innerHTML;
		                	}
	            if(addNewAddressStatus){
	            	if(document.getElementById('newAddressDiv'))
	            		document.getElementById('newAddressDiv').style.display='block';
	            	if(document.purchaseForm.elements['viewPurchaseModel.useSavedAddress']){
	            		for(i=0;i<document.purchaseForm.elements['viewPurchaseModel.useSavedAddress'].length;i++){
	            			if(document.purchaseForm.elements['viewPurchaseModel.useSavedAddress'][i].value=='newAddress')
	            				document.purchaseForm.elements['viewPurchaseModel.useSavedAddress'][i].checked=true;
	            		}
	            	}
	            }
	            if(addNewCardStatus){
	            	if(document.getElementById('newCardDiv'))
	            		document.getElementById('newCardDiv').style.display='block';
	            	if(document.purchaseForm.elements['viewPurchaseModel.useSavedCard']){
	            		for(i=0;i<document.purchaseForm.elements['viewPurchaseModel.useSavedCard'].length;i++){
	            			if(document.purchaseForm.elements['viewPurchaseModel.useSavedCard'][i].value=='newCard')
	            				document.purchaseForm.elements['viewPurchaseModel.useSavedCard'][i].checked=true;
	            		}
	            	}
	            	if(document.getElementById('newCardDiv') && document.getElementById('newCardDiv').style.display == 'block'){
	            		document.getElementById("id_cardHolderName").value=cardHolderNameBeforeAjax;
	            		document.getElementById("id_cardType").value=cardTypeBeforeAjax;
	            		document.getElementById("id_cardNumber").value=cardNoBeforeAjax;
	            		document.getElementById("id_cardExpMonth").value=cardExpMonthBeforeAjax;
	            		document.getElementById("id_cardExpYear").value=cardExpYearBeforeAjax;
	            		document.getElementById("id_cardSecurityCode").value=cardSecurityCodeBeforeAjax;
	            	}
	            }
	            if($('#ContainerRight').length>0 && $('#ContainerMiddle').length>0){
	            	$('#ContainerRight').height(($('#ContainerMiddle').height()-20));
	            }
		        		},
        	    	   success: function(html){
        	    		   $("#body").html(html.trim());
        			    }
        		});
}


function showHideTaxDetails()
{
	
	if(document.getElementById("PFC").style.display=="block" ||document.getElementById("PFC").style.display=="")
	{
		
		document.getElementById("PFC").style.display="none";
		document.getElementById("PFC1").style.display="none";
		document.getElementById("securityFee").style.display="none";
		document.getElementById("securityFee1").style.display="none";
		document.getElementById("segmentFee").style.display="none";
		document.getElementById("segmentFee1").style.display="none";
		document.getElementById("taxImage").innerHTML='<img alt="" src="https://static.virginamerica.com/images/taxFeesExpand.gif" onclick="javascript:showHideTaxDetails()"  onMouseOver="MakeCursor(this)"/>';
		
	}
	else
	{
		document.getElementById("PFC").style.display="block";
		document.getElementById("PFC1").style.display="block";
		document.getElementById("securityFee").style.display="block";
		document.getElementById("securityFee1").style.display="block";
		document.getElementById("segmentFee").style.display="block";
		document.getElementById("segmentFee1").style.display="block";
		document.getElementById("taxImage").innerHTML='<img alt="" src="https://static.virginamerica.com/images/taxFeesCollapse.gif" onclick="javascript:showHideTaxDetails()"  onMouseOver="MakeCursor(this)"/>';
		
	}
}


function showHideAIGTaxDetails(taxId,flight){
if(flight=='original'){
		 if(document.getElementById("taxBreakdown").style.display=="block" ||document.getElementById("taxBreakdown").style.display=="")
		     {
		                                document.getElementById("taxBreakdown").style.display="none";                               
		                                document.getElementById("taxImageAig").innerHTML='<img alt="" id="'+taxId+'" src="https://static.virginamerica.com/images/taxFeesExpand.gif" onclick="javascript:showHideAIGTaxDetails(this.id,'+'\''+flight+'\''+')"  onMouseOver="MakeCursor(this)"/>';
		      }else{
		                                document.getElementById("taxBreakdown").style.display="block";                               
		                                document.getElementById("taxImageAig").innerHTML='<img alt="" id="'+taxId+'" src="https://static.virginamerica.com/images/taxFeesCollapse.gif" onclick="javascript:showHideAIGTaxDetails(this.id,'+'\''+flight+'\''+')"  onMouseOver="MakeCursor(this)"/>';
		   }
   }else{
    if(document.getElementById("taxBreakdownNew").style.display=="block" ||document.getElementById("taxBreakdownNew").style.display=="")
		     {
		                                document.getElementById("taxBreakdownNew").style.display="none";                               
		                                document.getElementById("taxImageNew").innerHTML='<img alt="" id="'+taxId+'" src="https://static.virginamerica.com/images/taxFeesExpand.gif" onclick="javascript:showHideAIGTaxDetails(this.id,'+'\''+flight+'\''+')"  onMouseOver="MakeCursor(this)"/>';
		      }else{
		      		                    document.getElementById("taxBreakdownNew").style.display="block";                               
		                                document.getElementById("taxImageNew").innerHTML='<img alt="" id="'+taxId+'" src="https://static.virginamerica.com/images/taxFeesCollapse.gif" onclick="javascript:showHideAIGTaxDetails(this.id,'+'\''+flight+'\''+')"  onMouseOver="MakeCursor(this)"/>';
		                                
		   }   
   }
}

function showCompanionsList(objId){
document.getElementById(objId).style.width="420px"
document.getElementById(objId).style.display='inline';

}

function ChangeFormValue(optval, num)
{
         var values=new String(optval);
      var str=optval.split("|");
      var titleObj=document.displayPurchaseForm.elements['viewPurchase.title['+num+']'];
      var option = titleObj.options;
      titleObj.value=str[0];
      var prefix=str[0];
      if(prefix=='Mr')
            option.selectedIndex = 0;
      if(prefix=='Mrs')
            option.selectedIndex = 1;
      if(prefix=='Miss (Adult)')
            option.selectedIndex = 2;
      if(prefix=='Miss (Child)')
            option.selectedIndex = 3;
      if(prefix=='Ms')
            option.selectedIndex = 4;
      if(prefix=='Mstr (Child)')
            option.selectedIndex = 5;
            
    ChangeGuestType(prefix, document.displayPurchaseForm.elements['viewPurchase.guestType['+num+']']);
    document.displayPurchaseForm.elements['viewPurchase.firstName['+num+']'].value=str[1];
    document.displayPurchaseForm.elements['viewPurchase.lastName['+num+']'].value=str[2];
    document.displayPurchaseForm.elements['viewPurchase.guestNumber['+num+']'].value=str[3];

}

function switchPaymentType(paymentType,id){
	showWaitImage();
		document.barForm.method.value="switchPaymentType";
		document.barForm.tabSelect.value="5";
		document.barForm.action="switchPaymentType.do?paymentType="+paymentType;	
			document.barForm.submit();
}

var maintain_CCPreScreenStatus;
var myBarclaysCreditCardwWindow;
/*****************************/
// start Barcklay credit card
/*****************************/
function openBarclaysCreditCard(firstDivId, secondDivId, statusId){
	if(firstDivId!='BarclaysPreapprovedRightBarID')
		document.getElementById(firstDivId).style.display='none';
	//form will be submitted to barclays server.
	formDataHex=regenMD5(document.barclaysCreditCardPromptForm,statusId);
	document.barclaysCreditCardPromptForm.SIGNATURE.value=formDataHex;
	openPopUp();
}

// Open Barclay application
function openPopUp(){
	document.barclaysCreditCardPromptForm.target='BarclaysCreditCardPopUpWindow';
	// Send all data to barclay application in UPPERCASE
	var elementsToBeUpper = "FIRSTNAME,LASTNAME,EMAIL,ADDRESS1,CITY,STATE,POSTALCODE,ADDRESS2";
	for(eleCnt=0; eleCnt<document.barclaysCreditCardPromptForm.elements.length; eleCnt++){
		objectEle = document.barclaysCreditCardPromptForm.elements[eleCnt];
		if(elementsToBeUpper.indexOf(objectEle.name)>-1)
	  		objectEle.value = (objectEle.value).toUpperCase();
	}document.barclaysCreditCardPromptForm.submit();
}

// Encrypt secure data before passing it to Barclay, This data will come back 
// with post back data
function regenMD5(f,statusId) {
	plain = '';
	plain += 'SESSION=' + f.SESSION.value;
	plain += ':RETURL=' + f.RETURL.value;
	plain += ':SESSIONSTATE=' + f.SESSIONSTATE.value;
	if (statusId == 'APPROVED'){ plain += ':PRESCREENID=' + f.PRESCREENID.value;
	}else{ plain += ':PRESCREENID=';}
	plain += ':LASTNAME=' + f.LASTNAME.value;
	plain += ':PASSWORD=' + f.PASSWORD.value;
	return hex_md5(plain);
}

function statusUpdatePreScreenWithAJAX(firstDivId,actionMode,CCPreSceeenId,CCPreScreenStatus, ccFName, ccLName){
	myUrl="creditCardPostBack.do?method=getClosePreApprovedScreen&actionMode="+actionMode+"&CCPreSceeenId="+CCPreSceeenId+"&CCPreScreenStatus="+CCPreScreenStatus+"&ccFName="+ccFName+"&ccLName="+ccLName;
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myUrl=myUrl+"&dummy="+dummy;
	if(actionMode=='yes'){
		maintain_CCPreScreenStatus=CCPreScreenStatus
		myBarclaysCreditCardwWindow=window.open("/html/Virgin_America_Credit_Card.html", "BarclaysCreditCardPopUpWindow", "toolbar=no,status=yes,menubar=no,location=no,scrollbars=yes,resizable=no, top=" +200 + ", left=" + 100 + ", width=" + 840 + ",height=" + 700);
		ajaxOpenVACreditCard(myUrl, firstDivId);
	}else{
		ajaxVACreditCardWithBarclays(myUrl, firstDivId);
		document.getElementById("BarclaysPreapprovedID").style.display='none';
	}
	document.getElementById("disableTotalPage").style.display='none';
}

// Calling AJAX
function ajaxVACreditCardWithBarclays(myurl, div1){
	xmlhttp = new XMLHttpRequest();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div1;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange = handleResponseVACreditCardWithBarclays;
	xmlhttp.send("");
}

// wait for response and write it in div
function handleResponseVACreditCardWithBarclays() {
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
		if(xmlhttp.responseText!=""){
			}
	  }
	}
}

var isBCCError = false;
//Calling AJAX
function ajaxOpenVACreditCard(myurl, div1){

	$.ajax({
	 	   type: "POST",
	 	   url: myurl,
	 	   cache: false,
	 	   dataType:"script",
	 	   success: function(html){
					if(document.getElementById("isBCCError"))
						if(document.getElementById("isBCCError").value == 'true')
							isBCCError = true;
					if(document.getElementById(div1))
						document.getElementById(div1).style.display="none";
					if(!isBCCError){
						if(document.getElementById("BarclaysCreditCardPopUp"))
							document.getElementById("BarclaysCreditCardPopUp").style.display="block";
						//document.getElementById("disableTotalPage").style.display="none";
						openBarclaysCreditCard('BarclaysPreapprovedID','BarclaysCreditCardPopUp',maintain_CCPreScreenStatus);
					}
				 
					
		  
		}
	 	});
}
/******************************/
/** End barclays credit card **/
/******************************/

// ## s_code.js begin #### //

/* SiteCatalyst code version: H.14.
Copyright 1997-2008 Omniture, Inc. More info available at
http://www.omniture.com */
/************************ ADDITIONAL FEATURES ************************
     Plugins
*/
/* Specify the Report Suite ID(s) to track here */
var s_account=setOmnitureEnv();
var s=s_gi(s_account)
/************************** CONFIG SECTION **************************/
/* You may add or alter any code config here. */
/* Conversion Config */
s.currencyCode="USD"
/* Link Tracking Config */
s.trackDownloadLinks=true
s.trackExternalLinks=true
s.trackInlineStats=true
s.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,doc,pdf,xls"
s.linkInternalFilters="javascript:,virginamerica.com"
s.linkLeaveQueryString=false
s.linkTrackVars="None"
s.linkTrackEvents="None"
/* Plugin Config */
s.usePlugins=true
function s_doPlugins(s) {
	/* Add calls to plugins here */
	
	/* getTimeToComplete Examples */
	
	if (s.events){
		// Booking:
		if(s.events.indexOf('event1')>-1) {
		   s.prop18='start';
			s.gtctype='booking';
		}
		if(s.events.indexOf('purchase')>-1){
		   s.prop18='stop';
			s.gtctype='booking';
		   s.prop19="Booking Process";
		}
		if(s.events.indexOf('event45')>-1) {
			s.prop18='start'; 
			s.gtctype='Check-In';
		}
		if(s.events.indexOf('event7')>-1){
			s.prop18='stop';
			s.gtctype='Check-In';
			s.prop19='Check-In';
		}
		if(s.events.indexOf('event17')>-1) {
			s.prop18='start';
			s.gtctype='ChangeSeat';
		}
		if(s.events.indexOf('event20')>-1) {
			s.prop18='stop';
			s.gtctype='ChangeSeat';
			s.prop19='Change Seat';
		}
		if(s.events.indexOf('event46')>-1){
			s.prop18='start';
			s.gtctype='ChangeFlight';
		}
		if(s.events.indexOf('event11')>-1){
			s.prop18='stop';
			s.gtctype='ChangeFlight';
			s.prop19='Change Flight';
		}
		if(s.events.indexOf('event48')>-1){
			s.prop18='start';
			s.gtctype='Cancel';
		}
		if(s.events.indexOf('event10')>-1){
			s.prop18='stop';
			s.gtctype='Cancel';
			s.prop19='Cancel Flight';
		}

		/*Call the getTimeToComplete plug-in only once*/                   
		s.prop18=s.getTimeToComplete(s.prop18,s.gtctype,0);

		if(s.events.indexOf('event44')>-1){
	        s.events=s.getValOnce(s.events,"event44",0);
	}
	}
   	

   	
	 // tid takes precedence over cid if both exist in the query string.
    s.campaign=s.getQueryParam('tid');

	if(!s.campaign) {
		s.campaign=s.getQueryParam('cid');
		s.campaign=s.getValOnce(s.campaign,"extcmpgn",0);
	}
	if(!s.eVar44) {
    	s.eVar44=s.getQueryParam('eid');
	}
	if(!s.campaign) {
    	s.campaign=s.getQueryParam('eid');
	}// Virgin America Internal Campaign Variable
    if(!s.eVar30) {
        s.eVar30=s.getQueryParam('int');
		s.eVar30=s.getValOnce(s.eVar30,"intcmpgn",0);
	}
		
	var temphr=s.getTimeParting('h','-8',new Date().getFullYear()); // Set hour 
	var tempday=s.getTimeParting('d','-8',new Date().getFullYear()); // Set day
	var tempweek=s.getTimeParting('w','-8',new Date().getFullYear()); // Set Weekend / Weekday
			
	if(temphr)
		s.prop14=s.eVar19=tempweek + " : " + tempday + " : " + temphr;


	if(s.prop20) s.eVar31=s.prop20; // line 159
	if(s.eVar30) s.prop17=s.eVar30; // line 85

	if(s.prop21) s.eVar42=s.prop21; // line 170
	if(s.prop22) s.eVar43=s.prop22; // line 171
	if(s.campaign) s.eVar41=s.campaign; //evar41 
}
s.doPlugins=s_doPlugins
/************************** PLUGINS SECTION *************************/
/* You may insert any plugins you wish to use here.                 */
/*
 * Plugin: getQueryParam 2.1 - return query string parameter(s)
 */
s.getQueryParam=new Function("p","d","u",""
+"var s=this,v='',i,t;d=d?d:'';u=u?u:(s.pageURL?s.pageURL:s.wd.locati"
+"on);if(u=='f')u=s.gtfs().location;while(p){i=p.indexOf(',');i=i<0?p"
+".length:i;t=s.p_gpv(p.substring(0,i),u+'');if(t)v+=v?d+t:t;p=p.subs"
+"tring(i==p.length?i:i+1)}return v");
s.p_gpv=new Function("k","u",""
+"var s=this,v='',i=u.indexOf('?'),q;if(k&&i>-1){q=u.substring(i+1);v"
+"=s.pt(q,'&','p_gvf',k)}return v");
s.p_gvf=new Function("t","k",""
+"if(t){var s=this,i=t.indexOf('='),p=i<0?t:t.substring(0,i),v=i<0?'T"
+"rue':t.substring(i+1);if(p.toLowerCase()==k.toLowerCase())return s."
+"epa(v)}return ''");

/*
 * Plugin: getValOnce 0.2 - get a value once per session or number of days
 */
s.getValOnce=new Function("v","c","e",""
+"var s=this,k=s.c_r(c),a=new Date;e=e?e:0;if(v){a.setTime(a.getTime("
+")+e*86400000);s.c_w(c,v,e?a:0);}return v==k?'':v");

/*
 * Plugin: getTimeParting 1.3 - Set timeparting values based on time zone
 */


s.getTimeParting=new Function("t","z","y",""
+"dc=new Date('1/1/2000');f=15;ne=8;if(dc.getDay()!=6||"
+"dc.getMonth()!=0){return'Data Not Available'}else{;z=parseInt(z);"
+"if(y=='2009'){f=8;ne=1};gmar=new Date('3/1/'+y);dsts=f-gmar.getDay("
+");gnov=new Date('11/1/'+y);dste=ne-gnov.getDay();spr=new Date('3/'"
+"+dsts+'/'+y);fl=new Date('11/'+dste+'/'+y);cd=new Date();"
+"if(cd>spr&&cd<fl){z=z+1}else{z=z};utc=cd.getTime()+(cd.getTimezoneO"
+"ffset()*60000);tz=new Date(utc + (3600000*z));thisy=tz.getFullYear("
+");var days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Fr"
+"iday','Saturday'];if(thisy!=y){return'Data Not Available'}else{;thi"
+"sh=tz.getHours();thismin=tz.getMinutes();thisd=tz.getDay();var dow="
+"days[thisd];var ap='AM';var dt='Weekday';var mint='00';if(thismin>3"
+"0){mint='30'}if(thish>=12){ap='PM';thish=thish-12};if (thish==0){th"
+"ish=12};if(thisd==6||thisd==0){dt='Weekend'};var timestring=thish+'"
+":'+mint+ap;var daystring=dow;var endstring=dt;if(t=='h'){return tim"
+"estring}if(t=='d'){return daystring};if(t=='w'){return en"
+"dstring}}};"
);

/*
 * Plugin: getTimeToComplete 0.4 - return the time from start to stop
 */
s.getTimeToComplete=new Function("v","cn","e",""
+"var s=this,d=new Date,x=d,k;if(!s.ttcr){e=e?e:0;if(v=='start'||v=='"
+"stop')s.ttcr=1;x.setTime(x.getTime()+e*86400000);if(v=='start'){s.c"
+"_w(cn,d.getTime(),e?x:0);return '';}if(v=='stop'){k=s.c_r(cn);if(!s"
+".c_w(cn,'',d)||!k)return '';v=(d.getTime()-k)/1000;var td=86400,th="
+"3600,tm=60,r=5,u,un;if(v>td){u=td;un='days';}else if(v>th){u=th;un="
+"'hours';}else if(v>tm){r=2;u=tm;un='minutes';}else{r=.2;u=1;un='sec"
+"onds';}v=v*r/u;return (Math.round(v)/r)+' '+un;}}return '';");

/* WARNING: Changing any of the below variables will cause drastic
changes to how your visitor data is collected.  Changes should only be
made when instructed to do so by your account manager.*/
s.visitorNamespace="virginamerica"
s.dc=112

/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code='',s_objectID;function s_gi(un,pg,ss){var d="function s_dr"
+"(x,o,n){var i=x.indexOf(o);if(i>=0&&x.split)x=(x.split(o)).join(n);"
+"else while(i>=0){x=x.substring(0,i)+n+x.substring(i+o.length);i=x.i"
+"ndexOf(o)}return x}w.s_dr=s_dr;function s_d(x) {var t='`^@$#',l='01"
+"23456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',d,n=0"
+",b,k,w,i=x.lastIndexOf('~~');if(i>0){d=x.substring(0,i);x=x.substri"
+"ng(i+2);while(d){w=d;i=d.indexOf('~');if(i>0){w=d.substring(0,i);d="
+"d.substring(i+1)}else d='';b=parseInt(n/62);k=n-b*62;k=t.substring("
+"b,b+1)+l.substring(k,k+1);x=s_dr(x,k,w);n++}for(i=0;i<5;i++){w=t.su"
+"bstring(i,i+1);x=s_dr(x,w+' ',w)}}return x}w.s_d=s_d;",c=".substrin"
+"g(~.indexOf(~return ~=fun`K(~){`Os=^u~`t $6~;$6~.toLowerCase()~`cFu"
+"n`K('e`s`Os=s_c_il['+@i+']~};s.~.length~.toUpperCase~`cObject~s.wd~"
+"t^D~.location~')q='~dynamicAccount~link~s.apv~ction~$l$X~)$6x^X!Obj"
+"ect||!Object.prototype||!Object.prototype[x])~@G^Al)@G^Al['+@i+'].m"
+"rq(\"'+un+'\")'~var ~s.pt(~ookieDomainPeriods~,`s,'~while(~);s.~.pr"
+"otocol~){$6~visitor~=''~:'')~;@F^Vs[k],255)}~s_c2f~javaEnabled~=new"
+" ~.lastIndexOf('~tm.get~@5\"$Qs.b.addBehavior('# default# ~onclick~"
+"ternalFilters~entElement~Name~javascriptVersion~=parseFloat(~cookie"
+"~parseInt(~s.^J~Type~o^joid~browser~','~else~referrer~colorDepth~St"
+"ring~.host~s.rep(~}catch(e){~r=s.m(f)?s[f](~}$6~s.un~s.eo~s.sq~t=s."
+"ot(o)~track~j='1.~)?'Y':'N'~$dURL~^jc_i~s.ismac~lugins~=='~;for(~Sa"
+"mpling~s.rc[un]~s.b.addEventListener~Download~tfs~resolution~.get@I"
+"()~s.eh~s.isie~s.vl_l~s.vl_t~Height~t,h){t=t?t~isopera~escape(~scre"
+"en.~s.fl(~harCode~&&(~variableProvider~s.gg('objectID')~&&s.~:'';h="
+"h?h~e&&l$kSESSION'~');~f',~_'+~Date~name~home$d~.s_~s.c_r(~s.rl[u~o"
+".href~Lifetime~Width~sEnabled~'){q='~b.attachEvent~&&l$kNONE'){~Ext"
+"ernalLinks~this~charSet~onerror~currencyCode~s=s_gi(~e$SElement~;s."
+"gl(s.vl_g~.parent~Array~lnk~Opera~eval(~Math.~s.fsg~s.ns6~docum~s.o"
+"un~conne~InlineStats~Track~'0123456789~s[k]=~window~onload~Time~s.e"
+"pa(~s.c_w(~o.type~(s.ssl~n=s.oid(o)~LeaveQuery~')>=~&&t~'=')~){n=~+"
+"1))~' '+~s.t()}~\",''),~=s.oh(o);~+(y<1900?~ingServer~s_gs~true~ses"
+"s~campaign~lif~;fun~,100)~s.co(~s._in~x in ~='s_~ffset~s.c_d~'&pe~s"
+".gv(~s.qav~s.pl~=(apn~sqs',q);~Year(~=s.n.app~&&!~(''+~(\")>=~)+'/~"
+"',s~s()+':'+~){p=~():''~a):f(~){v=s.n.~channel~if(~un)~.target~o.va"
+"lue~etscape~(ns?ns:~s_')t=t~omePage~++}~')<~){x~1);~e))~'+n~height~"
+"events~trk~random~code~un,~try{~'MSIE ~.src~INPUT'~floor(~s.pg~s.nu"
+"m(~s.ape(~s.c_gd~s.dc~.inner~transa~Events~page~.set~Group,~Match,~"
+".fromC~++){~?'':~!='~='+~(\")<~?'&~+';~(f){~>=5)~&&i>~[b](~=l[n];~~"
+"fun`K `ae$p`Ox`X,s=0,e,a,b,c;`S1){e=f`1'\"@z);b=f`1'\\\\',s);c=f`1"
+"\"\\n\",s)`6e<0||(b>=0&&b<$Ie=b`6e<0||(c>=0&&c<$Ie=c`6e>=0$G+=(e>s?"
+"f`0s,e)`Y+(e==c?'\\\\n':'\\\\'+f`0e,e@T;s=e+1}`t `2x+f`0s)}`2f}w.`a"
+"e=`ae@f`K `aa$p`Os=f`1'(')+1,e=f`1')'),a`X,c;`Ss>=0&&s<e){c=f`0s,s+"
+"1)`6c==`s)a+='\",\"';`5(\"\\n\\r\\t \")`1c)<0)a+=c;s$E`2a?'\"'+a+'"
+"\"':a}w.`aa=`ae@f`K `a(cc){cc`X+cc;`Ofc='`Of`cFun`K(@z=cc`1';',cc`1"
+"'{')),e=cc`d}'),o,a,d,q,c,f,h,x;fc+=`aa(cc)+',\"`Os`C;';c=cc`0s+1,e"
+");s=c`1'fun`K^d`Ss>=0){d=1;q`X;x=0;f=c`0s);a=`aa(f);e=o=c`1'{@z);e+"
+"+;`Sd>0){h=c`0e,e+1)`6q`Vh==q@vx)q`X`6h^D\\\\')x=x?0:1;`t x=0}`t{$6"
+"h^D\"'||h==\"'\")q=h`6h^D{')d++`6h^D}')d--^1d>0)e$Ec=c`00,s)+'new F"
+"un`K('+(a?a+`s`Y+'\"'+`ae(c`0o+1,$I+'\")'+c`0e+$Hs=c`1'fun`K')}fc+="
+"`ae(c)$o`2s\");';@5fc);`2f}w.`a=`a`6pg){fun`K s_co(o){`O^y\"_\",1,$"
+"H`2@ho)}w^jco=s_co@f`K @a($7{`O^y$P1,$H`2@Vw^jgs=@a@f`K s_dc($7{`O^"
+"y$P$H`2@Vw^jdc=s_dc;}fun`K s_c($Ppg,ss`4;s._c@kc';`D=@G`6!`D^An){`D"
+"^Al`c@2;`D^An=0;}s._il=`D^Al;@i=`D^An;s._il[@i]=s;`D^An++;s.m`3m){`"
+"2@wm)`1'{$F0`9fl`3x,l){`2x?@wx)`00,l):x`9co`3o`V!o)`2o;`On`C,x^E@jo"
+")$6x`1'select$F0&&x`1'filter$F0)n[x]=o[x];`2n`9num`3x$G`X+x^E`Op=0;"
+"p<x`A;p++)$6(@E')`1x`0p,p@T<0)`20;`21`9rep`3x,o,n){`Oi=x`1o);`Sx$r="
+"0$G=x`00,i)+n+x`0i+o`A);i=x`1o,i+n`A)}`2x`9ape`3x`4,h=@EABCDEF',i,c"
+"=s.^v,n,l,e,y`X;c=c?c`B$2`6x$G`X+x`6c^DAUTO'^X'').c^WAt){for(i=0;i<"
+"x`A;i$ic=x`0i,i+$Hn=x.c^WAt(i)`6n>127){l=0;e`X;`Sn||l<4){e=h`0n%16,"
+"n%16+1)+e;n=`nn/16);l$Ey+='%u'+e}`5c^D+')y+='%2B';`t y+=^Tc)}x=y}`t"
+"{x=x?`y^T''+x),'+`s%2B'):x`6x&&c^aem==1&&x`1'%u$F0&&x`1'%U$F0){i=x`"
+"1'%^d`Si>=0){i++`6h`08)`1x`0i,i+1)`B())>=0)`2x`00,i)+'u00'+x`0i);i="
+"x`1'%',i)}}}}`2x`9epa`3x`4;`2x?un^T`y''+x,'+`s ')):x`9pt`3x,d,f,a`4"
+",t=x,z=0,y,r;`St){y=t`1d);y=y<0?t`A:y;t=t`00,y);^0t,$3t,a)`6r)`2r;z"
+"+=y+d`A;t=x`0z,x`A);t=z<x`A?t:''}`2''`9isf`3t,a){`Oc=a`1':')`6c>=0)"
+"a=a`00,c)`6t`00,2)^D$C`02);`2(t!`X@Q==a)`9fsf`3t,a`4`6`Pa`Ris^et))@"
+"7+=(@7!`X?`s`Y+t;`20`9fs`3x,f`4;@7`X;`Px`Rfs^ef);`2@7`9c_d`X;$Yf`3t"
+",a`4`6!$Wt))`21;`20`9c_gd`3`4,d=`D`F`x^h,n=s.fpC`Q,p`6!n)n=s.c`Q`6d"
+"@v@m@Sn?`nn):2;n=n>2?n:2;p=d`d.')`6p>=0){`Sp>=0&&n>1$1d`d.',p-$Hn--"
+"}@m=p>0&&`Pd,'.`sc_gd^e0)?d`0p):d}}`2@m`9c_r`3k`4;k=$Xk);`Oc=@Us.d."
+"`m,i=c`1@Uk+@R,e=i<0?i:c`1';',i),v=i<0$j@Jc`0i+2+k`A,e<0?c`A:$I;`2v"
+"$k[[B]]'?v:''`9c_w`3k,v,e`4,d=$Y(),l=s.`m^n,t;v`X+v;l=l?@wl)`B$2`6^"
+"c^st=(v!`X?`nl?l:0):-60)`6t){e`c^g;e$e@I(e^L+(t*1000))}^1k^ss.d.`m="
+"k+'`Lv!`X?v:'[[B]]')$o path=/;'+(^c?' expires$le.toGMT`w()$o'`Y+(d?"
+"' domain$ld$o'`Y;`2^kk)==v}`20`9eh`3o,e,r,f`4,b='s^fe+'^f@i,n=-1,l,"
+"i,x`6!^Ml)^Ml`c@2;l=^Ml^Ei=0;i<l`A&&n<0;i++`Vl[i].o==o&&l[i].e==e)n"
+"=i^1n<0@Si;l[n]`C}x$tx.o=o;x.e=e;f=r?x.b:f`6r||f$G.b=r?0:o[e];x.o[e"
+"]=f^1x.b$G.o[b]=x.b;`2b}`20`9cet`3f,a,t,o,b`4,r`6`J>=5^X!s.^S||`J>="
+"7))@5'$Q^0$3a)`zr=s.m(t)?s[t](e):t(e)}^d`t{$6^B^au`1$R4@P0)r=s.m(b)"
+"?s$sa):b(a);`t{^M(`D,'^w',0,o);^0$3a`Teh(`D,'^w',1)}}`2r`9g^Jet`3e`"
+"4;`2`o`9g^Joe`8;^M(@G,\"^w\",1`Te^J=1;`Oc=s.t()`6c)s.d.write(c`Te^J"
+"=0;`2@b'`Tg^Jfb`3a){`2@G`9g^Jf`3w`4,p=w@1,l=w`F;`o=w`6p&&p`F!=l&&p`"
+"F`x==l`x){`o=p;`2s.g^Jf(`o)}`2`o`9g^J`3`4`6!`o){`o=`D`6!s.e^J)`o=s."
+"cet('g^J^e`o,'g^Jet@z.g^Joe,'g^Jfb')}`2`o`9mrq`3u`4,l=^l],n,r;^l]=0"
+"`6l)for(n=0;n<l`A;n$ir$ts.mr(0,0,r.t,r.u,r.r)}`9mr`3@c,q,ta,u,rs`4,"
+"dc=$Z,t1=s.^6@Z,t2=s.^6@ZSecure,ns=s.`W`jspace,un=u?u:$Bs.f$7,unc=`"
+"y$P'_`s-'),r`C,l,imn@ki^f($7,im,b,e`6!rs){rs='http'+@M?'s'`Y+'://'+"
+"(t1?@M@Q2?t2:t1):($B@M?'102':unc))+'.'+($Z?$Z:112)+'.2o7.net')@yb/s"
+"s/'+^2+'/1/H.14/'+@c+'?[AQB]&ndh=1'+(q?q`Y+'&[AQE]'`6^N@v^B`V`J>5.5"
+")rs=^Vrs,4095);`t rs=^Vrs,2047)}^1s.d.images&&`J>=3^X!s.^S||`J>=7)^"
+"X@8<0||`J>=6.1)`V!s.rc)s.rc`C`6!^G){^G=1`6!s.rl)s.rl`C;^ln]`c@2;set"
+"@Iout('$6`N,750)}`t{l=^ln]`6l){r.t=ta;r.u=un;r.r=rs;l[l`A]=r;`2''}i"
+"mn+='^f^G;^G$Eim=`D[imn]`6!im)im=`D[imn]`cImage;im^jl=0;im.@H`cFun`"
+"K('e`s^u^jl=1`6`N);im$S=rs`6rs`1@n=@P0^X!ta||ta^D_self'||ta^D_top'|"
+"|(`D.^h@Qa==`D.^h))){b=e`c^g;`S!im^jl&&e^L-b^L<500)e`c^g}`2''}`2'<i"
+"m'+'g sr'+'c=\"'+rs+'\" width=1 $K=1 border=0 alt=\"\">'`9gg`3v`4`6"
+"!`D['s^fv])`D['s^fv]`X;`2`D['s^fv]`9glf`3t,a`Vt`00,2)^D$C`02);`Os=^"
+"u,v=s.gg(t)`6v)s[t]=v`9gl`3v`4`6$V)`Pv`Rgl^e0)`9gv`3v`4;`2s['vpm^fv"
+"]?s['vpv^fv]:(s[v]?s[v]`Y`9havf`3t,a`4,b=t`00,4),x=t`04),n=`nx),k='"
+"g^ft,m='vpm^ft,q=t,v=s.`I@DVars,e=s.`I@D$c;@F@ot)`6s.@3||^3){v=v?v+"
+"`s+^O+`s+^O2:''`6v@v`Pv`Ris^et))s[k]`X`6`E$L'&&e)@Fs.fs(s[k],e)}s[m"
+"]=0`6`E`WID`Gvid';`5`E^9^qg'`Z`5`E`u^qr'`Z`5`Evmk`Gvmt';`5`E^v^qce'"
+"`6s[k]&&s[k]`B()^DAUTO')@F'ISO8859-1';`5s[k]^aem==2)@F'UTF-8'}`5`E`"
+"W`jspace`Gns';`5`Ec`Q`Gcdp';`5`E`m^n`Gcl';`5`E^Y`Gvvp';`5`E^x`Gcc';"
+"`5`E$5`Gch';`5`E$b`KID`Gxact';`5`E@d`Gv0';`5`E^K`Gs';`5`E`v`Gc';`5`"
+"E`k`Gj';`5`E`b`Gv';`5`E`m^p`Gk';`5`E`r^o`Gbw';`5`E`r^Q`Gbh';`5`E@B`"
+"K`p`Gct';`5`E^i`Ghp';`5`Ep^C`Gp';`5$Wx)`Vb^Dprop`Gc$J;`5b^DeVar`Gv$"
+"J;`5b^Dhier^qh$J`Z^1s[k]@Q$k`I`j'@Q$k`I`p')@p+='&'+q+'`Ls[k]);`2''`"
+"9hav`3`4;@p`X;`P^P`Rhav^e0);`2@p`9lnf`3^R`7^b`7:'';`Ote=t`1@R`6t@Qe"
+">0&&h`1t`0te@T>=0)`2t`00,te);`2''`9ln`3h`4,n=s.`I`js`6n)`2`Pn`Rln^e"
+"h);`2''`9ltdf`3^R`7^b`7:'';`Oqi=h`1'?^dh=qi>=0?h`00,qi):h`6t&&h`0h`"
+"A-(t`A@T^D.'+t)`21;`20`9ltef`3^R`7^b`7:''`6t&&h`1t)>=0)`21;`20`9lt`"
+"3h`4,lft=s.`I^IFile`ps,lef=s.`IEx`h,@e=s.`IIn`h;@e=@e?@e:`D`F`x^h;h"
+"=h`7`6s.^6^ILinks&&lft&&`Plft`Rltd^eh))`2'd'`6s.^6^t^Xlef||@e)^X!le"
+"f||`Plef`Rlte^eh))^X!@e||!`P@e`Rlte^eh)))`2'e';`2''`9lc`8,b=^M(^u,"
+"\"`g\"`T@3=@h^u`Tt(`T@3=0`6b)`2^u$se);`2@b'`Tbc`8,f`6s.d^ad.all^ad."
+"all.cppXYctnr)return;^3=^z?^z:e$8;@5\"$Q$6^3^X^3.tag`j||^3.par`i||^"
+"3@1Nod$I@Vcatch$p}\"`Teo=0'`Toh`3o`4,l=`D`F,h=^m?^m:'',i,j,k,p;i=h`"
+"1':^dj=h`1'?^dk=h`1'/')`6h^Xi<0||(j>=0$rj)||(k>=0$rk))$1o`U&&o`U`A>"
+"1?o`U:(l`U?l`U`Y;i=l.path^h`d/^dh=(p?p+'//'`Y+(o`x?o`x:(l`x?l`x`Y)+"
+"(h`00,1)$k/'?l.path^h`00,i<0?0:i@y'`Y+h}`2h`9ot`3o){`Ot=o.tag`j;t=t"
+"@Q`B?t`B$2`6`ESHAPE')t`X`6t`V`E$T&&@L&&@L`B)t=@L`B();`5^m)t='A';}`2"
+"t`9oid`3o`4,^5,p,c,n`X,x=0`6t@v`q$1o`U;c=o.`g`6^m^X`EA'||`EAREA')^X"
+"!c||!p||p`7`1'javascript$F0))n@X`5c@S`ys.rep(`ys.rep@wc,\"\\r@W\"\\"
+"n@W\"\\t@W' `s^dx=2}`5$9^X`E$T||`ESUBMIT')@S$9;x=3}`5o$S&&`EIMAGE')"
+"n=o$S`6n){`q=^Vn@g;`qt=x}}`2`q`9rqf`3t,un`4,e=t`1@R,u=e>=0?`s+t`00,"
+"e)+`s:'';`2u&&u`1`s+un+`s)>=0?@Jt`0e@T:''`9rq`3un`4,c=un`1`s),v=^k'"
+"s_sq'),q`X`6c<0)`2`Pv,'&`srq^e$7;`2`Pun`Rrq',0)`9sqp`3t,a`4,e=t`1@R"
+",q=e<0$j@Jt`0e+1)`Tsqq[q]`X`6e>=0)`Pt`00,e)`R@s`20`9sqs`3$Pq`4;^4u["
+"un]=q;`20`9sq`3q`4,k@ksq',v=^kk),x,c=0;^4q`C;^4u`C;^4q[q]`X;`Pv,'&`"
+"ssqp',0);`P^2`R@sv`X^E@j^4u`M)^4q[^4u[x]]+=(^4q[^4u[x]]?`s`Y+x^E@j^"
+"4q`M&&^4q[x]^Xx==q||c<2)){v+=(v$n'`Y+^4q[x]+'`Lx);c$E`2@Kk,v,0)`9wd"
+"l`8,r=@b,b=^M(`D,\"@H\"),i,o,oc`6b)r=^u$se)^Ei=0;i<s.d.`Is`A;i$io=s"
+".d.`Is[i];oc=o.`g?\"\"+o.`g:\"\"`6(oc`1\"@a$m0||oc`1\"^joc@x0)&&oc`"
+"1\".tl$m0)^M(o,\"`g\",0,s.lc);}`2r^d`Ds`3`4`6`J>3^X!^N||!^B||`J$q`V"
+"s.b^a^r)s.^r('`g@z.bc);`5s.b&&^H)^H('click@z.bc,false);`t ^M(`D,'@H"
+"',0,`Dl)}`9vs`3x`4,v=s.`W^F,g=s.`W^F$fk@kvsn^f^2+(g?'^fg`Y,n=^kk),e"
+"`c^g,y=e.get@t);e$e@ty+10@Y1900:0))`6v){v*=100`6!n`V!@Kk,x,$I`20;n="
+"x^1n%10000>v)`20}`21`9dyasmf`3t,m`Vt&&m&&m`1t)>=0)`21;`20`9dyasf`3t"
+",m`4,i=t?t`1@R:-1,n,x`6i>=0&&m){`On=t`00,i),x=t`0i+1)`6`Px`Rdyasm^e"
+"m))`2n}`20`9uns`3`4,x=s.`HSele`K,l=s.`HList,m=s.`H$gn,i;^2=^2`7`6x&"
+"&l`V!m)m=`D`F`x`6!m.toLowerCase)m`X+m;l=l`7;m=m`7;n=`Pl,';`sdyas^em"
+")`6n)^2=n}i=^2`1`s`Tfun=i<0?^2:^2`00,i)`9sa`3un`4;^2=un`6!@A)@A=un;"
+"`5(`s+@A+`s)`1$7<0)@A+=`s+un;^2s()`9t`3`4,$M=1,tm`c^g,sed=Math&&@6$"
+"N?@6$U@6$N()*10000000000000):`e@I(),@c='s'+@6$U`e@I()/10800000)%10+"
+"sed,y=`e@t),vt=`e^g(@y'+`eMonth(@y'@Yy+1900:y)+@U`eHour$0`eMinute$0"
+"`eSeconds()+@U`eDay()+@U`e@IzoneO@l(),^J=s.g^J(),ta`X,q`X,qs`X@0`Tu"
+"ns()`6!s.td){`Otl=^J`F,a,o,i,x`X,c`X,v`X,p`X,bw`X,bh`X,^70',k=@K's_"
+"cc`s@b',0^8,hp`X,ct`X,pn=0,ps`6`w&&`w.prototype){^71'`6j.match){^72"
+"'`6tm$eUTC^g){^73'`6^N&&^B&&`J$q^74'`6pn.toPrecision){^75';a`c@2`6a"
+".forEach){^76';i=0;o`C;@5'$Qi`cIterator(o)`z}')`6i&&i.next)^77'}}}}"
+"^1`J>=4)x=^Uwidth+'x'+^U$K`6s.isns||s.^S`V`J>=3$4`b(^8`6`J>=4){c=^U"
+"pixelDepth;bw=`D$a^o;bh=`D$a^Q}}@q=s.n.p^C}`5^N`V`J>=4$4`b(^8;c=^U`"
+"v`6`J$q{bw=s.d.@9`i.o@l^o;bh=s.d.@9`i.o@l^Q`6!^B^ab){`fh$D^dhp=s.b."
+"isH$D(tl^8`z}\");`fclientCaps^dct=s.b.@B`K`p`z}\")}}}`t r`X^1@q)`Sp"
+"n<@q`A&&pn<30){ps=^V@q[pn].^h@g$o'`6p`1ps)<0)p+=ps;pn$Es.^K=x;s.`v="
+"c;s.`k=j;s.`b=v;s.`m^p=k;s.`r^o=bw;s.`r^Q=bh;s.@B`K`p=ct;s.^i=hp;s."
+"p^C=p;s.td=1^1s.useP^C)s.doP^C(s);`Ol=`D`F,r=^J.@9ent.`u`6!s.^9)s.^"
+"9=l`6!s.`u)s.`u=r`6s.@3||^3){`Oo=^3?^3:s.@3`6!o)`2'';`Op=@o'$d`j'),"
+"w=1,^5,@N,x=`qt,h,l,i,oc`6^3&&o==^3){`So@vn@Q$kBODY'){o=o.par`i?o.p"
+"ar`i:o@1Node`6!o)`2'';^5;@N;x=`qt}oc=o.`g?''+o.`g:''`6(oc`1\"@a@x0&"
+"&oc`1\"^joc$m0)||oc`1\".tl@x0)`2''}ta=n?o$8:1;h@Xi=h`1'?^dh=s.`I@O`"
+"w||i<0?h:h`00,i);l=s.`I`j?s.`I`j:s.ln(h);t=s.`I`p?s.`I`p`7:s.lt(h)`"
+"6t^Xh||l))q+=@n=@3^f(`Ed'||`Ee'?$Xt):'o')+(h?@nv1`Lh)`Y+(l?@nv2`Ll)"
+"`Y;`t $M=0`6s.^6@C`V!p$1@o'^9^dw=0}^5;i=o.sourceIndex`6^Z@S^Z;x=1;i"
+"=1^1p&&n@Q)qs='&pid`L^Vp,255))+(w$npidt$lw`Y+'&oid`L^Vn@g)+(x$noidt"
+"$lx`Y+'&ot`Lt)+(i$noi$li`Y}^1!$M@vqs)`2''`6s.p_r)s.p_r();`O$O`X`6$M"
+"^avs(sed))$O=s.mr(@c,(vt$nt`Lvt)`Y+s.hav()+q+(qs?qs:s.rq(^2)),ta`Ts"
+"q($M$jqs`T@3=^3=s.`I`j=s.`I`p=`D^jobjectID=s.ppu`X`6$V)`D^j@3=`D^je"
+"o=`D^j`I`j=`D^j`I`p`X;`2$O`9tl`3o,t,n`4;s.@3=@ho`T`I`p=t;s.`I`j=n;s"
+".t()`9ssl=(`D`F`U`7`1'https@P0`Td=@9ent;s.b=s.d.body;s.n=navigator;"
+"s.u=s.n.userAgent;@8=s.u`1'N$A6/^d`Oapn@u`j,v@uVersion,ie=v`1$R'),o"
+"=s.u`1'@4 '),i`6v`1'@4@P0||o>0)apn='@4';^N@r^DMicrosoft Internet Ex"
+"plorer'`Tisns@r^DN$A'`T^S@r^D@4'`Tismac=(s.u`1'Mac@P0)`6o>0)`J`ls.u"
+"`0o+6));`5ie>0){`J=`ni=v`0ie+5))`6`J>3)`J`li)}`5@8>0)`J`ls.u`0@8+10"
+"));`t `J`lv`Tem=0`6`w$h^W){i=^T`w$h^W(256))`B(`Tem=(i^D%C4%80'?2:(i"
+"^D%U0100'?1:0))}s.sa(un`Tvl_l='`WID,vmk,ppu,^v,`W`jspace,c`Q,`m^n,$"
+"d`j,^9,`u,^x';^P=^O+',^Y,$5,server,$d`p,$b`KID,purchaseID,@d,state,"
+"zip,$L,products,`I`j,`I`p'^E`On=1;n<51;n++)^P+=',prop$J+',eVar$J+',"
+"hier$J;^O2='^K,`v,`k,`b,`m^p,`r^o,`r^Q,@B`K`p,^i,p^C';^P+=`s+^O2;s."
+"vl_g=^P+',`W^F,`W^F$f`HSele`K,`HList,`H$g^6^ILinks,^6^t,^6@C,`I@O`w"
+",`I^IFile`ps,`IEx`h,`IIn`h,`I@DVars,`I@D$c,`I`js,@3';$V=pg@0)`6!ss)"
+"`Ds()}",
w=window,l=w.s_c_il,n=navigator,u=n.userAgent,v=n.appVersion,e=
v.indexOf('MSIE '),m=u.indexOf('Netscape6/'),a,i,s;if(un){un=
un.toLowerCase();if(l)for(i=0;i<l.length;i++){s=l[i];if(s._c=='s_c'){
if(s.oun==un)return s;else if(s.fs(s.oun,un)){s.sa(un);return s}}}}
eval(d);c=s_d(c);i=c.indexOf("function s_c(");eval(c.substring(0,i))
if(!un)return 0;c=c.substring(i);if(e>0){a=parseInt(i=v.substring(e
+5));if(a>3)a=parseFloat(i)}else if(m>0)a=parseFloat(u.substring(m+10)
);else a=parseFloat(v);if(a>=5&&v.indexOf('Opera')<0&&u.indexOf(
'Opera')<0){eval(c);return new s_c(un,pg,ss)}else s=s_c2f(c);return s(
un,pg,ss)}s_gi()

// ## s_code.js end #### //


/* Global Menu Functions starts here*/
var thisDocIDMain=null;
var thisDocID="";
var deactivate=false;
var subNavLinkNo=0
function selectedTag(moduleIn,deactivateLink){
	if(moduleIn=="flightx"){
		thisDocID="link2";
		subNavLinkNo=0;
	}
	else if(moduleIn=="flight"){
		thisDocID="link2";
		subNavLinkNo=0;
	}
	else if(moduleIn=="Cruise"){
		thisDocID="link2";
		subNavLinkNo=5;
	}
	else if(moduleIn=="Cars"){
		thisDocID="link2";
		subNavLinkNo=3;
	}	
	else if(moduleIn=="Hotels"){
		thisDocID="link2";
		subNavLinkNo=2;
	}
	else if(moduleIn=="manageTravel"){
		thisDocID="link3";
		subNavLinkNo=0;
	}
	else if(moduleIn=="ViewItinerary"){
		thisDocID="link3";
		subNavLinkNo=1;
	}
	else if(moduleIn=="CheckIn"){
		thisDocID="link3";
		subNavLinkNo=2;
	}
	else if(moduleIn=="changeFlight" || moduleIn=="ChangeFlight"){
		thisDocID="link3";
		subNavLinkNo=3;
	}
	else if(moduleIn=="cancelFlight" || moduleIn=="CancelFlight"){
		thisDocID="link3";
		subNavLinkNo=4;
	}
	else if(moduleIn=="flightStatus"){
		thisDocID="link3";
		subNavLinkNo=5;
	}
	else if(moduleIn=="flightAlerts"){
		thisDocID="link3";
		subNavLinkNo=6;
	}
	else if(moduleIn=="home"){
		thisDocID="link1";
		subNavLinkNo=0;
	}
	else if(moduleIn=="travelinfo" || moduleIn.indexOf('plan')!=-1){
		thisDocID="link5";
		subNavLinkNo=0;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="InfoDeskHelp"){
		thisDocID="link8";
		subNavLinkNo=0;
	}
	else if(moduleIn=="InfoDeskRouteMap"){
		thisDocID="link5";
		subNavLinkNo=1;
	}
	else if(moduleIn=="InfoDeskDestInfo"){
		thisDocID="link5";
		subNavLinkNo=5;
	}
	else if(moduleIn=="InfoDeskSchedule"){
		thisDocID="link5";
		subNavLinkNo=6;
	}else if(moduleIn=="fareToFlyBy"){
		thisDocID="link6";
		subNavLinkNo=1;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="Help"){
		thisDocID="link8";
		subNavLinkNo=0;
	}
	else if(moduleIn=="shop"){
		thisDocID="link7";
		subNavLinkNo=0;
	}
	else if(moduleIn=="shopGC"){
		thisDocID="link7";
		subNavLinkNo=1;
	}
	else if(moduleIn=="landingSearch"){
		thisDocID="link1";
		subNavLinkNo=0;
	}
	else if(moduleIn=="elevate"){
		thisDocID="link4";
		subNavLinkNo=0;
	}
	else if(moduleIn=="EarnPoints"){
		thisDocID="link4";
		subNavLinkNo=2;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="EnjoyRewards"){
		thisDocID="link4";
		subNavLinkNo=3;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="Partners"){
		thisDocID="link4";
		subNavLinkNo=5;
		deactivateLink='deactivate'
	}else if(moduleIn=="routemap" || moduleIn.indexOf('flight-routes')!=-1){
		thisDocID="link5";
		subNavLinkNo=1;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="entertainment" || moduleIn=="whats_on_board" || moduleIn=="movies" || moduleIn=="meals"|| 
			moduleIn=="amenities" || moduleIn=="satellite_tv" || moduleIn=="premium_tv" || moduleIn=="music_videos" 
				|| moduleIn=="radio" || moduleIn=="games" || moduleIn=="chat" || moduleIn=="snacks" || moduleIn=="drinks" || moduleIn=="first_class" || moduleIn.indexOf('whats-on-board')!=-1){
		thisDocID="link5";
		subNavLinkNo=2;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="cabins"){
		thisDocID="link5";
		subNavLinkNo=3;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="airlinepartners" || moduleIn.indexOf('virgin-partners')!=-1){
		thisDocID="link5";
		subNavLinkNo=4;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="airportinformation" || moduleIn.indexOf('airportinformation')!=-1 || moduleIn.indexOf('san-diego')!=-1 || moduleIn.indexOf('logan-bos')!=-1 || moduleIn.indexOf('las-vegas')!=-1 || moduleIn.indexOf('fort-lauderdale')!=-1 || moduleIn.indexOf('los-angeles')!=-1 || moduleIn.indexOf('new-york')!=-1 || moduleIn.indexOf('san-francisco')!=-1 || moduleIn.indexOf('seattle')!=-1 || moduleIn.indexOf('toronto')!=-1 || moduleIn.indexOf('dulles')!=-1){
		thisDocID="link5";
		subNavLinkNo=5;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="clubhouse" || moduleIn.indexOf('airport-lounge')!=-1){
		thisDocID="link5";
		subNavLinkNo=7;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="joinElevate"){
		thisDocID="link4";
		subNavLinkNo=1;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="buyGiftTransferPoints"){
		thisDocID="link4";
		subNavLinkNo=4;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="memberGuide"){
		thisDocID="link4";
		subNavLinkNo=6;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="whatIseleVAte"){
		thisDocID="link4";
		subNavLinkNo=0;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="dealsHotels"){
		thisDocID="link6";
		subNavLinkNo=3;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="dealsCars"){
		thisDocID="link6";
		subNavLinkNo=2;
		deactivateLink='deactivate'
	}
	else if(moduleIn=="dealsElevate"){
		thisDocID="link6";
		subNavLinkNo=4;
		deactivateLink='deactivate'
	}
	
	

	thisDocIDMain=thisDocID+"_main";
	if(typeof(deactivateLink)!='undefined')
		deactivate=true;
	
}

function setTitle(param){
	if(param=="travelinfo"){
		document.title="Virgin America | Travel Info";
	}else if(param=="routemap"){
		document.title="Virgin America | Route Map";
	}else if(param=="entertainment"){
		document.title="Virgin America | What's on Board";
	}else if(param=="cabins"){
		document.title="Virgin America | Cabins";
	}else if(param=="airlinepartners"){
		document.title="Virgin America | Airline Partners";
	}else if(param=="airportinformation"){
		document.title="Virgin America | Airport Info";
	}else if(param=="clubhouse"){
		document.title="Virgin America | Club House";
	}else if(param=="aboutusCorporate" || param=="environmentalSustainability" || param=="communitySupport"){
		document.title="Virgin America | Corporate Responsibility";
	}else if(param=="meetDavidCush" || param=="meetDianaWalke" || param=="meetFrancisFiorillo" || param=="meetJoeHoughton"
	|| param=="meetRickWysong" || param=="meetToddPawlowski" || param=="meetDavePflieger" || param=="meetKenScarince"
	|| param=="meetBobWeatherly" || param=="meetMarketing"){
		document.title="Virgin America | Bios";
	}else if(param=="press" || param=="photos" || param=="travelAwards"){
		document.title="Virgin America | Press";
	}else if(param=="aboutusOverview"){
		document.title="Virgin America | About Us";
	}else if(param=="corporatesales"){
		document.title="Virgin America | Corporate Sales";
	}else if(param=="whats_on_board" ||param=="movies" ||param=="meals" ||param=="amenities" ||param=="snacks"
		|| param=="drinks" || param=="first_class" || param=="satellite_tv" || param=="premium_tv" || param=="music_videos" || param=="radio"
			|| param=="games" || param=="chat"){
		document.title="Virgin America | What's on Board";
	}else{
		document.title="Virgin America ";
	}
	
}

function showBodySubNavLinks(thisObj){
	if(thisObj){
		thisObj.className='selected'
		thisObj.href="javascript:void(0)";
	}
}

function showNavigation(navId,subNavNo){
	thisDocID=navId
	subNavLinkNo=subNavNo;
	thisDocIDMain=thisDocID+"_main";
	intialiseHeader(thisDocID);
}

function intialiseHeader(_thisDocID,deactivateLink,_cursor)
{

  if((_thisDocID!="link1")&&(_thisDocID!="link8")&&(_thisDocID!="link9")) // && (_thisDocID!="link2")
  {
	
    if(document.getElementById(_thisDocID))
    {
		
      if(typeof(document.getElementById(_thisDocID+"_main").getElementsByTagName("ul")[0])!='undefined' && document.getElementById(_thisDocID+"_sub")){
		document.getElementById(_thisDocID+"_sub").style.visibility="visible"
		document.getElementById(_thisDocID+"_sub").style.top=29+"px"
      }
      if((subNavLinkNo == 0) && (_thisDocID=="link2") && document.getElementById(thisDocID+"_sub")){
    	  document.getElementById(thisDocID+"_sub").getElementsByTagName('li')[subNavLinkNo].className="selected";
      }
      if(subNavLinkNo!=0 && document.getElementById(thisDocID+"_sub")){
        document.getElementById(thisDocID+"_sub").getElementsByTagName('li')[subNavLinkNo-1].className="selected";
        if(deactivateLink && document.getElementById(_thisDocID+"_sub").getElementsByTagName('li')[subNavLinkNo-1]){
         //document.getElementById(_thisDocID+"_sub").getElementsByTagName('li')[subNavLinkNo-1].firstChild.href="javascript:void(0);";
        }
      }
      
		document.getElementById(_thisDocID).className=_thisDocID+"Selected";
		if(_cursor==true)
		{
			document.getElementById(_thisDocID).style.cursor='pointer';
		}
		else
		{
			//document.getElementById(_thisDocID).href='javascript:void(0);';
			//document.getElementById(_thisDocID).style.cursor='default';
			document.getElementById(_thisDocID).style.cursor='pointer';	
			
		}
      var lastsep=_thisDocID.charAt(4)-1;
	  document.getElementById(_thisDocID+'Seperator').className="noneseperator"
      document.getElementById("link"+lastsep+"Seperator").className="noneseperator"
    }
	
    
  }
  else
  {
    document.getElementById(_thisDocID).className=_thisDocID+"Selected";
    if(_cursor==true)
	{
		document.getElementById(_thisDocID).style.cursor='pointer';	
	}
	else
	{
		//document.getElementById(_thisDocID).href='javascript:void(0);';
		//document.getElementById(_thisDocID).style.cursor='default';
		document.getElementById(_thisDocID).style.cursor='pointer';
	}
  }
}

function deIntialiseHeader(_thisDocID)
{

  if((_thisDocID!="link1")&&(_thisDocID!="link8")&&(_thisDocID!="link9")) // && (_thisDocID!="link2")
  {
    if(document.getElementById(_thisDocID))
    {
		document.getElementById(_thisDocID).className=_thisDocID
		document.getElementById(_thisDocID+"_sub").style.visibility="hidden"
    }
	var lastsep=_thisDocID.charAt(4)-1;
	document.getElementById(_thisDocID+'Seperator').className="seperator"
    document.getElementById("link"+lastsep+"Seperator").className="seperator"
  }

}

function menuOver(x)
{
  var imgId=x.parentNode.firstChild.id;
  var lastsep=imgId.charAt(4)-1;
  
  document.getElementById(imgId).className=imgId+"Selected";
  
   if((imgId!="link1")&&(imgId!="link9")&&(imgId!="link8"))  // && (imgId!="link2")
  {
    document.getElementById(imgId+'Seperator').className="noneseperator"
    document.getElementById("link"+lastsep+"Seperator").className="noneseperator"
  }
   if(document.getElementById(thisDocID)){
	   deIntialiseHeader(thisDocID);
   }
	if(imgId==thisDocID){
		intialiseHeader(imgId, deactivate,false);
	}
	else{
		intialiseHeader(imgId, deactivate,true);
	}
}

function menuOut(x)
{
  var imgId=x.parentNode.firstChild.id
  var lastsep=imgId.charAt(4)-1;
  if((imgId!="link1")&&(imgId!="link9")&&(imgId!="8")) // && (imgId!="link2")
  {
	if(imgId!=thisDocID)
	{
		document.getElementById(imgId+'Seperator').className="seperator";
		document.getElementById("link"+lastsep+"Seperator").className="seperator";
	}
  }
  if(imgId==thisDocID)
  {
	document.getElementById(imgId).className=imgId+"Selected";
  }
  else
  {
	document.getElementById(imgId).className=imgId;
	deIntialiseHeader(imgId);
	intialiseHeader(thisDocID, deactivate);
	
  }

}

/* Global Menu Functions ends here*/

var PrevDivId="BookFlight"
			
function rollOverChangeImage(obj,IMG,mouseStyle)
{
	
	document.getElementById(obj).src=IMG;
	document.getElementById(obj).style.cursor=mouseStyle;
	
}

function showHideDiv(obj)
{
	//supersleight.init();
	document.getElementById(PrevDivId+"Div").style.display='none'
	document.getElementById(PrevDivId+"Img").style.display='none'
	document.getElementById(obj+"Div").style.display='block';
	document.getElementById(obj+"Img").style.display='block';
	PrevDivId=obj
}
function updateDashbordDiv(divId, signInStatus){
	if(document.getElementById(divId+'Div').innerHTML!=''){
			showHideDiv(divId);
		}else{
		$.ajax({
    	   type: "POST",
    	   url: "updateDashboardTool.do",
    	   data: "divName="+divId+"&signInStatus="+signInStatus,
    	   dataType:"html",
    	   success: function(html){
    	     
    	    $get_JsElement('CheckInDiv').innerHTML=''
	     	$get_JsElement('ChangeFlightDiv').innerHTML=''
	    	$get_JsElement('CancelFlightDiv').innerHTML=''
		    	if(html.trim()=='sessionOut'){
		    		window.location="/home.do?method=virginAmerica&backSessionOut=sessionTimeOut";	
		    	}else if(html.trim()=='AjaxError'){
		    		window.location="/home.do?method=virginAmerica&fromErrorPage=fromErrorPage"
		    	}else{
		    	     $("#"+divId+"Div").html(html.trim());
		    	     showHideDiv(divId);
		    	}
			}
    	});
	}
	
}
function togglePromoArea(obj){
	if(document.getElementById('PromoCodeDetail').style.display=='block'){
		document.getElementById('PromoCodeDetail').style.display='none';
		obj.className='imgPromoCode floatLeft';
		obj.firstChild.title='Open';
	}else{
		document.getElementById('PromoCodeDetail').style.display='block';
		obj.className='imgPromoCodeSelected floatLeft';
		obj.firstChild.title='Close';
	}
}

function applyPromoCode(tripType, pageName){
	var promoUrl='/promoCodeApply.do?method=applyPromoCode&certCode='+document.getElementById('promoCodeText').value+'&tripType='+tripType+'&pageName='+pageName;
	if(document.getElementById('loadingAnimationDiv')){
		//showHomeLoader('BookFlightDiv');
		showWaitImage();
	}else{
		//showWaitImage(document.getElementById('apply'));
		showWaitImage();
	}
	promoCodeAjax(promoUrl);	
}
function promoCodeAction(action,pageName){
	var tripType="other";
	//showWaitImage(document.getElementById(action));
	showWaitImage();
	if(document.getElementById('divOW').style.display=='block')
		{
			tripType="OW";
		}
	if(action=='apply'){
		var promoUrl='promoCodeApply.do?method=applyPromoCode&certCode='+document.getElementById('promoCodeValue').value+'&tripType='+tripType+'&pageName='+pageName;
	}else if(action=='remove'){
		var promoUrl='promoCodeRemove.do?method=removePromoCode&pageName='+pageName;
	}

	$('#sect').load(promoUrl,'',done);

	function done()
	{
		ajax("updateTitleBar.do?method=updateTitleBar","titleBarDiv");
		document.getElementById("loadingAnimationDiv").style.display="none";
		
	}
}
/* calander for Home Page */
var mainCalW='352';
var innerCalW='160';
//Use for the top two tables
var tableOpen = "<tr><td colspan='3' align='left' valign='top'>"
						+"<table width='352' border='0' cellpadding='0' cellspacing='0'>"
						+"<tr><td width='13' height='9' rowspan='3' align='left' valign='top' class='calenderLeft'><img src='https://static.virginamerica.com/images/spacer.gif' width='13'/></td>"
						+"<td style='background-color:#FFFFFF'><img src='https://static.virginamerica.com/images/spacer1.png' width='320' height='9'/></td>"
						+"<td width='14' height='9' rowspan='3' align='left' valign='top' class='calenderRight'><img src='https://static.virginamerica.com/images/spacer.gif' width='14'/></td></tr>"
						+"<tr><td align='left' valign='top' >"   
						+"<table width='325' border='0' cellspacing='0' cellpadding='0' style='background-color:#FFFFFF'>"  //for innerCal
						+"<tr><td width="+innerCalW+" align='left' valign='top' >";

var prev_cal=""
var next_cal=""

var tableCloseS = "</td></tr>"
					+"<tr><td>"
					+"<table width='325' border='0' cellspacing='0' cellpadding='0' bgcolor='#e5e5e5'>"
				    +'<tr>'
			       +'<td valign="bottom" width="36" height="20">'
			       
var tableCloseM="</td>"
			       +"<td width='255' height='20'>&nbsp;</td>"
			       +'<td valign="bottom" width="35" height="20">'
			     
var tableCloseL="</td></tr></table>"
					+"</td></tr>"
					+"</table></td></tr>"
					+"<tr><td width='352' height='14' colspan='3' align='left' valign='top' class='calenderBase'><img src='https://static.virginamerica.com/images/spacer.gif' width='352' height='14' /></td></tr></table>";

 					   

var tdFor3rdCalTable = "</td><td width='5' align='left' valign='top'><img src='https://static.virginamerica.com/images/calender_ct.png' width='5' height='136' /></td><td width="+innerCalW+" align='left' valign='top' >";


/*This function creates the structure for a table & sets the dates in 'tds' */
function makeCal(whichMonth){
	b_calinit = 1;
	o_cal= "";
	o_caltr="";o_caltd="";
	newM = whichMonth;
	
	if(newM < cM) newY = newY;
	
	if (newM>=12){
		newM=whichMonth-12;
		newY++;
	}
	if(i_numcal==0){
		i_firstMonth = newM
		switch(s_inputtype){
			case "object":
				i_ofirstMonth  = newM;
				i_ofirstYear = newY;
			break;
			default:
				i_sfirstMonth  = newM;
				i_sfirstYear = newY;
		}
	}
	
	newDs = datesArray[newM];
	isLeap 	= (newY % 4 == 0 && (newY % 100 !=0 || newY % 400 ==0 )) ? 1:0
	if (newM==1) newDs=newDs+isLeap;
	newD = findFirstDay();
	countDay = newD;
	
	s_calclass = (calDirection=="vertical")? "calTableH" : "calTableH";
	
var changeTDTOTABLEValue = "";
	o_cal+="<table month='"+newM+"' year='"+newY+"' width="+innerCalW+" border='0' cellspacing='0' cellpadding='0' style='background:color:blue'>";
	o_caltd+= "<td height='20' align='center' valign='middle' class='calMon' background='https://static.virginamerica.com/images/month_bg.png' colspan=7>";
	changeTDTOTABLEValue = mArray[newM]; 
	o_caltd+= "RWTCMT";
	o_caltd+= "</td>";
	
	o_caltr = ty_maketr(o_caltd);
	
	o_cal+=o_caltr;
	
	o_caltd = "";
	
	
	// Using image instead of Text
		
	o_caltd+="<td height='14' align='left' valign='top' colspan=7 ><img src='https://static.virginamerica.com/images/day_name.png' width="+innerCalW+" height='14' /></td>";		
	o_caltr = ty_maketr(o_caltd);
	o_caltd = "";
	
	o_cal+=o_caltr;
	
	o_caltd = "<td width='160' bgcolor='#e0e0e0' align='center' colspan=7><table width='158' border='0' cellpadding='0' cellspacing='0' align='center' style='background-color:#FFFFFF'>";	
	o_caltr = ty_maketr(o_caltd);
	
	o_cal+=o_caltr;
	
	o_caltd+="<td ><img src='https://static.virginamerica.com/images/spacer.gif'></td>";
	o_caltr = ty_maketr(o_caltd);
	o_cal+=o_caltr;
	o_caltd = "";
	i_calRows = 0;
	
	
	
	
	for (d=1;d<=newDs;d++){
		if(d==1)for(bd=0;bd < newD;bd++)o_caltd += "<td width='18' height='16' align='left' valign='top'><img src='https://static.virginamerica.com/images/spacer.gif' width='18' height='16' /></td>";
		o_caltd += ty_makeDate(d);
		
		countDay++;
		if(countDay==7){
			countDay=0;
			o_caltr = ty_maketr(o_caltd);
			o_cal+=o_caltr;
			o_caltd = "";
			i_calRows++
		}
		if(d==newDs && countDay!=0){
			for (bd=countDay;bd < 7;bd++) o_caltd += "<td width='18' height='16' align='left' valign='top' style='background-color:#FFFFFF'></td>";
			o_caltr = ty_maketr(o_caltd);
			o_cal+=o_caltr;			
			o_caltd ="";
			i_calRows++
		}
	}
	if(i_calRows < 6){
		for(calRow=1;calRow<(7-i_calRows);calRow++){
		o_caltd = "";
		for(bd=0;bd < 7;bd++)o_caltd += "<td width='18' height='6'  style='background-color:#FFFFFF'><img src='https://static.virginamerica.com/images/spacer.gif' width='18' height='16' /></td>";
		o_caltr = ty_maketr(o_caltd);
		o_cal+= o_caltr;
		}
	}
	
		o_cal+="</td></table>";
		
		o_caltd = "<td width="+innerCalW+" height='5' align='left' style='background-color:#e5e5e5;' colspan='7'><img src='https://static.virginamerica.com/images/calender_bt.png' width="+innerCalW+" height='5' /></td>";
		o_caltr = ty_maketr(o_caltd);
		o_cal+= o_caltr;
	
	
	if (i_numcal==0) {
		if (newM==cM&&newY==cY) {
			prev_cal=""
		}
		else
		{
			prev_cal="<a href='#' id='idcal1' onclick='"+s_jscall+"ty_changeMonths("+i_firstMonth+"-1);"+s_jscall+"preventClose(event);return false;'><img src='https://static.virginamerica.com/images/calender_prev.png' width='36' height='9' border='0' /></a>"
		}
	}
	
	o_calbody.innerHTML += o_cal;
	i_numcal++;
	
	if(i_numcal==numCalendars &&!b_date331) {
		next_cal="<a href='#' id='idcal2' onclick='"+s_jscall+"ty_changeMonths("+i_firstMonth+"+1);"+s_jscall+"preventClose(event);return false;'><img src='https://static.virginamerica.com/images/calender_nxt.png' width='36' height='9' border='0' /></a>"
	}else
	{
		next_cal="";
	}
		
	// for the months
	var monthtable1 = "<table width="+innerCalW+" border='0' cellspacing='0' cellpadding='0'>"
						+"<tr><td align='left' valign='top' width='5' height='17'><img src='https://static.virginamerica.com/images/spacer.gif' width='5' height='17' border='0' /></td>"
						+"<td width='16' align='left' valign='top'>";
	var monthtable2 = "</td><td width='5' align='center' valign='middle' class='style9'><img src='https://static.virginamerica.com/images/spacer.gif' width='5' height='17' border='0' /></td>"
						+"</tr></table>";
	
	if(i_numcal < numCalendars)
	{	
		o_calbody.innerHTML = o_calbody.innerHTML.replace("RWTCMT",changeTDTOTABLEValue);
		o_cal1=o_calbody.innerHTML;
		o_calbody.innerHTML = "";
	}
	else
	{
		o_calbody.innerHTML = o_calbody.innerHTML.replace("RWTCMT",changeTDTOTABLEValue);
		o_cal2=o_calbody.innerHTML;
		o_cal2 = o_cal2 + "</td></tr></table>";
		o_calbody.innerHTML = "";
		
	}
	
	if(i_numcal < numCalendars)
	{	
		makeCal(newM+1); 
		zzzz++;
		
	}
	else if (i_firstMonth > newM)
	{
		newY--;
	}
	if (zzzz%2 == 0) {
		o_calbody.innerHTML = s_closecal + tableOpen + o_cal1 + tdFor3rdCalTable + o_cal2  + tableCloseS + prev_cal + tableCloseM +next_cal +tableCloseL; 
		zzzz = 1;
	}

}

/*This function shows the calendar */
function openCalendar(v_input,s_from,s_to,s_cal,s_parent,s_mode,s_caldir, pos1, pos2, imageName){
calType="home";
flgDorR=imageName;
var imageClassName;
flgRetName=s_from;
var retLocalVar=s_from;
var dpDtStr="";
cM= today.getMonth();	
cY=today.getFullYear();
v_input.className = "";
if(document.flightSearchForm){
for(i=0;i<document.flightSearchForm.elements.length;i++){
	if(document.flightSearchForm.elements[i].name=="flightSearch.depDate.MMDDYYYY")
		dpDtStr=document.flightSearchForm.elements[i].value;
}
}

if(imageName=="return_date.png"){
	imageClassName="returnDate"
}else{
	imageClassName="departDate"
}

if(imageName=="return_date.png" || (retLocalVar=="flightSearch.returnDateMC.MMDDYYYY")){
	if(dpDtStr=="" ||dpDtStr=='mm/dd/yyyy'){
	
		i_ofirstMonth=new Date().getMonth();

		flgDateDisable=new Date();
		}else{
		flgDateDisable=new Date(dpDtStr);
		i_ofirstMonth=new Date(dpDtStr).getMonth();
		cM=i_ofirstMonth;
		cY=flgDateDisable.getFullYear();
	}
}
	
					if(isPCIE){
					s_closecal = "<table width='350' border='0' cellpadding='0' cellspacing='0'>"
					}else{
					s_closecal = "<table width='350' border='0' cellpadding='0' cellspacing='0' style='margin-left:-2px'>"
					}
					
					
		  s_closecal=s_closecal+"<tr><td width='280' height='31' align='left' valign='top' class='" + imageClassName+ "' ><img src='https://static.virginamerica.com/images/spacer.gif' width='280' height='31' /></td>"
					+"<td width='58' align='left' valign='top' class='closeCal' ><a href='#' id='idclose' onclick='"+s_jscall+"closeCal();return false;'><img src='https://static.virginamerica.com/images/spacer.gif' width='58' border='0' height='31'/></a></td>"
					+"<td width='14' align='left' valign='top' class='departDateRight'><img src='https://static.virginamerica.com/images/spacer.gif' width='14' height='31'/></td></tr>";	

	
	FieldClicked=v_input.name;
	displayImage = imageName;
	//if(o_parent) o_parent.className = "floatLeft cbrow";
	clearTimeout(t_calcloser);
	s_inputtype = typeof(v_input);
	a_v_input = null;
	calopen = 0;
	o_caldiv = document.getElementById(s_cal);
	o_caldiv.style.display = "block";
	o_caldiv.className = "calboxon";
	makeCalendar(v_input,s_from,s_to,s_mode);
	
	o_inputright = v_input; 
	o_parent = document.getElementById(s_parent);
	o_cal = document.getElementById(s_cal);
	//o_parent.className+=" datetext";
	i_calx = parseInt(o_inputright.offsetLeft)+parseInt(o_inputright.offsetWidth);
	i_caly = parseInt(o_parent.offsetTop)+(parseInt(o_parent.offsetHeight)/2)-(parseInt(o_cal.offsetHeight)/2);

	// setting calendar position 
	var top=parseInt(($('#BookFlightDiv').height()-209)/2);
	var divMargin=$('#BookFlightDiv').css('marginLeft');
	if(divMargin=='auto'){
		divMargin='0';
	}else{
		divMargin.replace(/px/,"");
	}
	var left=parseInt(($('#BookFlightDiv').width()-350)/2)+parseInt(divMargin)+20;

	o_cal.style.left = left+'px';
	o_cal.style.top = ($('#'+s_parent).offset().top-150)+'px';
	setTimeout("calopen = 1",100);

}
/* cal home end  */ 


function loadHomeHeadScripts(thisDate){

	document.write('<style type="text/css">.tabber{display:none;}<\/style>');
	s.pageName='Home Page';
	s.channel='Home';


	fixedConfiguratedDate=thisDate;

	$(document).ready(function() {
		MM_preloadImages('https://static.virginamerica.com/images/loadingBG.png','https://static.virginamerica.com/images/homeBgImage.png','https://static.virginamerica.com/images/rollOver.png','https://static.virginamerica.com/images/navDashBoard.png');
	});

}


function loadOrigins(Origin,Destination){
	var obj=$get_JsElement('flightSearchForm','flightSearch.origin');
	obj.value=Origin
	redirect(obj.selectedIndex);
	$get_JsElement('originFltOneMC').selectedIndex=obj.selectedIndex;
	
	obj=$get_JsElement('flightSearchForm','flightSearch.destination');
	obj.value=Destination;
	$get_JsElement('destinationFltOneMC').selectedIndex=obj.selectedIndex;
	
}

function loadMCOrigins(Origin,Destination){
	
	document.getElementById('originFltTwoMC').value=Origin;
	redirectMC(document.getElementById('originFltTwoMC').selectedIndex);
	document.getElementById('destinationFltTwoMC').value=Destination;
}


function loadHomeBottomScripts(elevateOrAcct,currentDivId){

	if(errorPresent){
		document.getElementById('ErrorMessage').style.display='block';
		//expandBookFlightWindow(true);
	}else{
		document.getElementById('ErrorMessage').style.display='none';
	}
	
	
	/*formTripType=document.flightSearchForm.elements['flightSearch.tripType'].value;
	changeTripType(formTripType);
	for(i=0;i<document.flightSearchForm.elements['flightSearch.tripType'].length;i++){
		if(formTripType==document.flightSearchForm.elements['flightSearch.tripType'][i].value)
			document.flightSearchForm.elements['flightSearch.tripType'][i].checked=true;
	}*/
	var radioObj=document.getElementsByName('flightSearch.tripType');	
	for(i=0;i<radioObj.length;i++){	
		if(radioObj[i].checked==true){
			changeTripType(radioObj[i].value);
			break;
	}
	}
		
	/* expand BookFlight */
	//expandBookFlightWindow();
	
	/* select Home Tag from Header and show current module at Home Page */
	selectedTag("home");
	$(document).ready(function() {	
		showHideDiv(currentDivId);
	});
	
	/* show Join Elevate for non-loggedIn member 
	 * for loggedIn members change Header value to My Account
	 */
	if(elevateOrAcct=='JoinElevate'){
		document.getElementById('joinOrAccount').innerHTML="<a href='/frequent-flyer/join-elevate.html'>Join Elevate</a>";
	}else{
		document.getElementById('joinOrAccount').innerHTML="<a href='signIn.do?method=homeProfileWithPagination'>My Account</a>";
	}
	
	/*to initialize Header*/
	var loadFunction=window.onload;
	window.onload=function(){
		if(loadFunction)
			loadFunction();
		intialiseHeader(thisDocID,deactivate);
	}
	
	//formTripType=null;

}


function originRTHome()
{
	for (i = 0; i < document.flightSearchForm.elements.length; i++)
	{
		elementName = document.flightSearchForm.elements[i].name;
		if (elementName == "flightSearch.origin" )
		{
			break;
		}
	}
}
/*This function implements the 'getCookie()' function*/
function loadDataFromCookiesHome(tripType) {
	for (j = 0; j < document.flightSearchForm.elements.length; j++){
		var obj = document.flightSearchForm.elements[j];
		if (obj.name == "flightSearch.origin" ){
			obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
		}else if(obj.name == "flightSearch.destination" ){
			obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
		}else if(obj.name == "flightSearch.adults" ){
			obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			if(obj.value !=null && obj.value.length >0){
				document.getElementById('adults').value=obj.value.trim();
				document.getElementById('adultsMC').value=obj.value.trim();
			}
		}else if(obj.name == "flightSearch.kids" ){
			obj.value = (getCookie (obj.name ) != null)?getCookie (obj.name):(obj.value);
			if(obj.value !=null && obj.value.length >0){
				document.getElementById('kids').value=obj.value;
				document.getElementById('kidsMC').value=obj.value;
			}
		}else if(obj.name == "flightSearch.infants" ){
			obj.value = (getCookie (obj.name ) != null)?getCookie (obj.name):(obj.value);
			if(obj.value !=null && obj.value.length >0){
				document.getElementById('infants').value=obj.value;
				document.getElementById('infantsMC').value=obj.value;
			}
		}else if (obj.name == "flightSearch.originMC" ){	
			obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			if(obj.value !=null && obj.value.length >0)
				document.getElementById('originFltTwoMC').value=obj.value;
		}else if(obj.name == "flightSearch.destinationMC" ){
			obj.value = (getCookie (obj.name) != null)?getCookie (obj.name):(obj.value);
			if(obj.value !=null && obj.value.length >0)
				document.getElementById('destinationFltTwoMC').value=obj.value;
		}
		if(tripType=="mc"){
			if(obj.name == "flightSearch.depDateMC.MMDDYYYY" ){
				obj.value = ((getCookie(obj.name) != null) && (Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie(obj.name):(obj.value);
			}else if(obj.name == "flightSearch.returnDateMC.MMDDYYYY" ){
				obj.value = ((getCookie(obj.name) != null) && (Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie("flightSearch.returnDate.MMDDYYYY"):(obj.value);
			}
		}
		else if(tripType=="mc" && obj.name == "flightSearch.depDateOW.MMDDYYYY" ){
			obj.value = ((getCookie(obj.name) != null) &&(Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie(obj.name):(obj.value);
		}else if(tripType=="rt"){
			if(obj.name == "flightSearch.depDate.MMDDYYYY" ){
				obj.value = ((getCookie(obj.name) != null) && (Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie(obj.name):(obj.value);
			}else if(obj.name == "flightSearch.returnDate.MMDDYYYY" ){
				obj.value = ((getCookie(obj.name) != null) && (Date.parse(getCookie(obj.name))>= (Date.parse(new Date())-24*60*60*1000)))?getCookie(obj.name):(obj.value);
			}
		}
	}	
		
	origin();
	Destination();
	updateDepDateInForm();
	updateRetDateInForm();
}

/*This function checks the value of a cookie & sets the tab*/
function loadDivForCookieHome(){
    

      if (getCookie("TT") == null || getCookie("TT") == '')
      {
            changeTripType('rt');
      }
      else
      {
    	  document.flightSearchForm.elements['flightSearch.tripType'].value=getCookie("TT");
    	  changeTripType(getCookie("TT"));
      }
}

function Destination(){
	if(currentTripType=='mc'){
		document.flightSearchForm.elements['flightSearch.destination'].selectedIndex=document.getElementById('destinationFltOneMC').selectedIndex;
	}else{
		document.getElementById('destinationFltOneMC').selectedIndex=document.flightSearchForm.elements['flightSearch.destination'].selectedIndex;	
	}
}
function origin(){
	if(currentTripType=='mc'){
		document.flightSearchForm.elements['flightSearch.origin'].selectedIndex=document.getElementById('originFltOneMC').selectedIndex;
		var destinationMC=document.getElementById('destinationFltTwoMC').value;
		document.getElementById('destinationFltTwoMC').value
		redirectMC(document.getElementById('originFltTwoMC').selectedIndex);
		document.getElementById('destinationFltTwoMC').value=destinationMC;
	}else{
		document.getElementById('originFltOneMC').selectedIndex=document.flightSearchForm.elements['flightSearch.origin'].selectedIndex;
	}
	var destination=document.flightSearchForm.elements['flightSearch.destination'].value;
	redirect(document.flightSearchForm.elements['flightSearch.origin'].selectedIndex);
	document.flightSearchForm.elements['flightSearch.destination'].value=destination;
	document.getElementById('destinationFltOneMC').value=destination;
	
}

function updateDepDateInForm(){
	if(currentTripType=='mc'){
		document.flightSearchForm.elements['flightSearch.depDate.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.depDateMC.MMDDYYYY'].value;
		document.flightSearchForm.elements['flightSearch.depDateOW.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.depDateMC.MMDDYYYY'].value;
	}else{
		document.flightSearchForm.elements['flightSearch.depDateMC.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.depDate.MMDDYYYY'].value;
		document.flightSearchForm.elements['flightSearch.depDateOW.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.depDate.MMDDYYYY'].value;
	}
}

function updateRetDateInForm(){
	if(currentTripType=='mc'){
		document.flightSearchForm.elements['flightSearch.returnDate.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.returnDateMC.MMDDYYYY'].value;
	}else{
		document.flightSearchForm.elements['flightSearch.returnDateMC.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.returnDate.MMDDYYYY'].value;	
	}
}
function closeDiv(divID){
	document.getElementById(divID).style.display='none';
}

function closeDashBoardDiv(div){
	document.getElementById(div+"Div").style.display='none';
	document.getElementById(div+"Img").style.display='none';
}

function showHomeLoader(divId){
	var top=parseInt(($('#'+divId).height()-$('#loadingAnimationDiv').height())/2)+132;
	var divMargin=$('#'+divId).css('marginLeft');
	if(divMargin=='auto'){
		divMargin='0';
	}else{
		divMargin.replace(/px/,"");
	}
	var left=parseInt(($('#'+divId).width()-$('#loadingAnimationDiv').width())/2)+parseInt(divMargin);
	document.getElementById('loadingAnimationDiv').style.marginTop=top+'px';
	document.getElementById('loadingAnimationDiv').style.marginLeft=left+'px';
	document.getElementById('loadingAnimationDiv').style.display='block';
}
var dropDownType='originDestination';

function updateDropDowns(selectobj, selectedVal){
		if($(selectobj).parent().attr('id')=='originDiv' || $(selectobj).attr('id')=='originFltOneMC'){
			redirect(selectobj.options.selectedIndex);
			refreshComboBox('destinationDiv');
			refreshComboBox('destinationFltOneMC');
			if($(selectobj).val()=='' && selectedVal.indexOf('Flight')==-1)
				$('#originFltOneMC').parent().find('a').empty().html("<b>Flight 1: </b>"+selectedVal);
			else
				$('#originFltOneMC').parent().find('a').empty().append(selectedVal);
			$('#originDiv').find('a').empty().append(selectedVal);
			if($(selectobj).attr('id')=='originFltOneMC'){
				$('#originDiv select').val($('#originFltOneMC').val());
			}else{
				$('#originFltOneMC').val($('#originDiv select').val())
			}
			//expandBookFlightWindow();
		}else if($(selectobj).attr('id')=='originFltTwoMC'){
			redirectMC(selectobj.options.selectedIndex);
			refreshComboBox('destinationFltTwoMC');
			if($(selectobj).val()=='' && selectedVal.indexOf('Flight')==-1)
				$('#originFltTwoMC').parent().find('a').empty().append("<b>Flight 2: </b>"+selectedVal);
			else
				$('#originFltTwoMC').parent().find('a').empty().append(selectedVal);
			//expandBookFlightWindow();
		}else if($(selectobj).attr('id')=='adults'){
			$('#adultsMC').val($(selectobj).val());
			$('#adultsMC').parent().find('a').empty().append($(selectobj).val());
		}else if($(selectobj).attr('id')=='adultsMC'){
			$('#adults').val($(selectobj).val());
			$('#adults').parent().find('a').empty().append($(selectobj).val());
		}else if($(selectobj).attr('id')=='kids'){
			$('#kidsMC').val($(selectobj).val());
			$('#kidsMC').parent().find('a').empty().append($(selectobj).val());
		}else if($(selectobj).attr('id')=='kidsMC'){
			$('#kids').val($(selectobj).val());
			$('#kids').parent().find('a').empty().append($(selectobj).val());
		}else if($(selectobj).attr('id')=='infants'){
			$('#infantsMC').val($(selectobj).val());
			$('#infantsMC').parent().find('a').empty().append($(selectobj).val());
		}else if($(selectobj).attr('id')=='infantsMC'){
			$('#infants').val($(selectobj).val());
			$('#infants').parent().find('a').empty().append($(selectobj).val());
		}else if($(selectobj).attr('name')=='flightStatus.origin'){
			changeFlightStatusDestinationFields(selectobj.options.selectedIndex,'To','home');
		}else if($(selectobj).parent().attr('id')=='destinationDiv' || $(selectobj).attr('id')=='destinationFltOneMC' || $(selectobj).attr('id')=='destinationFltTwoMC'){
			if($(selectobj).parent().attr('id')=='destinationDiv'){
				$('#destinationFltOneMC').parent().find('a').empty().append(selectedVal);
				$('#destinationFltOneMC').val($(selectobj).val());
			}else if($(selectobj).attr('id')=='destinationFltOneMC'){
				$('#destinationDiv').find('a').empty().append(selectedVal);
				$('#destinationDiv select').val($(selectobj).val());
			}
			//expandBookFlightWindow();
		}
}

function togglePromoCode(obj,divID){
    if(document.getElementById(divID).style.display=='block'){
    	document.getElementById(divID).style.display='none'
    	obj.src='https://static.virginamerica.com/images/rightArrow.gif';
    	obj.alt='Open';
    	obj.title='Open';
    }else{
    	document.getElementById(divID).style.display='block'
    	obj.src='https://static.virginamerica.com/images/downArrow.gif';
    	obj.alt='Close';
    	obj.title='Close';
    }
}

function setCookiesHome(){
	var i=0;
	var expiredays =30;
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	var mcDepDate2="";

		for (j = 0; j < document.flightSearchForm.elements.length; j++){
			var obj = document.flightSearchForm.elements[j];
			if (obj.name == "flightSearch.origin" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.destination" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.depDate.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.returnDate.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.depDateOW.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.depDateMC.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if (obj.name == "flightSearch.originMC" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.destinationMC" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.returnDateMC.MMDDYYYY" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.adults" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.kids" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}else if(obj.name == "flightSearch.infants" ){
				setCookie (obj.name, escape(obj.value), exdate);
			}
		}
}
/* This is onClick function of custom radio buttons */
function customRadioOnClick(obj){
	if($(obj).next("input").attr("name")=='flightSearch.tripType'){
		if($(obj).next("input").attr("value")!=currentTripType)
			clearSearchFormErrors();
		changeTripType($(obj).next("input").attr("value"));
		for(i=0;i<document.flightSearchForm.elements['flightSearch.tripType'].length;i++){
			if($(obj).next("input").attr("value")==document.flightSearchForm.elements['flightSearch.tripType'][i].value)
				document.flightSearchForm.elements['flightSearch.tripType'][i].checked=true;
		}
	}else{
		if($(obj).next("input").attr("value")=='Points'){
			$('#PopoupPointBetaAlert').css({marginTop:'100px',marginLeft:'100px'});
			$('#PopoupPointBetaAlert').show();
			$('#PromoCodeDiv').hide();
		}else{
			$('#PopoupPointBetaAlert').hide();
			$('#PromoCodeDiv').show();
		}
	}
}

function clearSearchFormErrors(){
	var els = document.getElementById('BookFlightDiv').getElementsByTagName("*");
	document.getElementById('ErrorMessage').style.display='none';
	for(var i=0,j=els.length; i<j; i++){
		if(els[i].className=='error')
			els[i].className='';
		else if(els[i].className!='ErrorMessage' && els[i].className.indexOf('Error')!=-1)
			els[i].className=els[i].className.substring(0,els[i].className.indexOf('Error'));
		else if(els[i].className.indexOf('errorLabel')!=-1)
			els[i].className=els[i].className.replace('errorLabel','');
	}
}
// Destination changes based on selected origin.
function redirect(x){
var destOpts=document.flightSearchForm.elements["flightSearch.destination"];
var destOptsMC=document.getElementById('destinationFltOneMC');
var selVal=document.flightSearchForm.elements["flightSearch.destination"].value;
var salValueFlg=0;
if(x!="0"){
	for (m=destOpts.options.length-1;m>0;m--)
	{
		destOpts.options[m]=null;
		if(destOptsMC)
		destOptsMC.options[m]=null;
	}
	for (i=0;i<group[x].length;i++){
		destOpts.options[i]=new Option(group[x][i].text,group[x][i].value);
		if(destOptsMC)
		destOptsMC.options[i]=new Option(group[x][i].text,group[x][i].value);
		if(group[x][i].value==selVal){
			salValueFlg=i;
		}
	}
	destOpts.options[salValueFlg].selected=true;
	if(destOptsMC)
	destOptsMC.options[salValueFlg].selected=true;
}
}
/* This function refresh the custom combobox */
function refreshComboBox(id){
	if(id!='destinationDiv'){
		$('#'+id).prev().remove();
		$('#'+id).prev().remove();
		$('#'+id).selectbox({debug: false});
	}else{
		$('#'+id+' a').remove();
		$('#'+id+' div').remove();
		$('#'+id+' select').selectbox({debug: false});
	}
}

function enableDisablePointsRadio(flag){
	$('#DisplayPriceDiv').find('input').each(function() {
		var boxtype=$(this).attr("type");
		if($(this).val()=='Points'){
			if(flag){
				$(this).prev('span').removeClass("cust_"+boxtype+"_on").removeClass("cust_"+boxtype+"_off").addClass("cust_"+boxtype+"_disabled_off").next("input").removeAttr("checked");
				//$(this).prev('span').addClass('cust_radio_disabled_off');
				$(this).attr('disabled', 'disabled');
			}else{
				$(this).prev('span').removeClass("cust_"+boxtype+"_disabled_off").addClass("cust_"+boxtype+"_off");
				//$(this).prev('span').addClass('cust_radio_disabled_off');
				$(this).attr('disabled', 'false');
			}
		}
	});
}
/* used to change trip type from the trip radio buttons */
function changeTripType(tripType){
	if(tripType=='mc'){
		document.getElementById('RoundTrip').style.display='none';
		document.getElementById('MultiCity').style.display='block';
		if(document.getElementById('MultiCityOption').style.display == 'none') {
			document.getElementById('BookExtraThingMulti').style.display='none';
		} else {
			document.getElementById('BookExtraThingMulti').style.display='block';
		}
		document.getElementById('BookFlightDiv').style.width='603px';
		document.getElementById('BookFlightDivTop').style.width='593px';
		document.getElementById('BookFlightDivBottom').style.width='593px';
		document.getElementById('bookFlightSpacer').style.height='13px';
	}else{
		document.getElementById('RoundTrip').style.display='block';
		document.getElementById('ReturnDateDiv').style.display='block';
		document.getElementById('MultiCity').style.display='none';
		document.getElementById('BookFlightDiv').style.width='485px';
		document.getElementById('BookFlightDivTop').style.width='475px';
		document.getElementById('BookFlightDivBottom').style.width='475px';
		document.getElementById('bookFlightSpacer').style.height='10px';
	}
	if(tripType=='ow'){
		document.getElementById('ReturnDateDiv').style.display='none';
	}
	currentTripType=tripType;
	setAdultAndInfants('mc',document.getElementById('adults').value,'adultsMC');
	//expandBookFlightWindow();
}

//Destination changes based on selected origin.
function redirectMC(x){
var destOptsMC=document.getElementById('destinationFltTwoMC');
var selValMC=document.getElementById('destinationFltTwoMC').value;
var salValueFlgMC=0;
if(x!="0"){
	for (m=destOptsMC.options.length-1;m>0;m--)
	{
		destOptsMC.options[m]=null;
	}
	for (i=0;i<group[x].length;i++){
		destOptsMC.options[i]=new Option(group[x][i].text,group[x][i].value);
		if(group[x][i].value==selValMC){
			salValueFlgMC=i;
		}
	}
	destOptsMC.options[salValueFlgMC].selected=true;
}}

//Destination changes based on selected origin.
function redirectMCD(x){
var tempMC1D=document.getElementById('originFltTwoMC');
var selValMCD=document.getElementById('originFltTwoMC').value;
var salValueFlgMCD=0;
if(x!="0"){
	for (m=tempMC1D.options.length-1;m>0;m--)
	{
		tempMC1D.options[m]=null;
	}
	for (i=0;i<groupMCD[x].length;i++){
		tempMC1D.options[i]=new Option(groupMCD[x][i].text,groupMCD[x][i].value);
		if(groupMCD[x][i].value==selValMCD){
			salValueFlgMCD=i;
		}
	}
	tempMC1D.options[salValueFlgMCD].selected=true;
}}
/* Expands book Flight tab if origin & destination are selected */
function expandBookFlightWindow(flag){
	var expand=false;
		if(currentTripType=='mc'){
			if(($('#originFltOneMC').val()!='' && $('#destinationFltOneMC').val()!='' && $('#originFltTwoMC').val()!='' && $('#destinationFltTwoMC').val()!='') || flag){
			expand=true;
			}
		}else{
			if(($('#originDiv select').val()!='' && $('#destinationDiv select').val()!='') || flag){
				expand=true;
			}
		}
		if(expand){
			$('#MultiCityOption').show();
			$('#RoundTripOption').show();	
			$('#PricePromoSearchDiv').show();
			if(currentTripType == 'mc') {
				$('#BookExtraThingMulti').show();
			}
			document.getElementById('bookFlightCollapseExpandBtn').className = 'collapse';
			//document.getElementById('bookFlightCollapseExpandBtn').onclick = expandBookFlightWindow;
			setCollapseOnClick();
		}
	
	if(document.getElementById('RoundTripOption').style.display = 'block') {
		if(document.getElementById('btnExpandBFW'))
			document.getElementById('btnExpandBFW').style.display = 'none';
	}
		
}
/* used to submit search form */
function submitSearchForm(){
	if(document.flightSearchForm.elements['flightSearch.returnDateMC.MMDDYYYY']){
		document.flightSearchForm.elements['flightSearch.returnDate.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.returnDateMC.MMDDYYYY'].value;
	}
	if(document.getElementById('originFltTwoMC')){
		document.flightSearchForm.elements['flightSearch.originMC'].value=document.getElementById('originFltTwoMC').value;
		document.flightSearchForm.elements['flightSearch.destinationMC'].value=document.getElementById('destinationFltTwoMC').value;
	}
	if(document.getElementById('adults'))
		document.flightSearchForm.elements['flightSearch.adults'].value=document.getElementById('adults').value;
	if(document.getElementById('kids'))
		document.flightSearchForm.elements['flightSearch.kids'].value=document.getElementById('kids').value;
	if(document.getElementById('infants'))
		document.flightSearchForm.elements['flightSearch.infants'].value=document.getElementById('infants').value;
	document.flightSearchForm.elements['flightSearch.depDateOW.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.depDate.MMDDYYYY'].value;

	if(currentTripType=='mc'){
		document.flightSearchForm.elements['flightSearch.origin'].value=document.getElementById('originFltOneMC').value;
		document.flightSearchForm.elements['flightSearch.destination'].value=document.getElementById('destinationFltOneMC').value;
		if(document.getElementById('adultsMC'))
			document.flightSearchForm.elements['flightSearch.adults'].value=document.getElementById('adultsMC').value;
		if(document.getElementById('kidsMC'))
			document.flightSearchForm.elements['flightSearch.kids'].value=document.getElementById('kidsMC').value;
		if(document.getElementById('infantsMC'))
			document.flightSearchForm.elements['flightSearch.infants'].value=document.getElementById('infantsMC').value;
		}
	var modifySearch=false;
	if(!document.flightSearchForm.elements['divName'] || document.flightSearchForm.elements['divName'].value!='BookFlight'){
		modifySearch=true;			
	}
	//if(document.getElementById('titleBarDiv'))
		//updateTitileBar("updateTitleBar.do?method=updateTitleBar&atHome=atHome","titleBarDiv");
		var dt=(new Date().getMonth()+1)+"/"+new Date().getDate()+"/"+(new Date().getYear()+1900);
		var dt1=(new Date().getMonth()+1)+"/"+new Date().getDate()+"/"+(new Date().getYear());
		var depDateStr=document.flightSearchForm.elements['flightSearch.depDate.MMDDYYYY'].value;
		//document.flightSearchForm.elements['flightSearch.returnDate.MMDDYYYY'].value=document.flightSearchForm.elements['flightSearch.returnDateMC.MMDDYYYY'].value
		var retDateStr=document.flightSearchForm.elements['flightSearch.returnDate.MMDDYYYY'].value
		if(currentTripType=='ow'){
			retDateStr='';
			if(document.flightSearchForm.elements['flightSearch.returnDate.MMDDYYYY'])
			document.flightSearchForm.elements['flightSearch.returnDate.MMDDYYYY'].value='';
		}
		var depDate=new Date(depDateStr);
		var retDate=new Date(retDateStr);
		FrmToSubmit=document.flightSearchForm;
		//for cookie
		var expiredays =30;
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		
		if(modifySearch)
		{
			if(getCookie("TT")==null || getCookie("TT")=='')
	        {   
        setCookie ("TT", currentTripType, exdate);
	        }
		}
		else
		{
			setCookie ("TT", currentTripType, exdate);
		}

        setCookiesHome();//call function for setting cookies.
        $('#formatMessage').css({top:($('#SearchFlight').offset().top-245)+'px',left:(($('#BookFlightDiv').width()-$('#formatMessage').width())/2)+'px'});
		if (isValidDate(depDateStr) && isValidDate(retDateStr)) {
			
			if((((depDateStr+"")==(dt+"") && (retDateStr+"")==(dt+"")) || ((depDateStr+"")==(dt1+"") && (retDateStr+"")==(dt1+"")))&& (depDateStr+"")!="mm/dd/yyyy" && (depDateStr+"")!=""){
				//This block will be changed by the popup window not message alert;
				flgMsg=false;
				// for same Day flight message show
				if(modifySearch){
					$('#SameDayFlightsMessageId').css({top:($('#btnModifySearch').offset().top)+'px',left:($('#btnModifySearch').offset().left-60)+'px'});
				}else{
					$('#SameDayFlightsMessageId').css({top:($('#SearchFlight').offset().top-245)+'px',left:(($('#BookFlightDiv').width()-$('#SameDayFlightsMessageId').width())/2)+'px'});
				}
				document.getElementById('SameDayFlightsMessageId').style.display="block";
				document.getElementById('sameDayContinueId').focus();
			}else if(((depDateStr+"")==(retDateStr+"")) && (retDateStr+"")!=(dt+"") && (depDateStr+"")!="mm/dd/yyyy" && (depDateStr+"")!=""){
				//This block will be changed by the popup window not message alert;
				flgMsg=true;
				// same Day flight message show
				if(modifySearch){
					$('#SameDayFlightsMessageId').css({top:($('#btnModifySearch').offset().top)+'px',left:($('#btnModifySearch').offset().left-60)+'px'});
				}else{
					$('#SameDayFlightsMessageId').css({top:($('#SearchFlight').offset().top-245)+'px',left:(($('#BookFlightDiv').width()-$('#SameDayFlightsMessageId').width())/2)+'px'});
				}
				document.getElementById('SameDayFlightsMessageId').style.display="block";
				document.getElementById('sameDayContinueId').focus();
				//decision("a",frm);
			}else if((((depDateStr+"")==(dt+"") && (retDateStr+"")!=(dt+"")) || ((depDateStr+"")==(dt1+"") && (retDateStr+"")!=(dt1+"")))&& (depDateStr+"")!="mm/dd/yyyy" && (depDateStr+"")!=""){
				//This block will be changed by the popup window not message alert;
				flgMsg=false;
				if(modifySearch){
					$('#message').css({top:($('#btnModifySearch').offset().top)+'px',left:($('#btnModifySearch').offset().left-60)+'px'});
				}else{
					$('#message').css({top:($('#SearchFlight').offset().top-245)+'px',left:(($('#BookFlightDiv').width()-$('#message').width())/2)+'px'});
				}
				document.getElementById("message").style.display="block";
				document.getElementById('timePopUp').focus();
			}else if((((depDateStr+"")!=(dt+"") && (retDateStr+"")==(dt+"")) || ((depDateStr+"")!=(dt1+"") && (retDateStr+"")==(dt1+"")))&& (depDateStr+"")!="mm/dd/yyyy" && (depDateStr+"")!=""){
				//This block will be changed by the popup window not message alert;
				flgMsg=false;
				if(modifySearch){
					$('#message').css({top:($('#btnModifySearch').offset().top)+'px',left:($('#btnModifySearch').offset().left-60)+'px'});
				}else{
					$('#message').css({top:($('#SearchFlight').offset().top-245)+'px',left:(($('#BookFlightDiv').width()-$('#message').width())/2)+'px'});
				}
				document.getElementById('message').style.display="block";
				document.getElementById('timePopUp').focus();
			}else{	
				document.flightSearchForm.submit();
				if(isPCIE == false) {setLoadingAniDivLocation();}
				showWaitImage();
				//if(document.flightSearchForm.elements['divName'] && document.flightSearchForm.elements['divName'].value=='BookFlight'){
					//showHomeLoader('BookFlightDiv');
					//showWaitImage();
				//}else{
					//setPosition(document.getElementById("btnModifySearch"), document.getElementById("loadingDiv"), -40, -20);
					/*$('#loadingDiv').css({top:($('#btnModifySearch').offset().top-30)+'px',left:(($('#btnModifySearch').offset().left+10))+'px'});
					document.getElementById("loadingDiv").style.display="block";*/
					//showWaitImage();
				//}
		
		}
	}
}
function sameDayMessageClose(closeType){
	if(closeType=='true') {
		if(flgMsg){
			FrmToSubmit.submit();
			//showHomeLoader('BookFlightDiv');
			showWaitImage();
		} else {
			document.getElementById('SameDayFlightsMessageId').style.display="none";
			if(document.flightSearchForm){
				if(document.flightSearchForm.elements['divName'] && document.flightSearchForm.elements['divName'].value=='BookFlight'){
					$('#message').css({top:($('#SearchFlight').offset().top-245)+'px',left:(($('#BookFlightDiv').width()-$('#message').width())/2)+'px'});
				} else {
					$('#message').css({top:($('#btnModifySearch').offset().top)+'px',left:($('#btnModifySearch').offset().left-60)+'px'});
				}
			} else if(document.getElementById('btnSearchFlights')){
				$('#message').css({top:($('#btnSearchFlights').offset().top)+'px',left:($('#btnSearchFlights').offset().left-60)+'px'});
			}
			document.getElementById('message').style.top = '200px';
			document.getElementById('message').style.left = '46%';
			document.getElementById('message').style.display="block";
			document.getElementById('timePopUp').focus();
		}
		document.getElementById('SameDayFlightsMessageId').style.display="none";
	} else {
		document.getElementById('message').style.display="none";
		document.getElementById('SameDayFlightsMessageId').style.display="none";
	}
		
}
/* returns all elements of given node having specified class name, if no node is given it returns all elements found in document body */
function getElementsByClassName(classname, node) {
	if(!node) node = document.getElementsByTagName("body")[0];
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for(var i=0,j=els.length; i<j; i++)
	if(re.test(els[i].className))a.push(els[i]);
	return a;
}

function openConfirmationCodePopUpHome(){
	document.getElementById('locateConfirmationDivId').style.top=($('#locate').offset().top+15)+'px';
	document.getElementById('locateConfirmationDivId').style.left=($('#locate').offset().left-150)+'px';
	document.getElementById('locateConfirmationDivId').style.display='block';
}

//CSS HACK CODE
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' '+s+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

//code for image-gallery

var imageGallery = function(){
	var c=0;
	var page=1;
	var idArr=new Array(['A',65],['B',205],['C',355]);
	var pageFlag='true';
	var x=0;
	var cval=.9;
	var ival=100;
	var arg=null;
	var thisObj=null;
	var tempPath=null;
	var vaXML={
		loadXML:function(xmlFile){
			xmlhttp.open("GET", xmlFile, false);  
		    xmlhttp.send('');  
		    xmlDoc=xmlhttp.responseXML;
			
		},
		
		createObjs: function(){
			xmlObj= xmlDoc.documentElement;
			container.createContainer('ulId');
		}
	};
	
	
	var container={
		createContainer:function(ulId){
			var imgPath=null;var imgName=null;
			var ulObj=document.createElement('ul');
			var imgContainer=null;
		ulObj.setAttribute('id',ulId);

		totalImages = xmlObj.getElementsByTagName('image').length;
		
		for(i=0;i<totalImages;i++){
			if(totalImages%3!=0)totalImages=totalImages+1;
			if(totalImages%3==0){totalPages=totalImages/3;break;}
			
		}

		pageArr=new Array(totalPages);
		
		for(k=0;k<2;k++){
			for(i=0;i<totalPages;i++){
				if(!pageArr[i])pageArr[i]=new Array(2);
				
				if(k==0)pageArr[i][k]=i+1;
				if(k==1){
					if(i==0)pageArr[i][k]=i;
					else pageArr[i][k]=3*i;
				}
				
			}
		}
	
		for(n=0;n<totalImages;n++){
			var liObj=document.createElement('li');
			var smallImgEl=null;
			
			
				slidespeed= xmlObj.getElementsByTagName("slidespeed")[0].firstChild.nodeValue;
				
				var pathInfo =  xmlObj.getElementsByTagName("pathinfo")[0];
				var imageEl =  xmlObj.getElementsByTagName('image')[n];
		
			if(imageEl){
				smallImgEl=imageEl.firstChild;
				imgName=smallImgEl.firstChild.nodeValue;    //return Image name
					
			}else{
				imgName = "whiteSeat_view.png";
			}
				
				imgPath = pathInfo.getAttribute('smallimgpath');
				larImgPath = pathInfo.getAttribute('largeimgpath');
				hiResImgPath = pathInfo.getAttribute('hiresimgpath');
				
				
			var imgObj= image.createImageObj(imgPath,imgName,n);
			if(imageEl)
				imgContainer=image.createImgContainer(imgObj,imgPath,hiResImgPath,imgName,smallImgEl.getAttribute('size'),imageEl.childNodes[1].getAttribute('size'));
			else
				imgContainer=image.createImgContainer(imgObj,imgPath,larImgPath,imgName,"undefined");
				
				if(imageEl)
				liObj.appendChild(imgContainer);
				
			if(n<3){
		 		liObj.setAttribute('class','inlineCss');liObj.setAttribute('className','inlineCss');}
			else{
				liObj.setAttribute('class','noneCss');liObj.setAttribute('className','noneCss');}
		
				ulObj.appendChild(liObj);
				
		}//end of for
		
		$get_JsElement('imgGallery').appendChild(ulObj);
		
		ulobj=$get_JsElement('ulId');
		$get_JsElement('displayPage').innerHTML="Displaying: "+page+" of "+totalPages;
		
		}
	
	};

	var image={
		index:function(){
			if(thisObj.id==idArr[0][0])
				return (page*3-3);
			if(thisObj.id==idArr[1][0])
				return (page*3-2);
			if(thisObj.id==idArr[2][0])
				return (page*3-1);
			 
			
		},
		writeMsg:function(){
			msg =  xmlObj.getElementsByTagName('image')[image.index()].lastChild.firstChild.nodeValue;
			$get_JsElement('seatMsg').innerHTML=msg;
		},
		createImageObj:function(imgPath,imgName,nval){
			var img=document.createElement('img');
				img.setAttribute('src',imgPath+imgName);
			
			if(nval==0){
				img.setAttribute('class','selected');
				img.setAttribute('className','selected');
			}else{
				img.setAttribute('class','unselected');
				img.setAttribute('className','unselected');
			}
			if(nval<3)
				img.setAttribute('id',idArr[nval][0]);
		return img;
		},
		
		createImgContainer:function(imgObj,smallImgPath,hiResImgPath,imgName,imgSize,imgSizeBig){
			var s="";
			var divmain=document.createElement('div');
				divmain.setAttribute('class','imgGalleryThumbnail');
				divmain.setAttribute('className','imgGalleryThumbnail');
				
			var divinner=document.createElement('div');
				divinner.setAttribute('class','podBodyBg');
				divinner.setAttribute('className','podBodyBg');
				
			var h4El=document.createElement('h4');
			var h4Text=document.createTextNode('Download');
				h4El.appendChild(h4Text);
			
			var pEl=document.createElement('p');
			var aEl=document.createElement('a');
				//s="downloadFile.jsp?path="+smallImgPath+"&fileName="+imgName
				//s=smallImgPath+imgName;
				s=smallImgPath+imgName;
					aEl.setAttribute('href',s);
				aEl.setAttribute('target','_blank');
			var aText=document.createTextNode('Small');
				aEl.appendChild(aText);
				pEl.appendChild(aEl);
			
			var spanEl=document.createElement('span');
			var spanText=document.createTextNode(imgSize);
				//removing image sizes
				//spanEl.appendChild(spanText);
				pEl.appendChild(spanEl);
				
		if (imgObj.addEventListener)
		{
			    imgObj.addEventListener('click', imageGallery.fadeInEffect, false);
		}else {
				imgObj.onclick=new Function("imageGallery.fadeInEffect(event);");
		}
				divinner.appendChild(imgObj);
				divinner.appendChild(h4El);
				divinner.appendChild(pEl);
				
				pEl=document.createElement('p');
				aEl=document.createElement('a');
				//Making a separate link to download hi-res images
				//s="downloadFile.jsp?path="+bigImgPath+"&fileName="+imgName
				//s="downloadFile.jsp?path="+hiResImgPath+"&fileName="+imgName
				s=hiResImgPath+imgName;
				aEl.setAttribute('href',s);
				aEl.setAttribute('target','_blank');
					
				aText=document.createTextNode('Large');
				aEl.appendChild(aText);
				pEl.appendChild(aEl);
				
				spanEl=document.createElement('span');
				spanText=document.createTextNode(imgSizeBig);
				//removing image sizes
				//spanEl.appendChild(spanText);
				pEl.appendChild(spanEl);
				
				divinner.appendChild(pEl);
				divmain.appendChild(divinner);
		
			return divmain;
		
		}
	};
	
	var move={
		Left:function (){
		if(page!=totalPages){
			if(pageFlag=='true' && page==pageArr[page-1][0])
			{	c=pageArr[page-1][1];pageFlag='false';x=0;
				imageGallery.setBorderWhite();
			}
		
				c=c+1;
				liobj=ulobj.getElementsByTagName('li')[c-1];
				liobj.firstChild.firstChild.firstChild.id='';
				liobj.style.display='none'
		
				liobj=ulobj.getElementsByTagName('li')[c+2];
			if(liobj.firstChild)//for blank image
				liobj.firstChild.firstChild.firstChild.id=idArr[x][0]
				liobj.style.display='inline';
				
				x=x+1;
				t=setTimeout("imageGallery.moveLeft()",slidespeed);
		
			if(c%3==0){
				page=page+1;pageFlag='true';
				move.Stop();
				$get_JsElement('A').className='selected'
				imageGallery.moveArrow($get_JsElement('A'));
				imageGallery.fadeInEffect($get_JsElement('A'));
			}
		
			$get_JsElement('displayPage').innerHTML="Displaying: "+page+" of "+totalPages;
		}
		
		},
		
		Right:function(){ 
		if(page!=1){
			if(pageFlag=='true' && page==pageArr[page-1][0])
			{	c=pageArr[page-1][1];pageFlag='false';x=2
			 	imageGallery.setBorderWhite();
			}
		
				liobj=ulobj.getElementsByTagName('li')[c+2];
			if(liobj.firstChild) //for blank image
				liobj.firstChild.firstChild.firstChild.id='';
				liobj.style.display='none'
				
				liobj=ulobj.getElementsByTagName('li')[c-1];
				liobj.firstChild.firstChild.firstChild.id=idArr[x][0]
				liobj.style.display='inline'
				
				c=c-1;x=x-1;
				t=setTimeout("imageGallery.moveRight()",slidespeed);
		
			if(c==0 || c%3==0){
				page=page-1;pageFlag='true';x=0;
				move.Stop();
				document.getElementById('A').className='selected'
				imageGallery.moveArrow($get_JsElement('A'));
				imageGallery.fadeInEffect($get_JsElement('A'));
			}
		
			$get_JsElement('displayPage').innerHTML="Displaying: "+page+" of "+totalPages;
		}
		},
		
		Stop:function(){
			clearTimeout(t);
		}
	};

	var fade={
		InEffect:function(){
			if(cval==.9 || ival==100){
				if(arg.srcElement)
					thisObj=arg.srcElement;
				else
					thisObj=arg.target;
				
				if(thisObj==null)thisObj=arg;
				$get_JsElement('imgMsg').style.display='none';
				tempPath=larImgPath+(thisObj.src).substring((thisObj.src).lastIndexOf("/")+1,(thisObj.src).length);
				imageGallery.moveArrow(thisObj);	
				
				
			}
			largeImgObj.style.opacity=cval;largeImgObj.style.filter="alpha(opacity="+ival+")";
			cval=cval-.08;ival=ival-8;
			r=setTimeout("imageGallery.fadeInEffect()",25);
			
			if(cval<.1 || ival<10){
				largeImgObj.style.opacity=.03;largeImgObj.style.filter="alpha(opacity=.3)";
				cval=0;
				ival=0;
				fade.Stop();
				$get_JsElement('loadingImage').style.display='block';
				setTimeout("imageGallery.insertImg()",0);
			}
	   },

		OutEffect:function(){
			$get_JsElement('loadingImage').style.display='none';
			largeImgObj.style.opacity=cval;
			
			largeImgObj.style.filter="alpha(opacity="+ival+")";
			cval=cval+.05;ival=ival+5;
			r=setTimeout("imageGallery.fadeOutEffect()",15);
			if(cval>.8 || ival>80){
				largeImgObj.style.opacity=1;
				largeImgObj.style.filter="alpha(opacity=100)";
				cval=.9;ival=100;
				fade.Stop();
				image.writeMsg();
				$get_JsElement('imgMsg').style.display='block';
			}
		},
		
		Stop:function(){
			clearTimeout(r);
		}
	};


	var vaIMG={
		loadIMG:function(imgPath){
				try{
					
					var url="dummy.jsp?imgPath="+imgPath;
					xmlhttp.open("GET", url, false);  
				    xmlhttp.send(null);  
				    xmlhttp.onreadystatechange=vaIMG.insertImg(imgPath);
				}catch(e){}
		},
		
		insertImg: function(imgPath){
			if (xmlhttp.readyState == 4) { // Complete
      			if (xmlhttp.status == 200) {
      				$get_JsElement('imgParentNode').innerHTML=xmlhttp.responseText.trim();
      				largeImgObj.src=$get_JsElement('largeImgIdTemp').src
      				imageGallery.fadeOutEffect();
      			}
      		}
		}
	};
	

	return {
		init: function(xmlFile)
		{ 
			vaXML.loadXML(xmlFile);
			vaXML.createObjs();
			largeImgObj=$get_JsElement('largeImgId');
		},
		
		setBorderWhite:function(){
			if($get_JsElement('A'))
				  $get_JsElement('A').className='unselected';
			if($get_JsElement('B'))
				  $get_JsElement('B').className='unselected';
			if($get_JsElement('C'))
				  $get_JsElement('C').className='unselected';
		},
		
		fadeInEffect:function(){
			if(arg==null || arg!=arguments[0]){arg=arguments[0]};
			fade.InEffect();
		},
		
		fadeOutEffect:function(){
			fade.OutEffect();
		},
		moveArrow:function(imgObj){
			var imgArrObj=$get_JsElement('imgArr')
			imageGallery.setBorderWhite();
		
			if(imgObj.id=='A')imgArrObj.style.marginLeft=idArr[0][1]+'px'
			if(imgObj.id=='B')imgArrObj.style.marginLeft=idArr[1][1]+'px'
			if(imgObj.id=='C')imgArrObj.style.marginLeft=idArr[2][1]+'px'
			
			
			imgObj.className='selected';
			
		},
		
		moveLeft:function(){
			move.Left();
		},
		
		moveRight:function(){
			move.Right();
		},
		
		insertImg:function(){
			vaIMG.loadIMG(tempPath);
		}		
	};
}();

//end code for image-gallery

function changeAirportInfoPage(airport){
	showWaitImage();
	if(airport=='SFO') {window.location.href='san-francisco-sfo.html';}
	else if(airport=='BOS') {window.location.href='logan-bos.html';}
	else if(airport=='CUN') {window.location.href='cancun-mexico-cun.html';}
	else if(airport=='ORD') {window.location.href='chicago-ord.html';}
	else if(airport=='DFW') {window.location.href='dallas-fort-worth-dfw.html';}
	else if(airport=='FLL') {window.location.href='fort-lauderdale-fll.html';}
	else if(airport=='LAS') {window.location.href='las-vegas.html';}
	else if(airport=='LAX') {window.location.href='los-angeles-lax.html';}
	else if(airport=='SJD') {window.location.href='los-cabos-sjd.html';}
	else if(airport=='JFK') {window.location.href='new-york-jfk.html';}
	else if(airport=='MCO') {window.location.href='orlando-mco.html';}
	else if(airport=='PSP') {window.location.href='palm-springs-psp.html';}
	else if(airport=='PHL') {window.location.href='philadelphia-phl.html';}
	else if(airport=='PVR') {window.location.href='puerto-vallarta-pvr.html';}
	else if(airport=='SAN') {window.location.href='san-diego-san.html';}
	else if(airport=='SEA') {window.location.href='seattle-sea.html';}
	else if(airport=='IAD') {window.location.href='dulles-iad.html';}	
	else {window.location.href='airportinformation.html';}
	//'airportinfo.do?pageName=airportinformation'+airport+'&rightBar=airportinformation_right_bar';
	/*setObjOffset($get_JsElement("infoDeskDestinationValue"),$get_JsElement("loadingAnimationDiv"),100,-25);
	$get_JsElement('loadingAnimationDiv').style.display='block';*/
}

//function to set links in footer as selected
var setLinkSelected=function(pageName){
	if($get_JsElement(pageName))
		$get_JsElement(pageName).className='selected';
	
		if($get_JsElement(pageName+"Footer"))
			$get_JsElement(pageName+"Footer").className='selected';
	
};


/*!
 * jQuery JavaScript Library v1.5.1
 * http://jquery.com/
 *
 * Copyright 2011, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2011, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Wed Feb 23 13:55:29 2011 -0500
 */
(function(a,b){function cg(a){return d.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cd(a){if(!bZ[a]){var b=d("<"+a+">").appendTo("body"),c=b.css("display");b.remove();if(c==="none"||c==="")c="block";bZ[a]=c}return bZ[a]}function cc(a,b){var c={};d.each(cb.concat.apply([],cb.slice(0,b)),function(){c[this]=a});return c}function bY(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function bX(){try{return new a.XMLHttpRequest}catch(b){}}function bW(){d(a).unload(function(){for(var a in bU)bU[a](0,1)})}function bQ(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var e=a.dataTypes,f={},g,h,i=e.length,j,k=e[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h==="string"&&(f[h.toLowerCase()]=a.converters[h]);l=k,k=e[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=f[m]||f["* "+k];if(!n){p=b;for(o in f){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=f[j[1]+" "+k];if(p){o=f[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&d.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function bP(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function bO(a,b,c,e){if(d.isArray(b)&&b.length)d.each(b,function(b,f){c||bq.test(a)?e(a,f):bO(a+"["+(typeof f==="object"||d.isArray(f)?b:"")+"]",f,c,e)});else if(c||b==null||typeof b!=="object")e(a,b);else if(d.isArray(b)||d.isEmptyObject(b))e(a,"");else for(var f in b)bO(a+"["+f+"]",b[f],c,e)}function bN(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bH,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l==="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bN(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bN(a,c,d,e,"*",g));return l}function bM(a){return function(b,c){typeof b!=="string"&&(c=b,b="*");if(d.isFunction(c)){var e=b.toLowerCase().split(bB),f=0,g=e.length,h,i,j;for(;f<g;f++)h=e[f],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bo(a,b,c){var e=b==="width"?bi:bj,f=b==="width"?a.offsetWidth:a.offsetHeight;if(c==="border")return f;d.each(e,function(){c||(f-=parseFloat(d.css(a,"padding"+this))||0),c==="margin"?f+=parseFloat(d.css(a,"margin"+this))||0:f-=parseFloat(d.css(a,"border"+this+"Width"))||0});return f}function ba(a,b){b.src?d.ajax({url:b.src,async:!1,dataType:"script"}):d.globalEval(b.text||b.textContent||b.innerHTML||""),b.parentNode&&b.parentNode.removeChild(b)}function _(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function $(a,b){if(b.nodeType===1){var c=b.nodeName.toLowerCase();b.clearAttributes(),b.mergeAttributes(a);if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(d.expando)}}function Z(a,b){if(b.nodeType===1&&d.hasData(a)){var c=d.expando,e=d.data(a),f=d.data(b,e);if(e=e[c]){var g=e.events;f=f[c]=d.extend({},e);if(g){delete f.handle,f.events={};for(var h in g)for(var i=0,j=g[h].length;i<j;i++)d.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function Y(a,b){return d.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function O(a,b,c){if(d.isFunction(b))return d.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return d.grep(a,function(a,d){return a===b===c});if(typeof b==="string"){var e=d.grep(a,function(a){return a.nodeType===1});if(J.test(b))return d.filter(b,e,!c);b=d.filter(b,e)}return d.grep(a,function(a,e){return d.inArray(a,b)>=0===c})}function N(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function F(a,b){return(a&&a!=="*"?a+".":"")+b.replace(r,"`").replace(s,"&")}function E(a){var b,c,e,f,g,h,i,j,k,l,m,n,o,q=[],r=[],s=d._data(this,"events");if(a.liveFired!==this&&s&&s.live&&!a.target.disabled&&(!a.button||a.type!=="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var t=s.live.slice(0);for(i=0;i<t.length;i++)g=t[i],g.origType.replace(p,"")===a.type?r.push(g.selector):t.splice(i--,1);f=d(a.target).closest(r,a.currentTarget);for(j=0,k=f.length;j<k;j++){m=f[j];for(i=0;i<t.length;i++){g=t[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,e=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,e=d(a.relatedTarget).closest(g.selector)[0];(!e||e!==h)&&q.push({elem:h,handleObj:g,level:m.level})}}}for(j=0,k=q.length;j<k;j++){f=q[j];if(c&&f.level>c)break;a.currentTarget=f.elem,a.data=f.handleObj.data,a.handleObj=f.handleObj,o=f.handleObj.origHandler.apply(f.elem,arguments);if(o===!1||a.isPropagationStopped()){c=f.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function C(a,c,e){var f=d.extend({},e[0]);f.type=a,f.originalEvent={},f.liveFired=b,d.event.handle.call(c,f),f.isDefaultPrevented()&&e[0].preventDefault()}function w(){return!0}function v(){return!1}function g(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function f(a,c,f){if(f===b&&a.nodeType===1){f=a.getAttribute("data-"+c);if(typeof f==="string"){try{f=f==="true"?!0:f==="false"?!1:f==="null"?null:d.isNaN(f)?e.test(f)?d.parseJSON(f):f:parseFloat(f)}catch(g){}d.data(a,c,f)}else f=b}return f}var c=a.document,d=function(){function I(){if(!d.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(I,1);return}d.ready()}}var d=function(a,b){return new d.fn.init(a,b,g)},e=a.jQuery,f=a.$,g,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,i=/\S/,j=/^\s+/,k=/\s+$/,l=/\d/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=navigator.userAgent,w,x=!1,y,z="then done fail isResolved isRejected promise".split(" "),A,B=Object.prototype.toString,C=Object.prototype.hasOwnProperty,D=Array.prototype.push,E=Array.prototype.slice,F=String.prototype.trim,G=Array.prototype.indexOf,H={};d.fn=d.prototype={constructor:d,init:function(a,e,f){var g,i,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!e&&c.body){this.context=c,this[0]=c.body,this.selector="body",this.length=1;return this}if(typeof a==="string"){g=h.exec(a);if(!g||!g[1]&&e)return!e||e.jquery?(e||f).find(a):this.constructor(e).find(a);if(g[1]){e=e instanceof d?e[0]:e,k=e?e.ownerDocument||e:c,j=m.exec(a),j?d.isPlainObject(e)?(a=[c.createElement(j[1])],d.fn.attr.call(a,e,!0)):a=[k.createElement(j[1])]:(j=d.buildFragment([g[1]],[k]),a=(j.cacheable?d.clone(j.fragment):j.fragment).childNodes);return d.merge(this,a)}i=c.getElementById(g[2]);if(i&&i.parentNode){if(i.id!==g[2])return f.find(a);this.length=1,this[0]=i}this.context=c,this.selector=a;return this}if(d.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return d.makeArray(a,this)},selector:"",jquery:"1.5.1",length:0,size:function(){return this.length},toArray:function(){return E.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var e=this.constructor();d.isArray(a)?D.apply(e,a):d.merge(e,a),e.prevObject=this,e.context=this.context,b==="find"?e.selector=this.selector+(this.selector?" ":"")+c:b&&(e.selector=this.selector+"."+b+"("+c+")");return e},each:function(a,b){return d.each(this,a,b)},ready:function(a){d.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(E.apply(this,arguments),"slice",E.call(arguments).join(","))},map:function(a){return this.pushStack(d.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:D,sort:[].sort,splice:[].splice},d.fn.init.prototype=d.fn,d.extend=d.fn.extend=function(){var a,c,e,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i==="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!=="object"&&!d.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){e=i[c],f=a[c];if(i===f)continue;l&&f&&(d.isPlainObject(f)||(g=d.isArray(f)))?(g?(g=!1,h=e&&d.isArray(e)?e:[]):h=e&&d.isPlainObject(e)?e:{},i[c]=d.extend(l,h,f)):f!==b&&(i[c]=f)}return i},d.extend({noConflict:function(b){a.$=f,b&&(a.jQuery=e);return d},isReady:!1,readyWait:1,ready:function(a){a===!0&&d.readyWait--;if(!d.readyWait||a!==!0&&!d.isReady){if(!c.body)return setTimeout(d.ready,1);d.isReady=!0;if(a!==!0&&--d.readyWait>0)return;y.resolveWith(c,[d]),d.fn.trigger&&d(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!x){x=!0;if(c.readyState==="complete")return setTimeout(d.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",A,!1),a.addEventListener("load",d.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",A),a.attachEvent("onload",d.ready);var b=!1;try{b=a.frameElement==null}catch(e){}c.documentElement.doScroll&&b&&I()}}},isFunction:function(a){return d.type(a)==="function"},isArray:Array.isArray||function(a){return d.type(a)==="array"},isWindow:function(a){return a&&typeof a==="object"&&"setInterval"in a},isNaN:function(a){return a==null||!l.test(a)||isNaN(a)},type:function(a){return a==null?String(a):H[B.call(a)]||"object"},isPlainObject:function(a){if(!a||d.type(a)!=="object"||a.nodeType||d.isWindow(a))return!1;if(a.constructor&&!C.call(a,"constructor")&&!C.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a){}return c===b||C.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!=="string"||!b)return null;b=d.trim(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return a.JSON&&a.JSON.parse?a.JSON.parse(b):(new Function("return "+b))();d.error("Invalid JSON: "+b)},parseXML:function(b,c,e){a.DOMParser?(e=new DOMParser,c=e.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),e=c.documentElement,(!e||!e.nodeName||e.nodeName==="parsererror")&&d.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(a){if(a&&i.test(a)){var b=c.head||c.getElementsByTagName("head")[0]||c.documentElement,e=c.createElement("script");d.support.scriptEval()?e.appendChild(c.createTextNode(a)):e.text=a,b.insertBefore(e,b.firstChild),b.removeChild(e)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,e){var f,g=0,h=a.length,i=h===b||d.isFunction(a);if(e){if(i){for(f in a)if(c.apply(a[f],e)===!1)break}else for(;g<h;)if(c.apply(a[g++],e)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(var j=a[0];g<h&&c.call(j,g,j)!==!1;j=a[++g]){}return a},trim:F?function(a){return a==null?"":F.call(a)}:function(a){return a==null?"":(a+"").replace(j,"").replace(k,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var e=d.type(a);a.length==null||e==="string"||e==="function"||e==="regexp"||d.isWindow(a)?D.call(c,a):d.merge(c,a)}return c},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length==="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,b,c){var d=[],e;for(var f=0,g=a.length;f<g;f++)e=b(a[f],f,c),e!=null&&(d[d.length]=e);return d.concat.apply([],d)},guid:1,proxy:function(a,c,e){arguments.length===2&&(typeof c==="string"?(e=a,a=e[c],c=b):c&&!d.isFunction(c)&&(e=c,c=b)),!c&&a&&(c=function(){return a.apply(e||this,arguments)}),a&&(c.guid=a.guid=a.guid||c.guid||d.guid++);return c},access:function(a,c,e,f,g,h){var i=a.length;if(typeof c==="object"){for(var j in c)d.access(a,j,c[j],f,g,e);return a}if(e!==b){f=!h&&f&&d.isFunction(e);for(var k=0;k<i;k++)g(a[k],c,f?e.call(a[k],k,g(a[k],c)):e,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},_Deferred:function(){var a=[],b,c,e,f={done:function(){if(!e){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=d.type(i),j==="array"?f.done.apply(f,i):j==="function"&&a.push(i);k&&f.resolveWith(k[0],k[1])}return this},resolveWith:function(d,f){if(!e&&!b&&!c){c=1;try{while(a[0])a.shift().apply(d,f)}catch(g){throw g}finally{b=[d,f],c=0}}return this},resolve:function(){f.resolveWith(d.isFunction(this.promise)?this.promise():this,arguments);return this},isResolved:function(){return c||b},cancel:function(){e=1,a=[];return this}};return f},Deferred:function(a){var b=d._Deferred(),c=d._Deferred(),e;d.extend(b,{then:function(a,c){b.done(a).fail(c);return this},fail:c.done,rejectWith:c.resolveWith,reject:c.resolve,isRejected:c.isResolved,promise:function(a){if(a==null){if(e)return e;e=a={}}var c=z.length;while(c--)a[z[c]]=b[z[c]];return a}}),b.done(c.cancel).fail(b.cancel),delete b.cancel,a&&a.call(b,b);return b},when:function(a){var b=arguments.length,c=b<=1&&a&&d.isFunction(a.promise)?a:d.Deferred(),e=c.promise();if(b>1){var f=E.call(arguments,0),g=b,h=function(a){return function(b){f[a]=arguments.length>1?E.call(arguments,0):b,--g||c.resolveWith(e,f)}};while(b--)a=f[b],a&&d.isFunction(a.promise)?a.promise().then(h(b),c.reject):--g;g||c.resolveWith(e,f)}else c!==a&&c.resolve(a);return e},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}d.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.subclass=this.subclass,a.fn.init=function b(b,c){c&&c instanceof d&&!(c instanceof a)&&(c=a(c));return d.fn.init.call(this,b,c,e)},a.fn.init.prototype=a.fn;var e=a(c);return a},browser:{}}),y=d._Deferred(),d.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){H["[object "+b+"]"]=b.toLowerCase()}),w=d.uaMatch(v),w.browser&&(d.browser[w.browser]=!0,d.browser.version=w.version),d.browser.webkit&&(d.browser.safari=!0),G&&(d.inArray=function(a,b){return G.call(b,a)}),i.test(" ")&&(j=/^[\s\xA0]+/,k=/[\s\xA0]+$/),g=d(c),c.addEventListener?A=function(){c.removeEventListener("DOMContentLoaded",A,!1),d.ready()}:c.attachEvent&&(A=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",A),d.ready())});return d}();(function(){d.support={};var b=c.createElement("div");b.style.display="none",b.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var e=b.getElementsByTagName("*"),f=b.getElementsByTagName("a")[0],g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=b.getElementsByTagName("input")[0];if(e&&e.length&&f){d.support={leadingWhitespace:b.firstChild.nodeType===3,tbody:!b.getElementsByTagName("tbody").length,htmlSerialize:!!b.getElementsByTagName("link").length,style:/red/.test(f.getAttribute("style")),hrefNormalized:f.getAttribute("href")==="/a",opacity:/^0.55$/.test(f.style.opacity),cssFloat:!!f.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,deleteExpando:!0,optDisabled:!1,checkClone:!1,noCloneEvent:!0,noCloneChecked:!0,boxModel:null,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableHiddenOffsets:!0},i.checked=!0,d.support.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,d.support.optDisabled=!h.disabled;var j=null;d.support.scriptEval=function(){if(j===null){var b=c.documentElement,e=c.createElement("script"),f="script"+d.now();try{e.appendChild(c.createTextNode("window."+f+"=1;"))}catch(g){}b.insertBefore(e,b.firstChild),a[f]?(j=!0,delete a[f]):j=!1,b.removeChild(e),b=e=f=null}return j};try{delete b.test}catch(k){d.support.deleteExpando=!1}!b.addEventListener&&b.attachEvent&&b.fireEvent&&(b.attachEvent("onclick",function l(){d.support.noCloneEvent=!1,b.detachEvent("onclick",l)}),b.cloneNode(!0).fireEvent("onclick")),b=c.createElement("div"),b.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";var m=c.createDocumentFragment();m.appendChild(b.firstChild),d.support.checkClone=m.cloneNode(!0).cloneNode(!0).lastChild.checked,d(function(){var a=c.createElement("div"),b=c.getElementsByTagName("body")[0];if(b){a.style.width=a.style.paddingLeft="1px",b.appendChild(a),d.boxModel=d.support.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,d.support.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="<div style='width:4px;'></div>",d.support.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";var e=a.getElementsByTagName("td");d.support.reliableHiddenOffsets=e[0].offsetHeight===0,e[0].style.display="",e[1].style.display="none",d.support.reliableHiddenOffsets=d.support.reliableHiddenOffsets&&e[0].offsetHeight===0,a.innerHTML="",b.removeChild(a).style.display="none",a=e=null}});var n=function(a){var b=c.createElement("div");a="on"+a;if(!b.attachEvent)return!0;var d=a in b;d||(b.setAttribute(a,"return;"),d=typeof b[a]==="function"),b=null;return d};d.support.submitBubbles=n("submit"),d.support.changeBubbles=n("change"),b=e=f=null}})();var e=/^(?:\{.*\}|\[.*\])$/;d.extend({cache:{},uuid:0,expando:"jQuery"+(d.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?d.cache[a[d.expando]]:a[d.expando];return!!a&&!g(a)},data:function(a,c,e,f){if(d.acceptData(a)){var g=d.expando,h=typeof c==="string",i,j=a.nodeType,k=j?d.cache:a,l=j?a[d.expando]:a[d.expando]&&d.expando;if((!l||f&&l&&!k[l][g])&&h&&e===b)return;l||(j?a[d.expando]=l=++d.uuid:l=d.expando),k[l]||(k[l]={},j||(k[l].toJSON=d.noop));if(typeof c==="object"||typeof c==="function")f?k[l][g]=d.extend(k[l][g],c):k[l]=d.extend(k[l],c);i=k[l],f&&(i[g]||(i[g]={}),i=i[g]),e!==b&&(i[c]=e);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[c]:i}},removeData:function(b,c,e){if(d.acceptData(b)){var f=d.expando,h=b.nodeType,i=h?d.cache:b,j=h?b[d.expando]:d.expando;if(!i[j])return;if(c){var k=e?i[j][f]:i[j];if(k){delete k[c];if(!g(k))return}}if(e){delete i[j][f];if(!g(i[j]))return}var l=i[j][f];d.support.deleteExpando||i!=a?delete i[j]:i[j]=null,l?(i[j]={},h||(i[j].toJSON=d.noop),i[j][f]=l):h&&(d.support.deleteExpando?delete b[d.expando]:b.removeAttribute?b.removeAttribute(d.expando):b[d.expando]=null)}},_data:function(a,b,c){return d.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=d.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),d.fn.extend({data:function(a,c){var e=null;if(typeof a==="undefined"){if(this.length){e=d.data(this[0]);if(this[0].nodeType===1){var g=this[0].attributes,h;for(var i=0,j=g.length;i<j;i++)h=g[i].name,h.indexOf("data-")===0&&(h=h.substr(5),f(this[0],h,e[h]))}}return e}if(typeof a==="object")return this.each(function(){d.data(this,a)});var k=a.split(".");k[1]=k[1]?"."+k[1]:"";if(c===b){e=this.triggerHandler("getData"+k[1]+"!",[k[0]]),e===b&&this.length&&(e=d.data(this[0],a),e=f(this[0],a,e));return e===b&&k[1]?this.data(k[0]):e}return this.each(function(){var b=d(this),e=[k[0],c];b.triggerHandler("setData"+k[1]+"!",e),d.data(this,a,c),b.triggerHandler("changeData"+k[1]+"!",e)})},removeData:function(a){return this.each(function(){d.removeData(this,a)})}}),d.extend({queue:function(a,b,c){if(a){b=(b||"fx")+"queue";var e=d._data(a,b);if(!c)return e||[];!e||d.isArray(c)?e=d._data(a,b,d.makeArray(c)):e.push(c);return e}},dequeue:function(a,b){b=b||"fx";var c=d.queue(a,b),e=c.shift();e==="inprogress"&&(e=c.shift()),e&&(b==="fx"&&c.unshift("inprogress"),e.call(a,function(){d.dequeue(a,b)})),c.length||d.removeData(a,b+"queue",!0)}}),d.fn.extend({queue:function(a,c){typeof a!=="string"&&(c=a,a="fx");if(c===b)return d.queue(this[0],a);return this.each(function(b){var e=d.queue(this,a,c);a==="fx"&&e[0]!=="inprogress"&&d.dequeue(this,a)})},dequeue:function(a){return this.each(function(){d.dequeue(this,a)})},delay:function(a,b){a=d.fx?d.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(){var c=this;setTimeout(function(){d.dequeue(c,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var h=/[\n\t\r]/g,i=/\s+/,j=/\r/g,k=/^(?:href|src|style)$/,l=/^(?:button|input)$/i,m=/^(?:button|input|object|select|textarea)$/i,n=/^a(?:rea)?$/i,o=/^(?:radio|checkbox)$/i;d.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"},d.fn.extend({attr:function(a,b){return d.access(this,a,b,!0,d.attr)},removeAttr:function(a,b){return this.each(function(){d.attr(this,a,""),this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(d.isFunction(a))return this.each(function(b){var c=d(this);c.addClass(a.call(this,b,c.attr("class")))});if(a&&typeof a==="string"){var b=(a||"").split(i);for(var c=0,e=this.length;c<e;c++){var f=this[c];if(f.nodeType===1)if(f.className){var g=" "+f.className+" ",h=f.className;for(var j=0,k=b.length;j<k;j++)g.indexOf(" "+b[j]+" ")<0&&(h+=" "+b[j]);f.className=d.trim(h)}else f.className=a}}return this},removeClass:function(a){if(d.isFunction(a))return this.each(function(b){var c=d(this);c.removeClass(a.call(this,b,c.attr("class")))});if(a&&typeof a==="string"||a===b){var c=(a||"").split(i);for(var e=0,f=this.length;e<f;e++){var g=this[e];if(g.nodeType===1&&g.className)if(a){var j=(" "+g.className+" ").replace(h," ");for(var k=0,l=c.length;k<l;k++)j=j.replace(" "+c[k]+" "," ");g.className=d.trim(j)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,e=typeof b==="boolean";if(d.isFunction(a))return this.each(function(c){var e=d(this);e.toggleClass(a.call(this,c,e.attr("class"),b),b)});return this.each(function(){if(c==="string"){var f,g=0,h=d(this),j=b,k=a.split(i);while(f=k[g++])j=e?j:!h.hasClass(f),h[j?"addClass":"removeClass"](f)}else if(c==="undefined"||c==="boolean")this.className&&d._data(this,"__className__",this.className),this.className=this.className||a===!1?"":d._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ";for(var c=0,d=this.length;c<d;c++)if((" "+this[c].className+" ").replace(h," ").indexOf(b)>-1)return!0;return!1},val:function(a){if(!arguments.length){var c=this[0];if(c){if(d.nodeName(c,"option")){var e=c.attributes.value;return!e||e.specified?c.value:c.text}if(d.nodeName(c,"select")){var f=c.selectedIndex,g=[],h=c.options,i=c.type==="select-one";if(f<0)return null;for(var k=i?f:0,l=i?f+1:h.length;k<l;k++){var m=h[k];if(m.selected&&(d.support.optDisabled?!m.disabled:m.getAttribute("disabled")===null)&&(!m.parentNode.disabled||!d.nodeName(m.parentNode,"optgroup"))){a=d(m).val();if(i)return a;g.push(a)}}if(i&&!g.length&&h.length)return d(h[f]).val();return g}if(o.test(c.type)&&!d.support.checkOn)return c.getAttribute("value")===null?"on":c.value;return(c.value||"").replace(j,"")}return b}var n=d.isFunction(a);return this.each(function(b){var c=d(this),e=a;if(this.nodeType===1){n&&(e=a.call(this,b,c.val())),e==null?e="":typeof e==="number"?e+="":d.isArray(e)&&(e=d.map(e,function(a){return a==null?"":a+""}));if(d.isArray(e)&&o.test(this.type))this.checked=d.inArray(c.val(),e)>=0;else if(d.nodeName(this,"select")){var f=d.makeArray(e);d("option",this).each(function(){this.selected=d.inArray(d(this).val(),f)>=0}),f.length||(this.selectedIndex=-1)}else this.value=e}})}}),d.extend({attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,e,f){if(!a||a.nodeType===3||a.nodeType===8||a.nodeType===2)return b;if(f&&c in d.attrFn)return d(a)[c](e);var g=a.nodeType!==1||!d.isXMLDoc(a),h=e!==b;c=g&&d.props[c]||c;if(a.nodeType===1){var i=k.test(c);if(c==="selected"&&!d.support.optSelected){var j=a.parentNode;j&&(j.selectedIndex,j.parentNode&&j.parentNode.selectedIndex)}if((c in a||a[c]!==b)&&g&&!i){h&&(c==="type"&&l.test(a.nodeName)&&a.parentNode&&d.error("type property can't be changed"),e===null?a.nodeType===1&&a.removeAttribute(c):a[c]=e);if(d.nodeName(a,"form")&&a.getAttributeNode(c))return a.getAttributeNode(c).nodeValue;if(c==="tabIndex"){var o=a.getAttributeNode("tabIndex");return o&&o.specified?o.value:m.test(a.nodeName)||n.test(a.nodeName)&&a.href?0:b}return a[c]}if(!d.support.style&&g&&c==="style"){h&&(a.style.cssText=""+e);return a.style.cssText}h&&a.setAttribute(c,""+e);if(!a.attributes[c]&&(a.hasAttribute&&!a.hasAttribute(c)))return b;var p=!d.support.hrefNormalized&&g&&i?a.getAttribute(c,2):a.getAttribute(c);return p===null?b:p}h&&(a[c]=e);return a[c]}});var p=/\.(.*)$/,q=/^(?:textarea|input|select)$/i,r=/\./g,s=/ /g,t=/[^\w\s.|`]/g,u=function(a){return a.replace(t,"\\$&")};d.event={add:function(c,e,f,g){if(c.nodeType!==3&&c.nodeType!==8){try{d.isWindow(c)&&(c!==a&&!c.frameElement)&&(c=a)}catch(h){}if(f===!1)f=v;else if(!f)return;var i,j;f.handler&&(i=f,f=i.handler),f.guid||(f.guid=d.guid++);var k=d._data(c);if(!k)return;var l=k.events,m=k.handle;l||(k.events=l={}),m||(k.handle=m=function(){return typeof d!=="undefined"&&!d.event.triggered?d.event.handle.apply(m.elem,arguments):b}),m.elem=c,e=e.split(" ");var n,o=0,p;while(n=e[o++]){j=i?d.extend({},i):{handler:f,data:g},n.indexOf(".")>-1?(p=n.split("."),n=p.shift(),j.namespace=p.slice(0).sort().join(".")):(p=[],j.namespace=""),j.type=n,j.guid||(j.guid=f.guid);var q=l[n],r=d.event.special[n]||{};if(!q){q=l[n]=[];if(!r.setup||r.setup.call(c,g,p,m)===!1)c.addEventListener?c.addEventListener(n,m,!1):c.attachEvent&&c.attachEvent("on"+n,m)}r.add&&(r.add.call(c,j),j.handler.guid||(j.handler.guid=f.guid)),q.push(j),d.event.global[n]=!0}c=null}},global:{},remove:function(a,c,e,f){if(a.nodeType!==3&&a.nodeType!==8){e===!1&&(e=v);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=d.hasData(a)&&d._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(e=c.handler,c=c.type);if(!c||typeof c==="string"&&c.charAt(0)==="."){c=c||"";for(h in t)d.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+d.map(m.slice(0).sort(),u).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!e){for(j=0;j<p.length;j++){q=p[j];if(l||n.test(q.namespace))d.event.remove(a,r,q.handler,j),p.splice(j--,1)}continue}o=d.event.special[h]||{};for(j=f||0;j<p.length;j++){q=p[j];if(e.guid===q.guid){if(l||n.test(q.namespace))f==null&&p.splice(j--,1),o.remove&&o.remove.call(a,q);if(f!=null)break}}if(p.length===0||f!=null&&p.length===1)(!o.teardown||o.teardown.call(a,m)===!1)&&d.removeEvent(a,h,s.handle),g=null,delete t[h]}if(d.isEmptyObject(t)){var w=s.handle;w&&(w.elem=null),delete s.events,delete s.handle,d.isEmptyObject(s)&&d.removeData(a,b,!0)}}},trigger:function(a,c,e){var f=a.type||a,g=arguments[3];if(!g){a=typeof a==="object"?a[d.expando]?a:d.extend(d.Event(f),a):d.Event(f),f.indexOf("!")>=0&&(a.type=f=f.slice(0,-1),a.exclusive=!0),e||(a.stopPropagation(),d.event.global[f]&&d.each(d.cache,function(){var b=d.expando,e=this[b];e&&e.events&&e.events[f]&&d.event.trigger(a,c,e.handle.elem)}));if(!e||e.nodeType===3||e.nodeType===8)return b;a.result=b,a.target=e,c=d.makeArray(c),c.unshift(a)}a.currentTarget=e;var h=d._data(e,"handle");h&&h.apply(e,c);var i=e.parentNode||e.ownerDocument;try{e&&e.nodeName&&d.noData[e.nodeName.toLowerCase()]||e["on"+f]&&e["on"+f].apply(e,c)===!1&&(a.result=!1,a.preventDefault())}catch(j){}if(!a.isPropagationStopped()&&i)d.event.trigger(a,c,i,!0);else if(!a.isDefaultPrevented()){var k,l=a.target,m=f.replace(p,""),n=d.nodeName(l,"a")&&m==="click",o=d.event.special[m]||{};if((!o._default||o._default.call(e,a)===!1)&&!n&&!(l&&l.nodeName&&d.noData[l.nodeName.toLowerCase()])){try{l[m]&&(k=l["on"+m],k&&(l["on"+m]=null),d.event.triggered=!0,l[m]())}catch(q){}k&&(l["on"+m]=k),d.event.triggered=!1}}},handle:function(c){var e,f,g,h,i,j=[],k=d.makeArray(arguments);c=k[0]=d.event.fix(c||a.event),c.currentTarget=this,e=c.type.indexOf(".")<0&&!c.exclusive,e||(g=c.type.split("."),c.type=g.shift(),j=g.slice(0).sort(),h=new RegExp("(^|\\.)"+j.join("\\.(?:.*\\.)?")+"(\\.|$)")),c.namespace=c.namespace||j.join("."),i=d._data(this,"events"),f=(i||{})[c.type];if(i&&f){f=f.slice(0);for(var l=0,m=f.length;l<m;l++){var n=f[l];if(e||h.test(n.namespace)){c.handler=n.handler,c.data=n.data,c.handleObj=n;var o=n.handler.apply(this,k);o!==b&&(c.result=o,o===!1&&(c.preventDefault(),c.stopPropagation()));if(c.isImmediatePropagationStopped())break}}}return c.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[d.expando])return a;var e=a;a=d.Event(e);for(var f=this.props.length,g;f;)g=this.props[--f],a[g]=e[g];a.target||(a.target=a.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var h=c.documentElement,i=c.body;a.pageX=a.clientX+(h&&h.scrollLeft||i&&i.scrollLeft||0)-(h&&h.clientLeft||i&&i.clientLeft||0),a.pageY=a.clientY+(h&&h.scrollTop||i&&i.scrollTop||0)-(h&&h.clientTop||i&&i.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==b&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a},guid:1e8,proxy:d.proxy,special:{ready:{setup:d.bindReady,teardown:d.noop},live:{add:function(a){d.event.add(this,F(a.origType,a.selector),d.extend({},a,{handler:E,guid:a.handler.guid}))},remove:function(a){d.event.remove(this,F(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,c){d.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}}},d.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},d.Event=function(a){if(!this.preventDefault)return new d.Event(a);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?w:v):this.type=a,this.timeStamp=d.now(),this[d.expando]=!0},d.Event.prototype={preventDefault:function(){this.isDefaultPrevented=w;var a=this.originalEvent;a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=w;var a=this.originalEvent;a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=w,this.stopPropagation()},isDefaultPrevented:v,isPropagationStopped:v,isImmediatePropagationStopped:v};var x=function(a){var b=a.relatedTarget;try{if(b!==c&&!b.parentNode)return;while(b&&b!==this)b=b.parentNode;b!==this&&(a.type=a.data,d.event.handle.apply(this,arguments))}catch(e){}},y=function(a){a.type=a.data,d.event.handle.apply(this,arguments)};d.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){d.event.special[a]={setup:function(c){d.event.add(this,b,c&&c.selector?y:x,a)},teardown:function(a){d.event.remove(this,b,a&&a.selector?y:x)}}}),d.support.submitBubbles||(d.event.special.submit={setup:function(a,b){if(this.nodeName&&this.nodeName.toLowerCase()!=="form")d.event.add(this,"click.specialSubmit",function(a){var b=a.target,c=b.type;(c==="submit"||c==="image")&&d(b).closest("form").length&&C("submit",this,arguments)}),d.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,c=b.type;(c==="text"||c==="password")&&d(b).closest("form").length&&a.keyCode===13&&C("submit",this,arguments)});else return!1},teardown:function(a){d.event.remove(this,".specialSubmit")}});if(!d.support.changeBubbles){var z,A=function(a){var b=a.type,c=a.value;b==="radio"||b==="checkbox"?c=a.checked:b==="select-multiple"?c=a.selectedIndex>-1?d.map(a.options,function(a){return a.selected}).join("-"):"":a.nodeName.toLowerCase()==="select"&&(c=a.selectedIndex);return c},B=function B(a){var c=a.target,e,f;if(q.test(c.nodeName)&&!c.readOnly){e=d._data(c,"_change_data"),f=A(c),(a.type!=="focusout"||c.type!=="radio")&&d._data(c,"_change_data",f);if(e===b||f===e)return;if(e!=null||f)a.type="change",a.liveFired=b,d.event.trigger(a,arguments[1],c)}};d.event.special.change={filters:{focusout:B,beforedeactivate:B,click:function(a){var b=a.target,c=b.type;(c==="radio"||c==="checkbox"||b.nodeName.toLowerCase()==="select")&&B.call(this,a)},keydown:function(a){var b=a.target,c=b.type;(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&B.call(this,a)},beforeactivate:function(a){var b=a.target;d._data(b,"_change_data",A(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in z)d.event.add(this,c+".specialChange",z[c]);return q.test(this.nodeName)},teardown:function(a){d.event.remove(this,".specialChange");return q.test(this.nodeName)}},z=d.event.special.change.filters,z.focus=z.beforeactivate}c.addEventListener&&d.each({focus:"focusin",blur:"focusout"},function(a,b){function c(a){a=d.event.fix(a),a.type=b;return d.event.handle.call(this,a)}d.event.special[b]={setup:function(){this.addEventListener(a,c,!0)},teardown:function(){this.removeEventListener(a,c,!0)}}}),d.each(["bind","one"],function(a,c){d.fn[c]=function(a,e,f){if(typeof a==="object"){for(var g in a)this[c](g,e,a[g],f);return this}if(d.isFunction(e)||e===!1)f=e,e=b;var h=c==="one"?d.proxy(f,function(a){d(this).unbind(a,h);return f.apply(this,arguments)}):f;if(a==="unload"&&c!=="one")this.one(a,e,f);else for(var i=0,j=this.length;i<j;i++)d.event.add(this[i],a,h,e);return this}}),d.fn.extend({unbind:function(a,b){if(typeof a!=="object"||a.preventDefault)for(var e=0,f=this.length;e<f;e++)d.event.remove(this[e],a,b);else for(var c in a)this.unbind(c,a[c]);return this},delegate:function(a,b,c,d){return this.live(b,c,d,a)},undelegate:function(a,b,c){return arguments.length===0?this.unbind("live"):this.die(b,null,c,a)},trigger:function(a,b){return this.each(function(){d.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){var c=d.Event(a);c.preventDefault(),c.stopPropagation(),d.event.trigger(c,b,this[0]);return c.result}},toggle:function(a){var b=arguments,c=1;while(c<b.length)d.proxy(a,b[c++]);return this.click(d.proxy(a,function(e){var f=(d._data(this,"lastToggle"+a.guid)||0)%c;d._data(this,"lastToggle"+a.guid,f+1),e.preventDefault();return b[f].apply(this,arguments)||!1}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var D={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};d.each(["live","die"],function(a,c){d.fn[c]=function(a,e,f,g){var h,i=0,j,k,l,m=g||this.selector,n=g?this:d(this.context);if(typeof a==="object"&&!a.preventDefault){for(var o in a)n[c](o,e,a[o],m);return this}d.isFunction(e)&&(f=e,e=b),a=(a||"").split(" ");while((h=a[i++])!=null){j=p.exec(h),k="",j&&(k=j[0],h=h.replace(p,""));if(h==="hover"){a.push("mouseenter"+k,"mouseleave"+k);continue}l=h,h==="focus"||h==="blur"?(a.push(D[h]+k),h=h+k):h=(D[h]||h)+k;if(c==="live")for(var q=0,r=n.length;q<r;q++)d.event.add(n[q],"live."+F(h,m),{data:e,selector:m,handler:f,origType:h,origHandler:f,preType:l});else n.unbind("live."+F(h,m),f)}return this}}),d.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){d.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.bind(b,a,c):this.trigger(b)},d.attrFn&&(d.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}if(i.nodeType===1){f||(i.sizcache=c,i.sizset=g);if(typeof b!=="string"){if(i===b){j=!0;break}}else if(k.filter(b,[i]).length>0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}i.nodeType===1&&!f&&(i.sizcache=c,i.sizset=g);if(i.nodeName.toLowerCase()===b){j=i;break}i=i[a]}d[g]=j}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,e,g){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!=="string")return e;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(f.call(n)==="[object Array]")if(u)if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&e.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&e.push(j[t]);else e.push.apply(e,n);else p(n,e);o&&(k(o,h,e,g),k.uniqueSort(e));return e};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},k.matches=function(a,b){return k(a,null,null,b)},k.matchesSelector=function(a,b){return k(b,null,null,[a]).length>0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e<f;e++){var g,h=l.order[e];if(g=l.leftMatch[h].exec(a)){var j=g[1];g.splice(1,1);if(j.substr(j.length-1)!=="\\"){g[1]=(g[1]||"").replace(i,""),d=l.find[h](g,b,c);if(d!=null){a=a.replace(l.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!=="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},k.filter=function(a,c,d,e){var f,g,h=a,i=[],j=c,m=c&&c[0]&&k.isXML(c[0]);while(a&&c.length){for(var n in l.filter)if((f=l.leftMatch[n].exec(a))!=null&&f[2]){var o,p,q=l.filter[n],r=f[1];g=!1,f.splice(1,1);if(r.substr(r.length-1)==="\\")continue;j===i&&(i=[]);if(l.preFilter[n]){f=l.preFilter[n](f,j,d,i,e,m);if(f){if(f===!0)continue}else g=o=!0}if(f)for(var s=0;(p=j[s])!=null;s++)if(p){o=q(p,f,s,j);var t=e^!!o;d&&o!=null?t?g=!0:j[s]=!1:t&&(i.push(p),g=!0)}if(o!==b){d||(j=i),a=a.replace(l.match[n],"");if(!g)return[];break}}if(a===h)if(g==null)k.error(a);else break;h=a}return j},k.error=function(a){throw"Syntax error, unrecognized expression: "+a};var l=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b==="string",d=c&&!j.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1){}a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&k.filter(b,a,!0)},">":function(a,b){var c,d=typeof b==="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&k.filter(b,a,!0)}},"":function(a,b,c){var d,f=e++,g=u;typeof b==="string"&&!j.test(b)&&(b=b.toLowerCase(),d=b,g=t),g("parentNode",b,f,a,d,c)},"~":function(a,b,c){var d,f=e++,g=u;typeof b==="string"&&!j.test(b)&&(b=b.toLowerCase(),d=b,g=t),g("previousSibling",b,f,a,d,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!=="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!=="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!=="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(i,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){return"text"===a.getAttribute("type")},radio:function(a){return"radio"===a.type},checkbox:function(a){return"checkbox"===a.type},file:function(a){return"file"===a.type},password:function(a){return"password"===a.type},submit:function(a){return"submit"===a.type},image:function(a){return"image"===a.type},reset:function(a){return"reset"===a.type},button:function(a){return"button"===a.type||a.nodeName.toLowerCase()==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}k.error(e)},CHILD:function(a,b){var c=b[1],d=a;switch(c){case"only":case"first":while(d=d.previousSibling)if(d.nodeType===1)return!1;if(c==="first")return!0;d=a;case"last":while(d=d.nextSibling)if(d.nodeType===1)return!1;return!0;case"nth":var e=b[2],f=b[3];if(e===1&&f===0)return!0;var g=b[0],h=a.parentNode;if(h&&(h.sizcache!==g||!a.nodeIndex)){var i=0;for(d=h.firstChild;d;d=d.nextSibling)d.nodeType===1&&(d.nodeIndex=++i);h.sizcache=g}var j=a.nodeIndex-f;return e===0?j===0:j%e===0&&j/e>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(f.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length==="number")for(var e=a.length;c<e;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var r,s;c.documentElement.compareDocumentPosition?r=function(a,b){if(a===b){g=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(r=function(a,b){var c,d,e=[],f=[],h=a.parentNode,i=b.parentNode,j=h;if(a===b){g=!0;return 0}if(h===i)return s(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return s(e[k],f[k]);return k===c?s(a,f[k],-1):s(e[k],b,1)},s=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),k.getText=function(a){var b="",c;for(var d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=k.getText(c.childNodes));return b},function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!=="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!=="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!=="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!=="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector,d=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(e){d=!0}b&&(k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(d||!l.match.PSEUDO.test(c)&&!/!=/.test(c))return b.call(a,c)}catch(e){}return k(c,null,null,[a]).length>0})}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!=="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g<h;g++)k(a,f[g],d);return k.filter(e,d)};d.find=k,d.expr=k.selectors,d.expr[":"]=d.expr.filters,d.unique=k.uniqueSort,d.text=k.getText,d.isXMLDoc=k.isXML,d.contains=k.contains}();var G=/Until$/,H=/^(?:parents|prevUntil|prevAll)/,I=/,/,J=/^.[^:#\[\.,]*$/,K=Array.prototype.slice,L=d.expr.match.POS,M={children:!0,contents:!0,next:!0,prev:!0};d.fn.extend({find:function(a){var b=this.pushStack("","find",a),c=0;for(var e=0,f=this.length;e<f;e++){c=b.length,d.find(a,this[e],b);if(e>0)for(var g=c;g<b.length;g++)for(var h=0;h<c;h++)if(b[h]===b[g]){b.splice(g--,1);break}}return b},has:function(a){var b=d(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(d.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(O(this,a,!1),"not",a)},filter:function(a){return this.pushStack(O(this,a,!0),"filter",a)},is:function(a){return!!a&&d.filter(a,this).length>0},closest:function(a,b){var c=[],e,f,g=this[0];if(d.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(e=0,f=a.length;e<f;e++)i=a[e],j[i]||(j[i]=d.expr.match.POS.test(i)?d(i,b||this.context):i);while(g&&g.ownerDocument&&g!==b){for(i in j)h=j[i],(h.jquery?h.index(g)>-1:d(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=L.test(a)?d(a,b||this.context):null;for(e=0,f=this.length;e<f;e++){g=this[e];while(g){if(l?l.index(g)>-1:d.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b)break}}c=c.length>1?d.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a==="string")return d.inArray(this[0],a?d(a):this.parent().children());return d.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a==="string"?d(a,b):d.makeArray(a),e=d.merge(this.get(),c);return this.pushStack(N(c[0])||N(e[0])?e:d.unique(e))},andSelf:function(){return this.add(this.prevObject)}}),d.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return d.dir(a,"parentNode")},parentsUntil:function(a,b,c){return d.dir(a,"parentNode",c)},next:function(a){return d.nth(a,2,"nextSibling")},prev:function(a){return d.nth(a,2,"previousSibling")},nextAll:function(a){return d.dir(a,"nextSibling")},prevAll:function(a){return d.dir(a,"previousSibling")},nextUntil:function(a,b,c){return d.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return d.dir(a,"previousSibling",c)},siblings:function(a){return d.sibling(a.parentNode.firstChild,a)},children:function(a){return d.sibling(a.firstChild)},contents:function(a){return d.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:d.makeArray(a.childNodes)}},function(a,b){d.fn[a]=function(c,e){var f=d.map(this,b,c),g=K.call(arguments);G.test(a)||(e=c),e&&typeof e==="string"&&(f=d.filter(e,f)),f=this.length>1&&!M[a]?d.unique(f):f,(this.length>1||I.test(e))&&H.test(a)&&(f=f.reverse());return this.pushStack(f,a,g.join(","))}}),d.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?d.find.matchesSelector(b[0],a)?[b[0]]:[]:d.find.matches(a,b)},dir:function(a,c,e){var f=[],g=a[c];while(g&&g.nodeType!==9&&(e===b||g.nodeType!==1||!d(g).is(e)))g.nodeType===1&&f.push(g),g=g[c];return f},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var P=/ jQuery\d+="(?:\d+|null)"/g,Q=/^\s+/,R=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,S=/<([\w:]+)/,T=/<tbody/i,U=/<|&#?\w+;/,V=/<(?:script|object|embed|option|style)/i,W=/checked\s*(?:[^=]|=\s*.checked.)/i,X={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};X.optgroup=X.option,X.tbody=X.tfoot=X.colgroup=X.caption=X.thead,X.th=X.td,d.support.htmlSerialize||(X._default=[1,"div<div>","</div>"]),d.fn.extend({text:function(a){if(d.isFunction(a))return this.each(function(b){var c=d(this);c.text(a.call(this,b,c.text()))});if(typeof a!=="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return d.text(this)},wrapAll:function(a){if(d.isFunction(a))return this.each(function(b){d(this).wrapAll(a.call(this,b))});if(this[0]){var b=d(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(d.isFunction(a))return this.each(function(b){d(this).wrapInner(a.call(this,b))});return this.each(function(){var b=d(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){d(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){d.nodeName(this,"body")||d(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=d(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,d(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,e;(e=this[c])!=null;c++)if(!a||d.filter(a,[e]).length)!b&&e.nodeType===1&&(d.cleanData(e.getElementsByTagName("*")),d.cleanData([e])),e.parentNode&&e.parentNode.removeChild(e);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&d.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return d.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(P,""):null;if(typeof a!=="string"||V.test(a)||!d.support.leadingWhitespace&&Q.test(a)||X[(S.exec(a)||["",""])[1].toLowerCase()])d.isFunction(a)?this.each(function(b){var c=d(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);else{a=a.replace(R,"<$1></$2>");try{for(var c=0,e=this.length;c<e;c++)this[c].nodeType===1&&(d.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(f){this.empty().append(a)}}return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(d.isFunction(a))return this.each(function(b){var c=d(this),e=c.html();c.replaceWith(a.call(this,b,e))});typeof a!=="string"&&(a=d(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;d(this).remove(),b?d(b).before(a):d(c).append(a)})}return this.pushStack(d(d.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,e){var f,g,h,i,j=a[0],k=[];if(!d.support.checkClone&&arguments.length===3&&typeof j==="string"&&W.test(j))return this.each(function(){d(this).domManip(a,c,e,!0)});if(d.isFunction(j))return this.each(function(f){var g=d(this);a[0]=j.call(this,f,c?g.html():b),g.domManip(a,c,e)});if(this[0]){i=j&&j.parentNode,d.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?f={fragment:i}:f=d.buildFragment(a,this,k),h=f.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&d.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)e.call(c?Y(this[l],g):this[l],f.cacheable||m>1&&l<n?d.clone(h,!0,!0):h)}k.length&&d.each(k,ba)}return this}}),d.buildFragment=function(a,b,e){var f,g,h,i=b&&b[0]?b[0].ownerDocument||b[0]:c;a.length===1&&typeof a[0]==="string"&&a[0].length<512&&i===c&&a[0].charAt(0)==="<"&&!V.test(a[0])&&(d.support.checkClone||!W.test(a[0]))&&(g=!0,h=d.fragments[a[0]],h&&(h!==1&&(f=h))),f||(f=i.createDocumentFragment(),d.clean(a,i,f,e)),g&&(d.fragments[a[0]]=h?f:1);return{fragment:f,cacheable:g}},d.fragments={},d.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){d.fn[a]=function(c){var e=[],f=d(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&f.length===1){f[b](this[0]);return this}for(var h=0,i=f.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();d(f[h])[b](j),e=e.concat(j)}return this.pushStack(e,a,f.selector)}}),d.extend({clone:function(a,b,c){var e=a.cloneNode(!0),f,g,h;if((!d.support.noCloneEvent||!d.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!d.isXMLDoc(a)){$(a,e),f=_(a),g=_(e);for(h=0;f[h];++h)$(f[h],g[h])}if(b){Z(a,e);if(c){f=_(a),g=_(e);for(h=0;f[h];++h)Z(f[h],g[h])}}return e},clean:function(a,b,e,f){b=b||c,typeof b.createElement==="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var g=[];for(var h=0,i;(i=a[h])!=null;h++){typeof i==="number"&&(i+="");if(!i)continue;if(typeof i!=="string"||U.test(i)){if(typeof i==="string"){i=i.replace(R,"<$1></$2>");var j=(S.exec(i)||["",""])[1].toLowerCase(),k=X[j]||X._default,l=k[0],m=b.createElement("div");m.innerHTML=k[1]+i+k[2];while(l--)m=m.lastChild;if(!d.support.tbody){var n=T.test(i),o=j==="table"&&!n?m.firstChild&&m.firstChild.childNodes:k[1]==="<table>"&&!n?m.childNodes:[];for(var p=o.length-1;p>=0;--p)d.nodeName(o[p],"tbody")&&!o[p].childNodes.length&&o[p].parentNode.removeChild(o[p])}!d.support.leadingWhitespace&&Q.test(i)&&m.insertBefore(b.createTextNode(Q.exec(i)[0]),m.firstChild),i=m.childNodes}}else i=b.createTextNode(i);i.nodeType?g.push(i):g=d.merge(g,i)}if(e)for(h=0;g[h];h++)!f||!d.nodeName(g[h],"script")||g[h].type&&g[h].type.toLowerCase()!=="text/javascript"?(g[h].nodeType===1&&g.splice.apply(g,[h+1,0].concat(d.makeArray(g[h].getElementsByTagName("script")))),e.appendChild(g[h])):f.push(g[h].parentNode?g[h].parentNode.removeChild(g[h]):g[h]);return g},cleanData:function(a){var b,c,e=d.cache,f=d.expando,g=d.event.special,h=d.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&d.noData[j.nodeName.toLowerCase()])continue;c=j[d.expando];if(c){b=e[c]&&e[c][f];if(b&&b.events){for(var k in b.events)g[k]?d.event.remove(j,k):d.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[d.expando]:j.removeAttribute&&j.removeAttribute(d.expando),delete e[c]}}}});var bb=/alpha\([^)]*\)/i,bc=/opacity=([^)]*)/,bd=/-([a-z])/ig,be=/([A-Z])/g,bf=/^-?\d+(?:px)?$/i,bg=/^-?\d/,bh={position:"absolute",visibility:"hidden",display:"block"},bi=["Left","Right"],bj=["Top","Bottom"],bk,bl,bm,bn=function(a,b){return b.toUpperCase()};d.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return d.access(this,a,c,!0,function(a,c,e){return e!==b?d.style(a,c,e):d.css(a,c)})},d.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bk(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{zIndex:!0,fontWeight:!0,opacity:!0,zoom:!0,lineHeight:!0},cssProps:{"float":d.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,e,f){if(a&&a.nodeType!==3&&a.nodeType!==8&&a.style){var g,h=d.camelCase(c),i=a.style,j=d.cssHooks[h];c=d.cssProps[h]||h;if(e===b){if(j&&"get"in j&&(g=j.get(a,!1,f))!==b)return g;return i[c]}if(typeof e==="number"&&isNaN(e)||e==null)return;typeof e==="number"&&!d.cssNumber[h]&&(e+="px");if(!j||!("set"in j)||(e=j.set(a,e))!==b)try{i[c]=e}catch(k){}}},css:function(a,c,e){var f,g=d.camelCase(c),h=d.cssHooks[g];c=d.cssProps[g]||g;if(h&&"get"in h&&(f=h.get(a,!0,e))!==b)return f;if(bk)return bk(a,c,g)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]},camelCase:function(a){return a.replace(bd,bn)}}),d.curCSS=d.css,d.each(["height","width"],function(a,b){d.cssHooks[b]={get:function(a,c,e){var f;if(c){a.offsetWidth!==0?f=bo(a,b,e):d.swap(a,bh,function(){f=bo(a,b,e)});if(f<=0){f=bk(a,b,b),f==="0px"&&bm&&(f=bm(a,b,b));if(f!=null)return f===""||f==="auto"?"0px":f}if(f<0||f==null){f=a.style[b];return f===""||f==="auto"?"0px":f}return typeof f==="string"?f:f+"px"}},set:function(a,b){if(!bf.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),d.support.opacity||(d.cssHooks.opacity={get:function(a,b){return bc.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style;c.zoom=1;var e=d.isNaN(b)?"":"alpha(opacity="+b*100+")",f=c.filter||"";c.filter=bb.test(f)?f.replace(bb,e):c.filter+" "+e}}),c.defaultView&&c.defaultView.getComputedStyle&&(bl=function(a,c,e){var f,g,h;e=e.replace(be,"-$1").toLowerCase();if(!(g=a.ownerDocument.defaultView))return b;if(h=g.getComputedStyle(a,null))f=h.getPropertyValue(e),f===""&&!d.contains(a.ownerDocument.documentElement,a)&&(f=d.style(a,e));return f}),c.documentElement.currentStyle&&(bm=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bf.test(d)&&bg.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bk=bl||bm,d.expr&&d.expr.filters&&(d.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!d.support.reliableHiddenOffsets&&(a.style.display||d.css(a,"display"))==="none"},d.expr.filters.visible=function(a){return!d.expr.filters.hidden(a)});var bp=/%20/g,bq=/\[\]$/,br=/\r?\n/g,bs=/#.*$/,bt=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bu=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bv=/(?:^file|^widget|\-extension):$/,bw=/^(?:GET|HEAD)$/,bx=/^\/\//,by=/\?/,bz=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bA=/^(?:select|textarea)/i,bB=/\s+/,bC=/([?&])_=[^&]*/,bD=/(^|\-)([a-z])/g,bE=function(a,b,c){return b+c.toUpperCase()},bF=/^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,bG=d.fn.load,bH={},bI={},bJ,bK;try{bJ=c.location.href}catch(bL){bJ=c.createElement("a"),bJ.href="",bJ=bJ.href}bK=bF.exec(bJ.toLowerCase()),d.fn.extend({load:function(a,c,e){if(typeof a!=="string"&&bG)return bG.apply(this,arguments);if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var g=a.slice(f,a.length);a=a.slice(0,f)}var h="GET";c&&(d.isFunction(c)?(e=c,c=b):typeof c==="object"&&(c=d.param(c,d.ajaxSettings.traditional),h="POST"));var i=this;d.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?d("<div>").append(c.replace(bz,"")).find(g):c)),e&&i.each(e,[c,b,a])}});return this},serialize:function(){return d.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?d.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bA.test(this.nodeName)||bu.test(this.type))}).map(function(a,b){var c=d(this).val();return c==null?null:d.isArray(c)?d.map(c,function(a,c){return{name:b.name,value:a.replace(br,"\r\n")}}):{name:b.name,value:c.replace(br,"\r\n")}}).get()}}),d.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){d.fn[b]=function(a){return this.bind(b,a)}}),d.each(["get","post"],function(a,c){d[c]=function(a,e,f,g){d.isFunction(e)&&(g=g||f,f=e,e=b);return d.ajax({type:c,url:a,data:e,success:f,dataType:g})}}),d.extend({getScript:function(a,c){return d.get(a,b,c,"script")},getJSON:function(a,b,c){return d.get(a,b,c,"json")},ajaxSetup:function(a,b){b?d.extend(!0,a,d.ajaxSettings,b):(b=a,a=d.extend(!0,d.ajaxSettings,b));for(var c in {context:1,url:1})c in b?a[c]=b[c]:c in d.ajaxSettings&&(a[c]=d.ajaxSettings[c]);return a},ajaxSettings:{url:bJ,isLocal:bv.test(bK[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":d.parseJSON,"text xml":d.parseXML}},ajaxPrefilter:bM(bH),ajaxTransport:bM(bI),ajax:function(a,c){function v(a,c,l,n){if(r!==2){r=2,p&&clearTimeout(p),o=b,m=n||"",u.readyState=a?4:0;var q,t,v,w=l?bP(e,u,l):b,x,y;if(a>=200&&a<300||a===304){if(e.ifModified){if(x=u.getResponseHeader("Last-Modified"))d.lastModified[k]=x;if(y=u.getResponseHeader("Etag"))d.etag[k]=y}if(a===304)c="notmodified",q=!0;else try{t=bQ(e,w),c="success",q=!0}catch(z){c="parsererror",v=z}}else{v=c;if(!c||a)c="error",a<0&&(a=0)}u.status=a,u.statusText=c,q?h.resolveWith(f,[t,c,u]):h.rejectWith(f,[u,c,v]),u.statusCode(j),j=b,s&&g.trigger("ajax"+(q?"Success":"Error"),[u,e,q?t:v]),i.resolveWith(f,[u,c]),s&&(g.trigger("ajaxComplete",[u,e]),--d.active||d.event.trigger("ajaxStop"))}}typeof a==="object"&&(c=a,a=b),c=c||{};var e=d.ajaxSetup({},c),f=e.context||e,g=f!==e&&(f.nodeType||f instanceof d)?d(f):d.event,h=d.Deferred(),i=d._Deferred(),j=e.statusCode||{},k,l={},m,n,o,p,q,r=0,s,t,u={readyState:0,setRequestHeader:function(a,b){r||(l[a.toLowerCase().replace(bD,bE)]=b);return this},getAllResponseHeaders:function(){return r===2?m:null},getResponseHeader:function(a){var c;if(r===2){if(!n){n={};while(c=bt.exec(m))n[c[1].toLowerCase()]=c[2]}c=n[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){r||(e.mimeType=a);return this},abort:function(a){a=a||"abort",o&&o.abort(a),v(0,a);return this}};h.promise(u),u.success=u.done,u.error=u.fail,u.complete=i.done,u.statusCode=function(a){if(a){var b;if(r<2)for(b in a)j[b]=[j[b],a[b]];else b=a[u.status],u.then(b,b)}return this},e.url=((a||e.url)+"").replace(bs,"").replace(bx,bK[1]+"//"),e.dataTypes=d.trim(e.dataType||"*").toLowerCase().split(bB),e.crossDomain||(q=bF.exec(e.url.toLowerCase()),e.crossDomain=q&&(q[1]!=bK[1]||q[2]!=bK[2]||(q[3]||(q[1]==="http:"?80:443))!=(bK[3]||(bK[1]==="http:"?80:443)))),e.data&&e.processData&&typeof e.data!=="string"&&(e.data=d.param(e.data,e.traditional)),bN(bH,e,c,u);if(r===2)return!1;s=e.global,e.type=e.type.toUpperCase(),e.hasContent=!bw.test(e.type),s&&d.active++===0&&d.event.trigger("ajaxStart");if(!e.hasContent){e.data&&(e.url+=(by.test(e.url)?"&":"?")+e.data),k=e.url;if(e.cache===!1){var w=d.now(),x=e.url.replace(bC,"$1_="+w);e.url=x+(x===e.url?(by.test(e.url)?"&":"?")+"_="+w:"")}}if(e.data&&e.hasContent&&e.contentType!==!1||c.contentType)l["Content-Type"]=e.contentType;e.ifModified&&(k=k||e.url,d.lastModified[k]&&(l["If-Modified-Since"]=d.lastModified[k]),d.etag[k]&&(l["If-None-Match"]=d.etag[k])),l.Accept=e.dataTypes[0]&&e.accepts[e.dataTypes[0]]?e.accepts[e.dataTypes[0]]+(e.dataTypes[0]!=="*"?", */*; q=0.01":""):e.accepts["*"];for(t in e.headers)u.setRequestHeader(t,e.headers[t]);if(e.beforeSend&&(e.beforeSend.call(f,u,e)===!1||r===2)){u.abort();return!1}for(t in {success:1,error:1,complete:1})u[t](e[t]);o=bN(bI,e,c,u);if(o){u.readyState=1,s&&g.trigger("ajaxSend",[u,e]),e.async&&e.timeout>0&&(p=setTimeout(function(){u.abort("timeout")},e.timeout));try{r=1,o.send(l,v)}catch(y){status<2?v(-1,y):d.error(y)}}else v(-1,"No Transport");return u},param:function(a,c){var e=[],f=function(a,b){b=d.isFunction(b)?b():b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=d.ajaxSettings.traditional);if(d.isArray(a)||a.jquery&&!d.isPlainObject(a))d.each(a,function(){f(this.name,this.value)});else for(var g in a)bO(g,a[g],c,f);return e.join("&").replace(bp,"+")}}),d.extend({active:0,lastModified:{},etag:{}});var bR=d.now(),bS=/(\=)\?(&|$)|()\?\?()/i;d.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return d.expando+"_"+bR++}}),d.ajaxPrefilter("json jsonp",function(b,c,e){var f=typeof b.data==="string";if(b.dataTypes[0]==="jsonp"||c.jsonpCallback||c.jsonp!=null||b.jsonp!==!1&&(bS.test(b.url)||f&&bS.test(b.data))){var g,h=b.jsonpCallback=d.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2",m=function(){a[h]=i,g&&d.isFunction(i)&&a[h](g[0])};b.jsonp!==!1&&(j=j.replace(bS,l),b.url===j&&(f&&(k=k.replace(bS,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},e.then(m,m),b.converters["script json"]=function(){g||d.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),d.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){d.globalEval(a);return a}}}),d.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),d.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var bT=d.now(),bU,bV;d.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&bX()||bY()}:bX,bV=d.ajaxSettings.xhr(),d.support.ajax=!!bV,d.support.cors=bV&&"withCredentials"in bV,bV=b,d.support.ajax&&d.ajaxTransport(function(a){if(!a.crossDomain||d.support.cors){var c;return{send:function(e,f){var g=a.xhr(),h,i;a.username?g.open(a.type,a.url,a.async,a.username,a.password):g.open(a.type,a.url,a.async);if(a.xhrFields)for(i in a.xhrFields)g[i]=a.xhrFields[i];a.mimeType&&g.overrideMimeType&&g.overrideMimeType(a.mimeType),(!a.crossDomain||a.hasContent)&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(i in e)g.setRequestHeader(i,e[i])}catch(j){}g.send(a.hasContent&&a.data||null),c=function(e,i){var j,k,l,m,n;try{if(c&&(i||g.readyState===4)){c=b,h&&(g.onreadystatechange=d.noop,delete bU[h]);if(i)g.readyState!==4&&g.abort();else{j=g.status,l=g.getAllResponseHeaders(),m={},n=g.responseXML,n&&n.documentElement&&(m.xml=n),m.text=g.responseText;try{k=g.statusText}catch(o){k=""}j||!a.isLocal||a.crossDomain?j===1223&&(j=204):j=m.text?200:404}}}catch(p){i||f(-1,p)}m&&f(j,k,m,l)},a.async&&g.readyState!==4?(bU||(bU={},bW()),h=bT++,g.onreadystatechange=bU[h]=c):c()},abort:function(){c&&c(0,1)}}}});var bZ={},b$=/^(?:toggle|show|hide)$/,b_=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,ca,cb=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];d.fn.extend({show:function(a,b,c){var e,f;if(a||a===0)return this.animate(cc("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)e=this[g],f=e.style.display,!d._data(e,"olddisplay")&&f==="none"&&(f=e.style.display=""),f===""&&d.css(e,"display")==="none"&&d._data(e,"olddisplay",cd(e.nodeName));for(g=0;g<h;g++){e=this[g],f=e.style.display;if(f===""||f==="none")e.style.display=d._data(e,"olddisplay")||""}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cc("hide",3),a,b,c);for(var e=0,f=this.length;e<f;e++){var g=d.css(this[e],"display");g!=="none"&&!d._data(this[e],"olddisplay")&&d._data(this[e],"olddisplay",g)}for(e=0;e<f;e++)this[e].style.display="none";return this},_toggle:d.fn.toggle,toggle:function(a,b,c){var e=typeof a==="boolean";d.isFunction(a)&&d.isFunction(b)?this._toggle.apply(this,arguments):a==null||e?this.each(function(){var b=e?a:d(this).is(":hidden");d(this)[b?"show":"hide"]()}):this.animate(cc("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,e){var f=d.speed(b,c,e);if(d.isEmptyObject(a))return this.each(f.complete);return this[f.queue===!1?"each":"queue"](function(){var b=d.extend({},f),c,e=this.nodeType===1,g=e&&d(this).is(":hidden"),h=this;for(c in a){var i=d.camelCase(c);c!==i&&(a[i]=a[c],delete a[c],c=i);if(a[c]==="hide"&&g||a[c]==="show"&&!g)return b.complete.call(this);if(e&&(c==="height"||c==="width")){b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY];if(d.css(this,"display")==="inline"&&d.css(this,"float")==="none")if(d.support.inlineBlockNeedsLayout){var j=cd(this.nodeName);j==="inline"?this.style.display="inline-block":(this.style.display="inline",this.style.zoom=1)}else this.style.display="inline-block"}d.isArray(a[c])&&((b.specialEasing=b.specialEasing||{})[c]=a[c][1],a[c]=a[c][0])}b.overflow!=null&&(this.style.overflow="hidden"),b.curAnim=d.extend({},a),d.each(a,function(c,e){var f=new d.fx(h,b,c);if(b$.test(e))f[e==="toggle"?g?"show":"hide":e](a);else{var i=b_.exec(e),j=f.cur();if(i){var k=parseFloat(i[2]),l=i[3]||(d.cssNumber[c]?"":"px");l!=="px"&&(d.style(h,c,(k||1)+l),j=(k||1)/f.cur()*j,d.style(h,c,j+l)),i[1]&&(k=(i[1]==="-="?-1:1)*k+j),f.custom(j,k,l)}else f.custom(j,e,"")}});return!0})},stop:function(a,b){var c=d.timers;a&&this.queue([]),this.each(function(){for(var a=c.length-1;a>=0;a--)c[a].elem===this&&(b&&c[a](!0),c.splice(a,1))}),b||this.dequeue();return this}}),d.each({slideDown:cc("show",1),slideUp:cc("hide",1),slideToggle:cc("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){d.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),d.extend({speed:function(a,b,c){var e=a&&typeof a==="object"?d.extend({},a):{complete:c||!c&&b||d.isFunction(a)&&a,duration:a,easing:c&&b||b&&!d.isFunction(b)&&b};e.duration=d.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in d.fx.speeds?d.fx.speeds[e.duration]:d.fx.speeds._default,e.old=e.complete,e.complete=function(){e.queue!==!1&&d(this).dequeue(),d.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig||(b.orig={})}}),d.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(d.fx.step[this.prop]||d.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=d.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,b,c){function g(a){return e.step(a)}var e=this,f=d.fx;this.startTime=d.now(),this.start=a,this.end=b,this.unit=c||this.unit||(d.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,g.elem=this.elem,g()&&d.timers.push(g)&&!ca&&(ca=setInterval(f.tick,f.interval))},show:function(){this.options.orig[this.prop]=d.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),d(this.elem).show()},hide:function(){this.options.orig[this.prop]=d.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=d.now(),c=!0;if(a||b>=this.options.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),this.options.curAnim[this.prop]=!0;for(var e in this.options.curAnim)this.options.curAnim[e]!==!0&&(c=!1);if(c){if(this.options.overflow!=null&&!d.support.shrinkWrapBlocks){var f=this.elem,g=this.options;d.each(["","X","Y"],function(a,b){f.style["overflow"+b]=g.overflow[a]})}this.options.hide&&d(this.elem).hide();if(this.options.hide||this.options.show)for(var h in this.options.curAnim)d.style(this.elem,h,this.options.orig[h]);this.options.complete.call(this.elem)}return!1}var i=b-this.startTime;this.state=i/this.options.duration;var j=this.options.specialEasing&&this.options.specialEasing[this.prop],k=this.options.easing||(d.easing.swing?"swing":"linear");this.pos=d.easing[j||k](this.state,i,0,1,this.options.duration),this.now=this.start+(this.end-this.start)*this.pos,this.update();return!0}},d.extend(d.fx,{tick:function(){var a=d.timers;for(var b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||d.fx.stop()},interval:13,stop:function(){clearInterval(ca),ca=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){d.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),d.expr&&d.expr.filters&&(d.expr.filters.animated=function(a){return d.grep(d.timers,function(b){return a===b.elem}).length});var ce=/^t(?:able|d|h)$/i,cf=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?d.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){d.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return d.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(e){}var f=b.ownerDocument,g=f.documentElement;if(!c||!d.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=f.body,i=cg(f),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||d.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||d.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:d.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){d.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return d.offset.bodyOffset(b);d.offset.initialize();var c,e=b.offsetParent,f=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(d.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===e&&(l+=b.offsetTop,m+=b.offsetLeft,d.offset.doesNotAddBorder&&(!d.offset.doesAddBorderForTableAndCells||!ce.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),f=e,e=b.offsetParent),d.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;d.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},d.offset={initialize:function(){var a=c.body,b=c.createElement("div"),e,f,g,h,i=parseFloat(d.css(a,"marginTop"))||0,j="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";d.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),e=b.firstChild,f=e.firstChild,h=e.nextSibling.firstChild.firstChild,this.doesNotAddBorder=f.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,f.style.position="fixed",f.style.top="20px",this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15,f.style.position=f.style.top="",e.style.overflow="hidden",e.style.position="relative",this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),a=b=e=f=g=h=null,d.offset.initialize=d.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;d.offset.initialize(),d.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(d.css(a,"marginTop"))||0,c+=parseFloat(d.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var e=d.css(a,"position");e==="static"&&(a.style.position="relative");var f=d(a),g=f.offset(),h=d.css(a,"top"),i=d.css(a,"left"),j=e==="absolute"&&d.inArray("auto",[h,i])>-1,k={},l={},m,n;j&&(l=f.position()),m=j?l.top:parseInt(h,10)||0,n=j?l.left:parseInt(i,10)||0,d.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):f.css(k)}},d.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),e=cf.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(d.css(a,"marginTop"))||0,c.left-=parseFloat(d.css(a,"marginLeft"))||0,e.top+=parseFloat(d.css(b[0],"borderTopWidth"))||0,e.left+=parseFloat(d.css(b[0],"borderLeftWidth"))||0;return{top:c.top-e.top,left:c.left-e.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&(!cf.test(a.nodeName)&&d.css(a,"position")==="static"))a=a.offsetParent;return a})}}),d.each(["Left","Top"],function(a,c){var e="scroll"+c;d.fn[e]=function(c){var f=this[0],g;if(!f)return null;if(c!==b)return this.each(function(){g=cg(this),g?g.scrollTo(a?d(g).scrollLeft():c,a?c:d(g).scrollTop()):this[e]=c});g=cg(f);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:d.support.boxModel&&g.document.documentElement[e]||g.document.body[e]:f[e]}}),d.each(["Height","Width"],function(a,c){var e=c.toLowerCase();d.fn["inner"+c]=function(){return this[0]?parseFloat(d.css(this[0],e,"padding")):null},d.fn["outer"+c]=function(a){return this[0]?parseFloat(d.css(this[0],e,a?"margin":"border")):null},d.fn[e]=function(a){var f=this[0];if(!f)return a==null?null:this;if(d.isFunction(a))return this.each(function(b){var c=d(this);c[e](a.call(this,b,c[e]()))});if(d.isWindow(f)){var g=f.document.documentElement["client"+c];return f.document.compatMode==="CSS1Compat"&&g||f.document.body["client"+c]||g}if(f.nodeType===9)return Math.max(f.documentElement["client"+c],f.body["scroll"+c],f.documentElement["scroll"+c],f.body["offset"+c],f.documentElement["offset"+c]);if(a===b){var h=d.css(f,e),i=parseFloat(h);return d.isNaN(i)?h:i}return this.css(e,typeof a==="string"?a:a+"px")}}),a.jQuery=a.$=d})(window);


/*jQuery.ajaxSetup({dataType: 'script',cache:false});
*/


function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count; //remainder will always equal old_headline until it reaches headline_count - at which point it becomes zero. clock arithmetic
  $("div.headline:eq(" + old_headline + ")").animate({left: -628},"slow", function() {
    $(this).css('left','633px');
    });
  $("div.headline:eq(" + current_headline + ")").show().animate({left: 0},"slow");  
  old_headline = current_headline;
}

// this function is used for UATP card in all payment pages 

function setSavedCardInForm(cardName,cardType,val){

	 cardName.value=val.split('|')[0];
	 cardType.value=val.split('|')[1];
	 showHideSecurityCode(cardType.value, 'savedCardCodeTd')
}

function showHideSecurityCode(cardType, securityCodeId){
	if(cardType=='UATP')
		document.getElementById(securityCodeId).style.visibility='hidden';
	else
		document.getElementById(securityCodeId).style.visibility='visible';
}

/**
 * cust_checkbox_plugin.js
 * Copyright (c) 2009 myPocket technologies (www.mypocket-technologies.com)
 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * View the GNU General Public License <http://www.gnu.org/licenses/>.

 * @author Darren Mason (djmason9@gmail.com)
 * @date 3/13/2009
 * @projectDescription	Replaces the standard HTML form checkbox or radio buttons. Allows for disable, and very customizable.
 * @version 1.0.3
 * 
 * @requires jquery.js (tested with 1.3.2)
 * 
 * @param disable_all:	false,
 * @param wrapperclass:	"group"
 */

(function($) {	
	$.fn.custCheckBox = function(options){
		
		var defaults = {
				disable_all:	false,				//disables all the elements
				wrapperclass:	"group"
			};
		//override defaults
		var opts = $.extend(defaults, options);
		
		return this.each(function() { 
	 		 var obj = $(this);
	 		 
		$.fn.buildbox = function(thisElm){

			var currElm = $(thisElm);
			
			$(currElm).css({display:"none"}).before("<span class=\"cust_checkbox\">&nbsp;&nbsp;&nbsp;&nbsp;</span>");
			
			var isChecked = $(currElm).attr("checked");
			var boxtype = $(currElm).attr("type");
			var disabled = $(currElm).attr("disabled");
			
			if(boxtype === "checkbox")
			{
				$(currElm).prev("span").addClass("checkbox");
				if(disabled || opts.disable_all){boxtype = "checkbox_disabled";}
			}
			else
			{
				$(currElm).prev("span").addClass("radio");
				if(disabled || opts.disable_all){boxtype = "radio_disabled";}
			}
			
			if(isChecked)
				$(currElm).prev("span").addClass("cust_"+boxtype+"_on");
			else
				$(currElm).prev("span").addClass("cust_"+boxtype+"_off");
			
			if(opts.disable_all)
				$(currElm).attr("disabled","disabled");
		};
		
		$.fn.buildbox($(obj));
		
		$("."+ opts.wrapperclass+" label").unbind().click(function(){
			if(!opts.disable_all)
			{
				var custbox = $(this).prev().prev();
				var boxtype = $(custbox).next("input").attr("type");
				var disabled = $(custbox).next("input").attr("disabled");
					
				if($(custbox).hasClass("checkbox"))
				{
					if($(custbox).hasClass("cust_"+boxtype+"_off") && !disabled)
						$(custbox).removeClass("cust_"+boxtype+"_off").addClass("cust_"+boxtype+"_on"); //turn on
					else if(!disabled)
						$(custbox).removeClass("cust_"+boxtype+"_on").addClass("cust_"+boxtype+"_off"); //turn off
				}
				else if(!disabled)
				{
					$(custbox).parent().find(".cust_checkbox").removeClass("cust_"+boxtype+"_on").addClass("cust_"+boxtype+"_off").next("input").removeAttr("checked");
					$(custbox).removeClass("cust_"+boxtype+"_off").addClass("cust_"+boxtype+"_on"); //turn on
					customRadioOnClick($(custbox));
				}
			}
			
		});
		
		$(".cust_checkbox").unbind().click(function(){
			
			if(!opts.disable_all)
			{
				var boxtype = $(this).next("input").attr("type");
				var disabled = $(this).next("input").attr("disabled");
					
				if($(this).hasClass("checkbox"))
				{
					if($(this).hasClass("cust_"+boxtype+"_off") && !disabled)
						$(this).removeClass("cust_"+boxtype+"_off").addClass("cust_"+boxtype+"_on").next("input").attr("checked","checked"); //turn on
					else if(!disabled)
						$(this).removeClass("cust_"+boxtype+"_on").addClass("cust_"+boxtype+"_off").next("input").removeAttr("checked"); //turn off
				}
				else if(!disabled)
				{
					$(this).parent().find(".cust_checkbox").removeClass("cust_"+boxtype+"_on").addClass("cust_"+boxtype+"_off").next("input").removeAttr("checked");
					$(this).removeClass("cust_"+boxtype+"_off").addClass("cust_"+boxtype+"_on").next("input").attr("checked","checked"); //turn on
					customRadioOnClick($(this));
					
				}
			}
		});
	}); 	
};
	
})(jQuery);


/*
 * jQuery selectbox plugin
 *
 * Licensed under the GPL license and MIT:
 *   http://www.opensource.org/licenses/GPL-license.php
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Version: 0.5
 */

/* Below functionality is Added by VA team:
 * 
 * 1. Add script and css to insert image at first and last index of list.
 * 2. Replace the Input Field with Hyperlink(<a>) to resolve the cursor problem.  
 * 3. Add script to Select the value from the list with keyboard.
 */
 
jQuery.fn.extend({
	selectbox: function(options) {
		return this.each(function() {
			new jQuery.SelectBox(this, options);
		});
	}
});

/* work around for ie logging */
/*
if (!window.console) {
	var console = {
		log: function(msg) { 
	 }
	}
}
*/
jQuery.SelectBox = function(selectobj, options) {
	
	var opt = options || {};
	opt.inputClass = opt.inputClass || "selectbox";
	opt.inputChBgClass = opt.inputChBgClass || "chInputBg";
	opt.containerClass = opt.containerClass || "selectBoxWrapper";
	opt.hoverClass = opt.hoverClass || "current";
	opt.currentClass = opt.selectedClass || "selected";
	opt.firstOptionClass = opt.firstOptionClass || "first";
	opt.lastOptionClass = opt.lastOptionClass || "last";
	opt.inputClassError = opt.inputClassError || "selectboxError";
	opt.inputClassFocus = opt.inputClassFocus || "selectboxFocus";
	opt.debug = opt.debug || false;
	
	var LiIndArray=null;
	var fCharInList=new Array();
	var tempPressKey="";
	var actLen=0;
	var charInList=false;
	var keyCache="";
	var elm_id = selectobj.name;
	var active = -1;
	var inFocus = false;
	var hasfocus = 0;
	var clearTimeId=0;
	//jquery object for select element
	var $select = $(selectobj);
	// jquery container object
	var $container = setupContainer(opt);
	//jquery input object 
	var $input = setupInput(opt);
	// hide select and append newly created elements
	$select.hide().before($input).before($container);
	
	init();
	
	$input
	.click(function(){
    if (!inFocus) {
		  $container.toggle();
		}
    	$(selectobj).removeClass("1");
    	if($input.hasClass(options.inputClassError)){
	    	$input.addClass(options.inputClass);
	    	$input.removeClass(options.inputClassError);
    	}
    	if ($container.is(':visible')) {
    		$input.addClass(options.inputChBgClass);
    	}else{
    		$input.removeClass(options.inputChBgClass)
    		$(this).trigger('blur');
    	}
    	$input.removeClass(options.inputClassFocus);
	})
	
	.focus(function(){
		if (!$container.is(':visible')) {
			$(selectobj).removeClass("1");
			$input.removeClass(options.inputClassError);
			$input.addClass(options.inputClassFocus);
		}
	   closeCal();
	})
	
	.keydown(function(event) { 
		switch(event.keyCode) {
			case 38: // up
				event.preventDefault();
				moveSelect(-1);
				break;
			case 40: // down
				event.preventDefault();
				moveSelect(1);
				break;
			case 13: // return
				event.preventDefault(); // seems not working in mac !
				if ($container.is(':visible')){
					$('li.'+opt.currentClass).trigger('click');
				}else{
					sumitSearchWithEnterKey('SearchFlightBt',event);
				}
				inFocus = false;
				break;
			default: 
				if ($container.is(':visible')){
					setFocusOnList(event);
				}else{
					clearTimeout(clearTimeId);
					suggestNextValue(event);
					clearTimeId=setTimeout("keyCache='';", 1000 );
				}
			  break;
		}
	})

	.blur(function() {
		if ($container.is(':visible') && hasfocus > 0 ) {
			if(opt.debug) console.log('container visible and has focus')
		} else {
			if (!$container.is(':visible'))
				updateDropDowns(selectobj, $input.html());
			
			$input.removeClass(options.inputClassFocus);
			$input.addClass(options.inputClass)
			hideMe();	
		}
	});
	
	function hideMe() {
		hasfocus = 0;
		$input.removeClass(options.inputChBgClass);
		$input.addClass(options.inputClass);
		$container.hide(); 
	}
	
	function init() {
		$container.append(getSelectOptions($input.attr('id'))).hide();
		var width = $container.css('width');
		$container.width(width);
    }
	
	function setupContainer(options) {
		var container = document.createElement("div");
		$container = $(container);
		$container.attr('id', elm_id+'_container');
		$container.addClass(options.containerClass);

		return $container;
	}

	function suggestNextValue(event){
		var lis = $("li", $container);
		var pressKey=String.fromCharCode(event.keyCode);
		var matchFound=false;
		var firstOpt=-1;
		if (!lis) return;
		if(typeof(arguments[1])=='undefined')
			keyCache+=pressKey;
		var opts=findOptionsForKey();

		if(opts.length>0){
			for(j=0;j<opts.length;j++){
				if($input.html().substring(0,1)==opts[j].substring(0,1) && opts.length>1){
					if($input.html()==opts[j]){
						if((j+1)>=opts.length){
							$input.html(opts[0]);
						}else{
							$input.html(opts[j+1]);
						}
						matchFound=true;
						break;
					}
				}else{
					$input.html(opts[0]);
					matchFound=true;
					break;
				}
			}
		}
		if(!matchFound){
			if(keyCache.length>1){
				keyCache=keyCache.substring(keyCache.length-1,keyCache.length);
				suggestNextValue(event,'recursive')
			}else{
				keyCache='';
			}
		}
		setCurrentSelected();
	}
	function findOptionsForKey(){
		var lis = $("li", $container);
		var opts=new Array();
		for(i=0;i<lis.length;i++){
			if($(lis[i]).html()!='' && $(lis[i]).html().substring(0,keyCache.length).toUpperCase()==keyCache.toUpperCase()){
				opts.push($(lis[i]).html());
			}
		}
		return opts;
	}
	function setCurrentSelected(){
		var val='';
		var opts=$select.children('option');
		for(i=0;i<opts.length;i++){
			if($(opts[i]).html()==$input.html()){
				val=$(opts[i]).val();
				updateInputValue(val, $(opts[i]).html());
				break;
			}
		}
		$select.val(val);
	}
	function setupInput(options) {
		var input = document.createElement("a");
		var $input = $(input);
		if($select.attr("title")){
			$input.attr("title", $select.attr("title"));
    	}
																																													   
		$input.attr("id", elm_id+"_input");
		$(input).addClass(options.inputClass);
		if($(selectobj).hasClass("1")){
			$(input).addClass(options.inputClassError);
		}
		
		$input.attr("tabIndex", $select.attr("tabIndex")); // "I" capital is important for ie
		
		return $input;	
	}

	function setFocusOnList(event){
		var k=0;
		var n=0;
		var selectValue="";
		var pressKey=String.fromCharCode(event.keyCode);
		
		$select.children('option').each(function() {
			selectValue=$(this).html();
			fCharInList[k]=selectValue.substring(0,1);
			if(charInList==false){
				if(pressKey==fCharInList[k])
					charInList=true;
				else
					charInList=false;
			}
			k++;
		})
		
		if(charInList==true){
			charInList=false;
				if(tempPressKey!=pressKey){
					
					LiIndArray=new Array();
					for(m=0; m<fCharInList.length;m++){
							selectValue=fCharInList[m];
							if(pressKey==selectValue)
								{	
									tempPressKey=pressKey;
									active=m;
									LiIndArray.push(m);
									charInList=true;
								}
					}
					actLen=1;
					active=LiIndArray[0];
				}else{
					var len=LiIndArray.length;
						if(len!=actLen){
							for(var m=0; m<len; m++){
								if(active==LiIndArray[m]){
									actLen++;
									active++;
									break;
								}
							}
						}else{
						actLen=1;active=LiIndArray[0];
						}
				}
				var lis = $("li", $container);
				if(typeof(lis)!='undefined' && typeof($(lis[active]).html())!='undefined'){
					$('li.'+opt.currentClass).removeClass(opt.currentClass);
					lis.removeClass(opt.hoverClass);
					$(lis[active]).addClass(opt.currentClass);
					setCurrentValue($(lis[active]));
				}
	    } //end of if(charInList==true)
	}
	
	function moveSelect(step) {
		
			var lis = $("li", $container);
			if (!lis) return;
			for(i=0;i<lis.length;i++){
				if($(lis[i]).html()==$input.html()){
					active=i;
					break;
				}
			}
			active +=step;
			
			if (active < 0) {
				active = 0;
			} else if (active >= lis.size()) {
				active = lis.size() - 1;
			}

			if($container.is(':visible')){
				$(lis[active]).parent().children('li').removeClass(opt.hoverClass);
				$(lis[active]).parent().children('li').removeClass(opt.currentClass);
				$(lis[active]).addClass(opt.currentClass);
			}
			// set current value
			var ar = (''+$(lis[active]).attr('id')).split('_');
			var el = ar[ar.length-1];
			$select.val(el);
			updateInputValue($select.val(), $(lis[active]).html());
	}
	
	//this is called after clicking on the list
	function setCurrent() {
		var li = $("li."+opt.currentClass, $container).get(0);
		var ar = (''+li.id).split('_');
		var el = ar[ar.length-1];
		$select.val(el);
	
		updateInputValue($select.val(), $(li).html());

		updateDropDowns(selectobj, $(li).html());
		return true;
	}
	function updateInputValue(val, listVal){
		$input.empty();
		if(val=='' && ($select.attr("id")=='originFltOneMC' || $select.attr("id")=='originFltTwoMC')){
			if($select.attr("id")=='originFltTwoMC'){
				$input.html("<b>Flight 2: </b>"+listVal);
			}
			else{
				$input.html("<b>Flight 1: </b>"+listVal);
			}
		}else{
			$input.html(listVal);
		}
	}
	function setCurrentValue(li) {
			var ar = (''+li.id).split('_');
			var el = ar[ar.length-1];
			$select.val(el);
			updateInputValue($select.val(), $(li).html());
	}
	// select value
	function getCurrentSelected() {
		return $select.val();
	}
	
	// input value
	function getCurrentValue() {
		return $input.val();
	}

	function getSelectOptions(parentid) {
		var select_options = new Array();
		var ul = document.createElement('ul');
		
		$(ul).bind("mouseleave", function(e){
			$(ul).children("li").each(function(){
				var currentVal=$input.html();
				if(currentVal==$(this).html() || currentVal.indexOf($(this).html())!=-1){
					$(this).addClass(opt.currentClass);
				}	
			})
		});
		
		var lastIdx=$select.children('option').length-1;
		var i=0;
		$select.children('option').each(function() {
			var li = document.createElement('li');
			li.setAttribute('id', parentid + '_' + $(this).val());
			li.innerHTML = $(this).html();
			if (opt.debug) console.log('options  :'+$(this).val()+" [] "+opt.lastOptionClass);
			if (i==lastIdx) {
				$(li).addClass(opt.lastOptionClass);
			}
			if ($(this).is(':selected')) {
				updateInputValue($select.val(), $(li).html());
				$(li).addClass(opt.currentClass);
			}
			ul.appendChild(li);
			$(li)
			.mouseover(function(event) {
				hasfocus = 1;
				if (opt.debug) console.log('over on : '+this.id);
				$(this).parent().children('li').removeClass(opt.currentClass);
				jQuery(event.target, $container).addClass(opt.hoverClass);
			})
			
			.mouseout(function(event) {
				hasfocus = -1;
				if (opt.debug) console.log('out on : '+this.id);
				jQuery(event.target, $container).removeClass(opt.hoverClass);
			})
			
			//call when click on the li
			.click(function(event) {
				if (opt.debug) console.log('click on :'+this.id);
				$(this).parent().children('li').removeClass(opt.hoverClass);
				$(this).parent().children('li').removeClass(opt.currentClass);
				$(this).addClass(opt.currentClass);
				setCurrent();
				hideMe();
			});
			i++;
		});
		return ul;
	}
	
};

function checkClick(divId){
	var x=document.getElementById(divId);
	if(divId=="checkbox10")	{
		if(document.getElementById(divId).checked && document.getElementById('checkbox11')!=null){
			document.getElementById('checkbox11').checked=true;
		}
		if(!x.checked && document.getElementById('checkbox11')!=null){
			document.getElementById('checkbox11').checked=false;
		 }
	 }
	 if(divId=="checkbox11"){
	 	if(x.checked){
			document.getElementById('checkbox10').checked=true;
		}
		if(!x.checked){
			document.getElementById('checkbox10').checked=false;
		}
	}
	 if(divId=="checkbox20"){
		if(document.getElementById(divId).checked && document.getElementById('checkbox21')!=null){
			document.getElementById('checkbox21').checked=true;
		}
		if(!x.checked && document.getElementById('checkbox21')!=null){
			document.getElementById('checkbox21').checked=false;
		 }
	 }
	 if(divId=="checkbox21"){
	 	if(x.checked){
			document.getElementById('checkbox20').checked=true;
		}
		if(!x.checked){
			document.getElementById('checkbox20').checked=false;
		}
	}
}

function enableEmail()
{

	if(document.purchaseForm.elements['viewPurchaseModel.contact'].checked==true)
	{
		document.purchaseForm.elements['viewPurchaseModel.contactEmail'].disabled=false;
	}
	
}

function openTravelFlagCodeDiv(linkId)
{
	var positionObj=linkId;
	setPosition(document.getElementById(positionObj), document.getElementById("travelFlagCodeDiv"), -90, 350);
	document.getElementById("travelFlagCodeDiv").style.display="block";
}

function closeTravelFlagCodeDiv()
{
	document.getElementById("travelFlagCodeDiv").style.display="none";
	document.barForm.method.value="viewPurchaseTabLink";
	document.barForm.tabSelect.value="5";
	document.barForm.tabFlg.value = "6";
	document.barForm.action="viewPurchaseTabLink.do";
	document.barForm.submit();
}

function openTravelInsurancePopupDiv(linkId)
{
	var positionObj=linkId;
	setPosition(document.getElementById(positionObj), document.getElementById("travelInsuranceDes_one"),300, 150);
	document.getElementById("travelInsuranceDes").style.display="block";
}

function closeTravelInsurancePopupDiv()
{
	document.getElementById("travelInsuranceDes").style.display="none";
}

function submitPRForm(){

	document.receiptForm.tabNumber.value="7";
	document.receiptForm.tabSelect.value="7";
	document.receiptForm.method.value="finalReceipt";
	document.receiptForm.action="viewReceipt.do";
	if(getCookie('channel_session_id')!=null){
		document.receiptForm.channelId.value=getCookie('channel_session_id');
	}
	document.getElementById('purchaseBtnHref').style.display='none';
	document.getElementById('purchaseBtnHrefDisabled').style.display='block';
	document.receiptForm.submit();
	document.getElementById("transactionImageShow").style.display="block"

	
}


//***************************Start seat Map functions ********************************************
var isAdultWithInfant = 0;
var clearPopupInterval;
var counter = 8;
//UpGrade Variables//
var upGradeType;
var newSeatNumber;
var seatTypeUpgrade;
var currencyCodeDollar ='$';
var currentSeat = '';
var previousStyleClass = '';
var selectedSeat = '';
var selectedSeatId = '';
var selectedSeatClassName = '';
var selectedSeatCabinClass = '';
var selectedSeatStyleClass = '';
var selectedSeatDisplay = '';
var selectedSeatCabinClassDisplay = '';
var selectedSeatType = '';
var nSSIndex = 0;
var nSSIndex1 = 0;
//var paxCount = 0;
//var segmentCount = 0;
var activeSegment = 0;
//var activeSegmentIndex =0;
var oandDCount =0;
var activeGuest = 0;
//var activeGuestIndex = 0;
//var activeLegIndex =0;
var upgradeAmountMCS=0;
//var aCabinClass = 0;
var fareFormatType = 0;
//var notSelected=0;
//var methodValueReUse= "";
//var actionVal="";
//var methodVal="";
var restrictGuestArr ="";
var isUpgrSeat=new Array(1);

//----------------------------------
//new variables for change seat
//----------------------------------
var aGuestSeatsOrig = new Array(1);
aGuestSeatsOrig[0] = new Array(1);
aGuestSeatsOrig[0][0] = '';
var seatSelectPageId = 0; 
//0 == booking flow
//1 == change seat flow
//----------------------------------
//end new variables for change seat
//----------------------------------


//-------------------------------
//start check cabin class.This function displays the upgrade popUp  message on Roll over.
//-------------------------------


//-------------------------------
//start check cabin class
//-------------------------------

function isReaccommodated(){
	document.getElementById('diabilityMsgId').style.visibility='hidden';
	for(eachSegCnt=0; eachSegCnt<aGuestSeats.length; eachSegCnt++){
		for(eachGuestCnt=0; eachGuestCnt<aGuestSeats[eachSegCnt].length; eachGuestCnt++){
			if(aGuestSeats[eachSegCnt][eachGuestCnt]=='3C' || aGuestSeats[eachSegCnt][eachGuestCnt]=='3D'){
				document.getElementById('diabilityMsgId').style.visibility='visible';
				eachSegCnt=aGuestSeats.length;
				break;
			}else if(aGuestSeats[eachSegCnt][eachGuestCnt]=="Not Selected" && seatSelectPageId==1){
				if(aGuestSeatsOrig[eachSegCnt][eachGuestCnt]=='3C' || aGuestSeatsOrig[eachSegCnt][eachGuestCnt]=='3D'){
					document.getElementById('diabilityMsgId').style.visibility='visible';
					eachSegCnt=aGuestSeats.length;
					break;
				}
			}
		}
	}
}

function checkCabinClass(selectedClass,action,seatObject) {
	
	if(clearPopupInterval) {
		clearInterval(clearPopupInterval);
		counter = 8;
	}
	
	var yScrollOffset = f_scrollTop();
	var upgradeCost = '';
	var popUpHTML = '';
	var seat = seatObject.id.substr(7);
	var upgrade =true;
	var yPosOffSet = 0;
	var row = 0;
	var withIn24hrs = false;
	
	if(document.getElementById("withIn24hrs")){
		withIn24hrs = document.getElementById("withIn24hrs").value;
	} 
	if(seat.length == 2) {
		row = seat.substr(0,1);
	} else if(seat.length == 3) {
		row = seat.substr(0,2);
	}

	if(aCabinClass[activeSegmentIndex] != selectedClass){
		if(selectedClass == 'FIRST') {
			if(withIn24hrs==false){
				upgradeCost = upgradeAmountFirst;
				popUpHTML = 'html/popup-seatselect-firstclass.html';
				popUpTitle = 'First Class';
				yPosOffSet = -168;
				if(yScrollOffset >= 220) {
					yPosOffSet = 25;
				}
			}
		} else if(selectedClass == 'MCS') {
			if(upgradeAmountMCS <0 || eval(upgradeAmountMCS.replace(",",""))==999999){
				if(withIn24hrs==false){
					upgrade=false;
					popUpHTML = 'html/popup-seatselect-maincabin-refundable-hf.html';
					popUpTitle = 'Main Cabin Select';
					yPosOffSet = -150;
					if(yScrollOffset >= 325 && row == '3') {
						yPosOffSet = 25;
					}
				}
			}else {
				upgradeCost = upgradeAmountMCS;
				popUpHTML = 'html/popup-seatselect-maincabinselect.html';
				popUpTitle = 'Main Cabin Select';
				yPosOffSet = -185;
				if(yScrollOffset >= 325 && row == '3') {
					yPosOffSet = 25;
				} else if(yScrollOffset >= 546 && (row == '10' || row == '9')) {
					yPosOffSet = 25;
				}
			}
		}
	}
	
	if(action == 'mouseover' && popUpHTML != '') {
		if(aCabinClass[activeSegmentIndex] != selectedClass) {
			if(upgrade){
				if(fareFormatType== 'Dollars')
					upgradeCost=currencyCodeDollar+upgradeCost.split(".")[0]+".00";
				else
					upgradeCost=upgradeCost.split(".")[0]+' points';
			}	
			updatePopup(popUpHTML,popUpTitle,350,seatObject,false,-150,yPosOffSet,false,upgradeCost);
		}
	}
	if(action == 'mouseout') {
		closePopup('popupId');
	}
	
}

//-------------------------------
//end check cabin class
//-------------------------------

//-------------------------------
//start set guest/flight table js
//-------------------------------

function changeGuestSegment(type,guest,segment,isPageRefresh,sessionLegIndex,elementId) {

	var prevActiveSegment = activeSegment;
	var currentActiveGuest = activeGuest;
	//var prevActiveFlight = activeFlight;
	
	if(type == 'changeGuest') {
		// if guest is not the default '0' value
		if(guest != 99) {
			activeGuest = guest;
			activeGuestIndex = guest;
		}
		// if flight is not the default '0' value
		if(segment != 99) {
			activeSegment = segment;
			activeSegmentIndex = segment;
		}
		
		if(segment == 99) {
			activeSegment = prevActiveSegment;
			activeSegmentIndex = prevActiveSegment;
			activeGuest = guest;
			activeGuestIndex = guest;
		}
		
		if(guest == 99) {
			activeGuest = 0;
			activeGuestIndex = 0;
			activeSegment = segment;
			activeSegmentIndex = segment;
		}
		
		// default loop values
		var i;
		var j;
		
		// set all rows/columns to no style class / clean slate
		for(i=0;i<segmentCount;i++) {
			document.getElementById('segment_'+i).className='ssGuestTableInactive';
			for(j=0;j<paxCount;j++) {
				document.getElementById('segmentGuest_'+i+'_'+j).className='ssGuestTableInactive';
			}
		}
		// loop over the guest headers and reset to clean slate
		for(j=0;j<paxCount;j++) {
			document.getElementById('guest_'+j).className='ssGuestTableInactive';
		}
		
		
		// set flight div according to flight clicked
		if(activeSegment != prevActiveSegment && activeSegment <= segmentCount) {
			if(isPageRefresh !='true')
				reloadSeatMapForThisSegment(activeSegment,prevActiveSegment,sessionLegIndex,elementId);
		}
		
		// loop over guest flight table and set active table cells according to selection
		document.getElementById('guest_'+activeGuestIndex).className='ssGuestTableActive';
		document.getElementById('segment_'+activeSegmentIndex).className='ssGuestTableActive';
		// loop over flight cells and set appropriate active classes
		for(j=0;j<paxCount;j++) {
			document.getElementById('segmentGuest_'+activeSegmentIndex+'_'+j).className='ssGuestTableActive';
		}
		for(k=0;k<segmentCount;k++) {
			document.getElementById('segmentGuest_'+k+'_'+activeGuestIndex).className='ssGuestTableActive';
		}			
	
		// set dark gray where flight and guest intersect
		document.getElementById('segmentGuest_'+activeSegmentIndex+'_'+activeGuestIndex).className='ssGuestTableActiveIntersect';
		
	}
	
}


//seatID = table cell id of seat selected
//seatClassName = current class setting of selected cell (for revert functionality)

function setGuestSeat(seatObject,cabinClass,isExitRow,seatType,isNRSRow) {
	var i;
	var j;
	selectedSeat = seatObject.id.substr(7);
	selectedSeatClassName = seatObject.className;
	selectedSeatCabinClass = '';
	selectedSeatId = seatObject.id;
	currentCabinClass = aCabinClass[activeSegmentIndex];
	currentSeat = aGuestSeats[activeGuestIndex][activeSegmentIndex];
	previousStyleClass = aPrevSeatStyle[activeGuestIndex][activeSegmentIndex];
	var anotherGuestsSeat = 'false';
	var upgradeCost = '';
	var popUpHTML = '';
	var popUpWidth = '250';
	var popUpTitle = '';
	var popUpRecline = false;
	var popUpMCSExitRow = false;
	var popUpUpgrade = false;
	var popUpNoUpgrade =false;
	var popUpNoUpGrade =false;
	
	if(aGuestSeats[activeGuestIndex][activeSegmentIndex] && (aGuestSeats[activeGuestIndex][activeSegmentIndex] != null && aGuestSeats[activeGuestIndex][activeSegmentIndex] != '' && aGuestSeats[activeGuestIndex][activeSegmentIndex] != notSelected)) {
		currentSeat = 'seatId_'+aGuestSeats[activeGuestIndex][activeSegmentIndex];
	}
	// ------------------------------------------------------------------ //
	// set new seat and class values if seat does not equal existing seat //
	// ------------------------------------------------------------------ //
	if(seatObject.id != currentSeat) {
		// 	set first className for cell style
		if(cabinClass=='FIRST'){
			selectedSeatCabinClassDisplay='First';
			selectedSeatStyleClass = 'ssSeatMapFCSelected';
		}
		else if(cabinClass=='MCS'){
			selectedSeatCabinClassDisplay='Main Cabin Select';
			selectedSeatStyleClass = 'ssSeatMapMCSSelected';
		}
		else{
			selectedSeatCabinClassDisplay='Main Cabin';
			selectedSeatStyleClass = 'ssSeatMapMCSelected';
		}
		if(cabinClass == 'FIRST') {
			if(aCabinClass[activeSegmentIndex] == 'FIRST'){
				selectedSeatCabinClass = 'FIRST';
			}
			else{
				popUpHTML = 'html/popup-seatselect-ug-firstclass.html';
				upgradeCost=upgradeAmountFirst;
				popUpTitle = 'First Class';
				yPosOffSet = 0;
				popupWidth = 518;
				selectedSeatCabinClass = 'FIRST';
				popUpUpgrade = true;
				upGradeType='FIRST';
			}
		// set MCS className for cell style for row 3
		} else if(cabinClass=='MCS' && isExitRow=='false' && aCabinClass[activeSegmentIndex]=='ECONOMY') {
			
			if(upgradeAmountMCS<0 || eval(upgradeAmountMCS.replace(",",""))==999999){
					popUpHTML = 'html/popup-seatselect-mcs-cannot-upgrade.html';
					popUpTitle = 'Main Cabin Select';
					popupWidth = 400;
					yPosOffSet = 0;
					popUpUpgrade=false;
					popUpNoUpGrade =true;
			}
			else{
				popUpHTML = 'html/popup-seatselect-ug-maincabinselect.html';
				popUpTitle = 'Main Cabin Select';
				upgradeCost=upgradeAmountMCS;
				yPosOffSet = 0;
				popupWidth = 518;
				selectedSeatCabinClass = 'MCS';
				popUpUpgrade = true;
				upGradeType='MCS';
			}
			// if aircraft is a320 and is MCS/exit row
		} else if(cabinClass == 'MCS' && isExitRow == 'true') {
			popupWidth = 518;
			if(upgradeAmountMCS<0 || (eval(upgradeAmountMCS.replace(",",""))==999999 && aCabinClass[activeSegmentIndex]=='ECONOMY')){
					popUpHTML = 'html/popup-seatselect-mcs-cannot-upgrade.html';
					popUpTitle = 'Main Cabin Select';
					popupWidth = 350;
					yPosOffSet = -150;
					popUpUpgrade=false;
					popUpMCSExitRow = false;
					popUpNoUpGrade =true;
			}else if(aCabinClass[activeSegmentIndex] == 'MCS') { 
				if(restrictGuestArr[activeGuestIndex] && (restrictGuestArr[activeGuestIndex]=='restrict' || restrictGuestArr[activeGuestIndex]=='fullRestrict')){
					popUpHTML = 'html/popup-seatselect-restricted.html';
					popupWidth = 375;
				} else {
				popUpHTML = 'html/popup-seatselect-maincabinselect-exitrow.html';
				}
				popUpMCSExitRow = true;
			} else {
				upgradeCost=upgradeAmountMCS;
				upGradeType='MCS';
				if(restrictGuestArr[activeGuestIndex] && (restrictGuestArr[activeGuestIndex]=='restrict' || restrictGuestArr[activeGuestIndex]=='fullRestrict')){
					popUpHTML = 'html/popup-seatselect-restricted.html';
					popupWidth = 375;
					popUpMCSExitRow = true;
				} else {
				popUpHTML = 'html/popup-seatselect-ug-maincabinselect-exitrow.html';
				popUpUpgrade = true;
			}	
			}
			popUpTitle = 'Main Cabin Select';
			yPosOffSet = 0;
			selectedSeatCabinClass = 'MCS';
		} else if(cabinClass == 'ECONOMY' && isNRSRow == 'true') {
			popUpRecline = true;
			popUpHTML = 'html/popup-seatselect-recline.html';
			popUpTitle = 'FAA Restrictions';
			yPosOffSet = 0;
			popupWidth = 400;
			selectedSeatCabinClass = 'ECONOMY';
		}else if(cabinClass == 'ECONOMY' && isExitRow == 'true') {
			popUpRecline = true;
			popUpHTML = 'html/popup-seatselect-restricted.html';
			popUpTitle = '';
			yPosOffSet = 0;
			popupWidth = 375;
			popUpNoUpGrade=true
			selectedSeatCabinClass = 'ECONOMY';
		}
		
		selectedSeatType=seatType;
		if(selectedSeatType=='W'){
			selectedSeatType='Window';
		}else if(selectedSeatType=='A'){
			selectedSeatType='Aisle';
		}else if(selectedSeatType=='M'){
			selectedSeatType='Middle';
		}
		selectedSeatCabinClassDisplay =selectedSeatCabinClassDisplay+'/'+ selectedSeatType;
		// set variable to determine if selected seat is already assigned to another guest
		for(i=0;i<paxCount;i++) {
			if(aGuestSeats[i][activeSegmentIndex] == selectedSeat) {
				anotherGuestsSeat = 'true';
			}
		}
		// only set the seat if seat is not previously selected and available
		if(anotherGuestsSeat == 'false') {
			if(popUpUpgrade) {
				//document.getElementById('overlayOkId').style.display = 'none';
				closePopup('popupId');
				newSeatNumber=selectedSeat;
				seatTypeUpgrade=seatType;
				if(fareFormatType == 'Dollars')
					upgradeCost=currencyCodeDollar+upgradeCost;
				else
					upgradeCost=upgradeCost.split(".")[0]+' points';
				popupOverlay(popUpHTML,popUpTitle,popupWidth,seatObject,false,-200,yPosOffSet,false,upgradeCost);
		    }
			else if(popUpNoUpGrade) {
				closePopup('popupId');
				popupOverlay(popUpHTML,popUpTitle,popupWidth,seatObject,false,-200,yPosOffSet,false,'');
				
			}
			else if(popUpRecline == true) {
				closePopup('popupId');
				popupOverlay(popUpHTML,popUpTitle,popupWidth,seatObject,false,-200,yPosOffSet,false,'',setSeat());
				
			}
			else if(popUpRecline == true) {
				closePopup('popupId');
				popupOverlay(popUpHTML,popUpTitle,popupWidth,seatObject,false,-200,yPosOffSet,false,'',setSeat());
				
			} else {
				if(popUpMCSExitRow == true) {
					if(fareFormatType == 'Dollars')
						upgradeCost=currencyCodeDollar+upgradeCost;
					popupOverlay(popUpHTML,popUpTitle,popupWidth,seatObject,false,-200,yPosOffSet,false,upgradeCost);
				} else {
					setSeat();
				}
			
			}
			
		}
		
	// if the seat is an existing selection, then on second click, set values for deselection
	} else {
		if(cabinClass=='FIRST'){
			previousStyleClass = 'ssSeatMapFCAvailable';
		}else if(cabinClass=='MCS'){
			previousStyleClass = 'ssSeatMapMCSAvailable';
		}else{
			previousStyleClass = 'ssSeatMapMCAvailable';
		}
		aGuestSeats[activeGuestIndex][activeSegmentIndex] = notSelected;
		aPrevSeatStyle[activeGuestIndex][activeSegmentIndex] = '';
		aSeatType[activeGuestIndex][activeSegmentIndex] = notSelected;
		document.getElementById(seatObject.id).className = previousStyleClass;
		var displaySeatVal="--";
		if(seatSelectPageId == 1 && aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] != '' && aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] != 'Not Selected') {
			displaySeatVal = aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex];
			displaySeatVal+="3C,3D".indexOf(displaySeatVal.toUpperCase())>=0?'*':'';
		}
		document.getElementById('segmentGuest_'+activeSegmentIndex+'_'+activeGuestIndex).innerHTML = displaySeatVal;
		if(seatSelectPageId==1){
			if(eval(isUpgrSeat[activeLegIndex][activeSegmentIndex])){
				document.getElementById('Guest_'+activeLegIndex+'_'+activeSegmentIndex+'_'+activeGuestIndex).innerHTML='Not Selected';
			}else{
				document.getElementById('Guest_'+activeLegIndex+'_'+activeSegmentIndex+'_'+activeGuestIndex).innerHTML=
					aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex]!="" && aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex]!='Not Selected' ? 
							aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] : 'Not Selected';
			}
		}else{
		document.getElementById('Guest_'+activeLegIndex+'_'+activeSegmentIndex+'_'+activeGuestIndex).innerHTML='Not Selected';
		
	}isReaccommodated();
	}
	
	// -----------------------------------------------------------------
	// start local function to set appropriate values for seat selection
	// -----------------------------------------------------------------
	
	function setSeat() {
		if(cabinClass=='FIRST'){
			previousStyleClass = 'ssSeatMapFCAvailable';
		}else if(cabinClass=='MCS'){
			previousStyleClass = 'ssSeatMapMCSAvailable';
		}else{
			previousStyleClass = 'ssSeatMapMCAvailable';
		}
		var setSeat = 'true';
		// check if seat belongs to another guest, if so, do not allow seat assignment
		for(i=0;i<paxCount;i++) {
			if(aGuestSeats[i][activeSegmentIndex] == selectedSeat) {
				setSeat = 'false';
				break;
			}
		}
		
		// if seat assignment conditions met, then set seat
		if(setSeat == 'true') {
			var selectedSeatDisplay = selectedSeat.toUpperCase();
			// if current seat selected, set it's class back to it's previous state
			if(currentSeat && currentSeat != notSelected && currentSeat != '') {
				document.getElementById(currentSeat).className = previousStyleClass;
			}
			
			// set array value for guest, set previous style array value, set selected seat to selected state & set cabin class to selected
			aGuestSeats[activeGuestIndex][activeSegmentIndex] = selectedSeat;
			aPrevSeatStyle[activeGuestIndex][activeSegmentIndex] = seatObject.className; //seatClassName
			aSeatType[activeGuestIndex][activeSegmentIndex] = seatType;
			document.getElementById(seatObject.id).className = selectedSeatStyleClass;
			//aCabinClass[activeSegmentIndex] = selectedSeatCabinClass;
			
			// set guest table with selected seat
			var selectedSeatDisplayYTS = selectedSeatDisplay;
			if(selectedSeatDisplay=='3C' || selectedSeatDisplay=='3D')
				selectedSeatDisplay=selectedSeatDisplay+"*";
			
			if(seatSelectPageId == 1 && aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] != '' && aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] != 'Not Selected') {
				selectedSeatDisplay = '<span class="strikeOut">'+aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] + "</span> /" + selectedSeatDisplay;
			}
			document.getElementById('segmentGuest_'+activeSegmentIndex+'_'+activeGuestIndex).innerHTML = selectedSeatDisplay + '<br><span style="font-size:9px;font-family:arial;">' + selectedSeatCabinClassDisplay + '</span>';
			if(document.getElementById('Guest_'+activeLegIndex+'_'+activeSegmentIndex+'_'+activeGuestIndex))
				document.getElementById('Guest_'+activeLegIndex+'_'+activeSegmentIndex+'_'+activeGuestIndex).innerHTML=selectedSeatDisplayYTS
			
			// set next guest without seat assignment
			setNextGuest();
			isReaccommodated();
		}
		
	}
	
	// -----------------------------------------------------------------
	// end local function to set appropriate values for seat selection
	// -----------------------------------------------------------------
	
}

//-------------------------
//end set guest seat js
//-------------------------

var methodValueReUse="";
function upgradeSeat(){
	//showLoadingImageOpen('ssSeatMap01');
	showWaitImage();
	document.seatMapForm.guestIndex.value=activeGuestIndex;
	document.seatMapForm.newSeatNumber.value=newSeatNumber;
	document.seatMapForm.upgradeType.value=upGradeType;
	document.seatMapForm.seatType.value=seatTypeUpgrade;
	document.seatMapForm.activeSegmentIndex.value=activeSegmentIndex;
	document.seatMapForm.selectedSeatsForSegment.value="";
	if(methodValueReUse==null || methodValueReUse=="")
		document.seatMapForm.method.value='seatUpgrade';
	else
		document.seatMapForm.method.value=methodValueReUse;
	document.seatMapForm.submit();
	
} 


//---------------------------
//start set next active guest
//---------------------------
function setNextGuest() {
	
	var assignedSeatCount = 0;
	for(i=0;i<paxCount;i++) {
		if(aGuestSeats[i][activeSegmentIndex] == null || aGuestSeats[i][activeSegmentIndex] == '' || aGuestSeats[i][activeSegmentIndex] == notSelected) {
			changeGuestSegment('changeGuest',i,activeSegmentIndex);
			break;
		}
	}
}
//--------------------------
//end set next active guest
//---------------------------


function populateSelectedSeats(segmtNumber){
	var seatsForAsegment ='';
	var selectedSeatNameTypes='';
	for(j=0;j<paxCount;j++){
		var seat = aGuestSeats[j][segmtNumber];
		var seatType = aSeatType[j][segmtNumber];
		if(seatsForAsegment == '' || seatsForAsegment == null )
			seatsForAsegment = seat;
		else
			seatsForAsegment =seatsForAsegment+","+seat;
		if(selectedSeatNameTypes == '' || selectedSeatNameTypes == null )
				selectedSeatNameTypes = seatType;
		else
			selectedSeatNameTypes =selectedSeatNameTypes+","+seatType;
	}
	document.seatMapForm.selectedSeatsForSegment.value=seatsForAsegment;
	document.seatMapForm.selectedSeatNameTypes.value=selectedSeatNameTypes;
}

function reloadSeatMapForThisSegment(segmentId,prevActiveSegment,sessionLegIndex,elementId){
	
	
	//showLoadingImageOpen(elementId);
	showWaitImage();
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	var nextAction='';
	if(actionVal=='seatselect' || actionVal=='postseatselect'){
		methodValueReUse='seatselect';
		nextAction='seatselect';
	}
	else {
		nextAction=actionVal;
	}
	myurl=nextAction+".do?method="+methodValueReUse+"&activeSegmentIndex="+segmentId+"&prevActiveSegment="+prevActiveSegment+"&ajaxCall=true";
	
	if(actionVal=="showChangeSeatMap" || actionVal=="checkInSeatSelect"){
		populateSelectedSeats(prevActiveSegment);
		myurl=myurl+"&selectedSeatsForSegment="+document.seatMapForm.selectedSeatsForSegment.value+"&selectedSeatNameTypes="+document.seatMapForm.selectedSeatNameTypes.value+"";
	}
		
	myurl=myurl+"&dummy="+dummy;
	var seatsForAsegment ='';
	var selectedSeatNameTypes='';
	for(j=0;j<paxCount;j++){
		var seat = aGuestSeats[j][prevActiveSegment];
		var seatType = aSeatType[j][prevActiveSegment];
		if(seatsForAsegment == '' || seatsForAsegment == null )
			seatsForAsegment = seat;
		else
			seatsForAsegment =seatsForAsegment+","+seat;
		if(selectedSeatNameTypes == '' || selectedSeatNameTypes == null )
				selectedSeatNameTypes = seatType;
		else
			selectedSeatNameTypes =selectedSeatNameTypes+","+seatType;
	}
	myurl=myurl+"&selectedSeatsForSegment="+seatsForAsegment+"&selectedSeatNameTypes="+selectedSeatNameTypes;
	myurl=replaceAllFunction(myurl, " ", '%20');
	$("#ssSeatMap01").load(myurl,'data:script',showLoadingImageClose); 
}

function replaceAllFunction(txt, replace, with_this) {  return txt.replace(new RegExp(replace, 'g'),with_this);}

function submitTab(legIndex){
	//showLoadingImageOpen('ssSeatMap01');
	showWaitImage();
	var seatsForAsegment ='';
	var selectedSeatNameTypes='';
	for(j=0;j<paxCount;j++){
		var seat = aGuestSeats[j][activeSegmentIndex];
		var seatType = aSeatType[j][activeSegmentIndex];
		if(seatsForAsegment == '' || seatsForAsegment == null )
			seatsForAsegment = seat;
		else
			seatsForAsegment =seatsForAsegment+","+seat;
		if(selectedSeatNameTypes == '' || selectedSeatNameTypes == null )
				selectedSeatNameTypes = seatType;
		else
			selectedSeatNameTypes =selectedSeatNameTypes+","+seatType;
	}
	if(!(actionVal==null || actionVal==""))
		document.seatMapForm.action = actionVal+".do";
	if(!(methodValueReUse==null || methodValueReUse==""))
		document.seatMapForm.method.value = methodValueReUse;
	document.seatMapForm.selectedSeatsForSegment.value=seatsForAsegment;
	document.seatMapForm.selectedSeatNameTypes.value=selectedSeatNameTypes;
	document.seatMapForm.tabSelected.value=legIndex;
	document.seatMapForm.activeSegmentIndex.value=activeLegIndex;
	document.seatMapForm.submit();
}

function handleTabs(){
	var tabId ='tab_'+activeLegIndex;
	var tripId= 'tab_trip_'+activeLegIndex;
	var labelId= 'tab_label_'+activeLegIndex;
	if(document.getElementById(tabId) && document.getElementById(labelId)){
	document.getElementById(tabId).className="fsTripTypeActive";
	document.getElementById(tripId).className="fsTripTypeNumActive";
	document.getElementById(labelId).className="fsTripTypeLabelActive";
	}
	
	disableOtherTabs();
	function disableOtherTabs(){
		for(i=0;i<oandDCount;i++){
			if(i!= activeLegIndex){
				var tabId ='tab_'+i;
				var tripId= 'tab_trip_'+i;
				var labelId= 'tab_label_'+i;
				if(document.getElementById(tabId) && document.getElementById(labelId)){
				document.getElementById(tabId).className="fsTripTypeInactive";
				document.getElementById(tripId).className="fsTripTypeNumInactive";
				document.getElementById(labelId).className="fsTripTypeLabelInactive";
			}
		}
	}
}
}


//----------------------------------
//start function to validate if exit
//row check box has been clicked
//----------------------------------
function validateExitRow(functionType) {
	// get checkbox object
	var checkBoxObject = document.getElementById('ssExitRowAccept');
	// check if it's value is 0, then error msg, otherwise, 
	// set seatupgrade if upgrading OR assignseat if already MCS
	if(checkBoxObject.value == '0') {
		var divObject = document.getElementById('exitRowErrorDiv');
		var errorMsg = '<table width="100%"><tr><td>';
		errorMsg += '<img src="https://static.virginamerica.com/images/esc-sign.gif">';
		errorMsg += '</td><td class="font11 validationDefault fontBold">';
		errorMsg += 'To select this seat, please check the box below to accept the terms and conditions';
		errorMsg += '</td></tr></table>';
				
		divObject.style.display = 'block';
		divObject.innerHTML = errorMsg;
		document.getElementById('ssExitRowAcceptContainer').style.backgroundColor = '#993399';
		document.getElementById('exitRowTC').className = 'validationDefault fontBold';
	} else {
		closePopup('popupOverlayBg');
		if(functionType == 'setUpgrade') {
			upgradeSeat();
		} else {
			assignSeat();
		}
	}
}

function assignSeat() {
	var setSeat = 'true';
	// check if seat belongs to another guest, if so, do not allow seat assignment
	for(i=0;i<paxCount;i++) {
		if(aGuestSeats[i][activeSegmentIndex] == selectedSeat) {
			setSeat = 'false';
			break;
		}
	}
	if(setSeat == 'true') {
		var selectedSeatDisplay = selectedSeat.toUpperCase();
		// if current seat selected, set it's class back to it's previous state
		if(currentSeat && currentSeat !=notSelected && currentSeat != '') {
			document.getElementById(currentSeat).className = previousStyleClass;
		}
			
		// set class
		if(selectedSeatCabinClass == 'FIRST') {
			selectedSeatStyleClass = 'ssSeatMapFCSelected';
		} else if(selectedSeatCabinClass == 'MCS') {
			selectedSeatStyleClass = 'ssSeatMapMCSSelected';
		} else if(selectedSeatCabinClass == 'ECONOMY') {
			selectedSeatStyleClass = 'ssSeatMapMCSelected';
		}
		// set array with new selected seat
		aGuestSeats[activeGuestIndex][activeSegmentIndex] = selectedSeat;
		// set array with seat type
		aSeatType[activeGuestIndex][activeSegmentIndex] = selectedSeatType;
		// set new cabin class in cabinClass array
		aCabinClass[activeSegmentIndex] = selectedSeatCabinClass;
		// set new seat with selected class
		document.getElementById(selectedSeatId).className = selectedSeatStyleClass;
		// set guest table with selected seat
		var selectedSeatDisplayYTS = selectedSeatDisplay;
		if(selectedSeatDisplay=='3C' || selectedSeatDisplay=='3D')
			selectedSeatDisplay=selectedSeatDisplay+"*";
		if(seatSelectPageId == 1 && aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] != '' && aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] != 'Not Selected') {
			selectedSeatDisplay = '<span class="strikeOut">'+aGuestSeatsOrig[activeGuestIndex][activeSegmentIndex] + "</span> /" + selectedSeatDisplay;
		}
		document.getElementById('segmentGuest_'+activeSegmentIndex+'_'+activeGuestIndex).innerHTML = selectedSeatDisplay + '<br><span style="font-size:9px;font-family:arial;">' + selectedSeatCabinClassDisplay + '</span>';
		// store previous style
		aPrevSeatStyle[activeGuestIndex][activeSegmentIndex] = selectedSeatClassName;
		//Update YTS
		document.getElementById('Guest_'+activeLegIndex+'_'+activeSegmentIndex+'_'+activeGuestIndex).innerHTML=selectedSeatDisplayYTS;
		setNextGuest();
		isReaccommodated();
	}
}

function toggleExitRow() {
	// get checkbox object
	var checkBoxObj = document.getElementById('ssExitRowAccept');
	// if it's value is 0 or 'unchecked' then set 
	// it to checked onclick otherwise set back to 0
	if(checkBoxObj.value == '0') {
		checkBoxObj.value = '1';
	} else {
		checkBoxObj.value = '0';
	}
}

function goBack(){
	document.barForm.method.value="flightSearchTabLink";
	document.barForm.tabSelect.value="2";
	if(actionVal=='seatselect'){
		document.barForm.action="flightSearchTabLink.do";
	}
	else if(actionVal=='postseatselect'){
		document.barForm.action="postFlightSearchTabLink.do";
	}
	showWaitImage();
	document.barForm.submit();
	
	
}

function nextPage(){
	//showLoadingImageOpen('ssSeatMap01');
	showWaitImage();
	var seatsForAsegment ='';
	var selectedSeatNameTypes='';
	for(j=0;j<paxCount;j++){
		var seat = aGuestSeats[j][activeSegmentIndex];
		var seatType = aSeatType[j][activeSegmentIndex];
		if(seatsForAsegment == '' || seatsForAsegment == null )
			seatsForAsegment = seat;
		else
			seatsForAsegment =seatsForAsegment+","+seat;
		if(selectedSeatNameTypes == '' || selectedSeatNameTypes == null )
				selectedSeatNameTypes = seatType;
		else
			selectedSeatNameTypes =selectedSeatNameTypes+","+seatType;
	}
	document.seatMapForm.selectedSeatsForSegment.value=seatsForAsegment;
	document.seatMapForm.selectedSeatNameTypes.value=selectedSeatNameTypes;
	document.seatMapForm.method.value="viewPricing";
	if(actionVal=='seatselect')
		document.seatMapForm.action="viewPricing.do";
	else 
		document.seatMapForm.action="postViewPricing.do";
	document.seatMapForm.submit();
}

function selectNextFlightSeats(){
	//showLoadingImageOpen('ssSeatMap01');
	showWaitImage();
	var seatsForAsegment ='';
	var selectedSeatNameTypes='';
	
	for(j=0;j<paxCount;j++){
		var seat = aGuestSeats[j][activeSegmentIndex];
		var seatType = aSeatType[j][activeSegmentIndex];
		if(seatsForAsegment == '' || seatsForAsegment == null )
			seatsForAsegment = seat;
		else
			seatsForAsegment =seatsForAsegment+","+seat;
		if(selectedSeatNameTypes == '' || selectedSeatNameTypes == null )
				selectedSeatNameTypes = seatType;
		else
			selectedSeatNameTypes =selectedSeatNameTypes+","+seatType;
	}
	document.seatMapForm.selectedSeatsForSegment.value=seatsForAsegment;
	document.seatMapForm.selectedSeatNameTypes.value=selectedSeatNameTypes;
	document.seatMapForm.tabSelected.value='1';
	document.seatMapForm.activeSegmentIndex.value=activeLegIndex;
	document.seatMapForm.submit();
}
function availableSeatsPreview(fltBoardPoint, fltOffPoint, fltNumber, fltDate, clickedObj){
	showWaitImage();
	actionUrl="showseatmap.do?method=seatselect&boardPoint="+fltBoardPoint+"&offPoint="+fltOffPoint+"&flightNumber="+fltNumber+"&flightDate="+fltDate;
	updatePopup(actionUrl,'Seats Available on this Flight',450,clickedObj,false,50,-120,false);
}
//*************************End seat Map functions ************************

//************ Common Functions ************

function refreshDiv(url,divid,parameter,isRefresh){
	var respYts = $.post(url,parameter,done,"html");
	function done(){
		if(isRefresh=='true' && respYts.responseText!=''){
			document.getElementById(divid).innerHTML=respYts.responseText;
			if(divid=="travelExpeince"){
				if(document.getElementById("totalBottom"))		
					document.getElementById("totalTop").innerHTML=document.getElementById("totalBottom").innerHTML;
			}
		}
		closeWaitImage();
	}
}
//************ END: Common Functions ************



/*** Gift Certificate - BEGIN **/
function addGiftVoucher(id,div)
{
	/*setPosition(document.getElementById(id), document.getElementById("loadingDiv"),0,50);
	document.getElementById("loadingDiv").style.display="block";*/
	showWaitImage();
	saveTravelInsurance();
	var travelInsuranceFlagRetain=travelInsuranceFlag;
	var voucherNumber=document.getElementById("giftVoucherNumber").value;
	var transactionNumber=document.getElementById("giftTransactionNumber").value;
	var URL="giftVoucher.do?method=add&giftVoucherNumber="+voucherNumber+"&giftTransactionNumber="+transactionNumber;
	//$('#'+div).load(URL,'',showLoadingImageClose); 
	$.ajax({
	 	   type: "POST",
	 	   url: URL,
	 	   cache: false,
	 	   dataType:"html",
	 	   success: function(html){
			    	     $("#"+div).html(html.trim());
			    	      if(html.trim().indexOf('errormessage_hold')!=-1){
			    			window.scrollTo(0,0);
			    			}
			    	     closeWaitImage();
			    	     travelInsuranceFlag=travelInsuranceFlagRetain;
			    	     retainTravelInsurance();
			    	}
	 });
}

function removeGiftVoucher(voucherNumber,id,div)
{
	/*setPosition(document.getElementById(id), document.getElementById("loadingDiv"),50,50);
	document.getElementById("loadingDiv").style.display="block";*/
	showWaitImage();
	saveTravelInsurance();
	var travelInsuranceFlagRetain=travelInsuranceFlag;
	var URL="giftVoucher.do?method=remove&giftVoucherNumber="+voucherNumber;
	//$('#'+div).load(URL,'',showLoadingImageClose);
	$.ajax({
 	   type: "POST",
 	   url: URL,
 	   cache: false,
 	   dataType:"html",
 	   success: function(html){
		    	     $("#"+div).html(html.trim());
		    	     travelInsuranceFlag=travelInsuranceFlagRetain;
			    	 retainTravelInsurance();
		    	     showLoadingImageClose();
		    	}
 	});
}
/*** Gift Certificate - END **/
var clearToolTipInterval;
var clearPopupInterval;
var counter = 20;
// -------------------------------------
// start check count down to clear popup
// -------------------------------------
function checkPopupInterval(divid,intervalId) {
	
	if(divid) {
		divToClose = divid;
	} else {
		divToClose = 'popupId';
	}
	
	if(intervalId) {
		intervalToClear = intervalId;
	} else {
		intervalToClear = 'clearPopUpInterval';
	}
	
	if(counter > 0) {
		counter--;
	} else {
		closePopup(divToClose);
		window.clearInterval(clearPopupInterval);
		counter = 20;
	}
	 
}
// -----------------------------------
// end check count down to clear popup
// -----------------------------------

// -----------------------------------------
// start tool tip pop up script 
// rgtMrg actually equals top
// open parameter is free for user to define their own value to display within an html include.
// -----------------------------------------
function popupToolTip(pageName,title,popupWidth,clkObj,showBtn,lftMrg,rgtMrg,decision,openParameter,functionCalled){
	
	if(clearToolTipInterval) {
		clearInterval(clearToolTipInterval);
		counter = 20;
	}
	
	$('#toolTipMsgArea').load(pageName,'cache:false',toolTip);
	function toolTip() {
		
		document.getElementById("toolTipTitle").innerHTML = title;
		//var popupElement = document.getElementById("popupOverlayTable");
		//popupElement.style.width = eval(popupWidth);
		
		var popupFrame = document.getElementById("toolTipFrame");
		setObjOffset(clkObj, document.getElementById("toolTipId"), lftMrg, rgtMrg)

		document.getElementById("toolTipId").style.display='block';
		popupFrame.style.width=eval(popupWidth);
		popupFrame.style.height=document.getElementById('toolTipId').offsetHeight;
		//popupDiv.style.height = pageHeight;
		
		if(openParameter && openParameter != '') {
			document.getElementById("toolTipOpenParameter").innerHTML = openParameter;
		}
		
	}
	
	clearToolTipInterval = window.setInterval('checkPopupInterval("toolTipId")',1000);
	
}
// -----------------------------------------
// end tool tip pop up script 
// -----------------------------------------

// -------------------------
// start confirmation popups
// -------------------------

// find scroll offset if page has been scrolled at all
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

// find page height and width
function xDocSize()
// xDocSize r1, Copyright 2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
{
  var b=document.body, e=document.documentElement;
  var esw=0, eow=0, bsw=0, bow=0, esh=0, eoh=0, bsh=0, boh=0;
  if (e) {
    esw = e.scrollWidth;
    eow = e.offsetWidth;
    esh = e.scrollHeight;
    eoh = e.offsetHeight;
  }
  if (b) {
    bsw = b.scrollWidth;
    bow = b.offsetWidth;
    bsh = b.scrollHeight;
    boh = b.offsetHeight;
  }
  return {w:Math.max(esw,eow,bsw,bow),h:Math.max(esh,eoh,bsh,boh)};
}

// find viewable area to set center location of the browser for overlays
function getViewableArea() {
	
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	
	return winH;
	
}

// start set loading animation div location on home page only
function setLoadingAniDivLocation() {
	
	var vHeight = getViewableArea();
	var yScrollOffset = f_scrollTop();
	var loaderYPosition = vHeight/2;
	loaderYPosition += yScrollOffset;
	loaderYPosition += -100;
	var hWidth = xDocSize().w;
	var loaderXPosition = ((hWidth/2)-100);
	
	var loadingAnimationObject = document.getElementById('loadingAnimationBody');
	loadingAnimationObject.style.top = loaderYPosition+'px';
	loadingAnimationObject.style.left = loaderXPosition+'px';
	
	var loadingAnimationBgObject = document.getElementById('loadingAnimationBodyBg');
	loadingAnimationBgObject.style.top = loaderYPosition+'px';
	loadingAnimationBgObject.style.left = loaderXPosition+'px';
	//loadingAnimationObject.style.display = 'block';
		
}
// end set home loading animation div

// This function will work for show loading imageon search page.
function showWaitImage() {
	/*if(arguments[1]!=null){
		setSafariXY(250,100,260,100);	
	}else{
		setSafariXY(0,100,10,100);
	}*/
	//setPosition(buttonName, document.getElementById("loadingDiv"),loadX,loadY);
	var vHeight = getViewableArea();
	var yScrollOffset = f_scrollTop();
	var loaderYPosition = vHeight/2;
	loaderYPosition += yScrollOffset;
	loaderYPosition += -100;
	var hWidth = xDocSize().w;
	var loaderXPosition = ((hWidth/2)-110);
	
	if(document.getElementById("loadingAnimationDiv")){

		document.getElementById('loadingAnimationDiv').style.top = '0px';
		document.getElementById('loadingAnimationDiv').style.left = '0px';
		document.getElementById('loadingAnimationDiv').style.width = hWidth+'px';
		document.getElementById('loadingAnimationDiv').style.height = vHeight+'px';
		document.getElementById('loadingAnimationDiv').style.display = 'block';
		document.getElementById('loadingAnimationDisableDiv').style.display = 'block';
		document.getElementById("loadingAnimationBody").style.left = loaderXPosition;
		document.getElementById("loadingAnimationBody").style.top = loaderYPosition;
		document.getElementById("loadingAnimationBodyBg").style.left = loaderXPosition;
		document.getElementById("loadingAnimationBodyBg").style.top = loaderYPosition;
		
		if(isPCIE6 == 1) {
			//document.getElementById("loadingAnimationBodyBg").style.display = 'none';
			document.getElementById('loadingDivIFrame').style.top = '0px';
			document.getElementById('loadingDivIFrame').style.left = '0px';
			document.getElementById('loadingDivIFrame').style.height = xDocSize().h;
			document.getElementById('loadingDivIFrame').style.width = hWidth;
			document.getElementById('loadingDivIFrame').style.display = "block";
		}
		
	}

}
function closeWaitImage(){
	if(document.getElementById("loadingAnimationDiv")){
		document.getElementById("loadingAnimationDiv").style.display="none";
	}
}
function getPageSizeWithScroll(){
    if (window.innerHeight && window.scrollMaxY) {// Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
        xWithScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        yWithScroll = document.body.scrollHeight;
        xWithScroll = document.body.scrollWidth;
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.body.offsetHeight;
        xWithScroll = document.body.offsetWidth;
      }
    arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
    return arrayPageSizeWithScroll;
}

// This function will work for show loading imageon search page.
function popupElevateInturrupt() {
	var vHeight = getViewableArea();
	var yScrollOffset = f_scrollTop();
	var loaderYPosition = vHeight/2;
	loaderYPosition += yScrollOffset;
	loaderYPosition += -100;
	var hWidth = xDocSize().w;
	var hHeight = xDocSize().h;
	var loaderXPosition = 500; //hWidth/2;
	loaderXPosition = loaderXPosition - 280;
	var footerObj = document.getElementById("pageLengthIdentifier");
	var footerY = 0;
	
	if(isPCIE == 1 || isSafari == 1) {
		var ieOffset = 150;
	} else if(isMacFF == 1) {
		var ieOffset = -250;
	} else {
		var ieOffset = 100;
	}
	
	var test = getPageSizeWithScroll();
	footerY = arrayPageSizeWithScroll[1] + ieOffset;
	
	if(document.getElementById("elevateInterruptDiv")){
		var inturruptObj = document.getElementById("elevateInterruptDiv");
		var inturruptDivObj = document.getElementById("elevateOverlayId");
		var inturruptOverlayDivObj = document.getElementById("elevateOverlayBg");
		var inturruptIFrameObj = document.getElementById("popupOverlayFrame");
			
		//inturruptIFrameObj.style.height = footerY + 'px';
		inturruptOverlayDivObj.style.height = footerY + 'px';
		inturruptDivObj.style.left = loaderXPosition;
		inturruptDivObj.style.top = loaderYPosition;
		inturruptObj.style.display="block";
		if(isPCIE6==1)
			document.getElementById("popupOverlayFrameForIE6").style.display="block";
		
		if(isSafari) {
			inturruptOverlayDivObj.style.width = '100%';
		}
		
	}
	
	//document.getElementById("loginId")
	
}

// start popup function
function popupOverlay(pageName, title, popupWidth, clkObj, showBtn, lftMrg, rgtMrg, decision, openParameter, functionCalled){
	// get the html page and load it into the frame/display area
	$('#popupOverlayMsgArea').load(pageName,'',overlay);
	//$('#popupOverlayMsgArea').html($('#'+divId).html());
	//$('#'+divId).html('');
	function overlay() {

		// set default local vars
		var yScrollOffset = f_scrollTop();
		var pageWidth = xDocSize().w;
		var pageHeight = xDocSize().h;
		var vHeight = getViewableArea();
		var xOffSet = popupWidth/2;
		//var yOffSet = scrollHeightOffset();
		var xLocation = (pageWidth/2);
		xLocation = xLocation-xOffSet;
		var yLocation = (vHeight/2);
		yLocation += yScrollOffset;
		
		// set title from input parameter
		document.getElementById("popupOverlayTitle").innerHTML = title;
		// get table, div and frame elements
		var popupElement = document.getElementById("popupOverlayTable");
		var popupFrame = document.getElementById("popupOverlayFrame");
		var popupDiv = document.getElementById("popupOverlayBg");
		
		// set widths and heights
		popupElement.style.width = eval(popupWidth);
		popupFrame.style.width = eval(popupWidth)-30;
		popupFrame.style.height = popupElement.style.height;
		popupDiv.style.height = pageHeight;
		
		if(fareFormatType== 'Dollars'){
			openParameter=replaceAllFunction(openParameter,",","");
			openParameter=openParameter.split(".")[0]+".00";
		}
		
		// set location and display
		document.getElementById('popupOverlayId').style.left = '50%';
		document.getElementById('popupOverlayId').style.top = yLocation;
		document.getElementById("popupOverlayBg").style.top = 0;
		document.getElementById("popupOverlayBg").style.width = pageWidth + "px";
		document.getElementById("popupOverlayBg").style.display='block';
		
		// display user defined parameter
		if(openParameter && openParameter != '') {
			if(document.getElementById("popUpOverlayOpenParameter")) {
				document.getElementById("popUpOverlayOpenParameter").innerHTML = openParameter;
			}
		}
		
	}
	
}
// -------------------------
// end confirmation popups
// -------------------------

// --------------------------
// start collapse expand divs
// --------------------------
function ciCollapseExpand(divId,btnObject) {
	
	var divObject = document.getElementById(divId);
	
	if(divObject.style.display == 'none') {
		document.getElementById(divId).style.display = 'block';
		btnObject.src='https://static.virginamerica.com/images/btn-checkin-collapse.png';
	} else {
		document.getElementById(divId).style.display = 'none';
		btnObject.src='https://static.virginamerica.com/images/btn-checkin-expand.png';
	}
	
}
// --------------------------
// end collapse expand divs
// --------------------------

// --------------------------
// start toggle extra fees
// --------------------------
function toggleExtraFees(divId) {
	
	var exDiv = document.getElementById(divId);
	
	if(exDiv.style.display == 'block') {
		exDiv.style.display = 'none';
	} else {
		exDiv.style.display = 'block';
	}
	
}

function showDiv(divId) {
	
	var exDiv = document.getElementById(divId);
	exDiv.style.display = 'block';
	
}

function hideDiv(divId) {
	
	var exDiv = document.getElementById(divId);
	exDiv.style.display = 'none';
	
}

// ---------------------------
// start toggle image
// ---------------------------
function togglePlusMinus(imgObject) {
	
	if(imgObject.src.indexOf('plus') != -1) {
		imgObject.src = 'https://static.virginamerica.com/images/icon-minus.png';
	} else {
		imgObject.src = 'https://static.virginamerica.com/images/icon-plus.png';
	}
	
}

// --------------------------------
// start travel options div toggle
// --------------------------------
function toggleTravelOptionsFlights(newActiveFlight,tabObject) {

	// set all tabs to inactive for clean slate
	for(i=1;i<=flightCount;i++) {
		document.getElementById('fsTripTypeBg0'+i).className = 'fsTripTypeInactive';
		document.getElementById('fsTripTypeNum0'+i).className = 'fsTripTypeNumInactive';
		document.getElementById('fsTripTypeLabel0'+i).className = 'fsTripTypeLabelInactive';
		document.getElementById('toFlight0'+i).style.display = 'none';
	}
	
	// set passed tab to active
	tabObject.className = 'fsTripTypeActive';
	document.getElementById('fsTripTypeNum0'+newActiveFlight).className = 'fsTripTypeNumActive';
	document.getElementById('fsTripTypeLabel0'+newActiveFlight).className = 'fsTripTypeLabelActive';
	document.getElementById('toFlight0'+newActiveFlight).style.display = 'block';

}
// --------------------------------
// end travel options div toggle
// --------------------------------

// ------------------------------------
// function to swap images on rollover
// ------------------------------------
function imgRollOver(imgObject) {
	
	var imageDir = '';
	var imageObj = imgObject.src.substr(imgObject.src.indexOf('images/')+7);
	var imageName = imageObj.substr(0,imageObj.indexOf('.'));
	var imageType = imageObj.substr(imageObj.indexOf('.'));
	if(imageName.indexOf('/') != -1) {
		imageDir = imageName.substr(0,imageName.indexOf('/')+1);
		imageName = imageName.substr(imageName.indexOf('/')+1);
	}
	imgObject.src = 'https://static.virginamerica.com/images/'+imageDir+imageName + '-roll'+imageType;
}

function imgRollOut(imgObject) {
	
	var imageDir = '';
	var imageObj = imgObject.src.substr(imgObject.src.indexOf('images/')+7);
	var imageName = imageObj.substr(0,imageObj.indexOf('-roll.'));
	var imageType = imageObj.substr(imageObj.indexOf('.'));
	if(imageName.indexOf('/') != -1) {
		imageDir = imageName.substr(0,imageName.indexOf('/')+1);
		imageName = imageName.substr(imageName.indexOf('/')+1);
	}
	imgObject.src = 'https://static.virginamerica.com/images/'+imageDir+imageName+imageType;
	
}

function btnRoll(buttonObject,btnClassName) {
	
	buttonObject.className = btnClassName;
	
}

/***  Flight Select page script start  ***/
var nextDayFlight=new Array(1);
var ajaxDiv;
var seatActionUrl="seatSelectNew.do";
var fltsInfoIdx=0;
var fromNextDayMsg=false;
function popFSDivs(e,divID,index) {
	var posx = 0;
	var posy = 0;
	var xOffset = 0;
	var yOffset = 0; //21
	var AllPopUpX = 0;
	var AllPopUpY = 0;
	var obj = document.getElementById('mcPopUpInfoIconDeparture0'+index);
	var objFareDetails = document.getElementById('btnFareDetails01');

	// set default div offsets
	xOffset = 120;
	yOffset = 0;
	
	if(divID == 'popupGovFeesAndTaxes') {
		obj = document.getElementById('lnkGovernmentFeeTaxes');
		yOffset = -130;
	}

		if (!e) var e = window.event;
		
	// get mouse X coordinates
		if (e.pageX || e.pageY) 	{
			posx = e.pageX;
		}
		else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
		}
		
	// get mouse coordinates relative to icon image
	if (obj && obj.offsetParent) {
		while (obj.offsetParent) {
			posy += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj && obj.x) {
		posy += obj.y;
	}
	
	// get coordinates of fare details button
	if (objFareDetails.offsetParent) {
		while (objFareDetails.offsetParent) {
			AllPopUpX += objFareDetails.offsetLeft
			AllPopUpY += objFareDetails.offsetTop
			objFareDetails = objFareDetails.offsetParent;
		}
	} else if (objFareDetails.x) {
		AllPopUpX += objFareDetails.x;
		AllPopUpY += objFareDetails.y;
	}

	
	// set div offsets
	xOffset = 120;
	yOffset = 0;
	
	if(divID == 'mcPopUp' || divID == 'mcRefundPopUp' || divID == 'mcsIuPopUp' || divID == 'mcsPopUp' || divID == 'fcPopUp' || divID == 'fcrPopUp') {
		yOffset = 26;
	}
	
	// set position for ALL popup div
	if(divID == 'allPopUp') {
		posx = AllPopUpX - 400;
		posy = AllPopUpY + 20;
	}

	document.getElementById('mcsIuPopUp').style.visibility = "hidden" ;
	document.getElementById('mcsPopUp').style.visibility = "hidden" ;
	document.getElementById('mcPopUp').style.visibility = "hidden" ;
	document.getElementById('mcRefundPopUp').style.visibility = "hidden" ;
	document.getElementById('fcPopUp').style.visibility = "hidden" ;
	document.getElementById('fcrPopUp').style.visibility = "hidden" ;
	document.getElementById('allPopUp').style.visibility = "hidden" ;
	
	document.getElementById(divID).style.left = (posx-xOffset) ;
	document.getElementById(divID).style.top = (posy+yOffset) ;
    document.getElementById(divID).style.visibility = "visible" ;
	
}

function popFSDivsClose(divID) {
	if(document.getElementById(divID).style.visibility == "visible") {
		document.getElementById(divID).style.visibility = "hidden" ;
	}
}

function toggleModifySearchDiv() {
	if(document.getElementById('fsModifySearch').style.display == 'block') {
		document.getElementById('fsModifySearch').style.display = 'none';
		document.getElementById('modifySearchArrow').src = 'https://static.virginamerica.com/images/fareselect-modifysearch-rightarrow-red.gif';
	} else {
		document.getElementById('fsModifySearch').style.display = 'block';
		document.getElementById('modifySearchArrow').src = 'https://static.virginamerica.com/images/fareselect-modifysearch-downarrow-red.gif';
	}
}

function toggleActiveCell(thisActiveCell,thisActiveRadio, idx) {
	var currentActiveCell = document.getElementById(('activeCell'+idx)).value;
	var currentActiveRadio = document.getElementById(('activeRadio'+idx)).value;
	var currentClass = currentActiveCell.split('|')[2];
	
	if(currentActiveCell && currentActiveCell != '') {	
		if(currentClass == 'MCS' || currentClass == 'IUMCS') {
			document.getElementById(currentActiveCell).className = 'fsTableCellMCS';
		} else if(currentClass == 'FC') {
			document.getElementById(currentActiveCell).className = 'fsTableCellFC';
		} else {
			document.getElementById(currentActiveCell).className = 'fsTableCell';
		}
	}
	if(currentActiveRadio && currentActiveRadio != '') {
		document.getElementById(currentActiveRadio).checked = false;
	}
	
	document.getElementById(thisActiveCell).className = 'fsTableCellActive';
	document.getElementById(thisActiveRadio).checked = true;
	
	document.getElementById(('activeCell'+idx)).value = thisActiveCell;
	document.getElementById(('activeRadio'+idx)).value = thisActiveRadio;
	
}
function changeFlightTab(index,currentId,buttonId,isInternational){
	var checkDepart=true;
	if (document.getElementById(('routeInfo0')).innerHTML!='\n'){
	if(isInternational && isInternational=='true'){
		if(!document.getElementById("flightNumber0") && index>0){
			checkDepart=false;
		}
	}
	}
	//alert("::"+document.getElementById(('routeInfo0')).innerHTML+"::"+document.getElementById("fareSelectFlightList").getElementsByTagName('div')+":::"+isInternational+":::"+index +"--->"+document.getElementById("flightNumber0"));
	if(checkDepart){
	toggleFlightsInfo(index);
	toggleActiveTab(currentId);
	toggleActiveButtons(buttonId);
	}else{
		updatePopup('html/popup-fareselect-choosedepartfirst.html','Select Departing Flight',350,document.getElementById('pageHeaderBar'),false,170,50,false);
	}
	if(document.getElementById("flight0")){
		document.getElementById("flight0").style.display='none'
	}
	if(document.getElementById("flight1")){
		document.getElementById("flight1").style.display='none'
	}
	if(document.getElementById("flight"+index)){
		document.getElementById("flight"+index).style.display='block'
	}
}
function toggleFlightsInfo(index){
	currentId='flightInfo'+index;
	var buttonId='button'+index;
	var objs=document.getElementById("fareSelectFlightList").getElementsByTagName('div');
	for(i=0;i<objs.length;i++){
		if(objs[i].id==currentId){ 
			fltsInfoIdx=index;
			objs[i].style.display='block';
			document.getElementById('routeInfo').innerHTML=document.getElementById(('routeInfo'+index)).innerHTML;
			if(document.getElementById(buttonId))
				document.getElementById(buttonId).style.display='block';
		}else if((objs[i].id).indexOf('flightInfo')>=0){
			objs[i].style.display='none';
			$('#button'+i).hide();
		}
	}
}

function toggleActiveTab(currentId){
	var objs=document.getElementById("allTabs").getElementsByTagName('td');
	for(i=0;i<objs.length;i++){
		if(objs[i].id==currentId){ 
			toggleClass(objs[i], 'Active');
			//objs[i].addeventlistener("onmouseover", void(0), false);
		}else if((objs[i].id).indexOf('tab')>=0){
			//objs[i].addeventlistener("onmouseover", MakeCursor(this), false);
			toggleClass(objs[i], 'Inactive');
		}
	}
	function toggleClass(obj, classType){
		obj.className='fsTripType'+classType;
		var tdObjs=obj.getElementsByTagName('table')[0].getElementsByTagName('tr')[0].getElementsByTagName('td');
		for(j=0;j<tdObjs.length;j++){
			if(tdObjs[j].className.indexOf('fsTripTypeNum')>=0){
				tdObjs[j].className='fsTripTypeNum'+classType;
			}else if(tdObjs[j].className.indexOf('fsTripTypeLabel')>=0){
				tdObjs[j].className='fsTripTypeLabel'+classType;
			}
		}
	}
}

function toggleActiveButtons(currentId){
	var objs=document.getElementById("continueBtns").getElementsByTagName('div');
	for(i=0;i<objs.length;i++){
		if(objs[i].id==currentId){ 
			objs[i].style.display='block';
		}else if((objs[i].id).indexOf('button')>=0){
			objs[i].style.display='none';
		}
	}
}


/* This function is used to load fare details in YTS on Select page */
function loadFareDetails(fareId ,radioValue,flightNumber,airport,fareFormatType,fareLevel,fareBasisCode,mainPoints,mcsPoints,firstPoints,nextDayFlightInd){
	showWaitImage();
	disableSelectPage();
	var params='';
	toggleActiveCell(fareId,fareId+'|R',fltsInfoIdx);
	fltsInfoIdx=eval(fareId.split('|')[0]);
	flightIndex=eval(fareId.split('|')[1]);
	fareIndex=eval(fareId.split('|')[2]);
	//var respYts = $.post(URL,parms,done,"html");&
	var form=document.forms['form_'+fltsInfoIdx+'_'+flightIndex];
	params=params+"fareId="+fareId;
	if(form){
		 for (var i=0; i < form.elements.length; i++) {
			
			 params=params+"&"+form.elements[i].name+"="+form.elements[i].value;
		 }
	}
	//alert("mainPoints="+mainPoints+"&mcsPoints="+mcsPoints+"&firstPoints="+firstPoints);
	/*var flightSegmentLength=document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_SEGMENT_LENGTH'].value;
	var taxLength=document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_TAX_LENGTH'].value;
	params=params+"flightInfoIndex="+fltsInfoIdx;
	params=params+"&flightIndex="+flightIndex;
	params=params+"&fareIndex="+fareIndex;
	params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_SEGMENT_LENGTH'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_SEGMENT_LENGTH'].value;
	params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_TAX_LENGTH'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_TAX_LENGTH'].value;
	for(flightCounter=0;flightCounter<flightSegmentLength;flightCounter++){
		params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_ORIGIN'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_ORIGIN'].value;
		params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_DESTINATION'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_DESTINATION'].value;
		params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_FLIGHT_NUMBER'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_FLIGHT_NUMBER'].value;
		params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_DEPARTURE_TIME'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_DEPARTURE_TIME'].value;
		params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_ARRIVAL_TIME'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+flightCounter+'_ARRIVAL_TIME'].value;
	}
	params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_BASE_FARE'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_BASE_FARE'].value;
	params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_DISPLAY_FARE'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_DISPLAY_FARE'].value;
	params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_FARE_LEVEL'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_FARE_LEVEL'].value;
	params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_FARE_BASIS_CODE'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_FARE_BASIS_CODE'].value;
	for(taxCounter=0;taxCounter<taxLength;taxCounter++){
		params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_'+taxCounter+'_TAX_CODE'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_'+taxCounter+'_TAX_CODE'].value;
		params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_'+taxCounter+'_TAX_AMOUNT'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_'+taxCounter+'_TAX_AMOUNT'].value;
		params=params+'&'+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_'+taxCounter+'_TAX_TYPE'].name+"="+document.displayPricingForm.elements[fltsInfoIdx+'_'+flightIndex+'_'+fareIndex+'_'+taxCounter+'_TAX_TYPE'].value;
	}*/
	   if(document.getElementById("travelExpeince")){
		  if(fareFormatType=='Dollars'){
				var xmlHttp=$.ajax({
			 	   type: "POST",
			 	   url: "loadFareQuote.do?method=loadFlightDetails",
			 	   data: params,
			 	   dataType:"html",
			 	   success: function(html){
			 		  $("#travelExpeince").html(html.trim());
			 		 closeWaitImage();
			 		document.getElementById("disableTotalPage").style.display="none";
					}
			 	});
			}
			if(fareFormatType=='Points'){
				var xmlHttp=$.ajax({
			 	   type: "POST",
			 	   url: "loadFareQuote.do?method=loadFlightDetails&mainPoints="+mainPoints+"&mcsPoints="+mcsPoints+"&firstPoints="+firstPoints,
			 	   data: params,
			 	   dataType:"html",
			 	   success: function(html){
			 		  $("#travelExpeince").html(html.trim());
			 		 closeWaitImage();
			 		document.getElementById("disableTotalPage").style.display="none";
					}
			 	});
			}
		}
		if(document.getElementById("postTravelExpeince")){
			if(fareFormatType=='Dollars'){
				var xmlHttp=$.ajax({
			 	   type: "POST",
			 	   url: "loadFareQuote.do?method=loadFlightDetails",
			 	   data: params,
			 	   dataType:"html",
			 	   success: function(html){
			 		  $("#postTravelExpeince").html(html.trim());
			 		 closeWaitImage();
			 		document.getElementById("disableTotalPage").style.display="none";
					}
			 	});
			}
		}
	
	//myUrl='loadFareQuote.do?method=loadFareQuote&fareId='+fareId+'&fare='+radioValue+'&flightNumber='+flightNumber+'&airportName='+airport+'&fareLevel='+fareLevel+'&fareFormatType='+fareFormatType+'&fareBasisCode='+fareBasisCode+'&mainPoints='+mainPoints+'&mcsPoints='+mcsPoints+'&firstPoints='+firstPoints;
	/*$('#nextDayMsgOKbtn').unbind('click');
	$('#nextDayMsgCancelbtn').unbind('click');
	if(document.getElementById("errorDiv")){
		 document.getElementById("errorDiv").innerHTML='';
	}
	
	if(nextDayFlightInd=='true' && (document.getElementById("overNightFlightMessage").style.display=='none' || !fromNextDayMsg)){
			$('#overNightFlightMessage').css({top:($(document.getElementById(fareId+'|R')).offset().top-60)+'px',left:($(document.getElementById(fareId+'|R')).offset().left-110)+'px'});
			$('#nextDayMsgOKbtn').click(function(){
				fromNextDayMsg=true;
				$(document.getElementById(fareId)).trigger('click');
			nextDayFlight[fltsInfoIdx]=true;
				$('#overNightFlightMessage').hide();
				});
			$('#nextDayMsgCancelbtn').click(function(){
				if(fareId.split('|')[2] && (fareId.split('|')[2]=='MCS'|| fareId.split('|')[2]=='IUMCS')){
					document.getElementById(fareId).className='fsTableCellMCS';
				}else if(fareId.split('|')[2] && fareId.split('|')[2]=='FC'){
					document.getElementById(fareId).className='fsTableCellFC';
				}else{
					document.getElementById(fareId).className='fsTableCell';
				}
				document.getElementById(fareId+'|R').checked=false;
				if(document.getElementById(('activeCell'+fltsInfoIdx)) && document.getElementById(('activeCell'+fltsInfoIdx)).value!=''){
					var selectedCell=document.getElementById(('activeCell'+fltsInfoIdx)).value;
						toggleActiveCell(selectedCell,selectedCell+'|R',fltsInfoIdx);
				}
				$('#overNightFlightMessage').hide();
				});
			$('#overNightFlightMessage').show();
			return;
	}else{
			nextDayFlight[fltsInfoIdx]=false;
	}*/
	/*toggleActiveCell(fareId,fareId+'|R',fltsInfoIdx);
	showWaitImage();
	fromNextDayMsg=false;
	$('#overNightFlightMessage').hide();
	disableSelectPage();
	//calling omniture function
	if(window.populateOmnitureElements)
		populateOmnitureElements(fltsInfoIdx,airport);
	
	if(document.getElementById("postTravelExpeince")){
		ajaxSelect(myUrl, "postTravelExpeince",fareFormatType);
	}else{
		ajaxSelect(myUrl, "travelExpeince",fareFormatType);
	}*/
}	

function disableSelectPage(){
	pageSize=getPageSizeWithScroll();
	document.getElementById("disableTotalPage").style.width=pageSize[0];
	document.getElementById("disableTotalPage").style.height=pageSize[1];
	document.getElementById("disableTotalPage").style.left="0";
	document.getElementById("disableTotalPage").style.top="0";
	document.getElementById("disableTotalPage").style.display="block";
}

function ajaxSelect(myurl, div,fareFormatType){
	var thetime=new Date(); 
	var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
	myurl=myurl+"&dummy="+dummy;
	ajaxDiv = div;
	fareFormatTypePage=fareFormatType;
	xmlhttp.open("POST", myurl, true);
	xmlhttp.onreadystatechange = handleResponseSelect;
	xmlhttp.send("");
}
/* handle ajax response of load fare details */
function handleResponseSelect() {
    String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
    if (xmlhttp.readyState == 4) { // Complete
      if (xmlhttp.status == 200) { // OK response
   		if((xmlhttp.responseText).trim()=='AjaxSessionTimeOut'){
  			window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut"
  		}else if((xmlhttp.responseText).trim()=='AjaxError'){
  			window.location="/home.do?method=virginAmerica&fromErrorPage=fromErrorPage"
  		}else{
  			if((xmlhttp.responseText).trim()=='InventoryUpdate' || ((xmlhttp.responseText).length>4 && (xmlhttp.responseText).substring(0,5)=='error')){
  	  			if((xmlhttp.responseText).trim()=='InventoryUpdate'){
  	  				document.getElementById("VF_popup").style.display="block";
  	  			}else{
  	  	  			document.getElementById("errorDiv").style.display="block";
  	  	  			document.getElementById("errorDiv").innerHTML= '<table><tr><td><img src="https://static.virginamerica.com/images/esc-sign.gif" width="40" height="35" alt="" ></td><td><span class="validationDefault">'+(xmlhttp.responseText).substring(6)+'</span></td></tr></table>';
  	  			}
  	  			if(nextDayFlight[fltsInfoIdx]){
  	  				nextDayFlight[fltsInfoIdx]=false;
  	  			}
  	  			if(document.getElementById(('activeCell'+fltsInfoIdx)) && document.getElementById(('activeCell'+fltsInfoIdx)).value!='')
  	  				document.getElementById(document.getElementById(('activeCell'+fltsInfoIdx)).value).className = 'fsTableCell';
  	  			if(document.getElementById(('activeRadio'+fltsInfoIdx)) && document.getElementById(('activeRadio'+fltsInfoIdx)).value!='')
  	  				document.getElementById(document.getElementById(('activeRadio'+fltsInfoIdx)).value).checked = false;
  	  		}else if(xmlhttp.responseText.indexOf('esc-sign')>=0 || xmlhttp.responseText.indexOf('escSignImg')>=0){
	  			document.getElementById("errorDiv").style.display="block";
	  			document.getElementById("errorDiv").innerHTML=xmlhttp.responseText;
	  			document.getElementById("loadingAnimationDiv").style.display="none";
  	  			if(nextDayFlight[fltsInfoIdx]){
  	  				nextDayFlight[fltsInfoIdx]=false;
  	  			}
  	  			if(document.getElementById(('activeCell'+fltsInfoIdx)) && document.getElementById(('activeCell'+fltsInfoIdx)).value!='')
  	  				document.getElementById(document.getElementById(('activeCell'+fltsInfoIdx)).value).className = 'fsTableCell';
  	  			if(document.getElementById(('activeRadio'+fltsInfoIdx)) && document.getElementById(('activeRadio'+fltsInfoIdx)).value!='')
  	  				document.getElementById(document.getElementById(('activeRadio'+fltsInfoIdx)).value).checked = false;
  	  		}else{  
  				document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
  				if(ajaxDiv=="travelExpeince"){
  					if(document.getElementById("totalBottom"))		
  						document.getElementById("totalTop").innerHTML=document.getElementById("totalBottom").innerHTML;
  					if(fareFormatTypePage=='Points' && document.getElementById("pointsBottom")){
  					document.getElementById("pointsTop").innerHTML=document.getElementById("pointsBottom").innerHTML;
  					}
  					ajax("updateTitleBar.do?method=updateTitleBar","titleBarDiv");
  				}
  				if(ajaxDiv=="postTravelExpeince"){
  					ajax("postUpdateTitleBar.do?method=updateTitleBar","postTitleBarDiv");
  					document.getElementById("newFlightTotal").innerHTML=document.getElementById("totalAmountNew").innerHTML;
  					document.getElementById("originalFlightTotal").innerHTML=document.getElementById("totalAmountoriginal").innerHTML;
  				}
  	  		}

			document.getElementById("loadingAnimationDiv").style.display="none";
			//document.getElementById("loadingDiv").style.display="none";
			//document.getElementById("disablePage").style.display="none";
			document.getElementById("disableTotalPage").style.display="none";
			setPositionTravelExp();
	  	}
	  }
    	  document.getElementById("disableTotalPage").style.display="none";
	}
}
/* To change travle date using minimum fare grid on Select Page */
function changeTravelDate(offset , OandDetailsNumber) {
	fltsInfoIdx=OandDetailsNumber;
	if(document.getElementById("errorDiv")){
		 document.getElementById("errorDiv").innerHTML='';
	}
	showWaitImage();
	disableSelectPage();
	var form=document.forms['form_best_fare_'+OandDetailsNumber];
	var params="";
	params=params+"offset="+offset;
	params=params+"&oandDetailsNumber="+OandDetailsNumber;
	if(form){
		 for (var i=0; i < form.elements.length; i++) {
			 params=params+"&"+form.elements[i].name+"="+form.elements[i].value;
		 }
	}
	var positionObj='fareSelectCarousel'+OandDetailsNumber;
	var xmlHttp=$.ajax({
		   type: "POST",
		   url: "changeTravelDateAction.do?method=changeTravelDate",
		   data: params,
		   success: function(html){
			 //document.getElementById("fareSelectFlightList").innerHTML=xmlhttp.responseText
			  $("#fareSelectFlightList").html(html.trim());
			 closeWaitImage();
			document.getElementById("disableTotalPage").style.display="none";
			toggleFlightsInfo(fltsInfoIdx);
			toggleActiveButtons(('button'+fltsInfoIdx));
			//document.refresh();
			}
		});
		/*setPosition(document.getElementById(positionObj), document.getElementById("loadingDiv"), -305, 130);
		document.getElementById("loadingDiv").style.display="block";*/
		//showWaitImage();
	//myUrl="changeTravelDateAction.do?method=changeTravelDate&oandDetailsNumber=" + OandDetailsNumber + "&offset="+offset;
	//ajaxWithCache(myUrl, "fareSelectFlightList");
	//document.frmOverNight.depOverNight.value="false";
	//document.frmOverNight.retOverNight.value="false";
	}

/* To change next & previous week on Select Page */
function changeWeekSubmit(OandDetailsNumber, weekStatus,oandDetailsListSize) {
	fltsInfoIdx=OandDetailsNumber;
	if(document.getElementById("errorDiv")){
		 document.getElementById("errorDiv").innerHTML='';
	}
	var positionObj="fareSelectCarousel"+OandDetailsNumber;
	myUrl="changeWeekDateAction.do?method=changeWeekDate&oandDetailsNumber=" + OandDetailsNumber + "&weekStatus="+weekStatus+"&oandDetailsListSize="+oandDetailsListSize;
	/*setPosition(document.getElementById(positionObj), document.getElementById("loadingDiv"), -305, 130);
	document.getElementById("loadingDiv").style.display="block";*/
	showWaitImage();
	//document.getElementById("disablePage").style.display="block";
		ajaxWithCache(myUrl, "fareSelectFlightList");
		//document.frmOverNight.depOverNight.value="false";
		//document.frmOverNight.retOverNight.value="false";
}

/* This function is used for Show all Filghts and Promo Code flights with Ajax */
function showAllAndDiscountedFlights(showFlightType) {
myUrl="showAllFlights.do?method=showAllFlights&actionFor="+showFlightType;
showWaitImage();
ajaxWithCache(myUrl, "fareSelectFlightList");
}

/* To change travle date using minimum fare grid on Select Page */
function ajaxWithCache(myurl, div){
var thetime=new Date(); 
var dummy=""+thetime.getHours()+thetime.getMinutes()+thetime.getSeconds();
myurl=myurl+"&dummy="+dummy;
ajaxDiv= div;
xmlhttp.open("POST", myurl, true);
xmlhttp.onreadystatechange =handleResponseWithCache;
xmlhttp.send("");
}

/* handle response of ajax call */
function handleResponseWithCache() {
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
if (xmlhttp.readyState == 4) { // Complete
  if (xmlhttp.status == 200) { // OK response
		if((xmlhttp.responseText).trim()=='AjaxSessionTimeOut'){
			window.location="/home.do?method=virginAmerica&sessionState=sessionTimeOut"
		}else{
			if((xmlhttp.responseText.indexOf('esc-sign')>=0 || xmlhttp.responseText.indexOf('escSignImg')>=0) && xmlhttp.responseText.indexOf('fsCarouselBgActiveNotAvailable')<0){
	  			//document.getElementById("errorDivId").style.display="block";
	  			document.getElementById("errorDiv").innerHTML=xmlhttp.responseText;
	  			document.getElementById("loadingAnimationDiv").style.display="none";
	  		}else{
	  			document.getElementById(ajaxDiv).innerHTML=xmlhttp.responseText;
				var i=0
				while($(('#activeCell'+i)).length>0 && $(('#activeCell'+i)).val()!=''){
					toggleActiveCell($(('#activeCell'+i)).val(),$(('#activeCell'+i)).val()+'|R',i);
					i++;
	  		}
	  		}
			// this function is called to update the title bar.
	  		ajax("updateTitleBar.do?method=updateTitleBar","titleBarDiv");
			document.getElementById("loadingAnimationDiv").style.display="none";
			if(document.getElementById('showWIFIDep')){
				if(document.getElementById('flight0') && document.getElementById('WiFiImg0')){
					if(document.getElementById('showWIFIDep').value=='true'){
						$get_JsElement('WiFiImg0').src='https://static.virginamerica.com/images/wifi_rightbar_10282010a.gif';
					}else{
						$get_JsElement('WiFiImg0').src='https://static.virginamerica.com/images/wifi_rightbar.gif';
					}
				}
			}
			if(document.getElementById('showWIFIRet')){
				if(document.getElementById('flight1') && document.getElementById('WiFiImg1')){
					if(document.getElementById('showWIFIRet').value=='true'){
						$get_JsElement('WiFiImg1').src='https://static.virginamerica.com/images/wifi_rightbar_10282010a.gif';
					}else{
						$get_JsElement('WiFiImg1').src='https://static.virginamerica.com/images/wifi_rightbar.gif';
					}
				}
			}
			//document.getElementById("disablePage").style.display="none";
			setPositionTravelExp();
 		}
		toggleFlightsInfo(fltsInfoIdx);
		toggleActiveButtons(('button'+fltsInfoIdx));
  }
}
}
/* To change fare format type on Select Page */
function changeFareFormatType(obj) {
	document.displayPricingForm.fareType.value=obj.value;
	document.displayPricingForm.oandDetailsNumber.value=fltsInfoIdx;
	document.displayPricingForm.method.value="changeFareInPointsDollar";
	document.displayPricingForm.action="changeFareInPointsDollarAction.do";
	document.displayPricingForm.submit(); 
	showWaitImage();
	//document.getElementById("PopoupPointBetaAlertSelectPage").style.display="none";
	//setPosition(obj, document.getElementById("loadingDiv"), 30, 30);
	//document.getElementById("loadingDiv").style.display="block";
}
function submitSeatForm(obj){
	/*
	if(document.getElementById('overNightFlightMessage').style.display=='none'){
		for(i=0;i<nextDayFlight.length;i++){
			if(nextDayFlight[i]==true){
				setPosition(obj, document.getElementById("overNightFlightMessage"), 400, 30);
				document.getElementById('overNightFlightMessage').style.display='block';
				return;
			}
		}
	}else{
		document.getElementById('overNightFlightMessage').style.display='none';
	}
	*/
	/*setPosition(obj, document.getElementById("loadingDiv"), 250, 30);
	document.getElementById("loadingDiv").style.display="block";*/
	showWaitImage();
	document.displayPricingForm.method.value="seatselect";
	document.displayPricingForm.action=seatActionUrl;
	document.displayPricingForm.submit();
}
/***  Flight Select page script end  ***/

function pageOverlay(divId, title, popupWidth, clkObj, showBtn, lftMrg, rgtMrg, decision, openParameter, functionCalled){
	// get the html page and load it into the frame/display area
	//$('#popupOverlayMsgArea').load(divId,'',overlay);
	$('#popupOverlayMsgArea').html($('#'+divId).html());
	$('#'+divId).html('');
		// set default local var
		var yScrollOffset = f_scrollTop();
		var pageWidth = xDocSize().w;
		var pageHeight = xDocSize().h;
		var vHeight = getViewableArea();
		var xOffSet = popupWidth/2;
		//var yOffSet = scrollHeightOffset();
		var xLocation = (pageWidth/2);
		xLocation = xLocation-xOffSet;
		var yLocation = (vHeight/2);
		yLocation += yScrollOffset;
		
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			pageHeight += 340;
		}
		
		// set title from input parameter
		document.getElementById("popupOverlayTitle").innerHTML = title;
		// get table, div and frame elements
		var popupElement = document.getElementById("popupOverlayTable");
		var popupFrame = document.getElementById("popupOverlayFrame");
		var popupDiv = document.getElementById("popupOverlayBg");
		
		// set widths and heights
		popupElement.style.width = eval(popupWidth);
		popupFrame.style.width = eval(popupWidth);
		//popupFrame.style.height=document.getElementById('popupOverlayId').offsetHeight;
		popupDiv.style.height = pageHeight;
		
		// set location and display
		document.getElementById('popupOverlayId').style.left = '50%';
		document.getElementById('popupOverlayId').style.top = yLocation;
		document.getElementById("popupOverlayBg").style.top = 0;
		document.getElementById("popupOverlayBg").style.height = pageHeight + 200 + "px";
		document.getElementById("popupOverlayBg").style.width = pageWidth + "px";
		document.getElementById("popupOverlayBg").style.display='block';
		
		// display user defined parameter
		if(openParameter && openParameter != '') {
			document.getElementById("popUpOverlayOpenParameter").innerHTML = openParameter;
		}
	
}

//<---------------- Check In ------  Start  -------------------------->

//Check In Home Start
function ciToggleCheckBoxes(cmObject,cmFormId,paxCount) {
	var cmState = cmObject.src;
	var cmAppend = '';
	var cmFlightId = cmObject.id.substr(11,1);
	var cmFlightIdIndex = cmFlightId - 1;
	var cmFormTempId = '';
	var cmFormTempValue = '';
	var  allFlightsPassSelected = 0;
	if(cmObject.id.indexOf('_All') != -1) {
		
		if(cmState.indexOf('-off') == -1) {
			cmObject.src = 'https://static.virginamerica.com/images/icon-checkbox-off.png';
			cmAppend = '-off';
			cmFormTempValue = 'na';
		} else {
			cmObject.src = 'https://static.virginamerica.com/images/icon-checkbox.png';
			cmFormTempValue = 'selected';
		}
		
		for(i=0;i<paxCount;i++) {
			if(document.getElementById('ciCheckBox0'+cmFlightId+'_0'+i).src.indexOf('restricted')==-1 && 
					document.getElementById('ciCheckBox0'+cmFlightId+'_0'+i).src.indexOf('checkedin')==-1 && document.getElementById('ciCheckBox0'+cmFlightId+'_0'+i).src.indexOf('unavailable')==-1){
				document.getElementById('ciCheckBox0'+cmFlightId+'_0'+i).src='https://static.virginamerica.com/images/icon-checkbox'+cmAppend+'.png';
				document.getElementById('guest'+cmFlightId+'_'+i).value=cmFormTempValue;
				//document.checkInForm.elements['checkInGuestDetails.guestCheckInDetails['+cmFlightId+']['+i+']'].value=cmFormTempValue;
			}
		}
		
		
	} else {
		if(cmState.indexOf('-off') == -1) {
         cmObject.src = 'https://static.virginamerica.com/images/icon-checkbox-off.png';
         document.getElementById(cmFormId).value='na';
         document.getElementById('ciCheckBox0'+cmFlightId+'_All').src='https://static.virginamerica.com/images/icon-checkbox-off.png';
   } else {
         cmObject.src = 'https://static.virginamerica.com/images/icon-checkbox.png';
         document.getElementById(cmFormId).value='selected';
         for(i=0;i<paxCount;i++) {
               if(document.getElementById('ciCheckBox0'+cmFlightId+'_0'+i).src.indexOf('-off') != -1) {
                     allFlightsPassSelected = 1;
               }
         }
         if(allFlightsPassSelected == 0) {
               document.getElementById('ciCheckBox0'+cmFlightId+'_All').src='https://static.virginamerica.com/images/icon-checkbox.png';
         }
   }
	}
	
}
function ciCollapseExpand(divId,btnObject) {
	
	var divObject = document.getElementById(divId);
	
	if(divObject.style.display == 'none') {
		document.getElementById(divId).style.display = 'block';
		btnObject.src='https://static.virginamerica.com/images/btn-checkin-collapse.png';
	} else {
		document.getElementById(divId).style.display = 'none';
		btnObject.src='https://static.virginamerica.com/images/btn-checkin-expand.png';
	}
	
}
function resetCheckBox(flightCount,guestCount) {
	for(j=0;j<flightCount;j++) {
		for(i=0;i<guestCount;i++){
			if(document.getElementById('ciCheckBox0'+j+'_0'+i)){
				if(document.getElementById('ciCheckBox0'+j+'_0'+i).src.indexOf('-off') != -1 || 
						document.getElementById('ciCheckBox0'+j+'_0'+i).src.indexOf('-restricted') != -1) {
					if(document.getElementById('ciCheckBox0'+j+'_All'))
					 document.getElementById('ciCheckBox0'+j+'_All').src='https://static.virginamerica.com/images/icon-checkbox-off.png';
					 break;
		        }
			}
		}
	}
	
}

function printBoardingPass(guestID,flightID,showClubHouse){
	var osdetect = OSDetect.OS;  
	var browserdetect=OSDetect.browser;
	var url="printBoardingPass.do?method=printBoardingPass&guestID="+guestID+"&flightID="+flightID+"&OSDetect="+osdetect+ "&browserdetect=" + browserdetect+"&showClubHouse="+showClubHouse;
	mywindowForHtml = window.open("/html/Virgin_America_Boarding_Pass.html","BoardingPass","toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,top="
					+10+",left="+180+",width="+845+",height="+700);
	
	ajaxToGeneratePdfHTML(url);
}
//Check In Home End

//Check In Travel Options Start
function changeTab(flightID){
	document.checkInDetailForm.method.value='changeTab';
	document.checkInDetailForm.indexID.value=flightID;
	document.checkInDetailForm.submit();
}
function submitCheckInForm(methodName,flightID,actionName,guestID,flightName){
	document.checkInDetailForm.method.value=methodName;
	if(flightID && flightID!=''){
		document.checkInDetailForm.indexID.value=flightID;
	}
	if(actionName){
		if(actionName!=''){
			document.checkInDetailForm.action=actionName+".do";
		}
	}
	if(guestID){
		if(guestID!=''){
			document.checkInDetailForm.elements["checkInGuestDetails.guestID"].value=guestID;
		}
	}
	if(flightName){
		if(flightName!=''){
			document.checkInDetailForm.elements["checkInGuestDetails.flightName"].value=flightName;
		}
	}
	document.checkInDetailForm.submit();
}

// This method is for updating progress-bar in check in flow 
function updateCheckInTitleBar(){
	var xmlHttp=null;
	xmlHttp= $.post("checkInProgressBar.jsp","",updateTitle,"html");
	function updateTitle(){
		document.getElementById("postTitleBarDiv").innerHTML=xmlHttp.responseText;
		closeWaitImage();
	};
}
//Check In Travel Options End
function submitCheckInReview(){
	if(document.getElementById("transactionImage"))
		document.getElementById("transactionImage").style.display="block";
	if(document.getElementById("purchaseButton"))
		document.getElementById("purchaseButton").innerHTML='<img src="https://static.virginamerica.com/images/btn-purchase.png" >'
	document.checkInDetailForm.submit();
}
//Check In Add bags Start
function calculateBagAmount(flightID,numOfGuest){
	//document.checkInDetailForm.method.value='calculateBagAmount';
	showWaitImage();
	document.checkInDetailForm.indexID.value=flightID;
	//document.checkInDetailForm.submit();
var parms='';
var URL='checkInAddBags.do?method=calculateBagAmount'
if(document.checkInDetailForm){
 for (var i=0; i < document.checkInDetailForm.elements.length; i++) {
	   var element = document.checkInDetailForm.elements[i];
	   if(i==0){
		   parms=parms+element.name+'='+element.value;
	   }else{
		   parms=parms+'&'+element.name+'='+element.value;
	   }
 }
}
var respYts = $.post(URL,parms,done,"html");
function done(){
	if((respYts.responseText).indexOf("errormessage_hold")==-1){
		document.getElementById("areaYTS").innerHTML=respYts.responseText;
		document.getElementById("errorDiv").style.display='none';
		document.getElementById("GoOnButton").innerHTML='<img src="https://static.virginamerica.com/images/btn-go-on.gif" alt="Go On" alt="Go On" onmouseover="MakeCursor(this);imgRollOver(this);" onmouseout="imgRollOut(this);" onclick="javascript:document.checkInDetailForm.submit();showWaitImage();">';
		updateCheckInTitleBar();
	}else{
		document.getElementById("errorDiv").innerHTML=respYts.responseText;
		document.getElementById("errorDiv").style.display='block';
		window.scrollTo(0,0);
		document.getElementById("GoOnButton").innerHTML='<img src="https://static.virginamerica.com/images/btn-go-on.gif" alt="Go On" alt="Go On" >';
		closeWaitImage();
	}
	
}
}
//Check In Add bags End
function nextPageCheckin(actionName,methodName){
	//showLoadingImageOpen('ssSeatMap01');
	showWaitImage();
	var seatsForAsegment ='';
	var selectedSeatNameTypes='';
	for(j=0;j<paxCount;j++){
		var seat = aGuestSeats[j][activeSegmentIndex];
		var seatType = aSeatType[j][activeSegmentIndex];
		if(seatsForAsegment == '' || seatsForAsegment == null )
			seatsForAsegment = seat;
		else
			seatsForAsegment =seatsForAsegment+","+seat;
		if(selectedSeatNameTypes == '' || selectedSeatNameTypes == null )
				selectedSeatNameTypes = seatType;
		else
			selectedSeatNameTypes =selectedSeatNameTypes+","+seatType;
	}
	document.seatMapForm.selectedSeatsForSegment.value=seatsForAsegment;
	document.seatMapForm.selectedSeatNameTypes.value=selectedSeatNameTypes;
	document.seatMapForm.method.value=methodName;
	document.seatMapForm.action=actionName+".do";
	document.seatMapForm.submit();
}
function progressBar(selectedLink){
	document.progressBarForm.action="checkInProcess.do";
	if(selectedLink=='CheckInPayment' || selectedLink=='CheckInReview')
		document.progressBarForm.action="checkInProcessSecure.do";
	document.progressBarForm.method.value="checkInProcess";
	document.getElementById('selectedLink').value=selectedLink;
	showWaitImage();
	document.progressBarForm.submit()
}
//<---------------- Check In ------   End   -------------------------->

//Clear Text of given element if it have text available in 2nd input parameter
function clearText(obj, textValue){
	if(textValue){
		if(obj.value == textValue){obj.value = "";}
	}else{
		if(obj.value=="Email or Elevate#"){obj.value = "";}
	}
}

//Change the text of given element
function changeText(value, areaId) {
	document.getElementById(areaId).innerHTML = value;
}

// Set Text to given element with text available in 2nd input parameter
function showText(fieldObj, text){
	if((fieldObj.value).trim() == "")
		fieldObj.value=text;
}

function setText(obj, textValue){
	if(obj.value == ""){
		obj.value = textValue;
	}
}
function increaseErrorCount(errorType,form){
    var count=0;
    if(form){
    	if(errorType=='promoCode'){
    		count=form.promo_code_error.value;
    		count++;
		  	form.promo_code_error.value=count;
         }
    }
}
function submitUpsellOptions(methodName,form,value,action){
	showWaitImage();
	form.method.value=methodName;
	if(value && value!=''){
		var newObject=document.createElement('input');
		newObject.name=value;
		newObject.type='hidden';
		newObject.value="on";
		form.appendChild(newObject);
	}
	if(action && action!='')
		form.action=action+".do";
	form.submit();

}
function submitFromReview(form){
	if(document.getElementById("transactionImage"))
		document.getElementById("transactionImage").style.display="block";
	if(document.getElementById("purchaseButton"))
		document.getElementById("purchaseButton").innerHTML='<img src="https://static.virginamerica.com/images/btn-purchase.png" >'
	form.submit();
}
function progressBarUpSell(selectedLink){
	document.progressBarForm.action="upSellProcess.do";
	if(selectedLink=='UPSellPayment' || selectedLink=='UPSellReview')
		document.progressBarForm.action="upSellProcessSecure.do";
	document.progressBarForm.method.value="upSellProcessBar";
	document.getElementById('selectedLink').value=selectedLink;
	showWaitImage();
	document.progressBarForm.submit()
}
function printClubHousePass(){
	var osdetect = OSDetect.OS;  
	var browserdetect=OSDetect.browser;
	var url="printClubHousePass.do?method=getClubHousePass&OSDetect="+osdetect+ "&browserdetect=" + browserdetect;
	mywindowForHtml = window.open("/html/Virgin_America_Boarding_Pass.html","BoardingPass","toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,top="
					+10+",left="+180+",width="+845+",height="+700);
	
	ajaxToGeneratePdfHTML(url);
}
function changeInputType(oldObject, oType, executeOnce, setText) {
	var newObject = document.createElement('input');
	newObject.type = oType;
	if(oldObject.value && oldObject.type==oType) newObject.value = oldObject.value;
	if(setText) newObject.value=setText;
	if(oldObject.name) newObject.name = oldObject.name;
	if(oldObject.id) newObject.id = oldObject.id;
	if(oldObject.className) newObject.className = oldObject.className;
	if(oldObject.size) newObject.size = oldObject.size;
	
	newObject.onblur=	function(){
							if(newObject.value=='')
								changeInputType(newObject,'text', true, 'Password');
						}
	newObject.onfocus=	function(){
							if(newObject.type=='text')
		  						changeInputType(newObject,'password', false);
		  				}
	/*newObject.onkeypress=function(){
	if(newObject.type!='text' && newObject.valve!="")
			sumitSearchWithEnterKey('enterSignInForm',event);
	}*/
	newObject.onkeypress=oldObject.onkeypress;
	newObject.onchange=function(){if(document.signInForm){document.signInForm.password.value=newObject.value;}}
	oldObject.parentNode.replaceChild(newObject,oldObject);
	if(!executeOnce){
		newObject.focus();
		newObject.select();
	}
	return newObject;
}

function submitPreferences(){
	showWaitImage();
	var userOptions="";
	for(optCnt=0; optCnt<document.emailPreferencesForm.preference.length; optCnt++){
		optObject = document.emailPreferencesForm.preference[optCnt];
		userOptions=userOptions + optObject.value + "-" + optObject.checked + ",";
	}
	document.emailPreferencesForm.preferences.value=userOptions;
	document.emailPreferencesForm.submit();
}

function makeSubscription(){
	myurl="email-preference-options.do?";
	for(optCnt=0; optCnt<document.emailPreferencesForm.elements.length; optCnt++){
		optObject = document.emailPreferencesForm.elements[optCnt];
		myurl=myurl+optObject.name+"="+optObject.value+"&";
	}
	$('#ContainerDealsAndOffer').load(myurl,'',done);
	function done(){
		closeWaitImage();
	}
}

/***********************************************
js for bookFlightWindow.jsp adults, infants    *
and children - start						   *
************************************************/
function setAdultAndInfants(tripType,paxCount,fieldId) {
	//*********************************
	// start build select option arrays
	var adults = new Array();
	var infants = new Array();
	var children = new Array();
	
	for(var i=0;i<10;i++) {
		//create infants array
		infants[i] = new Array();
		infants[i][0] = i;
		infants[i][1] = i;
	}
	for(var i=0;i<9;i++) {
		//create childrens array
		children[i] = new Array();
		children[i][0] = i;
		children[i][1] = i;
	}
	for(var i=0;i<9;i++) {
		adults[i] = new Array();
		adults[i][0] = i+1;
		adults[i][1] = i+1;
	}
	
	// end build select option arrays
	//*********************************
	// start

	// set default variables
	var thisIndex = 0;
	var thisElementIdAppend = '';
	
	// append MC to field name if multi-city
	if(tripType == 'mc') {
		thisElementIdAppend = 'MC';
	} else if(tripType == 'ow') {
		thisElementIdAppend = 'OW';
	}
	// get current value of fields
	var currentAdultCount = document.getElementById('adults'+thisElementIdAppend).value;
	var currentKidsCount = document.getElementById('kids'+thisElementIdAppend).value;
	var currentInfantCount = document.getElementById('infants'+thisElementIdAppend).value;
	// clear all options from add fields
	document.getElementById('adults'+thisElementIdAppend).options.length = 0;
	document.getElementById('kids'+thisElementIdAppend).options.length = 0;
	document.getElementById('infants'+thisElementIdAppend).options.length = 0;
	// determine which field to calculate and disable options in
	var paxCeilingAdults = 9 - currentKidsCount;
	var paxCeilingKids = 10 - currentAdultCount;
	var paxCeilingInfants = parseInt(currentAdultCount)+1;
	
	for(var j=0;j<paxCeilingAdults;j++) {
		if(isFF == 1 || isMacFF == 1) {
			document.getElementById('adults'+thisElementIdAppend).add(new Option(adults[j][0], adults[j][1]),null);
		} else {
			document.getElementById('adults'+thisElementIdAppend).add(new Option(adults[j][0], adults[j][1]));
		}
	}
	for(var j=0;j<paxCeilingKids;j++) {
		if(isFF == 1 || isMacFF == 1) {
			document.getElementById('kids'+thisElementIdAppend).add(new Option(children[j][0], children[j][1]),null);
		} else {
			document.getElementById('kids'+thisElementIdAppend).add(new Option(children[j][0], children[j][1]));
		}
	}
	for(var j=0;j<paxCeilingInfants;j++) {
		if(isFF == 1 || isMacFF == 1) {
			document.getElementById('infants'+thisElementIdAppend).add(new Option(infants[j][0], infants[j][1]),null);
		} else {
			document.getElementById('infants'+thisElementIdAppend).add(new Option(infants[j][0], infants[j][1]));
		}
	}
	
	if(currentInfantCount > currentAdultCount) {
		document.getElementById('infants'+thisElementIdAppend).options[currentAdultCount].selected = 'selected';
		if(isPCIE6 == 1) {
			//document.getElementById('infants'+thisElementIdAppend).options[currentAdultCount].setAttribute('selected',true);
			document.getElementById('infants'+thisElementIdAppend).options[currentAdultCount].selected = true;
		}
	}
	
	// set other trip type fields to the same as currently displayed fields.
	if(document.getElementById('infantsMC')) {
		document.getElementById('infantsMC').value=currentInfantCount;
	}
	if(document.getElementById('infantsOW')) {
		document.getElementById('infantsOW').value=currentInfantCount;
	}
	if(document.getElementById('infants')) {
		document.getElementById('infants').value=currentInfantCount;
	}
	if(document.getElementById('kidsMC')) {
		document.getElementById('kidsMC').value=currentKidsCount;
	}
	if(document.getElementById('kidsOW')) {
		document.getElementById('kidsOW').value=currentKidsCount;
	}
	if(document.getElementById('kids')) {
		document.getElementById('kids').value=currentKidsCount;
	}
	if(document.getElementById('adultsMC')) {
		document.getElementById('adultsMC').value=currentAdultCount;
	}
	if(document.getElementById('adultsOW')) {
		document.getElementById('adultsOW').value=currentAdultCount;
	}
	if(document.getElementById('adults')) {
		document.getElementById('adults').value=currentAdultCount;
	}
	
}

/***********************************************
js for bookFlightWindow.jsp adults, infants    *
and children - end							   *
************************************************/

/**************************************
 * start js for passport field checks *
 * to add required asterisks		  *
 **************************************/
function passportAddReqFieldInd(travelerNum) {
	if(document.displayPurchaseForm.elements['viewPurchase.passportCountry['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.passportNumber['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.passportExpMonth['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.passportExpDay['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.passportExpYear['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.countryOfResidence['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.citizenship['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.emergencyContact['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.emergencyContactNumber['+travelerNum+']'].value != '') {
		document.getElementById('passportCountryTd'+travelerNum).innerHTML = 'Issuing Country <span class="redAsterisk">*</span>';
		document.getElementById('passportNumberTd'+travelerNum).innerHTML = 'Passport # <span class="redAsterisk">*</span>';
		document.getElementById('passportExpDateTd'+travelerNum).innerHTML = 'Passport Exp. Date <span class="redAsterisk">*</span>';
		document.getElementById('countryOfResidenceTd'+travelerNum).innerHTML = 'Country of Residence <span class="redAsterisk">*</span>';
		document.getElementById('citizenshipTd'+travelerNum).innerHTML = 'Citizenship <span class="redAsterisk">*</span>';
		document.getElementById('emergencyContactNameTd'+travelerNum).innerHTML = 'Emergency Contact Name <span class="redAsterisk">*</span>';
		document.getElementById('emergencyContactNumberTd'+travelerNum).innerHTML = 'Emergency Contact Phone # <span class="redAsterisk">*</span>';
		
	}
	if(document.displayPurchaseForm.elements['viewPurchase.passportCountry['+travelerNum+']'].value == '' && document.displayPurchaseForm.elements['viewPurchase.passportNumber['+travelerNum+']'].value == '' && document.displayPurchaseForm.elements['viewPurchase.passportExpMonth['+travelerNum+']'].value == '' && document.displayPurchaseForm.elements['viewPurchase.passportExpDay['+travelerNum+']'].value == '' && document.displayPurchaseForm.elements['viewPurchase.passportExpYear['+travelerNum+']'].value == '' && document.displayPurchaseForm.elements['viewPurchase.countryOfResidence['+travelerNum+']'].value != '' && document.displayPurchaseForm.elements['viewPurchase.citizenship['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.emergencyContact['+travelerNum+']'].value != '' || document.displayPurchaseForm.elements['viewPurchase.emergencyContactNumber['+travelerNum+']'].value != '') {
		document.getElementById('passportCountryTd'+travelerNum).innerHTML = 'Issuing Country';
		document.getElementById('passportNumberTd'+travelerNum).innerHTML = 'Passport #';
		document.getElementById('passportExpDateTd'+travelerNum).innerHTML = 'Passport Exp. Date';
		document.getElementById('countryOfResidenceTd'+travelerNum).innerHTML = 'Country of Residence';
		document.getElementById('citizenshipTd'+travelerNum).innerHTML = 'Citizenship';
		document.getElementById('emergencyContactNameTd'+travelerNum).innerHTML = 'Emergency Contact Name';
		document.getElementById('emergencyContactNumberTd'+travelerNum).innerHTML = 'Emergency Contact Phone #';
	}
}
/**************************************
 * end js for passport field checks *
 * to add required asterisks		  *
 **************************************/

// function to set environment variable for omniture tracking.
function setOmnitureEnv() {
	var omnitureHostName = window.location.hostname;
	var omnitureEnv = 'vadev';
	if(omnitureHostName == 'www.virginamerica.com' || omnitureHostName == 'virginamerica.com') {
		omnitureEnv = 'vatest';
	}
	return omnitureEnv;
}
function submitPnrData(){
	$.post("viewReceipt.do?method=submitPnrData");
}
function signInPopUpOverlay(isAjax,tabNumber){
	if(document.getElementById('elevateInterruptDiv'))
		document.getElementById('elevateInterruptDiv').style.display='none';
	showWaitImage();
	document.signInForm.action="refer-friend.do";
	document.signInForm.submit();
}
function saveTravelInsurance(){
	travelInsuranceFlag=-1;
	if(document.purchaseForm){
		if(document.purchaseForm.elements['viewPurchaseModel.travelFlag']){
			for(i=0;i<document.purchaseForm.elements['viewPurchaseModel.travelFlag'].length;i++){
					if(document.purchaseForm.elements['viewPurchaseModel.travelFlag'][i].checked==true){
							travelInsuranceFlag=i;
					}
			}
		}
	}
}
function retainTravelInsurance(){
	if(document.purchaseForm){
		if(document.purchaseForm.elements['viewPurchaseModel.travelFlag']){
			if(travelInsuranceFlag>=0){
				if(document.purchaseForm.elements['viewPurchaseModel.travelFlag'][travelInsuranceFlag]){
					document.purchaseForm.elements['viewPurchaseModel.travelFlag'][travelInsuranceFlag].checked=true;	
				}
			}
		}
	}
}

function filterValue(fid){
	var fvalue = document.getElementById(fid).value;
	fvalue = replaceAllFunction(fvalue, "&", "");
	fvalue = replaceAllFunction(fvalue, "#", "");
	document.getElementById(fid).value = fvalue;
}

