function SubmitComment(){
	var Name=document.getElementById('CommentName').value;
	var Email=document.getElementById('CommentEmail').value;
	var Comment=document.getElementById('CommentMessage').value;
	var Captcha=document.getElementById('Captcha').value;
	var Show;
	for(var i = 0; i < document.form.Show.length; i++) {
		if(document.form.Show[i].checked) {
			Show=document.form.Show[i].value;
		}
	}
	if (document.getElementById('HideEmail').checked){
		var Hide =document.getElementById('HideEmail').value;}
	else {var Hide='';}
	if (document.getElementById('NewsLetter').checked){
		var EmailList =document.getElementById('NewsLetter').value;}
	else {var EmailList='';}
	var Journey = document.getElementById('Journey').value;
	var PostData='Name='+encodeURIComponent(Name)+'&Email='+encodeURIComponent(Email)+'&Comment='+encodeURIComponent(Comment)+'&Hide='+Hide+'&EmailList='+EmailList+'&Captcha='+Captcha+'&Journey='+Journey+'&JID='+JID+'&PageID='+PageID+'&Show='+Show;
	AjaxPost('/inc/Ajax_AddComment.asp',PostData,'HandleSubmitComment','SendingComment');
}

function HandleSubmitComment(){
	var CData=CheckStatus();
	if (CData){
		var IncomingLength=CData.incoming.length;
		if (IncomingLength>0) {				
			$('#'+LoadingBlock).fadeOut("slow");
			if(Cdata.incoming[0].Content=='failed'){
				parent.document.getElementById('IFR_Captcha').contentWindow.location='http://captchasystem.pregodigital.co.uk/default.asp?SID='+SID+'&Website=www.mylearning.org';
				$('#StatusResponse').html(Cdata.incoming[0].Errors);				
			}
			else{
				parent.document.getElementById('IFR_Captcha').contentWindow.location='http://captchasystem.pregodigital.co.uk/default.asp?SID='+SID+'&Website=www.mylearning.org';
				LoadComments();
				$('#StatusResponse').html("Your message was successfully added.");				
			}
			$('#StatusResponse').fadeIn('Slow',function(){
				setTimeout("$('#StatusResponse').fadeOut('Slow')",5000);
			});
		}
	}
}

function UpdateComment(){
	var Name=document.getElementById('CommentName').value;
	var Email=document.getElementById('CommentEmail').value;
	var Comment=document.getElementById('CommentMessage').value;
	var Captcha=document.getElementById('Captcha').value;	
	if (document.getElementById('NewsLetter').checked){
		var EmailList =document.getElementById('NewsLetter').value;}
	else {var EmailList='';}
	var Journey = document.getElementById('Journey').value;
	var GUID = document.getElementById('GUID').value;
	var PostData='Name='+encodeURIComponent(Name)+'&Email='+encodeURIComponent(Email)+'&Comment='+encodeURIComponent(Comment)+'&EmailList='+EmailList+'&Captcha='+Captcha+'&Journey='+Journey+'&JID='+JID+'&PageID='+PageID+'&GUID='+GUID;
	AjaxPost('/inc/Ajax_UpdateComment.asp',PostData,'HandleUpdateComment','SendingComment');
}

function HandleUpdateComment(){
	var CData=CheckStatus();
	if (CData){
		var IncomingLength=CData.incoming.length;
		if (IncomingLength>0) {				
			$('#'+LoadingBlock).fadeOut("slow");
			if(Cdata.incoming[0].Content=='failed'){
				parent.document.getElementById('IFR_Captcha').contentWindow.location='http://captchasystem.pregodigital.co.uk/default.asp?SID='+SID+'&Website=www.mylearning.org';
				$('#StatusResponse').html(Cdata.incoming[0].Errors);				
			}
			else{
				parent.document.getElementById('IFR_Captcha').contentWindow.location='http://captchasystem.pregodigital.co.uk/default.asp?SID='+SID+'&Website=www.mylearning.org';
				LoadComments();
				$('#StatusResponse').html("The message was updated.");				
			}
			$('#StatusResponse').fadeIn('Slow',function(){
				setTimeout("$('#StatusResponse').fadeOut('Slow')",5000);
			});
		}
	}
}

function DeleteComment(){
	var Captcha=document.getElementById('Captcha').value;
	var Journey = document.getElementById('Journey').value;
	var GUID = document.getElementById('GUID').value;
	var PostData='Captcha='+Captcha+'&PageID='+PageID+'&JID='+JID+'&GUID='+GUID;
	AjaxPost('/inc/Ajax_DeleteComment.asp',PostData,'HandleDeleteComment','SendingComment');
}

function HandleDeleteComment(){
	var CData=CheckStatus();
	if (CData){
		var IncomingLength=CData.incoming.length;
		if (IncomingLength>0) {				
			$('#'+LoadingBlock).fadeOut("slow");
			if(Cdata.incoming[0].Content=='failed'){
				parent.document.getElementById('IFR_Captcha').contentWindow.location='http://captchasystem.pregodigital.co.uk/default.asp?SID='+SID+'&Website=www.mylearning.org';
				$('#StatusResponse').html(Cdata.incoming[0].Errors);				
			}
			else{
				parent.document.getElementById('IFR_Captcha').contentWindow.location='http://captchasystem.pregodigital.co.uk/default.asp?SID='+SID+'&Website=www.mylearning.org';
				LoadComments();
				$('#StatusResponse').html("The message was deleted.");				
			}
			$('#StatusResponse').fadeIn('Slow',function(){
				setTimeout("$('#StatusResponse').fadeOut('Slow')",5000);
			});
		}
	}
}

function LoadComments(){
	var PostData='PageNumber='+PageNo+'&ItemsPerPage='+ItemsPerPage+'&JID='+PageID+'&TotalItems='+TotalItems;
	AjaxPost('/inc/Ajax_LoadComments.asp',PostData,'HandleLoadComments','LoadingComments');
}

function HandleLoadComments(){
	var CData=CheckStatus();
	if (CData){
		var IncomingLength=CData.incoming.length;
		if (IncomingLength>0) {				
			$('#'+LoadingBlock).fadeOut("slow");
			document.getElementById('CommentsListingBox').innerHTML=Cdata.incoming[0].Content;
		}
	}
}

$(document).ready
( 	
	function()
	{ 
		LoadComments();
	}
)