var L1Span=null;
var L2Span=null;
var L2Div=null;
var L3Div=null;
var ignoreMouseOut=false;
var proceedBack = true;
var processing = false;
var blank = "This field can not be blank.";
var please = " Please check the field and try again.";

var winModalWindow;
var modalContext;
var AdminMenu;
var RegistryMenu;
var LogonMenu;
var popupMenu;
var popupMenuExtra;
var popupMenuOptions;
var pageID = "";
var pid=2;
var ped='';
var pact='';
var sslURL='';
var agentDomain="";
var masterDomain="";
var sid='';
var month=new Array(13);

var vertMenuInsetPos=0;
var searchBoxInsetPos=0;
var horiMenuInsetPos=0;
var favMenuInsetPos=0;
var newsMenuInsetPos=0;
var calendarBoxInsetPos=0;
var emailIconInsetPos=0;
var printIconInsetPos=0;
var registryIconInsetPos=0;
var ccIconInsetPos=0;
var flashBannerInsetPos=0;
var logoHotspotInsetPos = 0;
var trollyBoxInsetPos = 0;
var templateWidth=0;
var xmlRequest=new Array(8);

function NSKeyPress(e){
    if (e) {
        if ((e.ctrlKey) && (e.which == 13)) {
            document.removeEventListener('keydown', NSKeyPress, false);
            window.onkeydown = "";
            waitChange(sslURL + '.?p=IN&target=1&sid=' + sid);
		}
	}
    
}
function CtrlAltEnter(sslURL,sid){
	if (window.event){
		if ((window.event.ctrlKey || window.event.altKey) && (window.event.keyCode==13)){waitChange('https://'+sslURL+'.?p=IN&target=1&sid='+sid);return false;}
		return true;
	}
	return false;	
}
function CreditCardPasteCheck(){
	if (window.event){
		if ((window.event.ctrlKey)&&(window.event.keyCode==86)){alert('Paste is not allowed in this field!');window.event.returnValue=false;}
		return true;
	}
	return false;	
}
function onloadFocus(){
	if (navigator.appName == 'Netscape') document.addEventListener("focus", HandleFocus, true);
	else window.top.attachEvent('onfocus',HandleFocus);
}
function HandleFocus(){
	if (winModalWindow){
		if (!winModalWindow.closed) winModalWindow.focus();
		else {
			if (navigator.appName == 'Netscape') window.top.removeEventListener("focus", HandleFocus, true);
			else window.top.detachEvent('onfocus',HandleFocus);
		}
	}
}
function rightMouseClick(e)
{
	if ((pid==1) && ((ped=="")||(ped=="spell")) && (pact=="")||(pact=="IF")) {
        if (popupMenu) popupMenu.style.display="none";
        if (popupMenuExtra) popupMenuExtra.style.display = "none";
        if (popupMenuOptions) popupMenuOptions.style.display = "none";       
		if (e) {
		    if ((e.target.id)&&(e.target.className)){
	            if (e.target.className.indexOf("HeadFont")>=0){
	                pageID = e.target.id.substr(4);
		            if (e.target.id.indexOf("NAME")>=0){moveAdminMenu('PAGEMENU',window.innerWidth,window.innerHeight,e.clientX,e.clientY,window.document.documentElement.scrollTop);}
		            if (e.target.id.indexOf("TOPH")>=0){moveAdminMenu('TOPPAGEMENU',window.innerWidth,window.innerHeight,e.clientX,e.clientY,window.document.documentElement.scrollTop);}
        	        return false;
        	    }
		    }
		    moveAdminMenu('ADMINMENU',window.innerWidth,window.innerHeight,e.clientX,e.clientY,window.document.documentElement.scrollTop);
		}
		else if (window.event) {
		    if ((window.event.srcElement.id)&&(window.event.srcElement.className)){
		        if (window.event.srcElement.className.indexOf("HeadFont")>=0){
	                pageID = window.event.srcElement.id.substr(4);
		            if (window.event.srcElement.id.indexOf("NAME")>=0){moveAdminMenu('PAGEMENU',window.document.documentElement.clientWidth,window.document.documentElement.clientHeight,window.event.clientX ,window.event.clientY,window.document.documentElement.scrollTop);}
		            if (window.event.srcElement.id.indexOf("TOPH")>=0){moveAdminMenu('TOPPAGEMENU',window.document.documentElement.clientWidth,window.document.documentElement.clientHeight,window.event.clientX ,window.event.clientY,window.document.documentElement.scrollTop);}
        	        return false;
            	}
		    }
		    moveAdminMenu('ADMINMENU',window.document.documentElement.clientWidth,window.document.documentElement.clientHeight,window.event.clientX,window.event.clientY,window.document.documentElement.scrollTop);
		}
	}
	return false;
}
function hideAll()
{
	if (L3Div) L3Div.style.display="none";
	if (L2Div) {
        if ((L1Span)&&(ignoreMouseOut==false)){
            if (L1Span.className=="LeftMenuOverFont") L1Span.className = "LeftMenuFont";
            else if (L1Span.className=="FavMenuOverFont") L1Span.className = "FavMenuFont";
        }	    
	    L2Div.style.display="none";
	}
	L3Div=null;
	L2Div=null;
    L2Span=null;
    L1Span=null;
}
function showLevel1(Div,Span)
{
	var newDiv = document.getElementById(Div);
	var newSpan = document.getElementById(Span);
	if (newSpan){
	    if (!newDiv) hideAll();
	    L1Span = newSpan;
        if (newSpan.className=="LeftMenuOverFont") {ignoreMouseOut=true;}
	    else {newSpan.className = "LeftMenuOverFont"; ignoreMouseOut=false;}
	}
	if (newDiv) {
	    if (L2Div) { if (newDiv != L2Div && (L2Div)) hideAll(); }
		L2Div = newDiv;
		newDiv.style.display="inline-block";
		newDiv.style.left=(newSpan.offsetWidth)+"px";
		newDiv.style.top=(newSpan.offsetTop)+"px";
 	}
}
function showLevel2(Div,Span)
{
	var newDiv = document.getElementById(Div);
	var newSpan = document.getElementById(Span);
	if (newSpan){
		L2Span = newSpan;
		L2Span.className = "LeftMenuOverFont";
		if (!newDiv && (L3Div)) {L3Div.style.display="none";L3Div=null;}
	}
	if (newDiv) {
		if (L3Div) {if (newDiv!=L3Div && (L3Div)) L3Div.style.display="none";}
		L3Div = newDiv;
		newDiv.style.display="inline-block";
		newDiv.style.left=(newSpan.offsetWidth)+"px";
		newDiv.style.top=(newSpan.offsetTop)+"px";
	}
	if (L1Span) L1Span.className = "LeftMenuOverFont";
}
function showLevel1Hori(Div,Span,index)
{
	var newDiv = document.getElementById(Div);
	var newSpan = document.getElementById(Span);
	if (newSpan){
		L1Span = newSpan;
        if (newSpan.className=="FavMenuOverFont") {ignoreMouseOut=true;}
	    else {newSpan.className = "FavMenuOverFont"; ignoreMouseOut=false;}
		L1Span.className = "FavMenuOverFont";
		if (!newDiv) hideAll();
	}
	var offsetWidth=0;
	var button=null;
    var wArray = index.split(",");
    for (var i=0;i<wArray.length;i++){
        if (wArray[i]!=''){
            button=document.getElementById(wArray[i]);
            if (button){offsetWidth=offsetWidth+button.offsetWidth;}
        }
    }
	if (newDiv) {
		if (L2Div) {if (newDiv!=L2Div && (L2Div)) hideAll();}
		L2Div = newDiv;
		newDiv.style.display="block";
		newDiv.style.width=newSpan.offsetWidth+"px";
		newDiv.style.left=offsetWidth+"px";
		newDiv.style.top=parseInt(newSpan.offsetHeight)+"px";
 	}
}
function showLevel2Hori(Div,Span)
{
	var newDiv = document.getElementById(Div);
	var newSpan = document.getElementById(Span);
	if (newSpan){
		L2Span = newSpan;
		L2Span.className = "FavMenu2OverFont";
		if (!newDiv && (L3Div)) {L3Div.style.display="none";L3Div=null;}
	}
	if (newDiv) {
		if (L3Div) {if (newDiv!=L3Div && (L3Div)) L3Div.style.display="none";}
		L3Div = newDiv;
		newDiv.style.display="block";
		newDiv.style.left=(newSpan.offsetWidth)+"px";
		newDiv.style.top=(newSpan.offsetTop)+"px";
	}
	if (L1Span) L1Span.className = "FavMenuOverFont";
}
function buttonMouseOver(Span)
{
	hideAll();
	var newSpan = document.getElementById(Span);
	if (newSpan) {
        if (newSpan.className=="LeftMenuOverFont") {ignoreMouseOut=true;}
	    else {newSpan.className = "LeftMenuOverFont"; ignoreMouseOut=false;}
	}
}
function buttonMouseOut(Span,ClassFont)
{
	var newSpan = document.getElementById(Span);
	if (newSpan) {
        if (!ignoreMouseOut) newSpan.className = ClassFont;
	}
}
function topButtonOver(element)
{
	var topButton = document.getElementById(element);
	if (L2Div) {if (topButton!=L2Div && (L2Div)) hideAll();}
	if (topButton) {
        if (topButton.className=="FavMenuOverFont") {ignoreMouseOut=true;}
	    else {topButton.className="FavMenuOverFont"; ignoreMouseOut=false;}
	}
}
function topButtonOut(element,ClassFont)
{
	var topButton = document.getElementById(element);
	if (topButton) {
        if (!ignoreMouseOut) topButton.className=ClassFont;
	}
}
function buttonClick(element,nextURL)
{
	var clickedButton = document.getElementById(element);
	if (clickedButton){
		clickedButton.className="LeftMenuFont";
		clickedButton.style.cursor='wait';
		document.body.style.cursor='wait';
		window.status = element;
		waitChange(nextURL);
	}
}
function infoValidation(details)
{
	if (processing) return false;
	if (details.Head) {
		if (details.Head.value.length==0){
			alert("Header: " + blank + please);
			details.Head.focus();return false;}
		details.Head.style.cursor='wait';
	}
	processing=true;
	document.body.style.cursor='wait';
	return true;
}
function logonValidation(details)
{
	if (processing) return false;
	if (details.Name){
		if (details.Name.value.length==0){
			alert("Name: " + blank + please);
			details.Name.focus();return false;}
		if (details.Password.value.length==0){
			alert("Password: " + blank + please);
			details.Password.focus();return false;}
		details.Name.style.cursor='wait';
		details.Password.style.cursor='wait';
	}
	processing=true;
	document.body.style.cursor='wait';
	if (details.submit){details.submit.style.cursor='wait';}
	return true;
}
function validChars(shift,ctrl,charCode)
{
    if (shift) return false;
    if ((ctrl)&&(charCode==86)){alert('Paste is not allowed in this field!');return false;}
    if (((charCode >= 48) && (charCode <= 57)) || ((charCode >= 65) && (charCode <= 90)) || ((charCode >= 8) && (charCode <= 9))) return true;
    else return false;
}
function trackValidation(details)
{
	if (processing) return false;
	if (details.orderNumber) {
		if (details.orderNumber.value.length==0){
			alert("Order Number: " + blank + please);
			details.orderNumber.focus();return false;}
		details.orderNumber.style.cursor='wait';
	}
	processing=true;
	document.body.style.cursor='wait';
	if (details.submit){details.submit.style.cursor='wait';}
	return true;
}
function registryValidation(details)
{
	if (processing) return false;
	if (details.giftcode) {
		if (details.giftcode.value.length==0){
			alert("Gift Code: " + blank + please);
			details.giftcode.focus();return false;}
		details.giftcode.style.cursor='wait';
	}
	processing=true;
	document.body.style.cursor='wait';
	if (details.submit){details.submit.style.cursor='wait';}
	return true;
}
function signupValidation(details)
{
	if (processing) return false;
	if (details.title) {
		if (details.title.value.length==0){alert(details.title.title + ": " + blank + please);details.title.focus();return false;}}
	if (details.firstname) {
		if (details.firstname.value.length==0){alert(details.firstname.title + ": " + blank + please);details.firstname.focus();return false;}}
	if (details.lastname) {
		if (details.lastname.value.length==0){alert(details.lastname.title + ": " + blank + please);details.lastname.focus();return false;}}
	if (details.businessname) {
		if (details.businessname.value.length==0){alert(details.businessname.title + ": " + blank + please);details.businessname.focus();return false;}}
	if (details.abn) {
		if (details.abn.value.length==0){alert(details.abn.title + ": " + blank + please);details.abn.focus();return false;}}
	if (details.password) {
		if (details.password.value.length==0){alert(details.password.title + ": " + blank + please);details.password.focus();return false;}}
	if (details.address) {
		if (details.address.value.length==0){alert(details.address.title + ": " + blank + please);details.address.focus();return false;}}
	if (details.address2) {
		if (details.address2.value.length==0){alert(details.address2.title + ": " + blank + please);details.address2.focus();return false;}}
	if (details.state) {
		if (details.state.value.length==0){alert(details.state.title + ": " + blank + please);details.state.focus();return false;}}
	if (details.postcode) {
		if (details.postcode.value.length==0){alert(details.postcode.title + ": " + blank + please);details.postcode.focus();return false;}}
	if (details.address5) {
		if (details.address5.value.length==0){alert(details.address5.title + ": " + blank + please);details.address5.focus();return false;}}
	if (details.phone) {
		if (details.phone.value.length==0){alert(details.phone.title + ": " + blank + please);details.phone.focus();return false;}}
	if (details.phone2) {
		if (details.phone2.value.length==0){alert(details.phone2.title + ": " + blank + please);details.phone2.focus();return false;}}
	if (details.mobile) {
		if (details.mobile.value.length==0){alert(details.mobile.title + ": " + blank + please);details.mobile.focus();return false;}}
	if (details.fax) {
		if (details.fax.value.length==0){alert(details.fax.title + ": " + blank + please);details.fax.focus();return false;}}
	if (details.email) {
		if (details.email.value.length==0){alert(details.email.title + ": " + blank + please);details.email.focus();return false;}
		if (details.email.value.indexOf("@")==-1){alert("Email: does not appear to be valid. " + please);details.email.focus();return false;}
		if (details.email.value.indexOf(".")==-1){alert("Email: does not appear to be valid. " + please);details.email.focus();return false;}
	}
	if (details.position) {
		if (details.position.value.length==0){alert(details.position.title + ": " + blank + please);details.position.focus();return false;}}
	if (details.web) {
		if (details.web.value.length==0){alert(details.web.title + ": " + blank + please);details.web.focus();return false;}}
	if (details.dob) {
		if (details.dob.value.length==0){alert(details.dob.title + ": " + blank + please);details.dob.focus();return false;}}
	if (details.reference) {
		if (details.reference.value.length==0){alert(details.reference.title + ": " + blank + please);details.reference.focus();return false;}}
	if (details.comment) {
		if (details.comment.value.length==0){alert(details.comment.title + ": " + blank + please);details.comment.focus();return false;}}
	if (details.captcha) {
		if (details.captcha.value.length==0){alert(details.captcha.title + ": " + blank + please);details.captcha.focus();return false;}}

	processing=true;
	document.body.style.cursor='wait';
	if (details.submit){details.submit.style.cursor='wait';}
	return true;
}
function interactValidation(details)
{
	if (processing) return false;
	if (details.email) {
		if (details.email.value.length==0){alert(details.email.title + ": " + blank + please);details.email.focus();return false;}
		if (details.email.value.indexOf("@")==-1){alert("Email: does not appear to be valid. " + please);details.email.focus();return false;}
		if (details.email.value.indexOf(".")==-1){alert("Email: does not appear to be valid. " + please);details.email.focus();return false;}
		details.email.style.cursor='wait';
	}
	processing=true;
	document.body.style.cursor='wait';
	return true;
}
function transactValidation(details)
{
	if (processing) return false;
	document.body.style.cursor='default';

	if (details.CreditCardNumber) {
		if (details.CreditCardNumber.value.length==0){alert("Credit Card Number: " + blank + please);details.CreditCardNumber.focus();return false;}}
	if (details.CreditCardCVV) {
		if (details.CreditCardCVV.value.length==0){alert("Credit Card CVV code: " + blank + "\r\nYour CVV code is the last 3 digits of the number printed on the back of your credit card\r\n(or the 4 digits printed on the front of your Amex card). " + please);details.CreditCardCVV.focus();return false;}}
	if (details.CreditCardHolderName) {
		if (details.CreditCardHolderName.value.length==0){alert("Credit Card Holder Name: " + blank + please);details.CreditCardHolderName.focus();return false;}}
	if (details.FirstName) {
		if (details.FirstName.value.length==0){alert("Name: " + blank + please);details.FirstName.focus();return false;}}
	if (details.LastName) {
		if (details.LastName.value.length==0){alert("Name: " + blank + please);details.LastName.focus();return false;}}
	if (details.Phone) {
		if (details.Phone.value.length==0){alert("Phone: " + blank + please);details.Phone.focus();return false;}}
	if (details.Email) {
		if (details.Email.value.length==0){
			alert("Email: " + blank + please);
			details.Email.focus();return false;}
		if (details.Email.value.indexOf("@")==-1){
			alert("Email: does not appear to be valid. " + please);
			details.Email.focus();return false;}
		if (details.Email.value.indexOf(".")==-1){
			alert("Email: does not appear to be valid. " + please);
			details.Email.focus();return false;}
	}
	if (details.Address) {
		if (details.Address.value.length==0){alert("Address: " + blank + please);details.Address.focus();return false;}}
	if (details.Address2) {
		if (details.Address2.value.length==0){alert("Address: " + blank + please);details.Address2.focus();return false;}}
	if (details.Address3) {
		if (details.Address3.value.length==0){alert("Address: " + blank + please);details.Address3.focus();return false;}}
	if (details.Address4) {
		if (details.Address4.value.length==0){alert("Address: " + blank + please);details.Address4.focus();return false;}}
	if (details.Address5) {
		if (details.Address5.value.length==0){alert("Address: " + blank + please);details.Address5.focus();return false;}}
	if (details.CustomerReference) {
		if (details.CustomerReference.value.length==0){alert("Purchase Order no.: " + blank + please);details.CustomerReference.focus();return false;}}

	if (details.SelectDeliveryDetails) {
        switch (details.SelectDeliveryDetails.selectedIndex){
        case 0: break;
        case 1:
            if (details.DeliveryInstruction) {
	            if (details.DeliveryInstruction.value.length==0){alert("Delivery Instructions: " + blank + please);details.DeliveryInstruction.focus();return false;}}
            break;
        case 2:break;
        }
    }
	processing=true;
	document.body.style.cursor='wait';
	if (details.CreditCardNumber) details.CreditCardNumber.style.cursor='wait';
	if (details.CreditCardCVV) details.CreditCardCVV.style.cursor='wait';
	if (details.CreditCardHolderName) details.CreditCardHolderName.style.cursor='wait';
	if (details.ContactName) details.ContactName.style.cursor='wait';
	if (details.DeliveryAddress) details.DeliveryAddress.style.cursor='wait';
	if (details.PostCode) details.PostCode.style.cursor='wait';
	if (details.DeliveryInstruction) details.DeliveryInstruction.style.cursor='wait';
	if (details.ContactPhone) details.ContactPhone.style.cursor='wait';
	if (details.ContactEmail) details.ContactEmail.style.cursor='wait';
	return true;
}
function bookingValidation(totalPrice)
{
    if (IsNumeric(totalPrice)){
        if (parseInt(totalPrice)<=0){alert("Sorry we cannot refund this amount\n\rThe total order amount must be greater than zero");return false;}
    }else{return false;}
	
	if (processing) return false;
	processing=true;
	document.body.style.cursor='wait';
	return true;
}
function stdValidation()
{
	if (processing) return false;
	processing=true;
	document.body.style.cursor='wait';
	return true;
}
function waitCursor(targetURL, objectID)
{
	if (document.getElementById('IMG'+objectID)) document.getElementById('IMG'+objectID).style.cursor='wait';
	if (document.getElementById('NAME'+objectID)) document.getElementById('NAME'+objectID).style.cursor='wait';
	waitChange(targetURL);
}
function waitMenu(menuItem)
{
	if (menuItem){if (document.getElementById(menuItem)) document.getElementById(menuItem).style.cursor='wait';}
	hideAll();
	document.body.style.cursor='wait';
}
function waitChange(newPage)
{
	if (document.getElementById('Name')) document.getElementById('Name').style.cursor='wait';
	if (document.getElementById('Description')) document.getElementById('Description').style.cursor='wait';
	if (document.getElementById('submit')) document.getElementById('submit').style.cursor='wait';
	if (document.getElementById('CANCEL')) document.getElementById('CANCEL').style.cursor='wait';
	if (document.getElementById('Menu')) document.getElementById('Menu').style.cursor='wait';
	if (document.getElementById('Head')) document.getElementById('Head').style.cursor='wait';
	if (document.getElementById('Body')) document.getElementById('Body').style.cursor='wait';
	if (document.getElementById('Tail')) document.getElementById('Tail').style.cursor='wait';
	if (document.getElementById('ImageCheckbox')) document.getElementById('ImageCheckbox').style.cursor='wait';
	if (document.getElementById('allotment')) document.getElementById('allotment').style.cursor='wait';
	if (document.getElementById('Price')) document.getElementById('Price').style.cursor='wait';
	if (document.getElementById('orderNumber')) document.getElementById('orderNumber').style.cursor='wait';
	if (document.getElementById('history')) document.getElementById('history').style.cursor='wait';
	if (document.getElementById('REMOVEALL')) document.getElementById('REMOVEALL').style.cursor='wait';
	if (document.getElementById('returnbutton')) document.getElementById('returnbutton').style.cursor='wait';
	if (document.getElementById('hitCount')) document.getElementById('hitCount').style.cursor='wait';

	if (document.getElementById('ContactName')) document.getElementById('ContactName').style.cursor='wait';
	if (document.getElementById('DeliveryAddress')) document.getElementById('DeliveryAddress').style.cursor='wait';
	if (document.getElementById('DeliveryAddress2')) document.getElementById('DeliveryAddress2').style.cursor='wait';
	if (document.getElementById('DeliveryAddress3')) document.getElementById('DeliveryAddress3').style.cursor='wait';
	if (document.getElementById('PostCode')) document.getElementById('PostCode').style.cursor='wait';
	if (document.getElementById('DeliveryInstruction')) document.getElementById('DeliveryInstruction').style.cursor='wait';
	if (document.getElementById('ContactPhone')) document.getElementById('ContactPhone').style.cursor='wait';
	if (document.getElementById('ContactEmail')) document.getElementById('ContactEmail').style.cursor='wait';
	if (document.getElementById('MailingList')) document.getElementById('MailingList').style.cursor='wait';

	document.body.style.cursor='wait';
	if (newPage!="") {window.location = newPage;}
}
function waitChangeParam(newPage,Param)
{
	waitChange(newPage+Param);
}
function AreYouSure(msg, newPage)
{
	if (confirm(msg) && (newPage != '')) waitChange(newPage);
}
function register(sid,pid,domain){
	onloadFocus();
	winModalWindow = window.open('register.asp?sid='+sid+'&pid='+pid+'&domain='+domain,'REGISTER','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,dependent=yes,width=330,height=300');
}
function createStdMenu(name,menuText,domain,page,forcedLogon,editor)
{
	var menu="";
	menu=menu+"<a class=LeftMenuFont id=\""+name+"\" ";
	if (forcedLogon){menu=menu+"NOHREF onclick=\"alert('To enter this site, please log on.');\">&nbsp;"+menuText+"</a>";}
	else if (editor=="true"){menu=menu+"NOHREF onclick=\"alert('You are currently editing this page. To save your changes, click on SAVE.');\">&nbsp;"+menuText+"</a>";}
	else{
		menu=menu+"HREF=\""+domain+".?p="+page+"\" ";
		menu=menu+"onclick=\"waitMenu();\" ";
		menu=menu+"onmouseover=\"buttonMouseOver(\'"+name+"\');\" ";
		menu=menu+"onmouseout=\"buttonMouseOut(\'"+name+"\',\'LeftMenuFont\');\">"+menuText+"</a>";
	}
	return menu;
}
function setMenu(features, partyID, agentURL, homeURL, secureURL, fileURL, secureID, siteType, logonOption, editor, action, vertMenuInset, searchBoxInset, horiMenuInset, favMenuInset, newsMenuInset, calendarBoxInset, emailIconInset, printIconInset, registryIconInset, ccIconInset, flashBannerInset, logoHotspotInset, trollyBoxInset, pageTop, template, templateHeight, navBar, reloadMenu, barFavMenu, barHoriMenu, barMenu, vmenuID, hmenuID)
{
	var menuText, horiMenu, horiMenu2, vertMenu, newsMenu, calendarBox, AdminMenu,editorMenu,forcedLogon;
	var searchBox, emailIcon, printIcon, registryIcon, creditcardIcon;
	var flashBanner, logoHotspot, trollyBox;
	var calendarDates;
	var l1Text, l2Text, l3Text;
	var l1Count, l2Count, l3Count;
	var hideMenuItem;
	var lm="";
	var ef="";
	var sf="";
	var ff="";
	var rf="";
	var suf="";
	var br="";

	vertMenuInsetPos=vertMenuInset;
	searchBoxInsetPos=searchBoxInset;
	horiMenuInsetPos=horiMenuInset;
	favMenuInsetPos=favMenuInset;
	newsMenuInsetPos=newsMenuInset;
	calendarBoxInsetPos=calendarBoxInset;
	emailIconInsetPos=emailIconInset;
	printIconInsetPos=printIconInset;
	registryIconInsetPos=registryIconInset;
	ccIconInsetPos=ccIconInset;
	flashBannerInsetPos=flashBannerInset;
	logoHotspotInsetPos = logoHotspotInset;
	trollyBoxInsetPos = trollyBoxInset;
	templateWidth=template;

    agentDomain="http://"+agentURL+"/"
    masterDomain=homeURL;
	pid=partyID;
	ped=editor;
	pact=action;
	if ((pid==1)&&(ped=="")&&(pact==0)){pact=""}
	menuText="";
	AdminMenu="";
	forcedLogon=false;
	if (siteType==3){BottomMenu="";BottomMenuCount=0;}
	if ((logonOption=="True") && (siteType>0) && (partyID==2))forcedLogon=true;
	if ((partyID==1)&&((action=="UP")||(action=="IN")))editor="true";
	else editor="false";

	if (navigator.appName == 'Netscape'){
		sslURL=secureURL;
		sid = secureID;
		window.onkeydown = NSKeyPress;
		if (partyID == 1) window.onclick = NSclick;
}

	window.document.oncontextmenu=rightMouseClick;
	if ((pid==1)&&(ped=="true")) {window.onscroll=scrollEditorMenu;}

	horiMenu = document.getElementById('HORIMENU');
	horiMenu2 = document.getElementById('HORIMENU2');
	vertMenu = document.getElementById('VERTMENU');
	if (vertMenu){
	    if (partyID>2) {lm=createStdMenu('LOGON',"LOG OFF",homeURL,'IN&target=2',false,editor);}
	    else if ((features&8) && (LogonMenu.length>0)) {lm=createStdMenu('LOGON',LogonMenu,secureURL,'IN&target=1&sid='+secureID,false,editor);}
        if (navigator.appName=="Microsoft Internet Explorer")
            vertMenu.insertAdjacentHTML("beforeEnd",lm);
        else{
            var range = document.createRange();
            if (vertMenu.lastChild) {range.setStartBefore(vertMenu.lastChild);}
            else {range.setStart(vertMenu,0);}
            vertMenu.appendChild(range.createContextualFragment(lm));
        }
    }
	newsMenu = document.getElementById('NEWSMENU');
	calendarBox = document.getElementById('CALENDARMENU');
	searchBox = document.getElementById('SEARCHBOX');
	emailIcon = document.getElementById('EMAILICON');
	printIcon = document.getElementById('PRINTICON');
	registryIcon = document.getElementById('REGISRTYICON');
	creditcardIcon = document.getElementById('CREDITCARDICON');
	editorMenu = document.getElementById('EDITORMENU');
	flashBanner = document.getElementById('FLASHBANNER');
	logoHotspot = document.getElementById('LOGOHOTSPOT');
	trollyBox = document.getElementById('TROLLYBOX');
	
	if (window.document.body.clientWidth>=templateWidth){
		if (vertMenu)vertMenu.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(vertMenuInsetPos))+"px";
		if (horiMenu)horiMenu.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(favMenuInsetPos))+"px";
		if (horiMenu2)horiMenu2.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(horiMenuInsetPos))+"px";
		if (newsMenu)newsMenu.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(newsMenuInsetPos))+"px";
		if (calendarBox)calendarBox.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(calendarBoxInsetPos))+"px";
    	if (searchBox)searchBox.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(searchBoxInsetPos))+"px";
    	if (emailIcon)emailIcon.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(emailIconInsetPos))+"px";
    	if (printIcon)printIcon.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(printIconInsetPos))+"px";
    	if (registryIcon)registryIcon.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(registryIconInsetPos))+"px";
    	if (creditcardIcon)creditcardIcon.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(ccIconInsetPos))+"px";
    	if (flashBanner)flashBanner.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(flashBannerInsetPos))+"px";
    	if (logoHotspot)logoHotspot.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(logoHotspotInsetPos))+"px";
    	if (trollyBox) trollyBox.style.left = parseInt(parseInt((window.document.body.clientWidth - templateWidth) / 2) + parseInt(trollyBoxInsetPos)) + "px";
    } else {
		if (vertMenu)vertMenu.style.left=parseInt(vertMenuInsetPos)+"px";
		if (horiMenu)horiMenu.style.left=parseInt(favMenuInsetPos)+"px";
		if (horiMenu2)horiMenu2.style.left=parseInt(horiMenuInsetPos)+"px";
		if (newsMenu)newsMenu.style.left=parseInt(newsMenuInsetPos)+"px";
		if (calendarBox)calendarBox.style.left=parseInt(calendarBoxInsetPos)+"px";
    	if (searchBox)searchBox.style.left=parseInt(searchBoxInsetPos)+"px";
    	if (emailIcon)emailIcon.style.left=parseInt(emailIconInsetPos)+"px";
    	if (printIcon)printIcon.style.left=parseInt(printIconInsetPos)+"px";
    	if (registryIcon)registryIcon.style.left=parseInt(registryIconInsetPos)+"px";
    	if (creditcardIcon)creditcardIcon.style.left=parseInt(ccIconInsetPos)+"px";
    	if (flashBanner)flashBanner.style.left=parseInt(flashBannerInsetPos)+"px";
    	if (logoHotspot)logoHotspot.style.left=parseInt(logoHotspotInsetPos)+"px";
    	if (trollyBox) trollyBox.style.left = parseInt(trollyBoxInsetPos) + "px";
 }
	if (calendarBox){
		var currentDate = new Date();
		calendarDates='';
		if (document.getElementById('CALENDARDATES')) calendarDates=document.getElementById('CALENDARDATES').value;
		calendarBox.innerHTML=createCalendar('','','',currentDate.getMonth()+1,currentDate.getFullYear(),calendarDates);
		if (document.getElementById('CALENDARDATES')) calendarBox.style.display='block';
	}

	if (newsMenu) newsMenu.style.display='block';
	if (horiMenu) horiMenu.style.display='block';
	if (horiMenu2) horiMenu2.style.display='block';
	if (vertMenu) vertMenu.style.display='block';
	if (searchBox) searchBox.style.display='block';
	if (emailIcon) emailIcon.style.display='block';
	if (printIcon) printIcon.style.display='block';
	if (registryIcon) registryIcon.style.display='block';
	if (creditcardIcon) creditcardIcon.style.display='block';
	if (flashBanner) flashBanner.style.display='block';
	if (logoHotspot) logoHotspot.style.display='block';
	if (trollyBox) trollyBox.style.display = 'block';

    fillMargin=0;
    if (navigator.appName == 'Netscape') {fillMargin=document.body.offsetHeight-5-parseInt(templateHeight+parseInt(pageTop));
    }else{fillMargin=document.body.scrollHeight-19-parseInt(templateHeight+parseInt(pageTop));}

    if ((navBar&&1)||(navBar&&2)||(navBar&&4)||(navBar&&8)||(navBar&&16)){
        fillMargin=fillMargin-28;
        if (fillMargin<0)fillMargin=0;
    }
	if (editorMenu) {
	    editorMenu.style.left="0px";
	    marginLeft = document.getElementById('TLMARGIN1');
	    if (marginLeft) editorMenu.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2) + parseInt(marginLeft.style.width))+"px";
	}
    if (vmenuID!=''){
        var highlightVMenu = document.getElementById(vmenuID);
        if (highlightVMenu) highlightVMenu.className = "LeftMenuOverFont";
    }
    if (hmenuID!=''){
        var highlightHMenu = document.getElementById(hmenuID);
        if (highlightHMenu) highlightHMenu.className = "FavMenuOverFont";
    }
}
function setTopMenu(Logon,Registry)
{
	LogonMenu=Logon;
	RegistryMenu=Registry;

	if (document.getElementById('Tail')) {
		document.getElementById('Tail').focus();
	}else if (document.getElementById('Name')) {
		if (document.getElementById('Name').disabled==false)
			document.getElementById('Name').focus();
	}else if (document.getElementById('orderNumber')) {
		if (document.getElementById('orderNumber').disabled==false)
			document.getElementById('orderNumber').focus();
	}else if (document.getElementById('businessname')) {
		if ((document.getElementById('businessname').disabled==false) && (document.getElementById('businessname').visible==true))
			document.getElementById('businessname').focus();
	}
}
function SubmitUserForm()
{
	var rowText;
	var rowTextArray;
	var rowInputCtrl;
	var count=0;
	var len;
	var key="";
	var value="";
	var parseChoice;
	var formData="";
	var element="";
	var formPart;
	var inputField;
	var multiInput;
	var userForm = document.getElementById('UserForm');
	var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);

	if (userForm){
		len=userForm.rows.length;
		for (x=0; x<len-1; x++) {
			value="";
			formPart=null;
			if (userForm.rows.item(x).cells.item(1)){
			    if (userForm.rows.item(x).cells.item(1).getElementsByTagName("*").length>0){
				    formPart=userForm.rows.item(x).cells.item(1).getElementsByTagName("*");
				    if(formPart.item(0).tagName=="FONT") inputField=formPart.item(0).getElementsByTagName("*");
				    else inputField=formPart;
				    if (inputField.item(0)){
                        if ((inputField.item(0).type)||(inputField.item(0).id)){
					        if (inputField.item(0).type=="text"){
						        value=inputField.item(0).value;
						        if (value.length==0) {alert('Please fill in all fields');inputField.item(0).focus();return false;}
					        }else if (inputField.item(0).type=="textarea"){
						        if (isIE) value=inputField.item(0).innerText; else value=inputField.item(0).value;
					        }else if ((inputField.item(0).type=="radio") || (inputField.item(0).type=="checkbox")){
						        if (isIE){
							        rowText=inputField.item(0).parentElement.innerText;
							        rowInputCtrl=inputField.item(0).parentElement.getElementsByTagName("INPUT");
						        }else{
							        rowText=inputField.item(0).parentNode.textContent;
							        rowInputCtrl=inputField.item(0).parentNode.getElementsByTagName("INPUT");
						        }
						        if (isIE) {rowTextArray=rowText.split("\n");}
						        else{
							        if (rowText.indexOf(String.fromCharCode(160))>=0){rowTextArray=rowText.split(String.fromCharCode(160));}else rowTextArray=rowText.split(" ");
							        for (y=0; y<rowTextArray.length; y++){if ((rowTextArray[y].length==0)||(rowTextArray[y]==" "))rowTextArray.shift();}
							    }
						        for (y=0; y<rowInputCtrl.length; y++){
							        if (rowInputCtrl.item(y).checked){
								        if (rowInputCtrl.item(y).type=="radio"){value=rowTextArray[y];y=inputField.length;}
								        else if (rowInputCtrl.item(y).checked){
								            if (rowTextArray[y]){if (rowTextArray[y].length==0)value=value+"yes "; else value=value+rowTextArray[y]+" ";}
								            else{value=value+"yes ";}
								        }
							        }
						        }
					        }else if(inputField.item(0).id.substring(0,8)=="userFile"){
						        if (isIE)value=inputField.item(0).innerText;else value=inputField.item(0).textContent;
						        if (value=="click to upload file")value=""
					        }else if(inputField.item(0).type.substring(0,6)=="select"){
				                count=inputField.item(0).selectedIndex;
			                    if (isIE){value=inputField.item(0).children.item(count).innerText;}
			                    else {value = inputField.item(0).childNodes[count].textContent;}
					        }
					    }
					    if (isIE){key=userForm.rows.item(x).cells.item(0).innerText;}
					    else{key=userForm.rows.item(x).cells.item(0).textContent;}
					    value=value.replace(/[&#~|]/g," ");
					    key=key.replace(/[&#~|]/g," ");
					    formData = formData + key + "~" + value + "|";
				    }
			    }
			}
		}
    }
	waitChange('.?p=IT&action=4&formData='+formData);
}
function PositionMenu()
{
	var vertMenu,horiMenu,horiMenu2,newsMenu,calendarBox;
	var searchBox, emailIcon, printIcon, registryIcon, creditcardIcon
	if (window.document.body.clientWidth<templateWidth)return true;
	vertMenu = document.getElementById('VERTMENU');
	searchBox = document.getElementById('SEARCHBOX');
	horiMenu2 = document.getElementById('HORIMENU2');
	horiMenu = document.getElementById('HORIMENU');
	newsMenu = document.getElementById('NEWSMENU');
	calendarBox = document.getElementById('CALENDARMENU');
	emailIcon = document.getElementById('EMAILICON');
	printIcon = document.getElementById('PRINTICON');
	registryIcon = document.getElementById('REGISRTYICON');
	creditcardIcon = document.getElementById('CREDITCARDICON');
	flashBanner = document.getElementById('FLASHBANNER');
	trollyBox = document.getElementById('TROLLYBOX');

	if (vertMenu) vertMenu.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(vertMenuInsetPos))+"px";
	if (searchBox) searchBox.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(searchBoxInsetPos))+"px";
	if (horiMenu2) horiMenu2.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(horiMenuInsetPos))+"px";
	if (horiMenu) horiMenu.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(favMenuInsetPos))+"px";
	if (newsMenu) newsMenu.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(newsMenuInsetPos))+"px";
	if (calendarBox) calendarBox.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(calendarBoxInsetPos))+"px";
	if (emailIcon)emailIcon.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(emailIconInsetPos))+"px";
	if (printIcon)printIcon.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(printIconInsetPos))+"px";
	if (registryIcon)registryIcon.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(registryIconInsetPos))+"px";
	if (creditcardIcon)creditcardIcon.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(ccIconInsetPos))+"px";
	if (flashBanner)flashBanner.style.left=parseInt(parseInt((window.document.body.clientWidth-templateWidth)/2)+parseInt(flashBannerInsetPos))+"px";
	if (trollyBox) trollyBox.style.left = parseInt(parseInt((window.document.body.clientWidth - templateWidth) / 2) + parseInt(trollyBoxInsetPos)) + "px";
}
function nsEditCheck(editPage)
{
    var height=400;
	if (!document.designMode) {
		alert("Your browser does not support editing.\r\nPlease use Internet Explorer version 5 and above,\r\nor Netscape version 7.1");
		return false;
	}else {
	    if (navigator.appName == 'Netscape') {height=document.body.offsetHeight;}
	    else{height=document.body.scrollHeight-25;}
	    waitChange(editPage+"&eh="+height)
	}
}
function lostPassword()
{
	onloadFocus();
	modalContext="lostPassword";
	winModalWindow = window.open ("input.asp?text=Enter you email address?&size=20&max=50&type=alpha","INPUT","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,dependent=yes,width=350,height=120");
}
function inputCallBack(text){
	switch (modalContext){
	case "lostPassword":
		if (text!="") {waitChange('.?p=IT&action=6&return='+text);}
		break;
	}
}
function changeCalendar(domain,page,param,mth,yr,dates)
{
	var calendar = document.getElementById('CALENDARMENU');
	if (calendar){
		if (mth==0){mth=12; yr=yr-1;}
		else if (mth==13){mth=1; yr=yr+1;}
		calendar.innerHTML=createCalendar(domain,page,param,mth,yr,dates);
	}
}
function createCalendar(domain,page,param,mth,yr,dates)
{
	month[0]=""
	month[1]="January"
	month[2]="February"
	month[3]="March"
	month[4]="April"
	month[5]="May"
	month[6]="June"
	month[7]="July"
	month[8]="August"
	month[9]="September"
	month[10]="October"
	month[11]="November"
	month[12]="December"

	var rowCount=0;
	var datesPageLink=new Array(32);
	var datesPageName=new Array(32);
	var parseDates;
	var parseADate;
	var parseLinks;
	var thisMonth;
	var calendarTable = "";
	var dateCount=1;
	var todaysDate = new Date();
	var todaysMonth = parseInt(mth);
	var todaysYear = parseInt(yr);
	var firstOfMonth = new Date(todaysYear,todaysMonth-1,1);
	var monthStartDay = firstOfMonth.getDay();
	if (monthStartDay == 0) monthStartDay=7;

	var lastDateOfMonth=31;
	switch (todaysMonth){
	case 9: case 4: case 6: case 11: lastDateOfMonth=30;break;
	case 2:lastDateOfMonth=28; if (todaysYear%4==0) {lastDateOfMonth=29;} break;
	}
	for (x=0; x<datesPageLink.length; x++){datesPageLink[x]="";datesPageName[x]="";}
	
	if ((dates)&&(dates!='undefined')){
		parseDates=dates.split("|");
		if(todaysMonth>=10) thisMonth=new RegExp("/"+todaysMonth+"/"+todaysYear);
		else  thisMonth=new RegExp("/0"+todaysMonth+"/"+todaysYear);
		for (x=0; x<parseDates.length; x++){
			if (parseDates[x].search(thisMonth)>=0) {
				parseADate=parseDates[x].split("/");
				parseLinks=parseDates[x].split("~");
				datesPageLink[parseInt(parseADate[0])]=parseLinks[1];
				datesPageName[parseInt(parseADate[0])]=parseLinks[2];
			}
		}
	}
	calendarTable=calendarTable+"<table title=\"\" class=\"calendarFont\" style=\"width:120px;\" cellpadding=\"0\" cellspacing=\"0\">";
	if (dates){calendarTable=calendarTable+"<tr><td colspan=\"7\" style=\"text-align:center;\">"+todaysDate.getDate()+" "+month[todaysDate.getMonth()+1]+" "+todaysDate.getFullYear()+"</td></tr>";}
	else{calendarTable=calendarTable+"<tr><td colspan=\"7\" style=\"text-align:center;\">Select a date</td></tr>";}
	calendarTable=calendarTable+"<tr>";
	calendarTable=calendarTable+"<td style=\"width:15px;\">M</td>";
	calendarTable=calendarTable+"<td style=\"width:15px;\">T</td>";
	calendarTable=calendarTable+"<td style=\"width:15px;\">W</td>";
	calendarTable=calendarTable+"<td style=\"width:15px;\">T</td>";
	calendarTable=calendarTable+"<td style=\"width:15px;\">F</td>";
	calendarTable=calendarTable+"<td style=\"width:15px;\">S</td>";
	calendarTable=calendarTable+"<td style=\"width:15px;\">S</td>";
	calendarTable=calendarTable+"</tr><tr>";
	for (x=0; x<lastDateOfMonth+monthStartDay; x++){
		if (x >= monthStartDay){
			if ((dates)&&(dates!='undefined')){
				if (datesPageLink[dateCount].length>0) {calendarTable=calendarTable+"<td id=\"TDCAL"+x+"\" class=\"calendarFontLink\" style=\"width:15px;cursor:pointer;\" onclick=\"waitChange('.?p="+datesPageLink[dateCount]+"');\" title=\""+datesPageName[dateCount]+"\">"+dateCount+"</td>";}
				else {calendarTable=calendarTable+"<td class=\"calendarFont\" style=\"width:15px;\" title\"\">"+dateCount+"</td>";}
			}else{calendarTable=calendarTable+"<td id=\"TDCAL"+x+"\" class=\"calendarFont\" style=\"width:15px;cursor:pointer;\" onmouseover=\"document.getElementById('TDCAL"+x+"').className='calendarFontLink';\" onmouseout=\"document.getElementById('TDCAL"+x+"').className='calendarFont';\" onclick=\"CalendarSetDate('"+domain+"','"+page+"','"+param+"','"+todaysMonth+"','"+dateCount+"','"+todaysYear+"');\" title=\"\">"+dateCount+"</td>";}
			dateCount=dateCount+1;
		}else{calendarTable=calendarTable+"<td></td>";}
		if (x%7==0){calendarTable=calendarTable+"</tr><tr>";rowCount++;}
	}
	if ((rowCount==5)||(x%7==1)){calendarTable=calendarTable+"<tr><td class=\"calendarFont\" style=\"border:0;\" colspan=\"7\">&nbsp;</td></tr>";}
	calendarTable=calendarTable+"<tr><td style=\"text-align:center;\" colspan=\"7\">";
	calendarTable=calendarTable+"<u style=\"cursor:pointer\" title=\"click to go back a month\" onclick=\"changeCalendar('"+domain+"','"+page+"','"+param+"',"+(todaysMonth-1)+","+yr+",'"+dates+"');\"><<<</u>&nbsp;&nbsp;";
	calendarTable=calendarTable+month[todaysMonth].substring(0,3)+".&nbsp;"+String(todaysYear)+"&nbsp;&nbsp;";
	calendarTable=calendarTable+"<u style=\"cursor:pointer\" title=\"click to go forward a month\" onclick=\"changeCalendar('"+domain+"','"+page+"','"+param+"',"+(todaysMonth+1)+","+yr+",'"+dates+"');\">>>></u>";
	calendarTable=calendarTable+"</td><tr></table>";
	return calendarTable;
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++){ 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) IsNumber = false;
   }
   return IsNumber;
}
function convertColour(clr,format)
{
    if (clr.length==0) return "";
    switch (format){
    case "hex":
        var char = "0123456789ABCDEF"; 
        return String(char.charAt(Math.floor(clr / 16))) + String(char.charAt(clr - (Math.floor(clr / 16) * 16))); 
    case "rgb":
        var clr = (clr.charAt(0)=="#") ? clr.substring(1,7):clr;
        return parseInt(clr.substring(0,2),16)+','+parseInt(clr.substring(2,4),16)+','+parseInt(clr.substring(4,6),16);
    default: return "";
    }
    return "";
}
function getConsumerGroup(Domain)
{
    var consumerGroupControl = document.getElementById('ConsumerGroupControl');
    if (consumerGroupControl){sendAJAX("Ajax.asp?target=TX&method=GetConsumerDeliveryDetails&id="+consumerGroupControl.item(consumerGroupControl.selectedIndex).value,"getConsumerGroup","");}
}
function getConsumerGroupCallBack(result)
{
    var deliveryInstruction = document.getElementById('DeliveryInstruction');
    if (deliveryInstruction){deliveryInstruction.innerText=result;}
}
function setTransactionDelivery()
{
    var deliveryDetails = document.getElementById('SelectDeliveryDetails');
    var DeliveryAddress = document.getElementById('TRdeliveryAddress');
    var DeliveryInstructions = document.getElementById('TRdeliveryInstructions');
    if (deliveryDetails){
		switch (deliveryDetails.selectedIndex){
		case 0: 
            if (DeliveryAddress){DeliveryAddress.style.display='none';}
            if (DeliveryInstructions){DeliveryInstructions.style.display='none';}
		    break;
		case 1:
            if (DeliveryAddress){DeliveryAddress.style.display='none';}
            if (DeliveryInstructions){DeliveryInstructions.style.display='block';}
		    break;
		case 2:
            if (DeliveryAddress){DeliveryAddress.style.display='block';}
            if (DeliveryInstructions){DeliveryInstructions.style.display='none';}
		    break;
        }
    }
}
function createViewer()
{
    var viewerXML = document.getElementById('viewerXML');
    if (viewerXML){
        var fo = new SWFObject("viewer.swf", "viewer", "100%", "100%", "8", "transparent");
        fo.addParam("wmode", "transparent");
        fo.addVariable("xmlDataPath", viewerXML.value);
        fo.addVariable("firstImageIndex", "0");
        fo.addVariable("preloaderColor", "transparent");
        fo.write("flashcontent");
    }
}
function sendToAFriend()
{
	onloadFocus();
    winModalWindow = window.open("friend.asp","FRIEND","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,dependent=yes,width=350,height=200");
}
function addToBookings(party, id, index, sid, comment)
{
    var orderNumber = getCookie('on');
    var allotment = document.getElementById('allotment' + index);
    if (!allotment) return;
    if (allotment.value == "") { alert('Please enter a value!'); return; }
    sendAJAX('Ajax.asp?target=PG&method=AddToBookings&party=' + party + '&id=' + id + '&qty=' + allotment.value + '&on=' + orderNumber + '&sid=' + sid + '&comment=' + comment, 'callbackAddToBookings', '');
    allotment.value = "";
}
function callbackAddToBookings(msg)
{
    var orderNumber = getCookie('on');
    var trollyBox = msg.split("~");
    if (orderNumber != trollyBox[0]) { document.cookie = "on=" + trollyBox[0];}
    setTrollyBoxList(trollyBox[1]);
    setTrollyBoxDisplay('TROLLYBOXCOUNT', trollyBox[2]);
    setTrollyBoxDisplay('TROLLYBOXTOTAL', trollyBox[3]);
}
function setTrollyBoxDisplay(id, text)
{
    var trollyBoxDisplay = document.getElementById(id);
    if (!trollyBoxDisplay) return;
    var oldText = trollyBoxDisplay.firstChild;
    if (oldText) trollyBoxDisplay.removeChild(oldText);
    var newText = document.createTextNode(text);
    trollyBoxDisplay.appendChild(newText);
}
function setTrollyBoxList(newItemName)
{
    var trollyBoxList = document.getElementById('TROLLYBOXLIST');
    if (!trollyBoxList) return;
    var firstItem = trollyBoxList.firstChild;
    if (!firstItem) return;
    var firstItemValue = firstItem.getAttribute('value');
    if (!firstItemValue) trollyBoxList.removeChild(firstItem);
    var newOption = document.createElement('option');
    var newItem = document.createTextNode(newItemName);
    newOption.appendChild(newItem);
    newOption.setAttribute('value', newItemName);
    trollyBoxList.appendChild(newOption);
}
function getCookie(c_name)
{
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}