
	function funcMailTo(a,n) {
		var sp = Math.ceil(a.length / 2);
		var p1 = a.substring(0,sp);
		var p2 = a.substring(sp,sp+sp);
		var e = '';
		for(x=0;x<sp;x++) {
			e += p1.substring(x,x+1) + p2.substring(x,x+1);
		}
		document.write("<a href=\"mailto:"+e+"\">"+n+"</a>");
	}

	function funcYouTube(v,r,w) {
	 	document.write(
			"<div class=\"youTubeVideo\">"+
			"<object width=\""+((w == 1)? '480' : '425')+"\" height=\""+((w == 1)? '295' : '344')+"\">"+
			"<param name=\"movie\" value=\"http://www.youtube.com/v/"+v+"&rel="+r+"\"></param>"+
			"<param name=\"allowFullScreen\" value=\"true\"></param>"+
			"<embed src=\"http://www.youtube.com/v/"+v+"&rel="+r+"\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\""+((w == 1)? '480' : '425')+"\" height=\""+((w == 1)? '295' : '344')+"\"></embed>"+
			"</object>"+
			"</div>"
		);
	}

	function funcShowImage(i,d) {
		document.write("<img src=\"/img/"+i+"\" alt=\""+d+"\" title=\""+d+"\" />");
	}
	
	function funcShowThumb(i,d,t,w,h) {
		document.write("<img src=\"/img/"+i+"\" alt=\"thumbnail\" title=\""+d+"\" />");
	}

	function funcShowCommentForm(p,c) {
		document.write(
			"<h2>Have your say...</h2>"+
			"<div class=\"formBox\">"+
			"	<form class=\"formContainer\" action=\"\" method=\"post\" onSubmit=\"return funcSubmitCommentForm();\">"+
			"	<input type=\"hidden\" name=\"action\" value=\"contact\" />"+
			"	<input type=\"hidden\" id=\"pid\" name=\"pid\" value=\""+p+"\" />"+
			"	<input type=\"hidden\" id=\"chk\" name=\"chk\" value=\""+c+"\" />"+
			"	<div id=\"pageCommentFormFields\">"+
			"	<fieldset class=\"formItem\">"+
			"		<label for=\"yourName\" class=\"formLabel\">Your Name and Article / Subject Rating</label> (5 stars is best, 0 stars is worst)"+
			"		<span class=\"formField\">"+
			"			<input type=\"text\" id=\"yourName\" name=\"yourName\" size=\"30\" maxlength=\"30\" class=\"formTextInput\" value=\"\" />"+
			"			<select id=\"yourRating\" name=\"yourRating\"><option value=\"5\">***** 5 Stars</option><option value=\"4\">**** 4 Stars</option><option value=\"3\">*** 3 Stars</option><option value=\"2\">** 2 Stars</option><option value=\"1\">* 1 Star</option><option value=\"0\">0 Stars</option></select>"+
			"		</span>"+
			"	</fieldset>"+
			"	<fieldset class=\"formItem\">"+
			"		<label for=\"yourEmail\" class=\"formLabel\">Your Email Address</label> (required - will not be displayed to the public)"+
			"		<span class=\"formField\"><input type=\"text\" id=\"yourEmail\" name=\"yourEmail\" size=\"45\" maxlength=\"60\" class=\"formTextInput\" value=\"\" /></span>"+
			"	</fieldset>"+
			"	<fieldset class=\"formItem\">"+
			"		<label for=\"yourComments\" class=\"formLabel\">Your Comments</label> (please do not type all in capitals or include html)"+
			"		<span class=\"formField\"><textarea id=\"yourComments\" name=\"yourComments\" cols=\"30\" rows=\"8\" class=\"formTextArea\"></textarea></span>"+
			"	</fieldset>"+
			"	<label><input type=\"submit\" value=\"Submit Your Comments\" class=\"formButton\" id=\"contactFormButton\" /></label>"+
			"	</div>"+
			"	<div id=\"pageCommentStatus\"></div>"+
			"	</form>"+
			"</div>"
			);
	}
	
	function funcSubmitCommentForm() {
		var pidField = document.getElementById('pid');
		var chkField = document.getElementById('chk');
		var nameField = document.getElementById('yourName');
		var emailField = document.getElementById('yourEmail');
		var commentField = document.getElementById('yourComments');
		var ratingField = document.getElementById('yourRating');
		var contactFormButton = document.getElementById('contactFormButton');
		var commentStatus = document.getElementById('pageCommentStatus');
		var params = "pid="+escape(pidField.value)+"&chk="+escape(chkField.value)+"&yourName="+escape(nameField.value)+"&yourEmail="+escape(emailField.value)+"&yourComments="+escape(commentField.value)+"&yourRating="+escape(ratingField.value);
		commentStatus.innerHTML = 'Submitting your comments - please wait';
		commentStatus.style.display = 'block';
		funcDoAJAX('post','/comment.php',params,true,'text','funcUpdateContactForm');
		return false;
	}
	
	function funcUpdateContactForm(x) {
		var commentStatus = document.getElementById('pageCommentStatus');
		var commentFormFields = document.getElementById('pageCommentFormFields');
		commentStatus.innerHTML = x;
		if (x.search(/Thank You/i) > 0) { 
			commentFormFields.style.display = 'none'; 
			commentStatus.style.margin = '0px';
		}
	}
	