/////////////////////////////////////////////////////////////////////////////////
//
// File: msntravel.js
//
// Copyright (c) 2008 by Microsoft Corporation. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////////

// These 3 lines create the namespace Microsoft.Msn.Travel, which have to be at the beginning of the file
// If the namespace already exists, then it will just return the existing namespace object
var Microsoft;
if (!Microsoft) {
    Microsoft = {};
}

if (!Microsoft.Msn) {
    Microsoft.Msn = {};
}

if (!Microsoft.Msn.Travel) {
    Microsoft.Msn.Travel = {};
}

// Function to expand and collapse the MSN more section
Microsoft.Msn.Travel = {
    moreOnClick: function() {
		var moreDiv = document.getElementById("msnmore");
		var morelinkDiv = document.getElementById("morelink");
		var morelinkLi = document.getElementById("morelinkli");
	    //Orbitz edit: We'll need to expand/contract the iframe so set a var to reference it
	    var msnDiv = parent.document.getElementById("msndiv");
		if (moreDiv !== null && morelinkDiv !== null && morelinkLi !== null) {
			if (moreDiv.style.display === "none") {
				moreDiv.style.display = "block";
				morelinkDiv.className = "collapse";
				morelinkLi.className = "last";
				//Orbitz edit:  If there's no ad (secure pages), then expansion/contraction sizes will defer.  These
				//are determined by CSS classes in msntravel.css
				if (msnDiv !== null) {
					if (msnDiv.className === "noad") {
						msnDiv.className = "noadexpanded";
					} else {
						msnDiv.className = "expanded";
					}
				}
			} else if (moreDiv.style.display === "block") {
				moreDiv.style.display = "none";
				morelinkDiv.className = "expand";
				morelinkLi.className = "";
				if (msnDiv !== null) {
					if (msnDiv.className === "noadexpanded") {
						msnDiv.className = "noad";
					} else {
						msnDiv.className = "";
					}
				}
			}
		}
    }
}; 
/*End of MSN's original msntravel.js file (with modifications for third party sites)*/


/* Start orbitz MSN specific javascript*/

/*
This is the orbitz msn specific javascript for third party sites such as faq, travelerupdate, and cruises.  This has
been appended to MSN's orginal msntravel.js for performance issues (one less http request for another js file).  Any
updates from MSN for msntravel.js should be placed above. (Code optimized via http://www.jslint.com)
*/

var com;
if (!com) {
    com = {};
}

if (!com.orbitz) {
    com.orbitz = {};
}

if (!com.orbitz.msn) {
    com.orbitz.msn = {};
}

com.orbitz.msn = {
	isMSN: function() {
		/*
		we'll call the getCookie function from orbitzHeaderFooter.js, so it will have to be referenced in the html header.  Not ideal, but
		at least the MSN js is namespaced. Also, the CoBrand cookie value is in the form of "true|true", "true|false" etc.  We only need the
		value to the left of the pipe.
		*/

		var cookieVal = getCookie("CoBrand");

		if (cookieVal !== false) {
			var cookieValArr = cookieVal.split("|");

			if (cookieValArr[0] === "true") {
				return true;
			}
		}

		/*if no cookie, then let's also check the referer and the URL as they too determine cobranding*/
		return (document.referrer.indexOf("msn.") > -1 || window.location.hostname.indexOf("msn.") > -1);

	},
	/*MSN wants the booking path page group code for cruises, otherwise we'll use the merchandising page group code*/
	adPageGroup: function() {
		if (window.location.hostname.indexOf("cruises.") > -1) {
			return "TRVNB1";
		} else {
			return "TRVNM1";
		}
	}
};