function do_onkeyup(o,d)
{
	if (o.getAttribute&&o.value.length==o.getAttribute("maxlength"))
	d.focus()
}

function IsValidPhoneNumberBlock(idBox1, idBox2, idBox3, mandatory, hasRequiredFieldValidator)
{
	var part1 = document.getElementById(idBox1);
	var part2 = document.getElementById(idBox2);
	var part3 = document.getElementById(idBox3);		
	
	var phoneNumber = part1.value + part2.value + part3.value;

	if (hasRequiredFieldValidator == true)
	{
		if (mandatory == true && part1.value == "") 
			return true;// there is a RequiredFieldValidator in place that already did the test
						// we avoid double messages in this way.
	}
	
	if (mandatory == false)
	{
		if (phoneNumber.length == 0) 
			return true; 
	}
	
	// 10 digit phone number pattern
	var phonePat = /^(\d{10})$/;
	if (phoneNumber.match(phonePat) == null) //is the format ok?
		return false;
	else					
		return true;
}

function OpenSafeComputingPracticesWindow()
{
	window.open("SafeComputingPractices.aspx", "SafeComputingPractices", "height=550,width=645,scrollbars=yes,menubar=no,resizable=no,toolbar=no,location=no,status=no").focus();
}

function OpenKioskPrintCardWindow()
{
	window.open("KioskPrintCard.aspx", "KioskPrintCard", "top=200,left=300,height=230,width=320,scrollbars=no,menubar=no,resizable=no,toolbar=no,location=no,status=no").focus();
}

function OpenReferFriendsWindow()
{
	window.open("ReferFriends.aspx", "ReferFriends", "height=520,width=620,scrollbars=no,menubar=no,resizable=yes,toolbar=no,location=no,status=no").focus();
}

function OpenExtrasRulesAndRegulations()
{
	window.open("ExtrasRRPopup.aspx", "RulesAndRegulations", "height=550,width=645,scrollbars=yes,menubar=no,resizable=no,toolbar=no,location=no,status=no").focus();
}

function OpenPromoHelpPopup()
{
	window.open("PromoHelpPopup.aspx", "PromoHelpPopup", "height=550,width=645,scrollbars=yes,menubar=no,resizable=no,toolbar=no,location=no,status=no").focus();
}

function OpenPromoRulesRegPopup(url)
{
	window.open(url, "PromoHelpPopup", "height=550,width=645,scrollbars=yes,menubar=no,resizable=no,toolbar=no,location=no,status=no").focus();
}

function OpenVISAAccount (_url, _em) 
{
     var _params = "height=440,width=795, toolbar=0,scrollbars=1,location=1, locationbar=1,status=1, menubar=0,resizable=1,left=50,top=40";
     if ( window.open(_url, "SCENEwindow", _params) == null ) {
         alert (_em);
     }
}

function OpenBNSApplicationPage (_url, _em, _appid) 
{
	if (_appid == "")
	{
		var visaRadio = document.getElementById("WhiteCardRadioButton");		
		if (visaRadio != null)
		{
			if (visaRadio.checked == true)
				_appid = "VISA";
			else
				_appid = "OAO";
		}		
		if (_appid == "")
			_appid = "OAO";
	}
	
	var _params = "height=440,width=795,toolbar=0,scrollbars=1,location=1,locationbar=1,status=1,menubar=0,resizable=1,left=50,top=40";
	if (window.open(_url + "?APPID=" + _appid, "BNSApplicationWindow", _params) == null) 
	{
		alert (_em);
	}
}

function OpenPrintOrderWindow()
{
	window.open("RewardsOrderPrintPopup.aspx", "PRINTORDER", "height=520,width=620,scrollbars=yes,menubar=no,resizable=yes,toolbar=no,location=no,status=no").focus();
}

function HandlePlaceOrderButtonRequest(controlID, text)
{
	//document.forms[0].submit();
	window.setTimeout("HandlePlaceOrderButtonRequestOnTimer('" + 
                   controlID + "', '" + text + "')", 0);
}
function HandlePlaceOrderButtonRequestOnTimer(controlID, text)
{
	//document.forms[0].submit();
	document.getElementById(controlID).style.display = "none";
	document.getElementById("WaitMessage").innerHTML = text;
}
function OpenCustomWindow(intWidth, intHeight, strURL, strScollbars, strOtherOptions)
{
    window.open(strURL, "CustomWindow", "height="+intHeight+",width="+intWidth+",scrollbars="+strScollbars+",menubar="+strOtherOptions+",resizable="+strOtherOptions+",toolbar="+strOtherOptions+",location="+strOtherOptions+",status="+strOtherOptions).focus();
}

/* 
	Description: Attaching events dynamically 
	Note: Browser independant implementation.
*/
function attachEvent2(target, evt, func){
	if(typeof func != "function"){
		return false;
	}
	// Netscape/FireFox/Opera
	if(target.addEventListener != null){
		target.addEventListener(evt, func, true);
		return true;
	// IE
	}else if (target.attachEvent != null){
		target.attachEvent("on" + evt, func);
		return true;
	}
	return false;
}