/**************************************************************************************************
*           *       @       Created By              :       Sudeep Jain                           *
*           *       @       Modified By             :         Sudeep Jain                  		  *
*           *       @       Date Of Creation        :       05-01-2010                            *
*           *       @       Date Of Modification    :        03-08-10           			      *
*           *       @       Project Name            :       Webindiabusiness                      *
**************************************************************************************************/

/************************************************************************************************** 
* Ajax Function, Start 
**************************************************************************************************/
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
/************************************************************************************************** 
* Ajax Function, End
**************************************************************************************************/


/************************************************************************************************** 
* Function to check member avalability, Start
**************************************************************************************************/
function memberAvailable() {
	var email=document.getElementById("email").value;
	if(email){
		var url="getMember.php?email="+email;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	} else {
		document.getElementById("emailDiv").innerHTML="";
	}
}
function stateChanged() {
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	{
		if(xmlHttp.responseText==1 ) {
			document.getElementById("emailDiv").innerHTML="Email already in use.";
			document.getElementById("emailDiv").style.display="block";
			document.getElementById("email").focus();
		}
		if(xmlHttp.responseText==0 ) {
			document.getElementById("emailDiv").innerHTML="Email is avaliable.";
			document.getElementById("emailDiv").style.display="block";
		}
	} else {
			document.getElementById("emailDiv").style.display="none";
	}
}
/************************************************************************************************** 
* Function to check member avalability, Start
**************************************************************************************************/

/************************************************************************************************** 
* Function to Check uncheck all checkbox, Start
**************************************************************************************************/
function checkUncheckAll(chk){
	if(document.frm.checkBox.checked==false){
		if(chk.length==undefined){
			chk.checked=false;
		}
		else{
			for(i=0;i<chk.length;i++)
			chk[i].checked=false;
		}
	}
	else{
		if(chk.length==undefined){
			chk.checked=true;
		}
		else{
			for(i=0;i<chk.length;i++)
			chk[i].checked=true;
		}
	}
}
/************************************************************************************************** 
* Function to Check uncheck all checkbox, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to check all checkbox, Start
**************************************************************************************************/
function checkAll(chk){ 
	if(chk.length==undefined){
		chk.checked=true;	
	} else {
		for (i = 0; i < chk.length; i++)
		chk[i].checked = true ;
	}
} 
/************************************************************************************************** 
* Function to check all checkbox, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to Uncheck all checkbox, Start
**************************************************************************************************/
function unCheckAll(chk){ 
	if(chk.length==undefined){
		chk.checked=false;	
	} else {
		for (i = 0; i < chk.length; i++) 
		chk[i].checked = false;
	} 
}
/************************************************************************************************** 
* Function to Uncheck all checkbox, End
**************************************************************************************************/

/************************************************************************************************** 
* Functtion to get state, State 
**************************************************************************************************/
function getState(element,stateDivName,cityDivName,stateElement,cityElement){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url="getState.php";
	var countryID = element.value;
	url=url+"?countryID="+countryID+"&cityDivName="+cityDivName+"&stateDivName="+stateDivName+"&stateElement="+stateElement.name+"&cityElement="+cityElement;
	xmlHttp.onreadystatechange=
		function showState(){
			if (xmlHttp.readyState==4){ 
				document.getElementById(stateDivName).innerHTML=xmlHttp.responseText;
			}
		};		
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
/************************************************************************************************** 
* Functtion to get state, End  
**************************************************************************************************/

/************************************************************************************************** 
* Functtion to get city, Start 
**************************************************************************************************/
function getCity(element,divName,cityElement){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url="getState.php";
	var stateName = element.value;
	url=url+"?stateName="+stateName+"&divName="+divName+"&cityElement="+cityElement;
	
	xmlHttp.onreadystatechange=function showCity(){
		if (xmlHttp.readyState==4){ 
			document.getElementById(divName).innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
/************************************************************************************************** 
* Functtion to get city, End  
**************************************************************************************************/

/************************************************************************************************** 
* Functtion to get subcategory, Start  
**************************************************************************************************/
function getCat(catID){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getcategory.php";
	url=url+"?catID="+catID;
	xmlHttp.onreadystatechange=showCategory;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showCategory(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("Cat").innerHTML=xmlHttp.responseText;
	}
}
/************************************************************************************************** 
* Functtion to get subcategory, End  
**************************************************************************************************/

/************************************************************************************************** 
* Functtion to get product, Start  
**************************************************************************************************/
function getProduct(subCat_ID){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getProduct.php";
	url=url+"?subCat_ID="+subCat_ID;
	xmlHttp.onreadystatechange=showProduct;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showProduct(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("prod").innerHTML=xmlHttp.responseText;
	}
}
/************************************************************************************************** 
* Functtion to get product, End  
**************************************************************************************************/
/************************************************************************************************** 
* Functtion to get Category, Start  
**************************************************************************************************/
function gettype(red){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getcategory.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showCat;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showCat(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("cat").innerHTML=xmlHttp.responseText;
	}
}
/************************************************************************************************** 
* Functtion to get Product, Start  
**************************************************************************************************/
function gettypevalue(red){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="gettypevalue.php";
	url=url+"?red="+red;
	
	xmlHttp.onreadystatechange=showSubCategorys;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showSubCategorys(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("type").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get subcategory, Start  
**************************************************************************************************/
function getsubcat(red){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getsubcategory.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showsubCat;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showsubCat(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("subcat").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get Category, Start  
**************************************************************************************************/
function getcat(red){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getcat.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showCat;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showCat(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("cat").innerHTML=xmlHttp.responseText;
	}
}
/************************************************************************************************** 
* Functtion to get subcategory, Start  
**************************************************************************************************/
function getprod(red){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getProduct.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showproduct;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showproduct(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("product_ID").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get product, Start  
**************************************************************************************************/
function getproduct(red){
	document.form.type['1'].disabled=true;
	document.form.type['2'].disabled=true;
	document.form.type['3'].disabled=true;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getproducts.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showproducts;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showproducts(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("prods").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get product, Start  
**************************************************************************************************/
/************************************************************************************************** 
* Functtion to get product, Start  
**************************************************************************************************/
function getproducti(red){
	document.form.type['0'].disabled=true;
	document.form.type['1'].disabled=true;
	document.form.type['3'].disabled=true;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getproducts.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showproductsi;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showproductsi(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("prods").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get product, Start  
**************************************************************************************************/
function getsubprod(red){
	document.getElementById("cate").style.display="none";
	document.getElementById("subcate").style.display="none";
	document.getElementById("subproduct").style.display="block";
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getsubproduct.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showproducti;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showproducti(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("subproduct").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get subcategory, Start  
**************************************************************************************************/
function getprods(red){
	document.form.type['0'].disabled=true;
	document.form.type['2'].disabled=true;
	document.form.type['3'].disabled=true;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getproductcat.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showpro;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showpro(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("prods").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get Category, Start  
**************************************************************************************************/
function getcats(red){
	document.getElementById("subproduct").style.display="none";
	document.getElementById("cate").style.display="block";
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getcats.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showCate;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showCate(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("cate").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get subcategory, Start  
**************************************************************************************************/
function getsubcats(red){
	document.getElementById("subproduct").style.display="none";
	document.getElementById("subcate").style.display="block";
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getsubcats.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showsubCatr;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showsubCatr(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("subcate").innerHTML=xmlHttp.responseText;
	}
}

/************************************************************************************************** 
* Functtion to get product, Start  
**************************************************************************************************/
function getprodsi(red){
	document.form.type['0'].disabled=true;
	document.form.type['1'].disabled=true;
	document.form.type['2'].disabled=true;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="getproductcat.php";
	url=url+"?red="+red;
	xmlHttp.onreadystatechange=showproi;
	vam=xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showproi(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("prods").innerHTML=xmlHttp.responseText;
	}
}
