function showForm()
{
	var objBody = document.getElementsByTagName("body")[0];
		
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	var ObjForm = document.createElement('div');
	ObjForm.setAttribute('id','overlay');
	ObjForm.style.position = 'absolute';
	ObjForm.style.top = '0';
	ObjForm.style.left = '0';
	ObjForm.style.zIndex = '90';
 	ObjForm.style.width = '100%';

	// set height of Overlay to take up whole page and show
	ObjForm.style.height = (arrayPageSize[1] + 'px');
	//ObjForm.style.display = 'block';
	
	objBody.appendChild(ObjForm);	
	
	var lightboxTop = arrayPageScroll[1] + 200;

	// create keyboard message
	var objKeyboardMsg = document.createElement("div");
	objKeyboardMsg.setAttribute('id','keyboardMsg');
	objKeyboardMsg.style.height = (arrayPageSize[1] + 'px');
	objKeyboardMsg.style.position = 'absolute';
	objKeyboardMsg.style.top = '0';
	objKeyboardMsg.style.left = '0';
	objKeyboardMsg.style.zIndex = '100';
 	objKeyboardMsg.style.width = '100%';
	
	MarginTopTable =  (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	
	//objKeyboardMsg.innerHTML = 'press <kbd>x</kbd> to close gffff';
	//objKeyboardMsg.innerHTML = '<br /><div style=padding-left: 11px; padding-right: 25px; text-align: justify;><strong>All rates are :</strong><ul style=margin-top: 0px; margin-left: 18px;><li>Rates above are exclusive of 21% tax and service and per room per night</li><li>High season surcharge<br /><table cellpadding=0 cellspacing=0 border=0 style=width: 100%;><tr><td>01 – 31 August 2008 </td><td>US$ 15.00/room/night</td></tr><tr><td>27 December 2008 – 05 January 2008</td><td>US$ 25.00/room/night</td></tr></table></li></ul></div>';
	objKeyboardMsg.innerHTML = '<form name="form_download" action="download_1.php" method="post"><table style="margin-top:'+MarginTopTable+'; padding-bottom: 20px;" id="contact_form" cellspacing="0" cellpadding="0" border="0" align="center"><tr><td colspan="2"><br /><font style="font-size: 12px; color: #0061BE;">if you want to received our update and more detail in pricing, please put your email address, so we can give you updates and more information about us .<br /><br /></font></td></tr><tr><td>Email</td><td><input type="text" name="email" size="30" /></td></tr><tr><td>&nbsp;</td><td><input type="button" name="button" value="Submit"  onClick="return validateForm()" />&nbsp;<input type="button" name="button" value="Cancel"  onClick="hideLightbox()" />&nbsp;<a onClick="hideLightbox()" href="download_1.php">No Thanks</a></td></tr></table><br /><br /></td></tr></table></form>';
	objBody.appendChild(objKeyboardMsg);
	
}

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function hideLightbox()
{
	// get objects
	ObjForm = document.getElementById('overlay');
	objKeyboardMsg = document.getElementById('keyboardMsg');

	// hide lightbox and overlay
	ObjForm.style.display = 'none';
	objKeyboardMsg.style.display = 'none';
	
	var objBody = document.getElementsByTagName("body")[0];
	
	objBody.removeChild(ObjForm);
	objBody.removeChild(objKeyboardMsg);
	
	// disable keypress listener
	document.onkeypress = '';
}

function checkDepartment()
{
	if(document.form_download.sendto.value == 'Other')
	{
		document.form_download.other.disabled = false;
	}
	else
	{
		document.form_download.other.disabled = true;
	}
}

function validateForm()
{
	if(document.form_download.email.value=='')
	{
		alert('Please input your email address');
		return false;
	}
	else if(document.form_download.email.value!='')
	{
		flag = true;
		akeong = document.form_download.email.value.indexOf('@');
		titik = document.form_download.email.value.indexOf('.');
		for(i=0;i<document.form_download.email.value.length;i++)
		{
			if(document.form_download.email.value.charAt(i) == '.')
				titik = i;
		}
		if(akeong == -1 || titik == -1 || akeong > titik || akeong + 1 == titik || titik + 1 > document.form_download.email.value.length)
		{
			alert('Please input a valid email address \n(eg. example@indovickers.com)');
			return false;
		}
	}
	
	document.form_download.submit();
	hideLightbox();
}
