/*Copyright 2005. William Ukoh @ http://www.williamukoh.com. All rights reserved worldwide. This material remains a property of William Ukoh and should not used or otherwised distributed without the permission of the owner*/


//Email page to someone
function emailPage(){
	openBrWindow('extensions/email.php?link=http://www.thehardleysuites.com','email','status=yes,scrollbars=no,resizable=no,width=520,height=550');
}

function showPlatinum(){
	openBrWindow('extensions/platinum.php','platinum','status=yes,scrollbars=yes,resizable=yes,width=520,height=550');
}

function bookNow(){
	var result = openBrWindow('extensions/reservation.php','book','status=yes,scrollbars=yes,resizable=yes,width=600,height=580');
	
	//If the window doesn't open, show an error message
	if(!result){
		alert("Oops! Something prevented the payment page from opening.\Don't worry, you'll be directed to the page.");
		document.location.href = "/extensions/reservation.php";
	}
}

//Mail to someone
function mailto(user,domain) 
{ 
document.location.href = "mailto:" + user + "@" + domain;
}


//Add to Favourites
function addToFavorite(){
  if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) {
    window.external.AddFavorite(location.href, document.title);
  }
  else{
	  window.alert('Please use Internet Explorer to bookmark this site');
  }
}

//Set the URL address in the Address Bar
function flashPutHref(href) { 
	location.href = href; 
}

//Set the Title of the Window
function flashPutTitle(title) { 
	document.title = title; 
}
	
//Display my site
function displaySite(site){
	window.open(site);
}

//Open Browser Window
function openBrWindow(theURL,winName,features) {
  var result = window.open(theURL,winName,features);
  return result;
}

function showGallery(){
	
	var target;
	
	if(arguments.length > 0){
		target = arguments[0];
	}
	else{
		target = "";
	}
	openBrWindow('/gallery/viewer.php?cat='+target,'email','status=yes,scrollbars=no,resizable=no,width=750,height=630');
}

function getURLVar(urlVarName) {
//divide the URL in half at the '?' 
var urlHalves = String(document.location).split('?');
var urlVarValue = '';
if(urlHalves[1]){
//load all the name/value pairs into an array 
var urlVars = urlHalves[1].split('&');
//loop over the list, and find the specified url variable 
for(i=0; i<=(urlVars.length); i++){
if(urlVars[i]){
//load the name/value pair into an array 
var urlVarPair = urlVars[i].split('=');
if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
//I found a variable that matches, load it's value into the return variable 
urlVarValue = urlVarPair[1];
}
}
}
}
return urlVarValue;   
}


//Generate random string
function generateCode(iLen) {
	var sChrs = '123456789ABCDEFGHIJKLMNOPQRSTUVWZ-';
	var sRnd = '';
	for (var i=0; i < iLen ; i++){
		var randomPoz = Math.floor(Math.random() * sChrs.length);
		sRnd += sChrs.substring(randomPoz,randomPoz+1);
	}
	return sRnd;
}

function getRoomUnitPrice(category){
	var amount;
	switch(category){
				case "Median":
					amount=1700000;
					break;
				case "Upper":
					amount=3500000;
					break
				case "Premium":
					amount=4500000;
					break;
				case "Executive Premium":
					amount=5500000;
					break;
				case "Royal Suites":
					amount=6000000;
					break;
				case "Diplomat Suites":
					amount=10000000;
					break;
				case "Penthouse Suites":
					amount=40000000;
					break;
		}
		return amount;
}

function printPage(){
	window.print();
}