
   var http_request = false;
   function makePOSTRequest(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('POST', url, true);
      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() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('mycommentspan').innerHTML = result;
         } else {
            //alert('There was a problem with the request.');
			document.getElementById('mycommentspan').innerHTML = 'There was a problem with the request. Please contact us and report this problem!';
         }
      }
   }
   
   function get(obj) {
	   
	  var poststr;
	  if(document.getElementById("user_id").value == 0)
	  {
		 poststr = "comment_txt=" + encodeURI( document.getElementById("comment_txt").value ) +
                    "&vid=" + encodeURI( document.getElementById("vid").value ) +
					"&user_id=" + encodeURI( document.getElementById("user_id").value ) +
					"&username=" + encodeURI( document.getElementById("username").value ) +
					"&captcha=" + encodeURI( document.getElementById("captcha").value );
	  }
	  else {
		 poststr = "comment_txt=" + encodeURI( document.getElementById("comment_txt").value ) +
		 			"&user_id=" + encodeURI( document.getElementById("user_id").value ) +
                    "&vid=" + encodeURI( document.getElementById("vid").value );
	  }
	  
      makePOSTRequest(''+MELODYURL+'/comment.php', poststr);
   }

function submitonce(theform){
//if IE 4+ or NS 6+
	if(document.getElementById("user_id").value != 0)
	{
		if(document.getElementById("comment_txt").value == '' || document.getElementById("comment_txt").value == "test"){
			//alert('You need to write a comment first!');
		}
		else{
			if (document.all||document.getElementById){
				//screen thru every element in the form, and hunt down "submit" and "reset"
				for (i=0;i<theform.length;i++){
					var tempobj=theform.elements[i]
					if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
					//disable em
					tempobj.disabled=true;
				}
				//theform.style.display='none';
				$(theform).slideUp('normal');
			}
		}
	}
	else
	{
		//	guest comment
		var alert_msg = '';
		if(document.getElementById("comment_txt").value == ''){
			//alert('You need to write a comment first!');
			alert_msg = alert_msg+'You need to write a comment first!\n';
		}
		if(document.getElementById("username").value == '' || document.getElementById("captcha").value == ''){
			alert_msg = alert_msg+'Please fill in the required fields.\n';
		}
		
		if(alert_msg != '') {
			//alert(alert_msg);
		}
		else{
			if (document.all||document.getElementById){
				//screen thru every element in the form, and hunt down "submit"
				for (i=0;i<theform.length;i++){
					var tempobj=theform.elements[i]
					if(tempobj.type.toLowerCase()=="submit")
					//disable em
					tempobj.disabled=false;
				}
				//theform.style.display='none';
				$(theform).slideUp('normal');
			}
		}	
	}
	
}

function validateSearch(b_on_submit){
    if(document.forms['search'].keywords.value == '' || document.forms['search'].keywords.value == 'search'){
        alert('You did not enter a search term. Please try again.');
        if(b_on_submit == 'true')
            return false;
    }
    else{
        document.forms['search'].submit();
    }
}
function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else if(inputString.length > 2) {
		$.post(MELODYURL2+'/ajax_search.php', {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup

function fill(thisValue) {
	$('#inputString').val(thisValue);
	setTimeout("$('#suggestions').hide();", 200);
}

function catlist()
 {
  $("#ul_categories ul").each( function() {
  	$(this).hide().css({display: "none"});
 });
 
 $("#ul_categories li").hover(function(){ 
		$(this).find('ul').show().css({display: "block"});
	},function(){
		$(this).find('ul').hide().css({display: "none"});
	});
 }
