// Build array to preload common buttons
var b = [
'/insite/images/buttons/search_on.gif',
'/insite/images/buttons/forward_arrow_on.gif',
'/insite/images/buttons/back_arrow_on.gif',
'/insite/images/buttons/view_all_on.gif',
'/insite/images/buttons/cancel_on.gif',
'/insite/images/buttons/ok_on.gif',
'/insite/images/buttons/select_hotel_on.gif',
'/insite/images/buttons/previous_hotel_on.gif',
'/insite/images/buttons/next_hotel_on.gif',
'/insite/images/buttons/select_room_on.gif',
'/insite/images/buttons/previous_room_on.gif',
'/insite/images/buttons/next_room_on.gif',
'/insite/images/buttons/no_thanks_on.gif',
'/insite/images/buttons/select_package_on.gif',
'/insite/images/buttons/edit_on.gif',
'/insite/images/buttons/save_on.gif',
'/insite/images/buttons/book_now_on.gif',
'/insite/images/buttons/email_on.gif',
'/insite/images/buttons/print_on.gif',
'/insite/images/buttons/complete_on.gif'
];
var p = [];

/**
 * Loops through pre-defined array and preloads the images
 */
function preloadImages() { for(var i in b) {  var j = p.length; p[j] = new Image(); p[j].src = b[i];	} }

/**
 * Toggles the date selector popup
 *
 * @param string dateType 'checkin' or 'checkout'
 * @param string url The URL to request the calendar data from
 */
function datePopup(dateType, url) {
    var checkinDate = ( document.getElementById('checkinDate') ) ? document.getElementById('checkinDate').value : '';
    var checkoutDate = ( document.getElementById('checkoutDate') ) ? document.getElementById('checkoutDate').value : '';
    switch(dateType.toLowerCase()) {
        case 'checkin':
            if (document.getElementById('dateSelectCheckout')) {
                document.getElementById('dateSelectCheckout').style.display = 'none';
            }
            var targetObject = 'dateSelectCheckin';
            var popup = document.getElementById('dateSelectCheckin');
            if (popup.style.display != 'none') {
                popup.innerHTML = '';
                popup.style.display = 'none';
            } else {
                popup.style.display = '';
                ajaxToObject(url+'&ajaxCheckinDate='+checkinDate+'&ajaxCheckoutDate='+checkoutDate, 'dateSelectCheckin');
            }
        break;
        case 'checkout':
            document.getElementById('dateSelectCheckin').style.display = 'none';
            var targetObject = 'dateSelectCheckout';
            var popup = document.getElementById('dateSelectCheckout');
            if (popup.style.display != 'none') {
                popup.style.display = 'none';
            } else {
                popup.style.display = '';
                ajaxToObject(url+'&ajaxCheckinDate='+checkinDate+'&ajaxCheckoutDate='+checkoutDate, 'dateSelectCheckout');
            }
        break;
    }
}

/**
 * Toggles the day selector popup
 *
 * @param object date { month: , day:, year: }
 * @param string url The URL to request the calendar data from
 */
function dayPopup(date, url) {
    for ( var d = 1; d <= 31; d++ ) {
        if ( d == date.day ) {
            continue;
        }
        try {
            document.getElementById('dayPopup_'+d).style.display = 'none';
        } catch (e) {}
    } 
    var popup = document.getElementById('dayPopup_'+date.day);
    if (popup.style.display != 'none') {
        popup.innerHTML = '';
        popup.style.display = 'none';
    } else {
        popup.style.display = '';
        ajaxToObject(url, 'dayPopup_'+date.day);
    }
}

/**
 * Handles maintaining number of nights difference between in and out dates
 *
 * @param string type 'Checkin' or 'Checkout'
 * @param string date The formatted date
 * @param numeric date_diff Day gap to maintain
 */
function update_dates( type, date, date_diff ) {
	selectDate( type, date );

	// if template is in date + number of nights, no need to update
	if ( document.forms['preferencesForm'].elements['numberOfNights'] ) { return }

	if ( ! date_diff ) { return }
	date_diff = parseFloat( date_diff );

	var date_item;

	if ( type == 'Checkin' ) {
		date_item	= document.forms['preferencesForm'].elements['checkoutDate'];
	} else {
		date_item	= document.forms['preferencesForm'].elements['checkinDate'];
	}

	var date_array = date.split('/');
	var date_obj = new Date();
	date_obj.setFullYear( date_array[2], date_array[0]-1, date_array[1] );
	date_obj.setDate( date_obj.getDate() + date_diff );

	var dy = date_obj.getFullYear();
	var dm = date_obj.getMonth() + 1;
	var dd = date_obj.getDate();
	if ( dy < 1970 ) dy = dy + 100;
	var ys = new String(dy);
	var ms = new String(dm);
	var ds = new String(dd);
	ys = ms + "/" + ds + "/" + ys;

	date_item.value = ys;
}
/**
 * Handles population of date field when a date is selected in the popup
 *
 * @param string dateType 'checkin' or 'checkout'
 * @param string dateStr The formatted date
 */
function selectDate(dateType, dateStr) { switch(dateType.toLowerCase()) { case 'checkin': document.getElementById('checkinDate').value = dateStr; break; case 'checkout': document.getElementById('checkoutDate').value = dateStr; break; } datePopup(dateType); }

/**
 * Makes an AJAX request and passes the response text/XML to a function
 *
 * @param string url The URL to request data from
 * @param object targetFunction The function to pass the returned data to
 * @param string parameters (oprional) URL encoded parameters to be sent as POST vars
 */
function ajaxToFunction(url, targetFunction, parameters) {
	Ajax.sendToFunction(url, parameters, targetFunction);
}

/**
 * Makes an AJAX request and inserts the response text into an HTML element
 *
 * @param string url The URL to request data from
 * @param string targetObj The ID of the object to place the returned data into
 * @param string parameters (oprional) URL encoded parameters to be sent as POST vars
 */
function ajaxToObject(url, targetObj, parameters)
{
	Ajax.sendToObject(url, parameters, targetObj);
}

/**
 * set up poll for changed content to get lightbox working with ajax
 */
function pollLightboxContent(id)
{
    if (document.getElementById(id)) {
        initLightbox();
    } else {
        setTimeout("pollLightboxContent('"+id+"')",100);
    } 
} 

/**
 * wraps an ajax request with a lightbox init
 */
function lightboxToAjax(id,url,targetObj,parameters)
{
    if ( !document.getElementById(id) ) {
        ajaxToObject(url,targetObj,parameters);
        pollLightboxContent(id);
    }
} 

/**
 * Fixes alpha transparency bug in IE
 *
 * The first time the function is called, it sets a timer to call itself again after a fraction of a second.
 * This is a workaround for a onload timing bug in IE
 */
var pngFixTimerId = false;
function pngFix() { if (pngFixTimerId === false) { pngFixTimerId = setTimeout(pngFix, 350); return; } clearTimeout(pngFixTimerId); var arVersion = navigator.appVersion.split("MSIE"); var version = parseFloat(arVersion[1]); if ((version >= 5.5) && (document.body.filters)) { for(var i=0; i<document.images.length; i++) { var img = document.images[i]; var imgName = img.src.toUpperCase(); if (imgName.substring(imgName.length-3, imgName.length) == "PNG") { var imgID = (img.id) ? "id='" + img.id + "' " : ""; var imgClass = (img.className) ? "class='" + img.className + "' " : ""; var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "; var imgStyle = "display:inline-block;" + img.style.cssText; if (img.align == "left") imgStyle = "float:left;" + imgStyle; if (img.align == "right") imgStyle = "float:right;" + imgStyle; if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle; var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='image');\"></span>"; img.outerHTML = strNewHTML; i = i-1; } } } }


/**
 * Opens a popup window or brings it to the top if it's already open
 *
 * @param string url the URL to open in the new window
 */
var newWin;
var width = 500;
var height = 500;
function zoom(url) { if (!newWin || newWin.closed) newWin = window.open(url,'newWin','width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes'); else { newWin.close(); newWin = window.open(url,'newWin','width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes'); newWin.focus(); } }

/**
 * Tracks mouse X position
 *
 * @param event evt Mouse event to track
 */
function mouseX(evt) {if (!evt) evt = window.event; if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;}

/**
 * Tracks mouse Y position
 *
 * @param event evt Mouse event to track
 */
function mouseY(evt) {
    if (!evt) evt = window.event;
    if (evt.pageY) return evt.pageY;
    else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    else return 0;
}

/**
 * Snaps an 'absolute' positioned DIV to the mouse
 *
 * @param event evt Mouse event to track
 */
function follow(evt) { 
    if (document.getElementById) {
        var obj = document.getElementById(loadingDiv);
        var x; var y;
        try {
            x = mouseX(evt);
        } catch (e) {
            x = 0;
        } 
        try {
            y = mouseY(evt);
        } catch (e) {
            y = 0;
        } 
        obj.style.left = (parseInt(x) + 15) + 'px';
        obj.style.top = (parseInt(y)) + 'px';
    }
}

/**
 * Initializes mouse tracking
 */
var loadingDiv = 'loading'; // div that is to follow the mouse (must be position:absolute)
function initFollow() { document.onmousemove = follow; }

/**
 * Collection of onLoad events
 */
function onLoadHandler() { initFollow(); preloadImages(); Ajax.setStatusIndicator('loading'); }

/**
 * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/ *
 * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com)
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}

function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}
/**
 * Centers the popup window
 *
 * @param object obj  the popup obj to center
 */
function centerPopWin(obj) {
    var width = obj.offsetWidth; 
    var height = obj.offsetHeight; 
    if (width == 0 || height == 0 ) {
        window.setTimeout(function () { centerPopWin(obj); }, 10);
    } else {
        var fullHeight = getViewportHeight();
        var fullWidth = getViewportWidth();
        var scLeft,scTop;
        if ( self.pageYOffset ) {
            scLeft = self.pageXOffset;
            scTop = self.pageYOffset;
        } else if ( document.documentElement && document.documentElement.scrollTop ) {
            scLeft = document.documentElement.scrollLeft;
            scTop = document.documentElement.scrollTop;
        } else if (document.body) {
                scLeft = document.body.scrollLeft;
                scTop = document.body.scrollTop;
        } 
        var topMargin = scTop + ( ( fullHeight - height ) / 2 );
        if ( topMargin < 0 ) {
            topMargin = 0;
        } 
        var leftMargin = scLeft + ( ( fullWidth - width ) / 2 );
        obj.style.top = topMargin + 'px';
        obj.style.left = leftMargin  + 'px';
    }
} 
/**
 * Toggles visibility of the addon scheduler popup
 * 
 * @param string url The URL to request the addon scheduling form from
 * @param string targetObj ID of the object to place the response data into
 */
var openPopups = [];
function addonSchedulePopup(url, targetObj) {
    for (i in openPopups) {
        document.getElementById(openPopups[i]).style.display = 'none';
    }
    toggleWindowObjects(true);
    if (targetObj) {
        openPopups.push(targetObj);
        var obj = document.getElementById(targetObj);
        ajaxToObject(url, targetObj);
        toggleWindowObjects(false);
        centerPopWin(obj);
    }
}

/**
 * Toggles visibility of of SELECT objects with an ID of 'addonQty'.
 *
 * This is a work-around for a bug in IE, which displays window objects above "floating" DIVs
 * @params bool toggleState 'true' makes object visible, 'false' hides them
 */
function toggleWindowObjects(toggleState) { if (!Browser.isIE()) return; var
selectAry = (document.getElementsByTagName('select')); for(var i = 0; i <
selectAry.length; i++) { if (selectAry[i].className == 'addonQty') selectAry[i].style.visibility = toggleState ? 'visible' : 'hidden'; } }

/**
 * Submits a form via AJAX
 *
 * @param object form The URL to submit the form to
 * @param string url URL encoded parameters to be sent as POST vars
 * @param string targetObj The ID of the object to place the returned data into
 */
function ajaxSubmitForm(form, url, targetObject) { if (targetObject) Ajax.sendToObject(url, Form.serialize(form), targetObject); else Ajax.send(url, Form.serialize(form)); }

/**
 * Browser Class
 */
var Browser = {
	n: navigator.appName,
	u: navigator.userAgent,
	isOpera: function () {	return Browser.u.indexOf("Opera") != -1 && parseInt(Browser.u.charAt(Browser.u.indexOf("Opera") + 6)) >= 8; },
	isIE: function () { return Browser.n == 'Microsoft Internet Explorer' && !Browser.isOpera(); },
	isNS: function () { return Browser.u.indexOf('Netscape') != -1; },
	isFF: function () { return Browser.u.indexOf('Firefox') != -1; },
	isPIE: function () { return Browser.n == 'Microsoft Pocket Internet Explorer'; }
}

/**
 * AJAX Class
 */
var Ajax = {
	xmlHttpReq: false,
	transport: false,
	statusIndicator: false,
	validationCode: false,
	response: false,
	targetFunction: false,
	targetObject: false,
	
	error: function (msg)
	{
		alert(msg);
		window.status = msg;
	},

	setValidationCode: function (val)
	{
		Ajax.validationCode = val;
	},
	
	setStatusIndicator: function (id)
	{
		Ajax.statusIndicator = id;
	},
	
	showStatusIndicator: function ()
	{
		if (Ajax.statusIndicator)
			document.getElementById(Ajax.statusIndicator).style.display = '';
	},
	
	hideStatusIndicator: function ()
	{
		if (Ajax.statusIndicator)
			document.getElementById(Ajax.statusIndicator).style.display = 'none';
	},
	
	request: function (url, params)
	{
		if (url)
		{		
			if (Ajax.getTransport())
			{
				Ajax.showStatusIndicator();
				
				var method = (Browser.isOpera()) ? 'get' : 'post';
				
				if (method == 'get' && params.length > 0)
			        url += (url.match(/\?/) ? '&' : '?') + params;
				Ajax.xmlHttpReq.open(method, url, true);
				Ajax.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				Ajax.xmlHttpReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
				if (Ajax.validationCode)
					Ajax.xmlHttpReq.setRequestHeader('X-Validation-Code', Ajax.validationCode);
				Ajax.xmlHttpReq.send(params);
				return true;
			}
			else
			{
				Ajax.error('This browser doesn\'t support AJAX.');
			}
		}
		else
			Ajax.error('No URL defined.');
		return false;
	},
	
	getTransport: function () {
		if (Browser.isIE() || Browser.isPIE()) {
			try
			{
				Ajax.xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					Ajax.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
				}
			}
		}
		else
		{
			try
			{
				Ajax.xmlHttpReq = new XMLHttpRequest();
			}
			catch (e)
			{
			}
		}
		return Ajax.xmlHttpReq;
	},
	
	send: function (url, params)
	{
		if (Ajax.request(url, params))
		{
			Ajax.xmlHttpReq.onreadystatechange = function ()
			{
				if (Ajax.xmlHttpReq.readyState == 4)
					Ajax.hideStatusIndicator();
			};
		}
	},
	
	sendToFunction: function (url, params, targetFunction)
	{
		if (targetFunction)
			Ajax.targetFunction = targetFunction;
		else
		{
			Ajax.error('No target function defined.');
			return false;	
		}

		if (Ajax.request(url, params))
		{
			Ajax.xmlHttpReq.onreadystatechange = function ()
			{
				if (Ajax.xmlHttpReq.readyState == 4)
				{
					Ajax.targetFunction(Ajax.xmlHttpReq);
					Ajax.hideStatusIndicator();
				}
			};
		}
	},
	
	sendToObject: function (url, params, targetObject)
	{
		if (targetObject)
			Ajax.targetObject = document.getElementById(targetObject);
		else
		{
			Ajax.error('No target object defined.');
			return false;
		}
		
		if (Ajax.request(url, params))
		{
			Ajax.xmlHttpReq.onreadystatechange = function()
			{
				if (Ajax.xmlHttpReq.readyState == 4)
				{
					Ajax.response = Ajax.xmlHttpReq.responseText;
					Ajax.targetObject.style.display = '';
					Ajax.targetObject.innerHTML = Ajax.response;
					Ajax.targetObject.scrollTop = 0;
					pngFix();
					Ajax.hideStatusIndicator();
				}
			};
		}
	}
}

/**
 * Form Class
 */
var Form = {
	serialize: function(form)
	{
		var elements = Form.getElements(form);
		var queryComponents = new Array();;
		
		for (var i =0; i < elements.length; i++)
		{
			var queryComponent = Form.serializeElement(elements[i]);
			if (queryComponent)
				queryComponents.push(queryComponent);
		}
		
		return queryComponents.join('&');
	},
	
	getElements: function(form)
	{
		var elements = new Array();
		
		for (var i =0; i < form.elements.length; i++)
		{
			elements.push(form.elements[i]);
		}
		return elements;
	},
	
	serializeElement: function(element)
	{
		var method = element.tagName.toLowerCase();
		var parameter = Form.elementSerializers[method](element);
		if (parameter)
		{
			var key = encodeURIComponent(parameter[0]);
			if (key.length == 0)
				return;
		
			if (parameter[1].constructor != Array)
				parameter[1] = [parameter[1]];

			var queryValues = [];
			
			for(var i = 0; i < parameter[1].length; i++)
			{
				queryValues.push(key + '=' + encodeURIComponent(parameter[1][i]));
			}

			return queryValues.join('&');
		}
	},
	
	elementSerializers: {
		input: function(element)
		{
			switch (element.type.toLowerCase())
			{
				case 'submit':
				case 'hidden':
				case 'password':
				case 'text':
					return Form.elementSerializers.textarea(element);
				case 'checkbox':
				case 'radio':
					return Form.elementSerializers.inputSelector(element);
			}
			return false;
		},
	
		inputSelector: function(element)
		{
			if (element.checked)
				return [element.name, element.value];
		},
	
		textarea: function(element)
		{
			return [element.name, element.value];
		},
	
		select: function(element)
		{
			return Form.elementSerializers[element.type == 'select-one' ? 'selectOne' : 'selectMany'](element);
		},
	
		selectOne: function(element)
		{
			var value = '', opt, index = element.selectedIndex;
			if (index >= 0)
			{
				opt = element.options[index];
				value = opt.value;
				if (!value && !('value' in opt))
					value = opt.text;
			}
			return [element.name, value];
		},
	
		selectMany: function(element)
		{
			var value = new Array();
			for (var i = 0; i < element.length; i++)
			{
				var opt = element.options[i];
				if (opt.selected)
				{
					var optValue = opt.value;
					if (!optValue && !('value' in opt))
						optValue = opt.text;
					value.push(optValue);
				}
			}
			return [element.name, value];
		}
	}
}

/* Genares added bits */

function changeDate(date) {
    var selectAry = (document.getElementsByTagName('div'));
    for ( var i = 0; i < selectAry.length; i++ ) {
        var element = selectAry[i];
        if ( element.className == 'schedule_time' ) {
            if ( element.id == 'schTime_'+date ) {
                element.style.display = 'block';
            } else {
                element.style.display = 'none';
            }
        }
    }
}


function callback(instance, method)
{
	return function() {
		method.apply(instance, arguments);
	}
}


myAjax.prototype.readyStateObjectEventHandler = function()
{
	if (this.xmlHttpReq.readyState == 4)
	{
		this.response = this.xmlHttpReq.responseText;
		this.targetObject.style.display = '';
		this.targetObject.innerHTML = this.response;
		this.targetObject.scrollTop = 0;
		pngFix();
		this.hideStatusIndicator();
	}
}


myAjax.prototype.readyStateFunctionEventHandler = function()
{
	if (this.xmlHttpReq.readyState == 4)
	{
		this.targetFunction(this.xmlHttpReq);
		this.hideStatusIndicator();
	}
}


myAjax.prototype.sendToObject = function (url, params, targetObject)
{
	if (targetObject)
		this.targetObject = document.getElementById(targetObject);
	else
	{
		this.error('No target object defined.');
		return false;
	}
	
	if (this.request(url, params))
	{
		this.xmlHttpReq.onreadystatechange = callback(this, this.readyStateObjectEventHandler);
	}
}


myAjax.prototype.sendToFunction = function (url, params, targetFunction)
{
	if (targetFunction)
		this.targetFunction = targetFunction;
	else
	{
		this.error('No target function defined.');
		return false;	
	}

	if (this.request(url, params))
	{
		this.xmlHttpReq.onreadystatechange = callback(this, this.readyStateFunctionEventHandler);
	}
}


myAjax.prototype.send = function (url, params)
{
	if (this.request(url, params))
	{
		this.xmlHttpReq.onreadystatechange = function ()
		{
			if (this.xmlHttpReq.readyState == 4)
				this.hideStatusIndicator();
		};
	}
}


myAjax.prototype.getTransport = function () {
	if (Browser.isIE() || Browser.isPIE()) {
		try
		{
			this.xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				this.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
			}
		}
	}
	else
	{
		try
		{
			this.xmlHttpReq = new XMLHttpRequest();
		}
		catch (e)
		{
		}
	}
	return this.xmlHttpReq;
}


myAjax.prototype.request = function (url, params)
{
	if (url)
	{		
		if (this.getTransport())
		{
			this.showStatusIndicator();
			
			var method = (Browser.isOpera()) ? 'get' : 'post';
			
			if (method == 'get' && params.length > 0)
				url += (url.match(/\?/) ? '&' : '?') + params;
			
			this.xmlHttpReq.open(method, url, true);
			this.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			// fix for FF3 not setting Content-Length
			if ( ! params || params.length == 0)
			    params = '';
			this.xmlHttpReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
			if (this.validationCode)
				this.xmlHttpReq.setRequestHeader('X-Validation-Code', this.validationCode);
			this.xmlHttpReq.send(params);
			return true;
		}
		else
		{
			this.error('This browser doesn\'t support AJAX.');
		}
	}
	else
		this.error('No URL defined.');
	return false;
}


myAjax.prototype.hideStatusIndicator = function ()
{
	if (this.statusIndicator)
		document.getElementById(this.statusIndicator).style.display = 'none';
}


myAjax.prototype.showStatusIndicator = function ()
{
	if (this.statusIndicator)
		document.getElementById(this.statusIndicator).style.display = '';
}


myAjax.prototype.setStatusIndicator = function (id)
{
	this.statusIndicator = id;
}


myAjax.prototype.setValidationCode = function (val)
{
	this.validationCode = val;
}


myAjax.error = function (msg)
{
	alert(msg);
	window.status = msg;
};


var Ajax = new myAjax();
function myAjax() 
{
	this.xmlHttpReq = null;
	this.transport = null;
	this.statusIndicator = false;
	this.validationCode = false;
	this.response = null;
	this.targetFunction = null;
	this.targetObject = null;
}


/**
 * Toggles visibility of the package scheduler popup
 * 
 * @param string url The URL to request the package scheduling form from
 * @param string targetObj ID of the object to place the response data into
 */
var openPopups = [];
function packageSchedulePopup(url, targetObj) { for (i in openPopups) document.getElementById(openPopups[i]).style.display = 'none'; toggleWindowObjects(true); if (targetObj) { openPopups.push(targetObj); var obj = document.getElementById(targetObj); ajaxToObject(url, targetObj); toggleWindowObjects(false); } }


/**
 * Sets the total price ('$' is prepended) for the quantity of selected packages
 * @param int qty Number of packages selected
 * @param float price Package price
 * @param string targetObj ID of the object to place the total price into
 */
function selectPackageQty(qty, price, targetObj) { var total = parseInt(qty) * parseFloat(price); document.getElementById(targetObj).innerHTML = '$' + total.toFixed(2); }


