// JavaScript Document
//get the httpXHTML response
function getHTTPObject() {
  var xmlhttp;
  if(window.XMLHttpRequest){
	    xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		
		if (!xmlhttp)
			{
	        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
	}
return xmlhttp;

}

/*
* function to clear field
*/
function clearField(id){

	var nId = id.toLowerCase();

	if (document.getElementById(id).value == id)
		{
		document.getElementById(id).value = "";
		document.getElementById(id).style.color = "#000";
		}


	if (nId == 'password')
		{
		document.getElementById(id).type = "password";		
		}
}

function populateField(id){
	
	var nId = id.toLowerCase();
	
	if ( document.getElementById(id).value == '' )
		{
		document.getElementById(id).value = id;
		document.getElementById(id).style.color = "#888";
		if (nId == 'password')
			{
			document.getElementById(id).type = "text";		
			}
		}
}

//function to display the responsed based on id provided
function showResponse(id){
		var http = getHTTPObject(); 
		http.open("GET","../admin/temp1.php?id="+id,true);
	  	http.send(null);
		http.onreadystatechange = function()
		{
		if(http.readyState == 4)
			{
			//alert(http.responseText);
			document.hold.message.value=http.responseText;	
			}
		}
}

//function to show or hide an html tag based on checkbox check/uncheck
function show_or_hide(chkid,id)
{
	chkobj = document.getElementById(chkid);
	obj = document.getElementById(id);
	if(chkobj.checked == true)
		obj.style.display = '';
	else
		obj.style.display = 'none';
}

/*
* all jquery functions 
* done by zainul for various jobs using javascript
* Updated October 2008 onwards
*/

/*
* function using jquery to do the 
* fade in and out of the testimonial
*/

/*
$(document).ready(function() {
	//display the random testimonial
	//showMessage();  
	//alert("On Ready");	
	showmessage();
	//doToggleCheckbox();
});
*/

function showmessage(){
	$.ajax({
		type: "POST",
   		url: "randomTestimonials.php",
    	success: function(data){
		$("#testimonial_content").fadeOut('slow', function(){
					$("#testimonial_content").html(data).fadeIn("slow");
					});
		}
	});
  setTimeout('showmessage()',30000);
};  



/*
* Select all / Unselect all option
* used in various options
*/
function doToggle(){
		$("#select_all").click(function() 
            { 
			var checked_status = this.checked; 			
	        $("input[@id=check]").each(function() 
				{
					this.checked = checked_status;
				}); 

            }); 
}

function unSelect(){
	$("input[id=check]").click(function(){			   
	//alert("selected me");
		if (!this.checked)
			{
			$("input[id=select_all]").attr("checked",false);	
			}
	});
}



