function CreatePopup(src, features) {
		var theWindow = window.open(src.getAttribute('href'), '_blank', features);
		theWindow.focus();
		return theWindow;
	}
	
function ImageViewer(imageElement)
{
	var theTitle = imageElement.getElementsByTagName("img")[0].alt;
	var theImage = imageElement.href;
	
	window.location.href = "/includes/imageviewer.php?image=" +theImage + "&title=" + theTitle;
}

function WriteCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function ReadCookie(name) {
	var nameeq = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameeq) == 0) return decode(c.substring(nameeq.length,c.length));
	}
	return null;
}

$(document).ready(function() {
	var startstring = 'enter comments here'
	$("#commentbox_button").click(function() {
		$("#commentbox_button").hide();
		$("#commentbox").show(500);
		$("#comment_text").val(startstring);
		});
	
	$("#comment_submit").click(function() {
		$("#commentbox").hide(500);
		$("#commentbox_button").text("Thanks!");
		$("#commentbox_button").show();
		var ctext = escape($("#comment_text").val());
		var curl = escape(document.URL);
		$.post("/other/commentsmailer.php", { text: ctext, url: curl });
		});
	
	$("#comment_text").click(function() {
		var contents = $("#comment_text").val();
		if(contents == startstring)
			$("#comment_text").val("");
		});

	$("#container").click(function() {
		$("#commentbox").hide(500);
		$("#commentbox_button").text("Comments?");
		$("#commentbox_button").show();
		});
		
	$("#comment_close").click(function() {
		$("#commentbox").hide(500);
		$("#commentbox_button").text("Comments?");
		$("#commentbox_button").show();
		});
	});