// JavaScript Document
   var http_request = false;
  // var url="wp-comments-post.php";
   function SubmitNewComment(url, parameters, post_id) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
 
      http_request.onreadystatechange =function()
  	  {
		  ////////////////////////////////////////////////
		   document.getElementById('submitstatus'+post_id).innerHTML = "loading...";
		   var result="";
		  if (http_request.readyState == 4) {
			  
			 if (http_request.status == 200) {
				//alert(http_request.responseText);
				//result = http_request.responseText.toString();
				//var mySplitResult =result.split("<p>");
				//var mySplitResult2 =mySplitResult[1].split("</p></body>");
				//document.getElementById('submitstatus'+post_id).innerHTML = http_request.responseText;  
			    document.getElementById('submitstatus'+post_id).innerHTML = "";  
						  
			 } else {
				//alert('There was a problem with the request.');
				result = http_request.responseText.toString();
				var mySplitResult =result.split("<p>");
				var mySplitResult2 =mySplitResult[1].split("</p></body>");
				document.getElementById('submitstatus'+post_id).innerHTML = mySplitResult2[0];
			 }
		  }
		  
		  ///////////////////////////////////////////////
 	  }
	  
      http_request.open('POST', url, true);
      // http_request.setRequestHeader("Content-type", "text/plain");
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	  http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
	 
   }
 
   function alertContents(post_id) {
	   document.getElementById('submitstatus'+post_id).innerHTML = "loading...";
      if (http_request.readyState == 4) {
		  
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('submitstatus'+post_id).innerHTML = result;  
			          
         } else {
            //alert('There was a problem with the request.');
			document.getElementById('submitstatus'.post_id).innerHTML = "There was a problem with the request.";
         }
      }
   }
 
   function get(obj, statid) {
	   /*
      var poststr = "author=" + encodeURI( document.getElementById("author").value ) +
                    "&email=" + encodeURI( document.getElementById("email").value ) +
                    "&url=" + encodeURI( document.getElementById("url").value ) +
                    "&comment=" + encodeURI( document.getElementById("comment").value ) +
                    "&comment_post_ID=" + encodeURI( document.getElementById("comment_post_ID").value ) +
                    "&comment_parent=" + encodeURI( document.getElementById("comment_parent").value );
					*/
	
	var poststr = "author=" + encodeURI( obj.elements["author"].value ) +
                    "&email=" + encodeURI( obj.elements["email"].value ) +
                    "&url=" + encodeURI( obj.elements["url"].value ) +
                    "&comment=" + encodeURI( obj.elements["comment"].value ) +
                    "&comment_post_ID=" + encodeURI( obj.elements["comment_post_ID"].value ) +
                    "&comment_parent=" + encodeURI( obj.elements["comment_parent"].value );
					
					var post_id=obj.elements["comment_post_ID"].value;
     SubmitNewComment('./wp-comments-post.php', poststr, post_id);
   }
   
 function fbs_click(u,t) {
	// u=<?php the_permalink(); ?>;
	// t=<?php //the_title(); ?>;
	 window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;
	 }
	 
function tws_click(u) {
	// u=<?php the_permalink(); ?>;
	// t=<?php //the_title(); ?>;
	
	 window.open('http://twitter.com/home?status=Currentlyreading '+encodeURIComponent(u),'Twitter','toolbar=0,status=0,width=626,height=436');return false;
	 }
	

