// JavaScript Document

var xmlhttp;
var hxmlhttp;
function loadCategory(url)
{
	
	hxmlhttp=null;
	
	if (window.XMLHttpRequest)
	  {// code for Firefox, Opera, IE7, etc.
	  	hxmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {// code for IE6, IE5
	  	hxmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	if (hxmlhttp!=null)
	  {
		 
		
		  hxmlhttp.onreadystatechange=state_Change;
		  hxmlhttp.open("GET",url,true);
		  hxmlhttp.send(null);
	  }
	else
	  {
	  alert("Your browser does not support XMLHTTP.");
	  }
}

function state_Change()
{
	document.getElementById('putcategory').innerHTML ="<img src='../images/ajax-load.gif' alt='load'/>";
	if (hxmlhttp.readyState==4)
  	{
  		
		document.getElementById('putcategory').innerHTML=hxmlhttp.responseText;
    }
}


function loadCategoryfor(url)
{
	
	hxmlhttp=null;
	
	if (window.XMLHttpRequest)
	  {// code for Firefox, Opera, IE7, etc.
	  	hxmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {// code for IE6, IE5
	  	hxmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	if (hxmlhttp!=null)
	  {
		 
		
		  hxmlhttp.onreadystatechange=change_this;
		  hxmlhttp.open("GET",url,true);
		  hxmlhttp.send(null);
	  }
	else
	  {
	  alert("Your browser does not support XMLHTTP.");
	  }
}

function change_this()
{
	document.getElementById('thiscategory').innerHTML ="<img src='../images/ajax-load.gif' alt='load'/>";
	if (hxmlhttp.readyState==4)
  	{
  		
		document.getElementById('thiscategory').innerHTML=hxmlhttp.responseText;
    }
}

function loadSubcategory(val)
{

	
	hxmlhttp=null;
	
	if (window.XMLHttpRequest)
	  {// code for Firefox, Opera, IE7, etc.
	  	hxmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {// code for IE6, IE5
	  	hxmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	if (hxmlhttp!=null)
	  {
		 
		  url="catselect.php?catID="+val;
		  
		  hxmlhttp.onreadystatechange=change_state;
		  hxmlhttp.open("GET",url,true);
		  hxmlhttp.send(null);
	  }
	else
	  {
	  alert("Your browser does not support XMLHTTP.");
	  }
}
function change_state()
{
	document.getElementById('putsubcat').innerHTML ="<img src='../images/ajax-load.gif' alt='load'/>";
	if (hxmlhttp.readyState==4)
  	{
  		document.getElementById('putsubcat').innerHTML=hxmlhttp.responseText;
    }
}

function toggle_username(userid) 
{
 
  
   if (window.XMLHttpRequest) 
	{
        http = new XMLHttpRequest();
    } 
	else if (window.ActiveXObject) 
	{
        http = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
	handle = document.getElementById(userid);
    var url = 'checkuser.php?';
 
	if(handle.value.length > 0) 
	{   
		
        var fullurl = url + 'username=' + handle.value;
    	http.open("GET", fullurl, true);
        http.send(null);
        http.onreadystatechange = statechange_username;
    }
	else{
        document.getElementById('username_result').innerHTML = '';
		 
	}
	
}

function statechange_username() 
{
    document.getElementById('username_result').innerHTML ="<img src='../images/ajax-load.gif' alt='load'/>";   
	if (http.readyState == 4) 
	{
      	var result=http.responseText;
		if(result==1)
		{
			document.getElementById('username_result').innerHTML ="<font color='#CC0000'><b>Username already taken.</b></font>";
			
		}
		else
		{
				document.getElementById('username_result').innerHTML ="";
		}
		
	 }
}

function loadoptionValue(url)
{
	
	hxmlhttp=null;
	
	if (window.XMLHttpRequest)
	  {// code for Firefox, Opera, IE7, etc.
	  	hxmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {// code for IE6, IE5
	  	hxmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	if (hxmlhttp!=null)
	  {
		 
		
		  hxmlhttp.onreadystatechange=this_state_Change;
		  hxmlhttp.open("GET",url,true);
		  hxmlhttp.send(null);
	  }
	else
	  {
	  alert("Your browser does not support XMLHTTP.");
	  }
}

function this_state_Change()
{
	document.getElementById('putit').innerHTML ="<img src='../images/ajax-load.gif' alt='load'/>";
	if (hxmlhttp.readyState==4)
  	{
  		
		document.getElementById('putit').innerHTML=hxmlhttp.responseText;
    }
}
