
// JavaScript Document
var xmlHttp;

function subcat(str)
{ 
xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	if(str != 0)
	{
		var url="ajaxforproducts.php";
		url=url+"?cat="+str;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function()
		{
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
				document.getElementById("subcatdiv").innerHTML=xmlHttp.responseText;
			}
			else if (xmlHttp.readyState!=4 || xmlHttp.readyState!="complete")
			{ 
				document.getElementById("subcatdiv").innerHTML='<img src="../../images/ajax-loader.gif">';
			} 
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}
function subsubcat(str)
{ 
xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	if(str != 0)
	{
		var url="ajaxforproducts.php";
		url=url+"?scat="+str;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function()
		{
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
				document.getElementById("subsubcatdiv").innerHTML=xmlHttp.responseText;
			}
			else if (xmlHttp.readyState!=4 || xmlHttp.readyState!="complete")
			{ 
				document.getElementById("subsubcatdiv").innerHTML='<img src="../../images/ajax-loader.gif">';
			} 
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}
function add_attribute(which,dos,where)
{ 
xmlHttp=GetXmlHttpObject();
if(dos == "add")
{
	document.getElementById('tmp').value=document.getElementById('tmp').value+","+which;
}
document.getElementById('tmp1').value=which
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="ajax_attributes.php";
	url=url+"?which="+document.getElementById('tmp').value;
	url=url+"&dos=add&where="+where;
	if(dos == "remove")
	{
		url=url+"&remove="+which;
	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			if(where == "indus")
			{
				var tmp_product='';
				//var tmp_product=document.getElementById("product_attributes").innerHTML
				document.getElementById("product_attributes").innerHTML=tmp_product+xmlHttp.responseText;
			}
			else
			{
				var tmp_product='';
				//var tmp_product=document.getElementById("product_attributes2").innerHTML
				document.getElementById("product_attributes2").innerHTML=tmp_product+xmlHttp.responseText;
			}
			document.getElementById('tmp').value=document.getElementById('tmp1').value;
			if(dos == "add" )
			{
				document.getElementById(which).style.display="none";
			}
			if(dos == "remove" )
			{
				document.getElementById(which).style.display="block";
			}
		}
		else if (xmlHttp.readyState!=4 || xmlHttp.readyState!="complete")
		{ 
			if(where == "indus")
			{
			}
			else
			{
			}

		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function new_add_attribute(which,dos,where)
{
	if(dos == "add")
	{
		if(where == "indus")
		{
			document.getElementById(which).style.display="none";
			document.getElementById(which+'_txt').style.display="block";
		}
		if(where == "it")
		{
			document.getElementById(which+'_it').style.display="none";
			document.getElementById(which+'_it_txt').style.display="block";
		}
	}
	if(dos == "remove")
	{
		if(where == "indus")
		{
			document.getElementById(which+'_txt').style.display="none";
			document.getElementById(which).style.display="block";
		}
		if(where == "it")
		{
			document.getElementById(which+'_it').style.display="block";
			document.getElementById(which+'_it_txt').style.display="none";
		}
	}
}
function product_cat(str,which)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Browser does not support HTTP Request");
	  return;
	  }
	var url="ajax_product_cat.php";
	url=url+"?id="+str+"&which="+which;
	if(which == "three" )
	{
		url=url+"&parent2="+document.getElementById('parent2').value;
	}
	if(which == "four" )
	{
		url=url+"&parent2="+document.getElementById('parent2').value+"&parent3="+document.getElementById('parent3').value;
	}
	
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
		{
			document.getElementById("output").innerHTML=xmlhttp.responseText;
		}
		else if (xmlhttp.readyState!=4)
		{
			document.getElementById("output").innerHTML="<img src='../images/ajax-loader.gif' /> Content is Loading... Please be Patient.";
		}
	}

	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	if(which == "three" || which == "four")
	{
		test(str);
	}
}
function test(str)
{
	document.getElementById('product_ajax_file').style.display="block";
	document.getElementById('first').value=str;
}
function products_ajax_file()
{
	
	var third=document.getElementById('first').value;
	var first=document.getElementById('parent2').value;
	var second=document.getElementById('parent3').value;
	xmlhttps=GetXmlHttpObject();
	if (xmlhttps==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="ajax_product_file.php";
	url=url+"?first="+first+"&second="+second+"&third="+third;	
	url=url+"&sid="+Math.random();
	xmlhttps.onreadystatechange=function()
	{
		if (xmlhttps.readyState==4)
		{
			document.getElementById("product_ajax_file1").style.display="block";
			document.getElementById("product_ajax_file1").innerHTML=xmlhttps.responseText;
		}
		else if (xmlhttps.readyState!=4)
		{
			document.getElementById("product_ajax_file1").innerHTML="<img src='../images/ajax-loader.gif' /> Content is Loading... Please be Patient.";
		}
	}
	xmlhttps.open("GET",url,true);
	xmlhttps.send(null);
}
function contact_me1()
{
	if(document.getElementById('fname').value == 0)
	{
		alert("Enter the First Name")
		document.getElementById('fname').focus();
		return false;
	}
	else if(document.getElementById('lname').value == 0)
	{
		alert("Enter the Last Name")
		document.getElementById('lname').focus();
		return false;
	}
	else if(document.getElementById('email').value == 0)
	{
		alert("Enter the Email Address")
		document.getElementById('email').focus();
		return false;
	}
	else if(document.getElementById('phone').value == 0)
	{
		alert("Enter the Phone Number")
		document.getElementById('phone').focus();
		return false;
	}
	else if(document.getElementById('country_contact').value == 0)
	{
		alert("Choose your Country")
		document.getElementById('country_contact').focus();
		return false;
	}
	else if(document.getElementById('chk').checked == false)
	{
		alert("Have to accept Terms and condition")
		document.getElementById('chk').focus();
		return false;
	}
	else
	{
		xmlHttp=GetXmlHttpObject();	
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}
		var url="../contact_me_ajax.php";
		url=url+"?fname="+document.getElementById('fname').value;
		url=url+"&lname="+document.getElementById('lname').value;
		url=url+"&email="+document.getElementById('email').value;
		url=url+"&phone="+document.getElementById('phone').value;
		url=url+"&country="+document.getElementById('country_contact').value;
		url=url+"&company="+document.getElementById('company').value;
		url=url+"&email_sent="+document.getElementById('email_sent').value;
		url=url+"&prod_id="+document.getElementById('prod_id').value;
		url=url+"&type="+document.getElementById('type').value;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function()
		{
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
				document.getElementById("contact_me").style.display="none";
				document.getElementById("success_sent").style.display="block";
			}
			else if (xmlHttp.readyState!=4 || xmlHttp.readyState!="complete")
			{ 
			} 
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		setTimeout('document.getElementById("success_sent").style.display="none"',10);
	}
}
function contact_me()
{
	if(document.getElementById('fname').value == 0)
	{
		alert("Enter the First Name")
		document.getElementById('fname').focus();
		return false;
	}
	else if(document.getElementById('lname').value == 0)
	{
		alert("Enter the Last Name")
		document.getElementById('lname').focus();
		return false;
	}
	else if(document.getElementById('email').value == 0)
	{
		alert("Enter the Email Address")
		document.getElementById('email').focus();
		return false;
	}
	else if(document.getElementById('phone').value == 0)
	{
		alert("Enter the Phone Number")
		document.getElementById('phone').focus();
		return false;
	}
	else if(document.getElementById('country_contact').value == 0)
	{
		alert("Choose your Country")
		document.getElementById('country_contact').focus();
		return false;
	}
	else if(document.getElementById('chk').checked == false)
	{
		alert("Have to accept Terms and condition")
		document.getElementById('chk').focus();
		return false;
	}
	else
	{
		xmlHttp=GetXmlHttpObject();	
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}
		var url="contact_me_ajax.php";
		url=url+"?fname="+document.getElementById('fname').value;
		url=url+"&lname="+document.getElementById('lname').value;
		url=url+"&email="+document.getElementById('email').value;
		url=url+"&phone="+document.getElementById('phone').value;
		url=url+"&country="+document.getElementById('country_contact').value;
		url=url+"&company="+document.getElementById('company').value;
		url=url+"&email_sent="+document.getElementById('email_sent').value;
		url=url+"&prod_id="+document.getElementById('prod_id').value;
		url=url+"&type="+document.getElementById('type').value;
		url=url+"&sid="+Math.random();
		alert(url);
		xmlHttp.onreadystatechange=function()
		{
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{
				alert(xmlHttp.responseText);
				document.getElementById("contact_me").style.display="none";
				document.getElementById("success_sent").style.display="block";
			}
			else if (xmlHttp.readyState!=4 || xmlHttp.readyState!="complete")
			{ 
			} 
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		setTimeout('document.getElementById("success_sent").style.display="none"',10);
	}
}
