/*
	OPENING POP UP WINDOW
*/
function popupWindow(popupLocation, windowName, popupWidth, popupHeight, statusBarOn) {
	var heightspeed = 15; 	// vertical speed
	var widthspeed 	= 15;  	// horizontal speed
	var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
	var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
	if (document.all) {
		if (statusBarOn) {
			var popUpWin = window.open("", windowName, "left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes,menubar=no");
		} else { 
			var popUpWin = window.open("", windowName, "left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=no,status=no,menubar=no");
		}
		for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) {
			popUpWin.resizeTo("1", sizeheight);
		}
		for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) {
			popUpWin.resizeTo(sizewidth, sizeheight);
		}	
		popUpWin.resizeTo(popupWidth, popupHeight);
		popUpWin.location = popupLocation;
	} else {
		var popUpWin = window.open(popupLocation, windowName, "left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=no");
	}
}

/*
	ADD TO BOOKMARKS FROM THE WEB HOMEPAGE
*/
function AddToBookmarks (url,title) 
{ 
	window.external.AddFavorite(url,title); 
}

/*
	ADJUST PAGE CONTENT HEIGHT
*/
function adjustContentHeight()
{
	// get height
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}	
	else
	{
	}
	
	var elID = document.getElementById('pageContent');
	elID.style.height = myHeight - 20 - 193 - 46;
}

function updateUserDOB(formObj)
{
	formObj.userDateOfBirth.value = formObj.userDayOfBirth.value + "/" + formObj.userMonthOfBirth.value + "/2005";
}

function displayJoinForm()
{
	var myElement = document.getElementById('tblMembership');

	if ( myElement.style.display == 'none' )
	{
		myElement.style.display = 'block';
	} 
	else
	{
		myElement.style.display = 'none';
	}
}



/* External Link Pop-up */

//var recursiveIncrement = 0;
//var objDivMessage = document.createElement('DIV');
//var objBackgroundFade = document.createElement('DIV');
//var timer = null;
//
//function init() {
//	var objBody = document.getElementsByTagName('BODY')[0];
//	
//	objDivMessage.id = 'DivMessage';
//	objBackgroundFade.id = 'BackgroundFade';
//	
//	objDivMessage.innerHTML = '<img src="/images/externalLinkLogo.gif" style="padding:4px;" /><p style="color:#FFFFFF; margin:0px; padding:8px;">You are now leaving this website to go to a site that is not controlled by QIC, and for which QIC is not responsible.<br />Your link will open within 5 seconds.</p><p style="margin:0px; padding:8px;"><a href="javascript:reloadPage();" style="color:#FFFFFF;">Click here to return to the current page.</a></p>';
//	objDivMessage.style.backgroundColor = '#0081D3';
//	objDivMessage.style.height = '180px';
//	objDivMessage.style.position = 'absolute';
//	objDivMessage.style.width = '350px';
//	
//	objBackgroundFade.className = 'opaqueDiv';
//	
//	// quit if this function has already been called
//	if (arguments.callee.done) return;
//	
//	// flag this function so we don't do the same thing twice
//	arguments.callee.done = true;
//	
//	var aryLinks = document.getElementsByTagName('A');
//	
//	var http = /http:\/\/[^\/]*watergardens/;
//	var qic = /http:\/\/[^\/]*qic/;
//	var mailto = /mailto.*/;
//	var javascript = /javascript:.*/;
//	
//	for(increment = 0; increment < aryLinks.length; increment++){
//		aryLinks[increment].onclick = function(){
//			var curLink = this.href;
//			if(http.test(this.href) != true && qic.test(this.href) != true && mailto.test(this.href) != true && javascript.test(this.href) != true){
//				objBody.insertBefore(objDivMessage, objBody.firstChild);
//				objBody.insertBefore(objBackgroundFade, objDivMessage);
//				
//				objBackgroundFade.style.height = objBody.offsetHeight + 'px';
//				objBackgroundFade.style.width = objBody.offsetWidth + 'px';
//				
//				var scrOfX = 0, scrOfY = 0;
//				if( typeof( window.pageYOffset ) == 'number' ) {
//					//Netscape compliant
//					scrOfY = window.pageYOffset;
//					scrOfX = window.pageXOffset;
//				} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//					//DOM compliant
//					scrOfY = document.body.scrollTop;
//					scrOfX = document.body.scrollLeft;
//					
//					objBackgroundFade.style.height = objBody.offsetHeight + scrOfY + 'px';
//				} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//					//IE6 standards compliant mode
//					scrOfY = document.documentElement.scrollTop;
//					scrOfX = document.documentElement.scrollLeft;
//					
//					objBackgroundFade.style.height = objBody.offsetHeight + scrOfY + 'px';
//				}
//  					
//				objDivMessage.style.top = ((window.screen.height / 2) + scrOfY) - objDivMessage.offsetHeight + 'px';
//				objDivMessage.style.left = ((window.screen.width / 2) + scrOfX) - (objDivMessage.offsetWidth / 2) + 'px';
//				
//				timer = setTimeout(function(){window.open(curLink,'popupWindow','width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes'); reload = setTimeout(function(){reloadPage();}, 5000);}, 5000);
//				return false;
//			}
//		};
//	}
//};

function reloadPage(){
	var objBody = document.getElementsByTagName('BODY')[0];
	
	timer = null;
	objBody.removeChild(objDivMessage);
	objBody.removeChild(objBackgroundFade);
	
	window.location.reload();
}

///* for Mozilla */
//if (document.addEventListener) {
//	document.addEventListener("DOMContentLoaded", init, false);
//}else{
//	// for Internet Explorer
//
//	/*@cc_on @*/
//	/*@if (@_win32)
//		document.write("<script defer src=/ie_onload.js><\/script>");
//	/*@end @*/
//	
//	window.onload = init;
//}