var fontsize = 13
var savedFontSize = 13;
//	alert(savedFontSize);

function setFontSize() {
	if (savedFontSize)
	{
		savedFontSize = Get_Cookie("FontSize");
		if (parseInt(savedFontSize)) fontsize = savedFontSize;
		el = document.getElementsByTagName("body");
		if (el)
		{
			try
			{
				el[0].style.fontSize = fontsize + "px";	
			}
			catch (ex)
			{
				;
			}
			
		}
	}
}

function changeFontSize(direction) {
	el = document.getElementsByTagName("body");
	if (direction == 0)
	{
		el[0].style.fontSize = "13px";
		fontsize = 13;
	} else {
		if (fontsize >= 17 && direction > 0) return true;
		if (fontsize <= 10 && direction < 0) return true;
		fontsize = parseInt(fontsize) + parseInt(direction); 
		el[0].style.fontSize = fontsize + "px";
	}
	direction = 1 - direction;
	Set_Cookie("FontSize", fontsize, 1);
}


function mover(img) {
		img.src = img.src.replace("menu_", "menu-over_");
		img.src = img.src.replace("footer_", "footer-over_");
}

function mout(img) {
		img.src = img.src.replace("-over", "");
}


function imover(img) {
		img.src = img.src.replace(".png", "-over.png");
}

function imout(img) {
		img.src = img.src.replace("-over", "");
}

function popup(type) {
//alert2('title-privacy.png', '');	
	url = "get_page.php?page=" + type;
//	wait();
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_popup;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";
}

function _popup() {
	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("msg_title");
		title = getXMLNode(ret);
		ret=response.getElementsByTagName("msg_txt");
		msg= getXMLNode(ret);
		alert2(title, msg);
	}
}

function alert2(title,msg) {
	txt = "<table cellpadding='0' cellspacing='0' border='0' style='background-color: #ffffff; border: 4px solid #ccc'>";
	txt += "<tr><td width='353' style='padding: 0px 40px; vertical-align: middle;'><img src='images/"+title+"'></td><td width='51' height='61' align='center' valign='middle'><img src='images/bt-close.png' onmouseover='imover(this)' onmouseout='imout(this)' style='cursor: pointer;' onclick='closeWait();'></td></tr>";
	txt += "<tr><td colspan='2'><div style='width: 465px; padding: 0px 40px; overflow: auto; height: 529px; margin-bottom: 40px; color: #48124a;'>"+msg+"</div></td></tr>";
	txt += "</table>";
	showOverlay();
	box(txt);
}

function alert3(title,msg) {
	txt = "<table cellpadding='0' cellspacing='0' border='0' style='background-color: #f3f3f3; border: 4px solid #ccc'>";
	txt += "<tr><td width='353' style='padding: 0px 40px; vertical-align: middle;'><img src='images/"+title+"'></td><td width='51' height='61' align='center' valign='middle'><img src='images/bt-close2.png' onmouseover='imover(this)' onmouseout='imout(this)' style='cursor: pointer;' onclick='closeWait();'></td></tr>";
	txt += "<tr><td colspan='2'><div style='width: 559px; padding: 20px 40px 20px 52px;  margin-bottom: 40px; color: #48124a;'>"+msg+"</div></td></tr>";
	txt += "</table>";
	showOverlay();
	box(txt);
}

function alert4(msg) {
	txt = "<table cellpadding='0' cellspacing='0' border='0' style='background-color: #f3f3f3; border: 4px solid #ccc'>";
	txt += "<tr><td style='padding: 0px 40px; vertical-align: middle;'></td><td width='51' height='61' align='center' valign='middle'><img src='images/bt-close2.png' onmouseover='imover(this)' onmouseout='imout(this)' style='cursor: pointer;' onclick='closeWait();'></td></tr>";
	txt += "<tr><td colspan='2'><div style=' padding: 20px 40px 60px; overflow: auto; margin-bottom: 40px; color: #48124a;'>"+msg+"</div></td></tr>";
	txt += "</table>";
	showOverlay();
	box(txt);
}

function alert5(msg) {
	txt = "<div style='position: relative;'>";
	txt += "<img src='images/bt-close2.png' onmouseover='imover(this)' onmouseout='imout(this)' style='cursor: pointer; position: absolute; right: 60px; top: 40px;' onclick='closeWait();'>";
	txt += "<div style=' padding: 20px 40px 60px; overflow: auto; margin-bottom: 40px; color: #48124a;'>"+msg+"</div>";
	txt += "</div>";
	showOverlay();
	box(txt);
}

var curProduct = 0;
function loadProduct(id) {
	curProduct = id;
	el = document.getElementById("name_" + id);
	el2 = document.getElementById("descr_" + id);
	el22 = document.getElementById("image_" + id);
	el3 = document.getElementById("productImage");
	el4 = document.getElementById("productDescr");
	el5 = document.getElementById("reviewBox");
	if (el22.innerHTML)  el5.style.display = "block";
	if (el22.innerHTML) el3.src = el22.innerHTML; else el3.src = "images/sample1.jpg";
	el3.onclick=showReviews;
	el3.style.cursor = "pointer";
	if (el2.innerHTML) 
		el4.innerHTML = '<a href="#self" onclick="showReviews();"><table cellpadding="0" cellspacing="0" style="cursor: pointer;" ><tr><td valign="top" style="background-image: url(images/productbox_bg.png); background-repeat: no-repeat; background-position: top right;"><div style="width: 160px"><span>'+el.innerHTML+'</span></div></td></tr><tr><td style="vertical-align: bottom; padding-bottom: 10px;">'+el2.innerHTML+'</td></tr></table></a>';
	else 
		el4.innerHTML = '<table cellpadding="0" cellspacing="0" style="cursor: pointer;" ><tr><td valign="top" ><span style="width: 160px">'+el.innerHTML+'</span></td></tr><tr><td style="vertical-align: bottom; padding-bottom: 10px;">'+el2.innerHTML+'</td></tr></table></a>';
}

var videos = [];
videos[1] = "http://www.youtube.com/v/n887p5APiro?fs=1&amp;hl=en_US";
videos[2] = "http://www.youtube.com/v/-5BzupT7mQQ?fs=1&amp;hl=en_US";
videos[3] = "http://www.youtube.com/v/kh2l-G4-tqY?fs=1&amp;hl=en_US";
videos[4] = "http://www.youtube.com/v/1KbrBcWuIQg?fs=1&amp;hl=en_US";
videos[5] = "http://www.youtube.com/v/NAoX7i_oUlU?fs=1&amp;hl=en_US";
function playVideo(videoID) {
		el = document.getElementById("videoContainer");
		el.innerHTML = '<object width="318" height="187"><param name="movie" value="'+videos[videoID]+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+videos[videoID]+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="318" height="187"></embed></object>';

}

function playVideo2(videoID, title, descr) {
		el = document.getElementById("videoContainer");
		videoID = "http://www.youtube.com/v/"+videoID+"?fs=1&amp;hl=en_US";
		el.innerHTML = '<object width="318" height="187"><param name="movie" value="'+videoID+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+videoID+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="318" height="187"></embed></object>';
	el4 = document.getElementById("productDescr");
	el4.innerHTML = '<table cellpadding="0" cellspacing="0" style="width: 155px; " ><tr><td valign="top"><span>'+title+' </span></td></tr><tr><td style="vertical-align: bottom; padding-bottom: 10px;">'+descr+'</td></tr></table>';

}

function showSignup() {
	txt ='';
	txt += '<span><b>Stay in touch with us</b></span>';
	txt += '			<div style="padding-top: 5px; width: 500px">Simply enter your email address to receive Mark’s Foodie Review. You’ll also be the first to hear about upcoming store events, new impossible-to-find product introductions, seasonal food trends and more.<br><br>';
	txt += '			<input type="text" size="35" name="signupEmail2" id="signupEmail2"> <img src="images/bt-signup-over.png" style="position: relative; top: 4px;" onclick="signup()">';
	txt += '			</div>';
	alert4(txt);
}

function signup() {
	el = document.getElementById("signupEmail");
	el2 = document.getElementById("signupEmail2");
	if (el.value)
	{
		val = el.value; 
	} else if (el2) val = el2.value;
	url = "register.php?what=newsletter&email=" + val;
//	wait();
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_signup;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";
}

function _signup() {
	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("msg_title");
		title = getXMLNode(ret);
		ret=response.getElementsByTagName("msg_txt");
		msg= getXMLNode(ret);
		alert3(title, msg);
	}
}

function sendtofriend() {
	el = document.getElementById("FriendEmail");
	url = "register.php?what=referral&email=" + el.value + "&page=" + encode(window.location.href);
//	wait();
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_sendtofriend;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";
}

function _sendtofriend() {
	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("msg_title");
		title = getXMLNode(ret);
		ret=response.getElementsByTagName("msg_txt");
		msg= getXMLNode(ret);
		alert3(title, msg);
	}
}


function showMap() {
	txt = "<img width='747' height='651' src='images/map.png'>";
	alert5(txt);
}

function showAddReview() {
	url = "reviews.php?what=get_review_form&id=" + curProduct + "&url=" + encode(window.location.href);
//	wait();
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showAddReview;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";
}

function _showAddReview() {
	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
//		ret=response.getElementsByTagName("msg_title");
//		title = getXMLNode(ret);
		ret=response.getElementsByTagName("msg_txt");
		msg= getXMLNode(ret);
		showOverlay();
		box(msg);
	}
}

function postReview(productid) {
	el1 = document.getElementById("FirstName");
	el2 = document.getElementById("LastName");
	el3 = document.getElementById("Email");
	el4 = document.getElementById("Comments");
	url = "reviews.php?what=post_review&id="+productid+"&fname=" + encode(el1.value) + "&lname=" + encode(el2.value) + "&email=" + encode(el3.value) + "&review=" + encode(el4.value);
//	wait();
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_postReview;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _postReview() {
	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
//		ret=response.getElementsByTagName("msg_title");
//		title = getXMLNode(ret);
		alert('Your review was saved. Thank you for your interest!');
	}
}

function showReviews() {
	url = "reviews.php?what=get_reviews&id=" + curProduct + "&url=" + encode(window.location.href);
//	wait();
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showReviews;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";
}

function _showReviews() {
	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
//		ret=response.getElementsByTagName("msg_title");
//		title = getXMLNode(ret);
		ret=response.getElementsByTagName("msg_txt");
		msg= getXMLNode(ret);
		showOverlay();
		box(msg);
	}
}

function sharePage(ev, lk, lab) {
	txt = "";
	msg = "<div class='message'><img src='images/bt-close2.png' onmouseover='imover(this)' onmouseout='imout(this)' style='cursor: pointer; position: absolute; right: 10px; top: 10px;' onclick='closeWait();'> You are sharing <a href=\"" + lk + "\">"+lab+"</a>";
	msg += "<br>Enter your friend's email address: <br><input style='width: 300px' type='text' value='' name='friendEmail' id='friendEmail'><br><input type='button' value='SHARE' onclick='doSharePage()'><input type='hidden' value='"+lk+"' id='sharedUrl'></div>";

	dv = document.getElementById("shareWindow");
	if (!dv)
	{
		dv = document.createElement("div");

		dv.style.position = "absolute";
		dv.style.display = "block";
		dv.innerHTML = msg;
		opacity(dv, 0);
		dv.style.top = "0px";
		dv.style.left = "0px";
//		dv.style.backgroundColor = "#fff";
		dv.style.color = "#444444";
		dv.style.zIndex = overlayZ + 1;	
		dv.style.borderWidth = "0px";	
		dv.style.borderStyle = "solid";	
		dv.style.borderColor = "#bfbfbf";	
		dv.style.padding = "0px";
		dv.id = "shareWindow";
		document.body.appendChild(dv);
	} else  {
		dv.innerHTML = msg;
		dv.style.display = "block";
	}
	w = dv.offsetWidth; //if (parseInt(w) == 0) w = 600;
	h = dv.offsetHeight; //if (parseInt(h) == 0) h = 400;
	dv.style.left = (getMouseX(ev) - 300) + "px";
	dv.style.top = getMouseY(ev) + "px";
	opacity(dv, 100);
}

function doSharePage() {
	el = document.getElementById("sharedUrl");
	el2 = document.getElementById("friendEmail");

	url = "reviews.php?what=share_page&email=" + el2.value + "&url=" + encode(el.value);
//	wait();
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_doSharePage;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";
}

function _doSharePage() {
	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		dv = document.getElementById("shareWindow");
		dv.style.display = "none";
		dv.innerHTML = "";
	}
}


function showTour(tid, cnt) {
	for (i=1;i<=cnt ;i++ )
	{
		el = document.getElementById("tour" + i + "txt");
		el.style.visibility =  "hidden";
		el = document.getElementById("tour" + i + "img");
		opacity(el, 50);
	}
	el = document.getElementById("tour" + tid + "txt");
	el.style.visibility=  "visible";
	el = document.getElementById("tour" + tid + "img");
	opacity(el, 100);

	el = document.getElementById("tourArea");
	el.innerHTML = '<applet style="border: 5px solid #56004e; overflow: hidden;" name=ilaviewer2 code=ilaviewer2.class mayscript=true height=350 width=500 archive="tours/ilaviewer2.zip"><param name="yawStart" value="108"><param name="filename" value="tours/'+tid+'.jpg"><PARAM NAME=panotype VALUE="cube"><param name="splash" value="tours/splash.gif"><param name="helpURL" VALUE="window.open(\'help.htm\', \'help_window\', \'width=500, height=500, toolbar=no, scrollbars=yes, resizable=yes, status=no, copyhistory=0\'"><param name="toolbar" VALUE="tours/ilatoolbar.gif"><param name="backgroundcolor" value="000000"><font color="White"> <br />You currently do not have Java runtime installed on your computer. <br />To install Java click on the following link to download the software from theSun Microsystems website. <br /> <br /><P align="center"><A href="http://www.java.com" title="Click to download Java"><img src="tours/getjava.gif" border=0></A></P></font></applet>';
}

function loadCateringImage(pathtoimage) {
	el3 = document.getElementById("productImage");
	el3.src = pathtoimage;
//	el3.style.marginRight = "10px";
//	el3.width = "210";

}
