/**
*
*  AJAX IFRAME METHOD (AIM)
*  http://www.webtoolkit.info/
*
**/

AIM = {

	frame : function(c) {
		var n = 'f' + Math.floor(Math.random() * 99999);
		var d = document.createElement('DIV');
		
		d.innerHTML = '<iframe style="display:none" src="upload.php" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
		document.body.appendChild(d);
		

		var i = document.getElementById(n);
		if (c && typeof(c.onComplete) == 'function') {
			i.onComplete = c.onComplete;
		}

		return n;
	},

	form : function(f, name) {
		f.setAttribute('target', name);
	},

	submit : function(f, c) {

/* ================================ Start Validation =============================== */

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

	    if(document.frm_comments.Blog_Comments.value==""){
			  alert("Please enter blog comments");
			  document.frm_comments.Blog_Comments.focus();
			  return false;
	    } 

var comments;
comments=document.frm_comments.Blog_Comments.value;
comments = comments.trim();

	if(comments==""){
	  alert("Please enter blog comments");
	  document.frm_comments.Blog_Comments.focus();
	  return false;
	 } 

	if(document.frm_comments.Anti_Bot_User_Entered_Code.value==""){
			  alert("Please enter code");
			  document.frm_comments.Anti_Bot_User_Entered_Code.focus();
			  return false;
	} 

	if(document.frm_comments.Anti_Bot_User_Entered_Code.value!=document.frm_comments.Anti_Bot_User_Expected_Code.value){
			 alert("Please enter correct code");
		     document.frm_comments.Anti_Bot_User_Entered_Code.focus();
		     return false;
	}
/* ================================ End Validation =============================== */  
		AIM.form(f, AIM.frame(c));
		if (c && typeof(c.onStart) == 'function') {
			return c.onStart();
		} else {
			return true;
		}
	},

	loaded : function(id) {
		var i = document.getElementById(id);
		if (i.contentDocument) {
			var d = i.contentDocument;
		} else if (i.contentWindow) {
			var d = i.contentWindow.document;
		} else {
			var d = window.frames[id].document;
		}
		if (d.location.href == "about:blank") {
			return;
		}
		if (typeof(i.onComplete) == 'function') {
			i.onComplete(d.body.innerHTML);
		}
	}

}
