function stripAlphaChars(pstrSource) 
{ 
var m_strOut = new String(pstrSource); 
    m_strOut = m_strOut.replace(/[^0-9]/g, ''); 

    return m_strOut; 
}

function showCCDetails ()
{
	document.getElementById('taxInvoiceGW').style.display='block';
	document.getElementById('storeFrontGWCash').style.display='none';
	document.getElementById('storeFrontGWCC').style.display='block';
	document.getElementById('storeFrontGW').style.display='block';
	document.getElementById('impNotesGW').style.display='block';
	if((document.getElementById("seatButtonGW")!=null)||(document.getElementById("seatButton")!=null))
	{
		document.getElementById('seatButtonGW').style.display='none';
		document.getElementById('seatButton').style.display='block';
	}	
	document.getElementById('subButtonGW').style.display='none';
	document.getElementById('subButton').style.display='block';
	document.forms['paymentDetails'].elements['payType'].value='CC';
}

function showCashDetails ()
{
	document.getElementById('taxInvoiceGW').style.display='block';
	document.getElementById('storeFrontGWCash').style.display='block';
	document.getElementById('storeFrontGWCC').style.display='none';
	document.getElementById('storeFrontGW').style.display='block';
	document.getElementById('impNotesGW').style.display='block';
	if((document.getElementById("seatButtonGW")!=null)||(document.getElementById("seatButton")!=null))
	{
		document.getElementById('seatButtonGW').style.display='none';
		document.getElementById('seatButton').style.display='block';
	}	
	document.getElementById('subButtonGW').style.display='none';
	document.getElementById('subButton').style.display='block';
	document.forms['paymentDetails'].elements['payType'].value='cash';
}

function hideCashDetails()
{
	document.getElementById('taxInvoiceGW').style.display='block';
	document.getElementById('storeFrontGW').style.display='block';
	document.getElementById('impNotesGW').style.display='none';
	document.getElementById('storeFrontGWCash').style.display='none';
	document.getElementById('storeFrontGWCC').style.display='block';
	if((document.getElementById("seatButtonGW")!=null)||(document.getElementById("seatButton")!=null))
	{
		document.getElementById('seatButtonGW').style.display='block';
		document.getElementById('seatButton').style.display='none';
	}	
	document.getElementById('subButtonGW').style.display='block';
	document.getElementById('subButton').style.display='none';
	document.forms['paymentDetails'].elements['payType'].value='CC';
}

function minimise (obj) {
	document.getElementById(obj).style.display='none';
}

function minimiseHide (obj) {
	document.getElementById(obj).style.visibility='hidden';
}

function maximise (obj,action) {
	document.getElementById(obj).style.display=action;
}

function objVisibility (obj,action) {
	document.getElementById(obj).style.visibility=action;
}

function jsSleep(delay) {
	var today = new Date();
	var start = today.getMilliseconds();
	var diff = 0;	// This var will track in milliseconds the timedifference.
	
	// loop through date until you exceed the delay specified
	while (diff < delay) {
		var newday = new Date();
		diff = newday.getMilliseconds() - start;		// Get time that has passed in milliseconds
	}
}
			
function loadButton(){
		window.parent.status="";
		  var store = document.getElementsByTagName("img");
		  for (var i=0;i<store.length;i++){
		    var imgname = store[i].getAttribute("mouseover");
		    if (!imgname) {
		    	continue;
		    }	
		    store[i].onimage = new Image();
		    store[i].onimage.src= imgname;
		    
		    store[i].onmouseover = new Function("rollover(this,'mouseover');");
		    store[i].onmouseout = new Function("rollover(this);");
		    store[i].setAttribute("offimage",store[i].src);
		  }
}
function rollover(cache,key){
  cache.src=cache.getAttribute(key || "offimage");
  
}
function popUp (path, name, width, height) {
	return window.open(path, name,'width=' + width + ',height=' + height + ',menubar=no,scrollbars=no');
}

function popUpScrollable (path, name, width, height) {
	return window.open(path, name,'width=' + width + ',height=' + height + ',menubar=no,scrollbars=yes');
}

function disableButton(frmButton){ 
	frmButton.disabled = true; 
	return true; 
}

function hideElement(id){
	elementDisplay(id, 'none');
}

function showElement(id){
	elementDisplay(id, 'block');
}

function elementDisplay(id, display) {
	var HTMLElement = document.getElementById(id);

	if (HTMLElement == null) return false;
	HTMLElement.style.display = display;
	return true;
}

function disableElement(id){
	elementStatus(id, true);
}

function enableElement(id){
	elementStatus(id, false);
}

function elementStatus(id, status) {
	var HTMLElement = document.getElementsByName(id);

	if (HTMLElement == null) return false;
	HTMLElement.disabled = status;

	return true;
}

function browserCloseActions() {
	// Check if the browser is being closed and not just the page is unloaded.
	// This only works on IE!
	if (window.event.clientX < 0 && window.event.clientY < 0) {

		// All actions to be done on browser close
		deleteCookie("PRODUCT_ACCOUNT");
	}
}

function getValidationParams(str) {
	return str.substr(0, tmpStr.indexOf("]"));
}

function validateFormItems(tf) {
	var items=document.getElementsByTagName("INPUT");
	alert("running autovalidation on [" + items.length + "] items");

	for (i=0; i < items.length; i++) {
		validations = item[i].id.substr(0, item[i].id.indexOf("_"));
		alert ("validations required=[" + validations + "]");

		for (x=0; x< validations.length; x++) {
			switch (validations.charAt(x)) {
				case E: ;break;
				case M: ;break;
				case L: 
					x+=1;
					params=getValidationParams(validations.substr(x)) 
					validateDataType(params);
					x+=params.length;
					break;
				case T: ;break;
				case D: ;break;
				case S: ;break;
				case R: ;break;
				case C: ;break;
			}
		}
	}
}

function validateDataType(v) {
}

//---Added for the buttons on the new look and feel site.
var b = '/img/buttons/dynamic_button/';
function changesrc(o,l,c,r) {
	var tr = o.firstChild.firstChild;
	tr.firstChild.firstChild.src = b+l;
	tr.firstChild.nextSibling.style.backgroundImage = 'url("'+(b+c)+'")';
	tr.lastChild.firstChild.src = b+r;
}

function changeButtonSrc (objSrc,buttonSrc) {
	objSrc.src=buttonSrc;
}

//////////////////////////////////////
var  percent = 10,timePeriod = 400;

function getBar()
{
	var retBar = '';
	for(i = 0; i < percent; i++)
	{
		retBar += ".";

		if(percent>75){
			retBar = ".";
			percent = 10;
		}
	}
	return retBar;
}

function progressBar()
{
  if(percent < 80)
  {
    percent = percent + 1
    window.parent.status = "Processing " + getBar();
    setTimeout ("progressBar()", timePeriod);
  }
  else
  {
    window.parent.status = "";
  }
}

function submitUtils(idn){
	//alert(idn);
	document.getElementById(idn).disabled=true; 
	progressBar();
}
////////////////////////////////////////////

function checkLodge (doFunction) {
	if (parseInt(doFunction) == 1) {
		document.paymentDetails.isLodgeCard.value="LODGECARD";
	} else {
		document.paymentDetails.isLodgeCard.value="NORMAL";
	}	
}

function doLodgeCardCheck(checkLodge) {
	if (parseInt(checkLodge)) {
		var obj1=document.getElementById("ETKT_Heading");
		if (obj1==null) {
		} else {
			hideElement("ETKT_Heading");
			hideElement("ETKT_Desc");
		}	

		if (document.getElementById('SFDM_Heading_Lodge_0'))
		{
			showElement("SFDM_Heading_Lodge_0");
			showElement("SFDM_description_Lodge_0");
		}
		
		/*if (document.getElementById('SFDM_Heading_Lodge_1'))
		{
			showElement("SFDM_Heading_Lodge_1");
			showElement("SFDM_description_Lodge_1");
		}
		
		/*if (document.getElementById('SFDM_Heading_Lodge_2'))
		{
			showElement("SFDM_Heading_Lodge_2");
			showElement("SFDM_description_Lodge_2");
		}*/
		
		if (document.getElementById('SFDM_Heading_Lodge'))
		{
			showElement("SFDM_Heading_Lodge");
			showElement("SFDM_description_Lodge");
		}
		
		hideElement("SETK_Input");
		hideElement("SETK_Heading");
		hideElement("SETK_Desc");
	} else {
		var obj1=document.getElementById("ETKT_Heading");
		if (obj1==null) {
		} else {
			showElement("ETKT_Heading");
			showElement("ETKT_Desc");
		}	

		if (document.getElementById('SFDM_Heading_Lodge_0'))
		{
			hideElement("SFDM_Heading_Lodge_0");
			hideElement("SFDM_description_Lodge_0");
		}
		
		/*if (document.getElementById('SFDM_Heading_Lodge_1'))
		{
			hideElement("SFDM_Heading_Lodge_1");
			hideElement("SFDM_description_Lodge_1");
		}
		
		/*if (document.getElementById('SFDM_Heading_Lodge_2'))
		{
			hideElement("SFDM_Heading_Lodge_2");
			hideElement("SFDM_description_Lodge_2");
		}*/
		
		if (document.getElementById('SFDM_Heading_Lodge'))
		{
			hideElement("SFDM_Heading_Lodge");
			hideElement("SFDM_description_Lodge");
		}		
		showElement("SETK_Input");
		showElement("SETK_Heading");
		showElement("SETK_Desc");
	}	
}

//----Floating DIV 
var isMozilla;
var objDiv = null;
var originalDivHTML = "";
var DivID = "";
var over = false;


function buildDimmerDiv()
{
    document.write('<div id="dimmer" class="dimmer" style="width:'+ window.screen.width + 'px; height:' + window.screen.height +'px"></div>');
}

function hiddenFloatingDiv(divId) 
{
	document.getElementById(divId).innerHTML = originalDivHTML;
	document.getElementById(divId).style.visibility='hidden';
	document.getElementById('dimmer').style.visibility = 'hidden';
	
	DivID = "";
}

function displayWindow(divID)
{
	var w, h, l, t;
	l = screen.width/4;	t = screen.height/4;
	
	// no title
	displayFloatingDiv(divID, '', w, h, l, t);
}

function displayFloatingDiv(divId, title, width, height, left, top) 
{
	DivID = divId;
	originalDivHTML="";
	//document.getElementById('dimmer').style.visibility = "visible";
	document.getElementById(divId).style.width = '500px';
    document.getElementById(divId).style.height = document.getElementById(divId+ '_body').offsetHeight;
	document.getElementById(divId).style.left = left + 'px';
    document.getElementById(divId).style.top = '10px';
	
	var addHeader;
	
	if (originalDivHTML == "")
	    originalDivHTML = document.getElementById(divId).innerHTML;
	
	document.getElementById(divId).innerHTML = originalDivHTML;
	document.location.href=('#top');
	document.getElementById(divId).className = 'dimming';
	document.getElementById(divId).style.visibility = "visible";
}