function loadcategory(macvalue)
{
	 
	var cat;
	
	if ( document.myform.section[0].checked )
		cat=document.myform.section[0].value;
	else
		cat=document.myform.section[1].value;

	if(cat=="regular")
	{
		
	document.myform.category.options.length = 0;
	if (macvalue =="mac")
		{
		document.myform.category.options[0] = new Option('Machinery','21');	  
		document.myform.category.options[11] = new Option('Accessory','16');
			
		}
		else
		{
			document.myform.category.options[11] = new Option('Machinery','21');	  
	        document.myform.category.options[0] = new Option('Accessory','16');
		}
		
	//document.myform.category.options[0] = new Option('Accessory','16');
	document.myform.category.options[1] = new Option('Fabric','13');
	document.myform.category.options[2] = new Option('Fibre','11');
	document.myform.category.options[3] = new Option('Garment','14');
	document.myform.category.options[4] = new Option('Home Textiles','18');
	document.myform.category.options[5] = new Option('Leather & Footwear','17');
	document.myform.category.options[6] = new Option('Trims','15');
	document.myform.category.options[7] = new Option('Yarn','12');
	document.myform.category.options[8] = new Option('Dyes','19');	
	document.myform.category.options[9] = new Option('Equipment','20');
	document.myform.category.options[10] = new Option('FeedStock','22');			
	//document.myform.category.options[11] = new Option('Machinery','21');	  
	document.myform.category.options[12] = new Option('Handloom','23');	  	
	document.myform.category.options[13] = new Option('Technical Textiles','24');
	document.myform.category.selectedIndex = 0;
	}
	else 
	{
	document.myform.category.options.length = 0;
	document.myform.category.options[0] = new Option('Accessory','16');
	document.myform.category.options[1] = new Option('Fabric','13');
	document.myform.category.options[2] = new Option('Fibre','11');
	document.myform.category.options[3] = new Option('Garment','14');
	document.myform.category.options[4] = new Option('Home Textiles','18');
	document.myform.category.options[5] = new Option('Leather & Footwear','17');
	document.myform.category.options[6] = new Option('Trims','15');
	document.myform.category.options[7] = new Option('Yarn','12');
	document.myform.category.selectedIndex = 0;
}
populateProduct( document.myform.category.options[document.myform.category.selectedIndex].text )
}
// new code -----------
function populateProduct(ccode)
{

	ccode = ccode.replace( "&" , "~" )
	ccode= encodeURI(ccode) 

	try
	{
		var xmlHttp = null
		if (typeof window.ActiveXObject != 'undefined' )
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{
			xmlHttp = new XMLHttpRequest();
		}
		
		var url = "new_bindProduct.asp?ccode="+ccode + "&sid=" + Math.random();

		xmlHttp.open("GET", url, false);	
		xmlHttp.send(null);

		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		{
			document.getElementById("productDiv").innerHTML=xmlHttp.responseText;
			document.getElementById("productDiv").style.visibility="visible";
			document.getElementById("productDiv").style.display = "block";
			
		}
		

	}
	catch(e)
	{
		//do nothing
	}
}

//----------------------

function SubmitForm(objFrm)
{	
	if ( validpersonalinfo(objFrm) == false )
	{
	return false;
	}
	document.getElementById("divContact").style.visibility="hidden";	


	if ( document.myform.section[0].checked == true)
	{
		section = document.myform.section[0].value;
	}
	else
	{
		section = document.myform.section[1].value;
	}
	
	category = document.myform.category.value;
	category = category.replace( "&" , "~" )
	category = encodeURI(category);	
	product = document.myform.product.value;
	product = document.myform.product.options[document.myform.product.selectedIndex].text;

	serviceban = document.getElementById("serviceban").value;

	if ( serviceban == "buyer")
	{
		offerType = "Buyer"
		offerTypeMsg = "M"
	}
	else
	{
		if ( document.myform.offerType.length )
		{
			if ( document.myform.offerType[0].checked == true)
			{
				offerType = document.myform.offerType[0].value;
			}
			else
			{
				offerType = document.myform.offerType[1].value;
			}
		}
		else
		{
			offerType = document.myform.offerType.value
		}
		offerTypeMsg = ""
	}
	
	name = document.myform.name.value;	
	company_name = document.myform.company_name.value;	
	email = document.myform.email.value;		
	country = document.myform.country.value;	
	phone = document.myform.phone.value;	
	url = document.myform.url.value;	
	mailerstatus = document.myform.mailerstatus.value;	
	postingtype= document.myform.postingtype.value;
	description1 = document.myform.description1.value;	
	
	quentity = document.myform.txtquentity.value;	
	price = document.myform.txtPrice.value;	
	unitQuantity = document.myform.selUnit.value;	
	currencyprice = document.myform.selCurrency.value;	
	txtkeywords = document.myform.txtkeywords.value;	
	
	document.getElementById("divContact").style.visibility="hidden";		
	//xmlHttpReceive = GetXmlHttpObject(CallbackReceiveRequestContact);
	
	//new code -----------------------
			var xmlHttp = null
		if (typeof window.ActiveXObject != 'undefined' )
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{
			xmlHttp = new XMLHttpRequest();
		}
		
	var szURL = "insertProduct.asp?section=" + section + "&category=" + category + "&product=" + product + "&offerType=" + offerType + "&description1=" + description1 + "&name=" + name + "&company_name=" + company_name + "&email=" + email + "&country=" + country + "&phone=" + phone + "&url=" + url + "&mailerstatus=" + mailerstatus + "&postingtype=" + postingtype + "&offerTypeMsg=" + offerTypeMsg + "&sid=" + Math.random()+ "&quentity=" + quentity+ "&price=" + price+ "&unitQuantity=" + unitQuantity+ "&currencyprice=" + currencyprice+ "&txtkeywords=" + txtkeywords;	
	 
		xmlHttp.open("GET", szURL, false);	
		xmlHttp.send(null);

	//------------------------------
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		{
			document.getElementById("divContact").innerHTML=xmlHttp.responseText;
			document.getElementById("divContact").style.visibility="visible";
			document.getElementById("divContact").style.display = "block";
		}

	//SendXmlHttpRequest(xmlHttpReceive, szURL);	
}

function validpersonalinfo(objFrm)
{	
	serviceban = document.getElementById("serviceban").value;

	if  (serviceban == "buyer" )
	{
	}
	else
	{
		var flag = false;
		var return1 = false;
		for ( i = 0; i < document.myform.section.length; i++ )
		{
			if ( objFrm.section[i].checked )
				return1 = true;
		}
		if ( return1 == false )
		{
			alert("Please provide Trade Lead Type");
			objFrm.section[0].focus();
			return false;
		}
		
		if ( document.myform.offerType.length )
		{
			for ( i = 0 ; i < objFrm.offerType.length ; i++ )
			{
				if ( objFrm.offerType[i].checked )
					flag = true;
			}			
		}
		else
		{
			flag = true;
		}
		if ( flag == false )
		{
			alert("Please provide Trade Lead Status");
			objFrm.offerType[0].focus();
			return false;
		}
	}	
	
	if ( document.getElementById("description1").value == "" )
	{
		alert("Please enter product description");
		document.getElementById("description1").focus();
		return false;
	}
	
	if (document.getElementById("name").value == "" )
	{
		alert("Please, Enter Name");
		document.getElementById("name").focus();
		return false;
	}
	
	if (document.getElementById("company_name").value == "" )
	{
		alert("Please, Enter company_name");
		document.getElementById("company_name").focus();
		return false;
	}
	
	if (document.getElementById("country").value == "" )
	{
		alert("Please, Enter country");
		document.getElementById("country").focus();
		return false;
	}		

	if (document.getElementById("email").value == "" )
	{
		alert("Please, Enter email");
		document.getElementById("email").focus();
		return false;
	}

	if ( document.getElementById("email").value == "" )
	{
		alert("Please enter valid Eamil Id");
		document.getElementById("email").focus();
		return false;
	}
	else if( document.getElementById("email").value.indexOf("@") < 1 )
	{
		alert("Please enter valid Eamil Id");
		document.getElementById("email").focus();
		return false;
	}	
	
	else if( document.getElementById("email").value.search(/[^A-Za-z0-9@;._-]/) >= 0 )
	{
		alert("Please enter valid Eamil Id.");
		document.getElementById("email").focus();
		return false;
	}
	else if( document.getElementById("email").value.indexOf("/") > 1 || document.getElementById("email").value.indexOf(",") > 1 )
	{
		alert("Please enter valid Eamil Id.");
		document.getElementById("email").focus();
		return false;
	}
	
	cnt = 0;
	instr = document.getElementById("email").value.toString()
	
	for(var i=0;i<document.getElementById("email").length;i++)
	{
		var char1=document.getElementById("email").charAt(i)
		if ( char1 == "@" )
		{
			cnt=cnt+1;
		}
	}					
	if( cnt > 1 )
	{
		alert("Please enter valid Eamil Id.");
		document.getElementById("email").focus();
		return false;
	}

	
	if (document.getElementById("phone").value == "" )
	{
		alert("Please, Enter phone");
		document.getElementById("phone").focus();
		return false;
	}	
									
	return true;
}
