var ajax = new Array();
var xmlhttp

function checkdata(radiovalue)
{
		
		var index = ajax.length;
		ajax[index] = new sack();
		var url='check_data.php?radiovalue='+radiovalue;
	
		ajax[index].requestFile = url;
		
		// Specifying which file to get
		ajax[index].onCompletion = function(){ fchecklpodata_success(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();
	
}

function fchecklpodata_success(index)	
{

	document.getElementById('radiobuttondiv').innerHTML=ajax[index].response;	

}
/*Duplicate username checking*/
function AjaxUserName(str,id)
{
	if (str.length==0)
 	{
 		document.getElementById("txtHint").innerHTML="";
  		return;
 	}
 	xmlhttp=GetXmlHttpObject();
 	if (xmlhttp==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}
	var url="getUserName.php";
	url= url+"?q="+str;
	if(id != ''){
		url= url+"&id="+id;
	}
 	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function stateChanged()
{
	if (xmlhttp.readyState==4)
  	{
  		document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
		
  	}
}
/*Duplicate username checking*/

/*Get States*/
function AjaxGetState(str)
{
	if (str.length==0)
 	{
 		document.getElementById("stateDiv").innerHTML="";
		document.getElementById("stateOld").style.display = "block";
		document.getElementById("stateDiv").style.display = "none";
  		return;
 	}
	document.getElementById("stateOld").style.display = "none";
	document.getElementById("stateDiv").style.display = "block";
  	xmlhttp=GetXmlHttpObject();
 	if (xmlhttp==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}
	var url="getStates.php";
	url=url+"?q="+str;
 	xmlhttp.onreadystatechange=stateStateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function stateStateChanged()
{
	if (xmlhttp.readyState==4)
  	{
  		document.getElementById("stateDiv").innerHTML=xmlhttp.responseText;
   	}
}
/*Get States*/
/*Get City*/
function AjaxGetCity(str)
{
	if (str.length==0)
 	{
 		document.getElementById("cityDiv").innerHTML="";
		document.getElementById("cityOld").style.display = "block";
		document.getElementById("cityDiv").style.display = "none";

  		return;
 	}
	document.getElementById("cityOld").style.display = "none";
	document.getElementById("cityDiv").style.display = "block";
 	xmlhttp=GetXmlHttpObject();
 	if (xmlhttp==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}
	var url="getCity.php";
	url=url+"?q="+str;
 	xmlhttp.onreadystatechange=stateCityChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function stateCityChanged()
{
	if (xmlhttp.readyState==4)
  	{
  		document.getElementById("cityDiv").innerHTML=xmlhttp.responseText;
  	}
}
/*Get City*/

/*Get Shipping States*/
function AjaxGetShipState(str)
{
	if (str.length==0)
 	{
 		document.getElementById("stateShipDiv").innerHTML="";
		document.getElementById("stateShipOld").style.display = "block";
		document.getElementById("stateShipDiv").style.display = "none";
  		return;
 	}
	document.getElementById("stateShipOld").style.display = "none";
	document.getElementById("stateShipDiv").style.display = "block";
  	xmlhttp=GetXmlHttpObject();
 	if (xmlhttp==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}
	var url="getStates.php";
	url=url+"?sState="+str;
 	xmlhttp.onreadystatechange=stateShipStateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function stateShipStateChanged()
{
	if (xmlhttp.readyState==4)
  	{
  		document.getElementById("stateShipDiv").innerHTML=xmlhttp.responseText;
   	}
}
/*Get Shipping States*/
/*Get Shipping City*/
function AjaxGetShipCity(str)
{
	if (str.length==0)
 	{
 		document.getElementById("cityShipDiv").innerHTML="";
		document.getElementById("cityShipOld").style.display = "block";
		document.getElementById("cityShipDiv").style.display = "none";

  		return;
 	}
	document.getElementById("cityShipOld").style.display = "none";
	document.getElementById("cityShipDiv").style.display = "block";
 	xmlhttp=GetXmlHttpObject();
 	if (xmlhttp==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}
	var url="getCity.php";
	url=url+"?sCity="+str;
 	xmlhttp.onreadystatechange=stateShipCityChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function stateShipCityChanged()
{
	if (xmlhttp.readyState==4)
  	{
  		document.getElementById("cityShipDiv").innerHTML=xmlhttp.responseText;
  	}
}
/*Get Shipping City*/
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
  	{
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		return new XMLHttpRequest();
 	}
	if (window.ActiveXObject)
  	{
  		// code for IE6, IE5
  		return new ActiveXObject("Microsoft.XMLHTTP");
  	}
	return null;
}

function getajaxdata(str)
{
	if (window.XMLHttpRequest)
  			{
  				// code for IE7+, Firefox, Chrome, Opera, Safari
  				xmlhttp=new XMLHttpRequest();
  			}
			else if (window.ActiveXObject)
  			{
  				// code for IE6, IE5
  				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  			}
			else
  			{
  				alert("Your browser does not support XMLHTTP!");
  			}
			
			var url="getsalesSorting.php";
			var arg="sortby="+str;


			xmlhttp.open("POST",url);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlhttp.send(arg);
		
			xmlhttp.onreadystatechange=function()
			{
				if(xmlhttp.readyState==4)
  				{
  					var str=xmlhttp.responseText;
					document.getElementById('method_div').value=str;
			
  				}
			}	
}
function checkSearchInputs(){
	var frm = document.searchform;
	if(frm.search_text.value == ""){
		alert("Please enter a search term to begin your search...");
		frm.search_text.focus();
		return false;
	}
	if(frm.search_text.value == "Part Number, Description, Manufacturer or Alternate"){
		alert("Please enter a search term to begin your search...");
		frm.search_text.focus();
		return false;
	}
	return true;
}
function checkSearchInputsHeader(){
	var frm = document.searchformheader;
	if(frm.search_text.value == ""){
		alert("Please enter a search term to begin your search...");
		frm.search_text.focus();
		return false;
	}
	if(frm.search_text.value == "Search"){
		alert("Please enter a search term to begin your search...");
		frm.search_text.focus();
		return false;
	}
	return true;
}
/*function clear_form_elements(ele) {

    tags = ele.getElementsByTagName('input');
	
    for(i = 0; i < tags.length; i++) {
        switch(tags[i].type) {
            case 'text':
                tags[i].value = 'Part Number, Description, Manufacturer or Alternate';
                break;
        }
    }
   
    tags = ele.getElementsByTagName('select');
    alert(tags.length);
	for(i = 0; i < tags.length; i++) {
        if(tags[i].type == '--------Select--------') {
            tags[i].selectedIndex = 0;
        }
        else {
            for(j = 0; j < tags[i].options.length; j++) {
                tags[i].options[j].selected = false;
            }
        }
    }
   
}*/


