var L1VertSpan=null;
var L2VertSpan=null;
var L1HoriSpan = null;
var L2HoriSpan = 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 modalContext;
var AdminMenu;
var RegistryMenu;
var LogonMenu;
var popupMenu;
var popupMenuExtra;
var popupMenuOptions;
var popupMenuReports;
var pageID = "";
var pageType = "";
var pid=2;
var ped='';
var pact='';
var sslURL='';
var agentDomain="";
var masterDomain = "";
var agentID = 0;
var sid = '';
var NShomeURL = "";
var month = new Array(13);

var xmlHttp = null;
var alertText = "";
var resume = "";
var resumeParams = "";

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 loginBoxInsetPos = 0;
var breadcrumbInsetPos = 0;
var dropdownInsetPos = 0;
var templateWidth = 0;
var templatePageTop = 0;
var allotmentFailed = false;

function notIE() {
    if ((navigator.appName == 'Netscape') || (navigator.appName == 'Opera')) { return true; }
    else return false;
}
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);
        }
        if (pid == 1) {
            if (e.ctrlKey) {
                e.stopPropagation();
                e.preventDefault();
                ShortCuts(e.which, NShomeURL, pageType);
            }
        }
	}    
}
function CtrlAltEnter(sslURL,sid,homeURL,page){
    if (window.event) {
        if (window.event.ctrlKey && (window.event.keyCode == 13)) { waitChange('https://' + sslURL + '.?p=IN&target=1&sid=' + sid); return false; }
        if (pid == 1) { if (window.event.ctrlKey) { return ShortCuts(window.event.keyCode, homeURL, page); } }
		return true;
	}
	return false;
}
function ShortCuts(key, homeURL, page) {
    if (key == 69) {
        if ((page == "IN") || (page == "SH") || (page == "CR") || (page == "PG") || (page == "PT")) {nsEditCheck(homeURL + '.?p=' + page + '&action=UP&target=&edit=true');} return false;
    }
    else if (key == 78) { 
        if ((page == "IN") || (page == "SH") || (page == "CR") || (page == "PG")) {waitChange(homeURL + '.?p=' + page + '&action=IN');} return false;
    }

    else if (key == 65) { showOptionsFrame(homeURL + 'PY.asp', '550'); return false; }
    else if (key == 77) { showOptionsFrame(homeURL + 'EM.asp', '520'); return false; }
    else if (key == 79) { waitChange(homeURL + '.?p=PL'); return false; }
    else if (key == 83) { waitChange(homeURL + '.?p=SH'); return false; }
    else return true;
}
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 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 (popupMenuReports) popupMenuReports.style.display = "none";
        if (e) {
            if ((e.target.id) && (e.target.className) && (agentID == pid)) {
                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); }
                    if (e.target.id.indexOf("TOPH") >= 0) { moveAdminMenu('TOPPAGEMENU', window.innerWidth, window.innerHeight, e.clientX, e.clientY); }
                }
            } else if (e.target.id.indexOf("IMG") >= 0) {
                pageID = e.target.id.replace("IMG", "");
                moveAdminMenu('PAGEMENU', window.innerWidth, window.innerHeight, e.clientX, e.clientY);
            } else {
                moveAdminMenu('ADMINMENU', window.innerWidth, window.innerHeight, e.clientX, e.clientY);
            }
		}
		else if (window.event) {
		    if ((window.event.srcElement.id) && (window.event.srcElement.className) && (agentID == pid)) {
		        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); }
		            if (window.event.srcElement.id.indexOf("TOPH") >= 0) { moveAdminMenu('TOPPAGEMENU', window.document.documentElement.clientWidth, window.document.documentElement.clientHeight, window.event.clientX, window.event.clientY); }
		        }
		    } else if (window.event.srcElement.id.indexOf("IMG") >= 0) {
                pageID = window.event.srcElement.id.replace("IMG", "");
                moveAdminMenu('PAGEMENU', window.document.documentElement.clientWidth, window.document.documentElement.clientHeight, window.event.clientX, window.event.clientY); 
            } else {
                moveAdminMenu('ADMINMENU', window.document.documentElement.clientWidth, window.document.documentElement.clientHeight, window.event.clientX, window.event.clientY);
	        }
		}
	}
	return false;
}
function hideAll()
{
	if (L3Div) L3Div.style.display="none";
	if (L2Div) {
        if (ignoreMouseOut==false){
            if (L1VertSpan) {
                if ((L1VertSpan.className == "LeftMenuFont") || (L1VertSpan.className == "LeftMenuOverFont")) {
                    if (ignoreMouseOut) { L1VertSpan.className = "LeftMenuOverFont"; } else { L1VertSpan.className = "LeftMenuFont"; }
                }
            }
            if (L1HoriSpan) {
                if ((L1HoriSpan.className == "HoriMenuFont") || (L1HoriSpan.className == "HoriMenuOverFont")) {
                    if (ignoreMouseOut) { L1HoriSpan.className = "HoriMenuOverFont"; } else { L1HoriSpan.className = "HoriMenuFont"; }
                }
            }
        }	    
	    L2Div.style.display="none";
	}
	L3Div=null;
	L2Div=null;
    L1VertSpan = null;
    L2VertSpan = null;
    L1HoriSpan = null;
    L2HoriSpan = null;
}
function getLeftMenuPadding() {
    var stylesheetRule = null;
    if (document.styleSheets[0].cssRules) { stylesheetRule = document.styleSheets[0].cssRules; }
    else { stylesheetRule = document.styleSheets[0].rules; }
    if (!stylesheetRule) return 0;
    for (i = 0; i < stylesheetRule.length; i++) {
        if (stylesheetRule[i].selectorText == ".LeftMenuFont") {
            return parseInt(stylesheetRule[i].style.paddingLeft.replace('px', '')) + parseInt(stylesheetRule[i].style.paddingRight.replace('px', ''));
        }
    }
}
function showLevel1(Div,Span)
{
	var newDiv = document.getElementById(Div);
	var newSpan = document.getElementById(Span);
	if (newSpan){
	    if (L1VertSpan) { if (ignoreMouseOut) { L1VertSpan.className = "LeftMenuOverFont"; } else { L1VertSpan.className = "LeftMenuFont"; } }
	    L1VertSpan = newSpan;
        if (newSpan.className=="LeftMenuOverFont") {ignoreMouseOut=true;}
	    else {newSpan.className = "LeftMenuOverFont"; ignoreMouseOut=false;}
	    L1VertSpan.className = "LeftMenuOverFont";
	    document.cookie = "solidID=" + L1VertSpan.id;
	}
	if (newDiv) {
	    if (L2Div) { if (newDiv != L2Div && (L2Div)) L2Div.style.display = "none"; }
		L2Div = newDiv;
		newDiv.style.display="inline-block";
		newDiv.style.left = parseInt(newSpan.offsetWidth - getLeftMenuPadding()) + "px";
		newDiv.style.top=(newSpan.offsetTop)+"px";
    } else {
        if (L2Div) { L2Div.style.display = "none"; }
    }
}
function showLevel2(Div,Span)
{
	var newDiv = document.getElementById(Div);
	var newSpan = document.getElementById(Span);
	if (newSpan){
		L1VertSpan = newSpan;
		L1VertSpan.className = "LeftMenuOverFont";
		if (!newDiv && (L3Div)) {L3Div.style.display="none";L3Div=null;}
		document.cookie = "solidID=" + L1VertSpan.id;
    }
	if (newDiv) {
	    if (L3Div) { if (newDiv != L3Div) { L3Div.style.display = "none"; } }
		L3Div = newDiv;
		newDiv.style.display = "inline-block";
		newDiv.style.left = parseInt(newSpan.offsetWidth - getLeftMenuPadding()) + "px";
		newDiv.style.top=(newSpan.offsetTop)+"px";
	}
	if (L1VertSpan) L1VertSpan.className = "LeftMenuOverFont";
}
function showLevel3(Span) {
    var newSpan = document.getElementById(Span);
    if (newSpan) {
        newSpan.className = "LeftMenuOverFont";
        document.cookie = "solidID=" + newSpan.id;
    }
}
function showLevel1Hori(Div,Span,index)
{
    var newDiv = document.getElementById(Div);
	var newSpan = document.getElementById(Span);
	if (newSpan) {
	    if (L1HoriSpan) {
	        if ((L1HoriSpan.className == "HoriMenuFont") || (L1HoriSpan.className == "HoriMenuOverFont")) {
	            if (ignoreMouseOut) { L1HoriSpan.className = "HoriMenuOverFont"; } else { L1HoriSpan.className = "HoriMenuFont"; }
	        }
	    }
	    L1HoriSpan = newSpan;
        if (newSpan.className=="HoriMenuOverFont") {ignoreMouseOut=true;}
	    else {newSpan.className = "HoriMenuOverFont"; ignoreMouseOut=false;}
		L1HoriSpan.className = "HoriMenuOverFont";
		document.cookie = "solidID=" + L1HoriSpan.id;
    }
	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.style.display = "none"; } }
        L2Div = newDiv;
        newDiv.style.display = "block";
        newDiv.style.width = newSpan.offsetWidth + "px";
        newDiv.style.left = offsetWidth + "px";
        newDiv.style.top = parseInt(newSpan.offsetHeight) + "px";
    } else {
        if (L2Div) { L2Div.style.display = "none"; }
    }
}
function showLevel2Hori(Div,Span)
{
    var newDiv = document.getElementById(Div);
	var newSpan = document.getElementById(Span);
	if (newSpan){
	    L1HoriSpan = newSpan;
	    if (L1HoriSpan.className == "HoriMenuOverFont") { ignoreMouseOut = true; }
	    else { L1HoriSpan.className = "HoriMenuOverFont"; ignoreMouseOut = false; }
	    L1HoriSpan.className = "HoriMenu2OverFont";
		if (!newDiv && (L3Div)) {L3Div.style.display="none";L3Div=null;}
		document.cookie = "solidID=" + L1HoriSpan.id;
    }
	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 (L1HoriSpan) L1HoriSpan.className = "HoriMenuOverFont";
}
function showLevel3Hori(Span) {
    var newSpan = document.getElementById(Span);
    if (newSpan) {
        newSpan.className = "HoriMenu2OverFont";
        document.cookie = "solidID=" + newSpan.id;
    }
}
function buttonMouseOver(Span, ClassFont)
{
	hideAll();
	var newSpan = document.getElementById(Span);
	if (newSpan) {
	    if (newSpan.className == ClassFont) { ignoreMouseOut = true; }
	    else { newSpan.className = ClassFont; ignoreMouseOut = false; }
	    document.cookie = "solidID=" + newSpan.id;
	}
}
function buttonMouseOut(Span,ClassFont)
{
	var newSpan = document.getElementById(Span);
	if (newSpan) {
	    if (!ignoreMouseOut) { newSpan.className = ClassFont; }
	    document.cookie = "solidID=";
    }
}
function objectMouseOver(obj, ClassFont) {
    if (obj) {
        switch (ClassFont) {
            case "LeftMenuFont": obj.className = "LeftMenuOverFont"; break;
            case "HoriMenuFont": obj.className = "HoriMenuOverFont"; break;
            case "FavMenuFont": obj.className = "FavMenuOverFont"; break;
        }
    }
}
function objectMouseOut(obj, ClassFont) {
    if (obj) {
        switch (ClassFont) {
            case "LeftMenuFont": 
            case "HoriMenuFont": 
            case "FavMenuFont": obj.className = ClassFont; break;
        }
    }
}
function pageLinkOver(id) {
    document.cookie = "solidID=" + id;
}
function pageLinkOut() {
    document.cookie = "solidID=";
}
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 (allotmentFailed) {allotmentFailed = false;return false; }
	if (processing) return false;
	processing=true;
	document.body.style.cursor='wait';
	return true;
}
function checkAllotment(obj, label) 
{
    if (obj) {
        if ((obj.value == "") || (obj.value == "0") || (!IsNumeric(obj.value))) {
            alert(label + ' must be a number greater than zero');
            obj.value = "";
            allotmentFailed = 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('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('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';

	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 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 + "\',\'LeftMenuOverFont\');\" ";
		menu = menu + "onmouseout=\"buttonMouseOut(\'" + name + "\',\'LeftMenuFont\');\">" + menuText + "</a>";
	}
	return menu;
}
function setMenu(features, partyID, pageCode, agentURL, homeURL, secureURL, fileURL, secureID, siteType, logonOption, editor, action, vertMenuInset, searchBoxInset, horiMenuInset, favMenuInset, newsMenuInset, calendarBoxInset, emailIconInset, printIconInset, registryIconInset, ccIconInset, flashBannerInset, logoHotspotInset, trollyBoxInset, loginBoxInset, breadcrumbInset, dropdownInset, pageTop, template, templateHeight, navBar, reloadMenu, barFavMenu, barHoriMenu, barMenu, vmenuID, hmenuID, fmenuID, groupMember, Logon, Registry,showAdminMenu)
{
	var menuText, horiMenu, horiMenu2, vertMenu, newsMenu, calendarBox, AdminMenu,editorMenu,forcedLogon;
	var searchBox, emailIcon, printIcon, registryIcon, creditcardIcon;
	var flashBanner, logoHotspot, trollyBox, loginBox,breadcrumb,dropdown;
	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="";

	LogonMenu = Logon;
	RegistryMenu = Registry;

	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;
	loginBoxInsetPos = loginBoxInset;
	breadcrumbInsetPos = breadcrumbInset;
	dropdownInsetPos = dropdownInset;
	templateWidth = template;
	templatePageTop = pageTop;

    agentDomain="http://"+agentURL+"/"
    masterDomain=homeURL;
    pid = partyID;
    pageType = pageCode;
	ped=editor;
	pact=action;
	if ((pid==1)&&(ped=="")&&(pact==0)){pact=""}
	menuText="";
	AdminMenu="";
	forcedLogon = false;
	agentID = groupMember;
	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 ((partyID == 1) && (showAdminMenu == "true")) {
	    var windowWidth = 800;
	    var windowHeight = 600;
	    if (window.event) { windowWidth = window.document.documentElement.clientWidth; windowHeight = window.document.documentElement.clientHeight; }
	    else { windowWidth=window.innerWidth;windowHeight=window.innerHeight;}
	    moveAdminMenu('ADMINMENU', windowWidth, windowHeight, 100, 150); 
	}

	if (notIE()) {
	    sslURL = secureURL;
	    sid = secureID;
	    NShomeURL = homeURL;
	    window.onkeydown = NSKeyPress;
	    window.onresize = PositionMenu;
	    if (partyID == 1) {window.onclick = windowOnclick;}
	}
	try {document.execCommand("BackgroundImageCache", false, true);} catch (err) { }

	window.document.oncontextmenu=rightMouseClick;

	horiMenu = document.getElementById('HORIMENU');
	horiMenu2 = document.getElementById('HORIMENU2');
	vertMenu = document.getElementById('VERTMENU');
	if (vertMenu){
	    if ((features&8) && (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');
	loginBox = document.getElementById('LOGINBOX');
	breadcrumb = document.getElementById('BREADCRUMBTRAIL');
	dropdown = document.getElementById('DROPMENU');
	
	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";
    	if (loginBox) loginBox.style.left = parseInt(parseInt((window.document.body.clientWidth - templateWidth) / 2) + parseInt(loginBoxInsetPos)) + "px";
    	if (breadcrumb) breadcrumb.style.left = parseInt(parseInt((window.document.body.clientWidth - templateWidth) / 2) + parseInt(breadcrumbInsetPos)) + "px";
    	if (dropdown) dropdown.style.left = parseInt(parseInt((window.document.body.clientWidth - templateWidth) / 2) + parseInt(dropdownInsetPos)) + "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 (loginBox) loginBox.style.left = parseInt(loginBoxInsetPos) + "px";
    	if (breadcrumb) breadcrumb.style.left = parseInt(breadcrumbInsetPos) + "px";
    	if (dropdown) dropdown.style.left = parseInt(dropdownInsetPos) + "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';
	if (loginBox) loginBox.style.display = 'block';
	if (breadcrumb) breadcrumb.style.display = 'block';
	if (dropdown) dropdown.style.display = 'block';

    fillMargin=0;
    if (notIE()) {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 = parseInt(parseInt((window.document.body.clientWidth) / 2) - 410) + "px";
	    if (notIE()) {editorMenu.style.top = parseInt(parseInt(window.innerHeight) - 95) + "px"; }
	    else { editorMenu.style.top = parseInt(parseInt(document.documentElement.clientHeight) - 95) + "px"; }
	    editorMenu.style.display = "block";
	}
    if (vmenuID!=''){
        var highlightVMenu = document.getElementById(vmenuID);
        if (highlightVMenu) highlightVMenu.className = "LeftMenuOverFont";
    }
    if (hmenuID!=''){
        var highlightHMenu = document.getElementById(hmenuID);
        if (highlightHMenu) highlightHMenu.className = "HoriMenuOverFont";
    }
    if (fmenuID != '') {
        var highlightFMenu = document.getElementById(fmenuID);
        if (highlightFMenu) highlightFMenu.className = "FavMenuOverFont";
    }
    var afLogin = getCookie('af_login');
    if ((afLogin.length > 0) && (partyID == 2)) {
        var parseLogin = afLogin.split("~");
        sendAJAX('Ajax.asp?target=PY&method=LogonBox&name=' + parseLogin[0] + '&password=' + parseLogin[1] + '&sid=' + secureID, 'reload', '');
    }
    document.cookie = "solidID=";
}
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 callback = "";
	var groupName = "";
	var userForm = document.getElementById('UserForm');
	var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);

	if (userForm) {
		len=userForm.rows.length;
		for (x=0; x<len; 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)) {
				            if (inputField.item(0).type == "button") {
				                callback = escape(inputField.item(0).name);
				                groupName = escape(inputField.item(0).lang);
				            }  else if (inputField.item(0).type == "text") {
				                value = inputField.item(0).value;
				                if ((inputField.item(0).alt == "mandatory") && (value.length == 0)) { alert('Please fill in mandatory 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;
				                if ((inputField.item(0).title == "mandatory") && (value.length == 0)) { alert('Please fill in mandatory fields'); inputField.item(0).focus(); return false; }
				            } 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");
				                }
				                rowTextArray = rowText.split(";");
				                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).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; }
				            }
				        } else if ((inputField.item(0))&&(inputField.item(1))) {
				            if ((inputField.item(0).tagName == "IMG") && (inputField.item(1).tagName == "SPAN")) {
				                if (inputField.item(1).id.substring(0, 8) == "userFile") {
			                            if (isIE) value = inputField.item(1).innerText; else value = inputField.item(1).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&callback=' + callback + '&groupName=' + groupName + '&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');
	loginBox = document.getElementById('LOGINBOX');
	breadcrumb = document.getElementById('BREADCRUMBTRAIL');
	dropdown = document.getElementById('DROPMENU');

	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";
	if (loginBox) loginBox.style.left = parseInt(parseInt((window.document.body.clientWidth - templateWidth) / 2) + parseInt(loginBoxInsetPos)) + "px";
	if (breadcrumb) breadcrumb.style.left = parseInt(parseInt((window.document.body.clientWidth - templateWidth) / 2) + parseInt(breadcrumbInsetPos)) + "px";
	if (dropdown) dropdown.style.left = parseInt(parseInt((window.document.body.clientWidth - templateWidth) / 2) + parseInt(dropdownInsetPos)) + "px";

	if ((pid == 1) && (ped == "true")) { scrollEditorMenu(); }
}
function nsEditCheck(editPage)
{
    var height=400;
	if (!document.designMode) {
		alert("Your browser does not support editing.");
		return false;
	}else {
	    if (notIE()) {height=document.body.offsetHeight;}
	    else{height=document.body.scrollHeight-25;}
	    waitChange(editPage+"&eh="+height)
	}
}
function lostPassword()
{
    var box = document.getElementById('FUNCTIONBOX');
    var frame = document.getElementById('FUNCTIONFRAME');
    showFunctionMenu(box, frame, "input.asp?text=Email Address:&box=text&type=alpha&title=Password", 200);
}
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 calendarFont = "calendarFontAdmin";
	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];
			}
        }
        calendarFont = "calendarFont";
    }
	calendarTable = calendarTable + "<table title=\"\" class=\"" + calendarFont + "\" style=\"width:120px;\" cellpadding=\"0\" cellspacing=\"0\">";
	if ((dates) && (dates != 'undefined')) { 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=\"" + calendarFont + "Link\" 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='" + calendarFont + "Link';\" 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 = 'table-row'; }
		    break;
		case 2:
		    if (DeliveryAddress) { DeliveryAddress.style.display = 'table-row'; }
            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 addToBookings(party, id, index, sid)
{
    var orderNumber = getCookie('on');

    var allotment = document.getElementById('allotment' + index);
    if (!allotment) return;
    if (allotment.value == "") { alert('Please enter a value!'); return; }

    var comment = "";
    var commentObj = document.getElementsByName('comment');
    if (commentObj) {
        for (x = 0; x < commentObj.length; x++) {
            if (commentObj[x]) {
                switch (commentObj[x].type) {
                    case "checkbox":
                    case "radio":
                        if (commentObj[x].checked) {
                            if (comment != '') { comment = comment + ', '; }
                            comment = comment + commentObj[x].value;
                        }
                        break;
                    case "text":
                        if (commentObj[x].value != '') {
                            if (comment != '') { comment = comment + ', '; }
                            comment = comment + commentObj[x].value; 
                        } 
                        break;
                    case "select-one":
                        if (comment != '') { comment = comment + ', '; }
                        comment = comment + commentObj[x].item(commentObj[x].selectedIndex).value; 
                        break;
                }
            }
        }
    }
    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 "";
}
function showFunctionMenu(box, frame, page, boxHeight) {
    var parentWindowHeight = 0;
    if ((box) && (frame)) {
        if (notIE()) {parentWindowHeight = parseInt(parent.innerHeight);
        } else {parentWindowHeight = parseInt(parent.document.documentElement.clientHeight);}
        box.style.top = parseInt(parentWindowHeight - boxHeight - 150) + "px";
        box.style.left = "0px";
        frame.style.height = boxHeight + "px";
        frame.src = page;
        box.style.display = 'block';
    }
}
function fileUploadFromForm(id) {
    var box = document.getElementById('FUNCTIONBOX');
    var frame = document.getElementById('FUNCTIONFRAME');
    showFunctionMenu(box, frame, "image.asp?type=F&id="+id, 200);
}
function showLoginBox(Title, Signup, SessionID, PartyID, LogoffPage) {
    if (PartyID == 2) {
        var box = document.getElementById('FUNCTIONBOX');
        var frame = document.getElementById('FUNCTIONFRAME');

        var parentWindowWidth = 0;
        var parentWindowHeight = 0;
        var scrollTopOffset = 0;
        if (notIE()) { parentWindowHeight = parseInt(parent.innerHeight); parentWindowWidth = parseInt(parent.innerWidth); scrollTopOffset = parseInt(parent.scrollY); }
        else { parentWindowHeight = parseInt(parent.document.documentElement.clientHeight); parentWindowWidth = parseInt(parent.document.documentElement.clientWidth); scrollTopOffset = parseInt(parent.document.documentElement.scrollTop); }
        box.style.top = parseInt(parentWindowHeight / 2 - 150 + scrollTopOffset) + "px";
        box.style.left = parseInt(parentWindowWidth / 2 - 300) + "px";

        showFunctionMenu(box, frame, "login.asp?title=" + Title + "&signup=" + Signup + '&sid=' + SessionID, 300);
    } else {
        document.cookie = "af_login=";
        resumeParams = masterDomain + 'default.asp?p=' + LogoffPage;
        sendAJAX('Ajax.asp?target=PY&method=LogoffBox&sid=' + SessionID, 'logon', '');
    }
}
function onChangDropDown() {
    var url = "";
    var option = "";
    var dropdown = document.getElementById('DROPDOWN');
    if (dropdown) {
        url = dropdown.item(dropdown.selectedIndex).value;
        option = dropdown.options[dropdown.selectedIndex].innerHTML;
        if ((url != '') && (option != '')) { window.location = url; }
    }
}
function AreYouSureSendAjax(msg, callPage, callBack, responseText) {
    if (confirm(msg) && (callPage != '')) sendAJAX(callPage, callBack, responseText);
}
function convertCurrency(from, amount) {
    var currencyid = document.getElementById('CURRENCYID');
    if (currencyid) {
        sendAJAX('Ajax.asp?target=BK&method=ConvertCurrency&from=' + from + '&to=' + currencyid.item(currencyid.selectedIndex).value + '&amount=' + amount, 'convertCurrencyCallback', '');
    }
}
function convertCurrencyCallback(amount) {
    var currencyvalue = document.getElementById('CURRENCYVALUE');
    if (currencyvalue) {
        amount = amount.replace("%80", "&euro;");
        currencyvalue.innerHTML = unescape(amount.replace(/\+/g, " "));
    }
}
function sendAJAX(callPage, callBack, responseText) {
    try { xmlHttp = new XMLHttpRequest(); }
    catch (e) {
        try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
    }

    if (xmlHttp) {
        alertText = responseText;
        resume = callBack;
        xmlHttp.onreadystatechange = ajaxResponse;
        xmlHttp.open("GET", callPage, true);
        xmlHttp.send(null);
        document.body.style.cursor = 'wait';
    }
}
function ajaxResponse() {
    if (xmlHttp.readyState == 4) {
        document.body.style.cursor = 'default';
        if (alertText != '') alert(alertText);
        switch (resume) {
            case "getConsumerGroup":
                getConsumerGroupCallBack(xmlHttp.responseText);
                break;
            case "callBackPageList":
                callBackPageList(xmlHttp.responseText);
                break;
            case "callBackTemplateImage":
                setTemplateImageCallback(xmlHttp.responseText, '');
                break;
            case "callBackScreenLayout":
                setScreenLayoutCallback();
                break;
            case "callbackAddToBookings":
                callbackAddToBookings(xmlHttp.responseText);
                break;
            case "galleryDialog":
                galleryDialog("gallery", xmlHttp.responseText);
                break;
            case "setGallery":
                setGallery();
                break;
            case "slideshowDialog":
                galleryDialog("slideshow", xmlHttp.responseText);
                break;
            case "slideshowArrow":
                galleryDialog("slideshow", document.getElementById("Identifier").value);
                break;
            case "setSlideshow":
                setSlideshow();
                break;
            case "reload":
                window.location = window.location.href;
                break;
            case "logon":
                if (resumeParams != '') { window.location = resumeParams; }
                else { window.location = "."; }
                break;
            case "convertCurrencyCallback":
                convertCurrencyCallback(xmlHttp.responseText);
            }
    }
}
function ajaxValue(val) {
    var re = /[(+?=&]/g;
    val = val.replace(re, function(m) { return replacechar(m) });
    return val;
}
function replacechar(match) {
    switch (match) {
        case "+": return "%2B";
        case "?": return "%3F";
        case "=": return "%3D";
        case "&": return "%26";
    }
}
