
function showHelp(obj) {
	window.open("index.cgi?showhelp=" + obj,"","width=400,height=400");
}


var xmlhttp;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
	xmlhttp = new ActiveXObject( 'Msxml2.XMLHTTP' );
} catch (e) {
	try {
		xmlhttp = new ActiveXObject( 'Microsoft.XMLHTTP' );
		} catch (E) {
		xmlhttp = false;
	}
}
@else
	if (
	!xmlhttp && document.createElement ) {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp = false;
	}
}@end @*/

if ( !xmlhttp && document.createElement ) {
	xmlhttp = new XMLHttpRequest();
}

var xmlhttp2;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
	xmlhttp2 = new ActiveXObject( 'Msxml2.XMLHTTP' );
} catch (e) {
	try {
		xmlhttp2 = new ActiveXObject( 'Microsoft.XMLHTTP' );
		} catch (E) {
		xmlhttp2 = false;
	}
}
@else
	if (
	!xmlhttp2 && document.createElement ) {
	try {
		xmlhttp2 = new XMLHttpRequest();
	} catch (e) {
		xmlhttp2 = false;
	}
}@end @*/

if ( !xmlhttp2 && document.createElement ) {
	xmlhttp2 = new XMLHttpRequest();
}






function addComment(item) {
	if (document.form001.commentName.value.length<5 || document.form001.commentLocation.value.length<5) {
		alert("You must enter a Name and Location into the comment form.");
	}
	else if (document.form001.commentEmail.value.length!=0 && (document.form001.commentEmail.value.indexOf("@")==-1 || document.form001.commentEmail.value.indexOf(".")==-1) ) {
		alert("Please enter a valid Email Address.");
	}
	else if (document.form001.commentText.value.length<5) {
		alert("You must type something useful into the comments box.");
	}
	else if (document.form001.number.value*1!=x) {
		alert("You enter the correct sum of the two numbers.");
	}
	else {
		url2 = systemURL + "index.cgi?addcomment=" + item + "&t=" + escape(document.form001.commentText.value) + "&n=" + escape(document.form001.commentName.value) + "&l=" + escape(document.form001.commentLocation.value) + "&r=" + document.form001.commentRating.options[document.form001.commentRating.selectedIndex].value + "&e=" + escape(document.form001.commentEmail.value);
		var now = new Date(), txt, url = url2;
		if( url ) {
			xmlhttp.open( 'GET', url, true );
			xmlhttp.onreadystatechange = function() {
				if ( xmlhttp.readyState===4 ) {
					txt = xmlhttp.responseText;
//alert(txt);
					if (txt=="OK") {
						document.form001.commentText.value="";
						document.form001.commentName.value="";
						document.form001.commentLocation.value="";
						document.form001.commentEmail.value="";
						document.form001.number.value="";
						document.form001.commentRating.selectedIndex=0;
						getComments(currentItem);
						alert("Your comment has been added, thank you.");
					}
					else {
						alert("There was a problem, your comment was not added.");
					}
				}
			}
			xmlhttp.send( null );
		}
	}
}


function getComments(obj) {
	url2 = systemURL + "index.cgi?getcomments=" + obj;
	var now = new Date(), txt, url = url2;
	if( url ) {
		xmlhttp.open( 'GET', url, true );
		xmlhttp.onreadystatechange = function() {
			if ( xmlhttp.readyState===4 ) {
				txt = xmlhttp.responseText;
//alert(txt);
				tmp = new Array();
				tmp = txt.split("|");
				if (tmp[0]!="") {
					var output="";
					for (var i=0; i!=tmp.length; i++) {
						tmp2 = new Array();
						tmp2 = tmp[i].split("^");
						if (tmp2[5].length!=0) {
							tmp2[2] = "<a href='mailto:" + tmp2[5] + "'>" + tmp2[2] + "</a>";
						}
						rating="";
						if (tmp2[4]!="X") {
							rating = "<font size=1>I rated this recipe " + tmp2[4] + " / 5</font><br>";
						}
						output+="<b>" + (tmp.length-i) + ". " + tmp2[2] + "</b> from " + tmp2[3] + " <font size=1>(" + tmp2[0] + " - " + tmp2[1] + ")</font><br>" + tmp2[6] + "<br>" + rating + "<br>";
					}
					document.getElementById("comments").innerHTML=output;
				}
			}
		}
		xmlhttp.send( null );
	}

}


added=0;
function addFave(x) {
	if (added==0) {
		added=1;
		tmp = new Array();
		tmp = document.cookie.split(";");
		cart=new Array();
		for (i=0; i!=tmp.length; i++) {
			tmp2 = new Array();
			tmp2 = tmp[i].split("=");
			if (tmp2[0].indexOf("list")!=-1 && tmp2[1] != null) {
				cart.push(tmp2[1]);
			}
		}
		cart.push(x);

		if (listed==0) {
			document.cookie="list="+cart.join("^")+"; path=/;";
			alert("This recipe has been added to your Quick List.");
		}
		else {
			alert("This recipe is already in your Quick List.");
		}
	}
}

function printRecipe(obj) {
	window.open("index.cgi?printrecipe="+obj,"print","width=600,height=750,scrollbars=yes");
}
