   var http_request = false;
   var http_request1 = false;
   function makeRequest(url, parameters) {
      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 = alertContents;
      http_request.open('GET', url + parameters, true);
      http_request.send(null);	
	   //$('#postcomments').css("display","none"); //option 1
      $('#postcomments').slideUp(500);           //option 2
	  $("#postcomments1").slideDown(500);
	  $('#postcomments1').highlightFade({       //Stunning Highlights uncomment it
		speed:1200
		});
	window.setTimeout('$("#message").attr(\'class\',\'user_review_text\')',1000,'javascript');
	
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
            document.getElementById('postcomments1').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   //If you're using your form in tables
   function get(obj) {
	   var commentlen = document.getElementById("comments").value.length;
	   if(commentlen<10){
	   alert("Comment length is too short");
	   document.getElementById("comments").focus();
	   return false;
	   }
	   if(document.getElementById("name").value == ""){
       alert("Write your full name!");
	   document.getElementById("name").focus();
	   return false;
	   }
	   if(document.getElementById("email").value == ""){
       alert("Write your valid emailid!");
	   document.getElementById("email").focus();
	   return false;
	   }
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms['myform'].elements['email'].value;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      return false;
   }

  var getstr = "?";
  getstr += "comments=" +  document.getElementById("comments").value + "&";
  getstr += "name=" +  document.getElementById("name").value + "&";     
  getstr += "email=" +  document.getElementById("email").value + "&";
    getstr += "security_code=" +  document.getElementById("security_code").value + "&";
	getstr += "model_id=" +  document.getElementById("model_id").value + "&"; 

   makeRequest('../ajax_get_reviewform_result.php', getstr);
   	 
}

function get_stuffs_comment(obj) {
  var getstr = "?";
  getstr += "comments=" +  document.getElementById("comments").value + "&";  
    getstr += "security_code=" +  document.getElementById("security_code").value + "&";
	getstr += "item_id=" +  document.getElementById("item_id_to_send").value + "&"; 
	getstr += "user_id=" +  document.getElementById("user_id").value + "&"; 
	getstr += "stuff_recog_id=" +  document.getElementById("stuff_recog_id").value + "&";
	
	if(!document.getElementById("user_id").value){
    document.getElementById("postcomments1").innerHTML = '<div class="alert"><img src="../images/info_icon.gif" alt="info" title="info" />You have to signup or login to post a comment.</div>';
	document.myform.reset();
	return false;
	}
	if(document.getElementById("comments").value.length<5){
	  alert("Comment is too short.")
		  document.getElementById("comments").focus();
	  return false;  
  }else{
   makeRequest('../php/ajax_get_stuffcomment_result.php', getstr);
    $('span.commentspan').fadeOut("slow");     //to show comment on the fly
	$('span.commentspan').fadeIn("slow",getTheResult('../php/get_stuff_comments.php', getstr));//to show comment on the fly
    return true;
   }  	 
}

function showReviewBlock(obj,obj_1) {
	var el = document.getElementById(obj);
    var el_1 = document.getElementById(obj_1);
			$('#'+obj+'').slideUp(1000);
		 $('#'+obj_1+'').slideDown(1000);
		 $( "#myform" )[ 0 ].reset();
	var rand_no=Math.floor(Math.random()*6);		 
    $("#catchaImage").attr({src : "../CaptchaSecurityImages.php?width=100&height=40&characters="+rand_no+""});
}

function showReviewBlockWhenCpatchaFailed(obj,obj_1) {
	var el = document.getElementById(obj);
    var el_1 = document.getElementById(obj_1);
			$('#'+obj+'').slideUp(1000);
		 $('#'+obj_1+'').slideDown(1000);
		 //window.location.reload()
		 var rand_no=Math.floor(Math.random()*6);
		 //var rand_no=Math.floor((6-3)*Math.random()) + 4;
		 //var rand_no = Math.floor((100-3)*Math.random()) + 4; //Multiply it with the difference of upper value and one less than the lower value of the range
        $("#catchaImage").attr({src : "../CaptchaSecurityImages.php?width=100&height=40&characters="+rand_no+""});
	   }

function getTheResult(url, params)
{
 http_request1 = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request1 = new XMLHttpRequest();
         if (http_request1.overrideMimeType) {
           http_request1.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request1 = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request1 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request1) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }	  
      
      http_request1.onreadystatechange = alertCommentsToDisplay;
      http_request1.open('GET', url + params, true);
      http_request1.send(null);
}

function alertCommentsToDisplay()
{
if (http_request1.readyState == 4) {
         if (http_request1.status == 200) {
            result = http_request1.responseText;
            document.getElementById("commentspan").innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
}

/*function get_ringtone_submit(obj) {
  var getstr = "?";
  getstr += "p_ringtone=p_ringtone&";
  getstr += "p_title=" +  document.getElementById("upParent").value + "&";     
  getstr += "p_description=" +  document.getElementById("p_description").value + "&";
  getstr += "p_tags=" +  document.getElementById("p_tags").value + "&";
 getstr += "p_category=" +  document.getElementById("navCat").value + "&";

   makeRequest('submit_ringtone.php', getstr);
   	 
}*/


/*//If you're using your form in tables,dont keep button inside tr and td then it will not work
function get2(obj) {
  var getstr = "?";
  for (i=0; i<obj.getElementsByTagName("input").length; i++) {
        if (obj.getElementsByTagName("input")[i].type == "text") {
           getstr += obj.getElementsByTagName("input")[i].name + "=" + 
                   obj.getElementsByTagName("input")[i].value + "&";
        }
        if (obj.getElementsByTagName("input")[i].type == "checkbox") {
           if (obj.getElementsByTagName("input")[i].checked) {
              getstr += obj.getElementsByTagName("input")[i].name + "=" + 
                   obj.getElementsByTagName("input")[i].value + "&";
           } else {
              getstr += obj.getElementsByTagName("input")[i].name + "=&";
           }
        }
        if (obj.getElementsByTagName("input")[i].type == "radio") {
           if (obj.getElementsByTagName("input")[i].checked) {
              getstr += obj.getElementsByTagName("input")[i].name + "=" + 
                   obj.getElementsByTagName("input")[i].value + "&";
           }
     }  
     if (obj.getElementsByTagName("input")[i].tagName == "SELECT") {
        var sel = obj.getElementsByTagName("input")[i];
        getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
     }
     
  }
   makeRequest('../ajax_get_reviewform_result.php', getstr);
}
   //If you're using your form without table

   function get1(obj) {
      var getstr = "?";
      for (i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT") {
            if (obj.childNodes[i].type == "text") {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else {
                  getstr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         
      }
      makeRequest('../ajax_get_reviewform_result.php', getstr);
   }


 $.fn.clearForm = function() {
  return this.each(function() {
	var type = this.type, tag = this.tagName.toLowerCase();
	if (tag == 'form')
	  return $(':input',this).clearForm();
	if (type == 'text' || type == 'password' || tag == 'textarea')
	  this.value = '';
	else if (type == 'checkbox' || type == 'radio')
	  this.checked = false;
	else if (tag == 'select')
	  this.selectedIndex = -1;
  });
};*/


