/*
	Copyright David Trewern Design         :: www.dtdesign.com ::
	Unauthorised modification / use is a criminal offence, and
	will be prosecuted to the fullest extent permitted by law.
	All Rights Reserved
*/

NAVarr = new Array("home", "restaurant", "menu", "dining", "bistro", "cafe", "shop", "bookings", "contactus", "smalldining", "smallshop", "smallbookings");
if (document.images) {
	for (var NAVitem in NAVarr) { 
		 for (var NAVicount=0; NAVicount < 2; NAVicount++) { 
				eval("b" + NAVarr[NAVitem] + NAVicount + " = new Image()");
				eval("b" + NAVarr[NAVitem] + NAVicount + ".src = 'assets/swap_" + NAVarr[NAVitem] + "_" + NAVicount + ".gif'");
		 } 
	} 
}

function BturnOn(imageName) {
	if (document.images) {
		var imageNumber = "";
		if (arguments.length > 1) imageNumber = arguments[1];
		document [imageName + imageNumber].src = eval("b" + imageName + "1.src");
	}
}

function BturnOff(imageName) {
	if (document.images) {
		var imageNumber = "";
		if (arguments.length > 1) imageNumber = arguments[1];
		document [imageName + imageNumber].src = eval("b" + imageName + "0.src");
	}
}

function imgPopup(path) {
	if (path) {
		window.open("utils_imagepopup.aspx?path=" + path, "popup", "width=400, height=300, toolbar=no, status=no, scrollbars=yes, resizable=yes");
	}
}

function ddRedirect(dd) {
	if (dd.options[dd.selectedIndex].value != "") self.location = dd.options[dd.selectedIndex].value;
}

function resizeWindow(layoutAdjustmentW, layoutAdjustmentH) {
	if ((document.images) && (document.theimage) && (document.theimage.width)) {

		var imageW = document.theimage.width;
		var imageH = document.theimage.height;

		var screenW = screen.availWidth;
		var screenH = screen.availHeight;

		var resizeToScreen = false;

		if (imageW <= screenW) {
			resizeW = imageW;
		}
		else {
			resizeW = screenW;
			resizeToScreen = true;
		}

		if (imageH <= screenH) {
			resizeH = imageH;
		}
		else {
			resizeH = screenH;
			resizeToScreen = true;
		}

		var userAgent = navigator.userAgent;

		//Windows Adjustments
		if (userAgent.indexOf("Windows") != -1) {
			if (userAgent.indexOf("MSIE 5") != -1) {
				resizeW += 29;
				resizeH += 38;

				if (resizeToScreen) {
					resizeW -= 29;
				}
			}
			if (userAgent.indexOf("MSIE 6") != -1) {
				resizeW += 31;
				resizeH += 61;
			}
			if (userAgent.indexOf("Firefox") != -1) {
				resizeW += 8;
				resizeH += 56;

				if (resizeToScreen) {
					resizeW -= 8;
				}
			}
			if (userAgent.indexOf("Netscape/7") != -1) {
				resizeW += 8;
				resizeH += 36;

				if (resizeToScreen) {
					resizeW -= 8;
				}
			}
		}

		//Mac Adjustments
		if (userAgent.indexOf("Mac") != -1) {
			if (userAgent.indexOf("Safari") != -1) {
				resizeW += 0;
				resizeH += 23;
			}
			if (userAgent.indexOf("MSIE 5") != -1) {
				resizeW += 0;
				resizeH += 0;
			}
			if (userAgent.indexOf("Firefox") != -1) {
				resizeW += 0;
				resizeH += 18;
			}
			if (userAgent.indexOf("Netscape/7") != -1) {
				resizeW += 0;
				resizeH += 2;
			}
		}

		if (!isNaN(layoutAdjustmentW)) {
			resizeW += layoutAdjustmentW;
		}
		if (!isNaN(layoutAdjustmentH)) {
			resizeH += layoutAdjustmentH;
		}

		if (resizeToScreen) {
			window.moveTo(0,0);
		}
		window.resizeTo(resizeW, resizeH);

	}
}


function printPage() {

	if(window.print) {
		window.print();
	} else {
		if(agt.indexOf("mac") != -1) {
			alert("To print this page press Command-P.");
		} else {
			alert("To print this page press Control-P.");
		}
	}
   
}

function pickRandom(range) {
	if (Math.random) {
		return Math.round(Math.random() * (range-1)) + 1;
	} else {
		var now = new Date();

		return (now.getTime() / 1000) % range;
	}
}

function menuPopupWithProductID(path, productID) {
	if (path) {
		
		path = "utils_menupopup.aspx?path=" + path;	
	
		
		if(productID) path += "&productID=" + productID;
		
		window.open(path, "popup", "width=400, height=300, toolbar=yes, status=yes, scrollbars=yes, resizable=yes");
		
	}
}

