
 /** popup contains logic for popup windows. It is cross browser compatible*/

	

	function openWindow(url, winName, aWidth, aHeight, X, Y) 
	{
		popupMessage(url, winName, aWidth, aHeight, X, Y, "");
	}
	
	/** 
	 * wrapper around window.open used for opening a non-resizable no-thrills popup message windows
	 */
	function popupMessage(url, winName, aWidth, aHeight, X, Y, windowFeatures) 
	{
		// if Height and Width are passed, but no X and Y coordinates passed, 
		// center the window on the screen
		if ( aHeight != null && aWidth != null && X == null && Y == null ) {
			X = Math.round((window.screen.availWidth - aWidth) / 2);
			Y = Math.round((window.screen.availHeight - aHeight) / 2);
		}

		var features= "height="+aHeight +", width="+aWidth +
				", screenX="+X +", screenY="+Y +", left="+X +", top="+Y;
	    if(windowFeatures != ""){
	    	features += ", " + windowFeatures;
	    }
	    else{
			features +=	", location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no";
		}

		var popup = window.open(url,winName, features); 
		popup.focus();
		return false;
	}

	/** 
	 * submits a form to its target window after opening a new window to receive it
	 */
	function _submitFormInWindow(aForm, aWidth, aHeight, X, Y, windowFeatures) {
		var target = "";
		if (aForm.target == null || aForm.target == "") {
			target = "popup";
		} else {
			target = aForm.target;
		}
		//popupMessage(aForm.action, target, aWidth, aHeight, X, Y);
		popupMessage("", target, aWidth, aHeight, X, Y, windowFeatures);
		aForm.target=target;
		aForm.submit();
	}

	/** 
	 * submits a form to its target window after opening a new window to receive it
	 * opening a non-resizable no-thrills popup message windows
	 */
	function submitFormInWindow(aForm, aWidth, aHeight, X, Y) {
		var features= createWindowFeatures("no", "no", "yes", "yes", "no", "no");

		_submitFormInWindow(aForm,aWidth,aHeight,X,Y,features);
	}
	
	function createWindowFeatures(location, menubar, resizable, scrollbars, status, toolbar){
		return "location=" + location + ", menubar=" + menubar + ", resizable="
			+ resizable + ", scrollbars=" + scrollbars + ", status=" + status
			+ ", toolbar=" + toolbar;
	}

	/**
	 * Controls the display of the map window.
	 * If a property code is passed, only that hotel is mapped, otherwise all hotels on the page are mapped.
	 */
	function openMapWindow(pCode, pForm) {
		if (pCode != null) {
			pForm.propertyCode.value = pCode;
			pForm.mapType.value = 'SINGLE'; 
		}
		else
		{
			pForm.propertyCode.value = '';
			pForm.mapType.value = 'MULTIPLE';			
		}  
		submitFormInWindow(pForm, 800, 450,window.screen.availWidth - 800, 0); 
	}
	
