/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

/* -------------------------- */
/* LOGIN */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;
function Member_Info_Sec() {
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('login_response').innerHTML = "Loading..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var author_name	= encodeURI(document.getElementById('author_name').value);
var title		= encodeURI(document.getElementById('title').value);
var category	= encodeURI(document.getElementById('category').value);
var post_content= encodeURI(document.getElementById('post_content').value);
// Set te random number to add to URL request
nocache = Math.random();


	var url		= "http://www.graphicdesignblog.org/guest_post_verification.php?";
	var params	=  'author_name='+author_name+'&title='+title+'&category='+category+'&post_content='+post_content;

	http.open("POST", url, true);
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");

	http.onreadystatechange = loginReply;
	http.send(params);


//// Pass the login variables like URL variable
////alert(author_name + "----" + title + "----" + category + "----" + post_content);
//http.open('get', 'http://www.graphicdesignblog.org/guest_post_verification.php?author_name='+author_name+'&title='+title+'&category='+category+'&post_content='+post_content+'&nocache = '+nocache);
//http.onreadystatechange = loginReply;
//http.send(null);

}


function loginReply() {
if(http.readyState == 4){ 
var response = http.responseText;
//document.getElementById('login_response').innerHTML = response;

	if (response == "0")
	{
		document.getElementById('guest_post').action	= "http://www.graphicdesignblog.org/send_guest_post.php";
		document.getElementById('guest_post').submit();
	}
	else
	{
		document.getElementById('login_response').innerHTML = response;	
	}
	
}
}
