function edit(form)
{
document.getElementById(form).onkeypress="return true";
}

	


//Captcha code Starts
var d = new Date();
var epoch_time =(d.getTime()-d.getMilliseconds())/1000;
var randomnumber=Math.floor(Math.random()*9999);
var randomnumber1=Math.floor(Math.random()*9999);
var ran_num=randomnumber+"."+epoch_time+"."+randomnumber1;
// var url="http://www.media4trade.com/captchaserver?cRef="+ran_num+"&style=2";
var url="/cgi/get_captcha.cgi?cref="+ran_num+"&style=2";
function setCaptchaRef()
{
	document.postForm.captcha_ref.value = ran_num;
}
//Captcha code Ends

function ajaxFunction()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	
	return xmlHttp;
}



function trim(sString)
{ 
	while (sString.substring(0,1) == ' ')
	{
	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	}
	return sString;
}



function assign_hidden_param(Form)
{
	Form.usr_pass.value = Math.floor(Math.random()*9999)+100000;
	
	var is_input = document.URL.indexOf('?');
	
	if (is_input != -1)
	{
		var x;
		var addr_str='';
		var pname='';
		var strarr = new Array();
		
		addr_str = document.URL.substring(is_input+1, document.URL.length);
		strarr = addr_str.split("&");
		
		for (x in strarr)
		{
			if((strarr[x].split("="))[0] == "ref")
			{ 
				pname = unescape((strarr[x].split("="))[1]);
			}
		}
		
		Form.ref.value = pname;
	}
}

/* for text value start*/
function RegValue(FieldName) 
{

	if(FieldName.value == 'First Name')
	{
		FieldName.value = '';
		FieldName.className='txtf';
	}
	
	else if(FieldName.value == '') 
	{
		FieldName.value = 'First Name';
		FieldName.className='txtfa';			
	}
	
	else
	{
		FieldName.className='txtf';
	}
}

function RegeValue(FieldName) 
{

	if(FieldName.value == 'Last Name')
	{
		FieldName.value = '';
		FieldName.className='txtf';
	}
	
	else if(FieldName.value == '') 
	{
		FieldName.value = 'Last Name';
		FieldName.className='txtfa';			
	}
	
	else
	{
		FieldName.className='txtf';
	}
}



function AriaValue(FieldName) 
{
	if(FieldName.value == 'Area Code')
	{
		FieldName.value = '';
		FieldName.className='txtf';
	}
	
	else if(FieldName.value == '') 
	{
		FieldName.value = 'Area Code';
		FieldName.className='txtfa';			
	}
	
	else
	{
		FieldName.className='txtf';
	}
	
}

function PhonValue(FieldName) 
{

	if(FieldName.value == 'Phone Number')
	{
		FieldName.value = '';
		FieldName.className='txtf';
	}
	
	else if(FieldName.value == '') 
	{
		FieldName.value = 'Phone Number';
		FieldName.className='txtfa';			
	}
	
	else
	{
		FieldName.className='txtf';
	}
}

function CellValue(FieldName) 
{
	if(FieldName.value == 'Mobile / Cell Phone Number')
	{
		FieldName.value = '';
		FieldName.className='txtf';
	}
	
	else if(FieldName.value == '') 
	{
		FieldName.value = 'Mobile / Cell Phone Number';
		FieldName.className='txtfa';			
	}
	
	else
	{
		FieldName.className='txtf';
	}
}



function Check_ModReg(Form)
{
	assign_hidden_param(Form); // setting the hidden parameters of states & cites ...

	/* Trade offer feilds checking Starts... */

		var data = new Array();
		data =['Aceh','Afghanistan','Aland','Albania','Algeria','America','American Samoa','Andorra','Angola','Anguilla','Antarctica','Antigua And Barbuda','Argentina','Armenia','Aruba','Aryavarta','Aussi','Australia','Austria','Azerbaijan','BRD','Bahamas','Bahrain','Bangladesh','Barbados','Basutoland','Batavian Republic','Bechuanaland','Belarus','Belau','Belgian Congo','Belgium','Belize','Benin','Bermuda','Bharat','Bhutan','Bolivia','Bosnia And Herzegovina','Botswana','Bourkina-Fasso','Brazil','Britain','British Indian Ocean Territory','Brunei','Bulgaria','Burkina Faso','Burma','Burundi','Cambodia','Cameroon','Canada','Cape Verde','Catalonia','Cayman Islands','Central African Republic','Cesko','Ceylon','Chad','Chechnya','Chile','Chili','Chilli','China','China (Hong Kong S.A.R.)','China (Macau S.A.R.)','Christmas Islands','Cocos Islands','Colchis','Colombia','Commonwealth of Australia','Comoros','Congo','Congo Belge','Congo Brazzaville','Congo Kinshasa','Cook Islands','Costa Rica','Cote D Ivoire','Crna Gora','Croatia','Cuba','Cyprus','Czech Republic','Czechia','DRC','Dahomey','Democractic Republic Of Congo','Denmark','Deutschland','Djibouti','Dominica','Dominican Republic','Dominion of Canada','Down Under','Dutch Guiana','Dutch Republic','East Bengal','East Timor','Easter Island','Ecuador','Egypt','Eire','El Salvador','Ellice Islands','England','Equatorial Guinea','Eritrea','Espana','Estonia','Ethiopia','Faeroe Islands','Falkland Islands','Federal Republic of Germany','Federative Republic of Brazil','Fiji Islands','Finland','France','French Congo','French Guiana','French Polynesia','French Republic','French Somaliland','French Southern Territories','Gabon','Gambia','Gandhar','Gaul','Georgia','Germany','Ghana','Gibraltar','Great Britain','Greece','Greenland','Grenada','Guadeloupe','Guam','Guatemala','Guinea','Guinea','Guinea-Bissau','Guyana','Haiti','Haute-Volta','Heard And Mcdonald Islands','Hellas','Hellenic Republic','Hind','Hindustan','Holland','Holy See','Honduras','Hong Kong','Hrvatska','Hungary','Iberia','Iceland','India','Indonesia','Iran','Iraq','Ireland','Islamic Republic of Pakistan','Island','Islas Malvin','Israel','Italy','Iveria','Ivory Coast','Jamaica','Japan','Jordan','KSA','Kampuchea','Kazakhstan','Keeling Islands','Kenya','Khmer','Khmer Republic','Kingdom of Cambodia','Kingdom of Lesotho','Kingdom of Romania','Kingdom of Saudi Arabia','Kingdom of Thailand','Kiribati','Kiwi','Korea','Korea, North','Kroatien','Kuwait','Kyrgyzstan','Lao','Lao Peoples Democratic Republic','Latvia','Lebanon','Lesotho','Liberia','Libya','Liechtenstein','Lithuania','Luxembourg','MEX','MX','Macau','Macedonia','Madagascar','Mainland China','Malawi','Malaysia','Maldives','Mali','Malta','Marshall Islands','Martinique','Mauritania','Mauritius','Mayotte','Mesopotamia','Mexico','Micronesia','Moldova','Monaco','Mongolia','Montenegro','Montserrat','Morocco','Mount Athos','Mozambique','Myanmar','Namibia','Nauru','Nepal','Netherlands','Netherlands Antilles','Netherlands Guiana','New Caledonia','New Zealand','Nicaragua','Niger','Nigeria','Niue','Norfolk Island','North Korea','Northern Ireland','Northern Mariana Islands','Northern Rhodesia','Norway','Nyasaland','Oman','Oubangui-Chari','Oz','PRC','Pakistan','Palau','Panama','Papua New Guinea','Paraguay','Peoples Republic of Bangladesh','Peoples Republic of China','Peoples Republic of Kampuchea','Persia','Peru','Philippines','Pindorama','Pitcairn Island','Poland','Polska','Porto Rico','Portugal','Portugese Guinea','Puerto Rico','Qatar','Qazaqstan','RF','Republic of Benin','Republic of Botswana','Republic of Dijbouti','Republic of Hungry','Republic of India','Republic of Ireland','Republic of Kazakhstan','Republic of Malawi','Republic of Moldova','Republic of Palau','Republic of Poland','Republic of Rwanda','Republic of Serbia','Republic of Singapore','Republic of Sudan','Reunion','Rhodesia','Romania','Roos','Rumania','Russia','Russian Federation','Rwanda','SGSSI','Saint Helena','Saint Kitts And Nevis','Saint Lucia','Saint Pierre And Miquelon','Saint Vincent And The Grenadin','Samoa','San Marino','Sao Tome And Principe','Saudi Arabia','Saudia','Scotland','Senegal','Serbia','Serbia And Montenegro','Seychelles','Shqiperia','Shri Vijaya','Siam','Sierra Leone','Singapore','Slovakia','Slovenia','Solomon Islands','Somalia','South Africa','South Georgia','South Sandwich Islands','Spain','Sri Lanka','St Helena','St Kitts And Nevis','St Lucia','St Pierre And Miquelon','St Vincent And The Grenadin','St. Helena','St. Kitts And Nevis','St. Lucia','St. Pierre And Miquelon','St. Vincent And The Grenadin','Sudan','Suriname','Svalbard And Jan Mayen Islands','Swaziland','Sweden','Swiss Confederation','Switzerland','Syria','Taiwan','Tajikistan','Tanganyika and Zanzibar','Tanzania','Thailand','The Bahamas','The Gambia','The Netherlands','The States','Tibet','Togo','Tokelau','Tonga','Trinidad And Tobago','Tunisia','Turkey','Turkmenistan','Turks And Caicos Islands','Tuvalu','UAE','UK','US','USA','Ubangi-Shari','Uganda','Ukraine','Ungarn','United Arab Emirates','United Kingdom','United Mexican States','United States','United States Minor Outlying I','United States Of America','United States of Brazil','Upper Volta','Uruguay','Uzbekistan','Vanuatu','Vatican City','Venezuela','Vietnam','Virgin Islands (British)','Virgin Islands (Us)','Wales','Wallis And Futuna Islands','West Germany','Western Sahara','Xile','Yemen','Yugoslavia','Zaire','Zambia','Zanzibar','Zimbabwe'];


	if(Form.title.value == "") {
		alert("Kindly enter Products / Services you are looking for.");
		Form.title.focus();
		return false;
	}

	if(Form.title.value.length < 3 && trim(Form.title.value) != "") {
		alert("Your product name should not be less than 3 charecters.");
		Form.title.focus();
		return false;
	}


	if(Form.title.value.length > 100) {
		alert("Your product name should not be greater than 100 charecters.");
		Form.title.focus();
		return false;
	}

	if(trim(Form.desc.value) == "" || trim(Form.desc.value) == "Please enter your buying requirements in detail. Provide key information like product specifications, estimated quantity etc." ) {
		alert("Kindly describe your Products / Services in detail.");
		Form.desc.focus();
		return false;
	}

	if(Form.desc.value.length < 20) {
		alert("Your description should not be less than 20 charecters.");
		Form.desc.focus();
		return false;
	}

	if(Form.desc.value.length > 1200) {
		alert("Your description should not be greater than 1200 charecters.");
		Form.desc.focus();
		return false;
	}

	var radio_choice1 = false;
	var period_index;
	for (counter = 0; counter < Form.period.length; counter++)
	{
		if (Form.period[counter].checked)
		{
		radio_choice1 = true;
		period_index = counter;
		}
	}
	if (!radio_choice1)
	{
		if(Form.name=="postForm")
		{
			alert("Kindly select how soon you want to purchase.");
		}
		else
		{
			alert("Kindly select your Offer Validity.");
		}
		Form.period[0].focus();
		return false;
	}


	if(Form.first_name.value == "" || Form.first_name.value == "First Name") 
	{
		alert("Kindly enter your First Name.");
		Form.first_name.focus();
		return false;
	}

	if((/[0-9]+/.test(Form.first_name.value)))
	{
		alert("Kindly enter your First Name in alphabets only.");
		Form.first_name.focus();
		return false;
	}


	
	
	if(Form.first_name.value.length < 3) {
		alert("Your Name should not be less than 3 charecters.");
		Form.first_name.focus();
		return false;
	}


	if((/[0-9]+/.test(Form.last_name.value)))
	{
		alert("Kindly enter your Last Name in alphabets only.");
		Form.last_name.focus();
		return false;
	}



	if(Form.email.value == "" ) {
		alert("Kindly enter your E-mail ID.");
		Form.email.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(Form.email.value))) {
			alert("Invalid Email ID. Kindly enter the correct ID.");
			Form.email.focus();
			return (false);
	}



	
	
	
	if (Form.qty && Form.qty.value == "")
	{
		alert("Please enter your Quantity.");
		Form.qty.focus();
		return false;
	}


	if(Form.country_name.value == "" || Form.country_name.value == 0) 
	{
		alert("Kindly enter your Country.");
		Form.country_name.focus();
		return false;
	}
	
// 	if(Form.ph_area.value == "" || Form.ph_area.value == "Area code" ) {
// 		alert("Kindly enter Area Code for Telephone Number.");
// 		Form.ph_area.focus();
// 		return false;
// 	}

	if((Form.ph_area) && Form.ph_area.value !='Area Code')
	{
		
		if(isNaN(Form.ph_area.value))
		{
			alert("Telephone (Area Code) should be an integer value.");
			Form.ph_area.focus();
			return false;
		}
		
		if(Form.ph_area.value.length > 6) 
		{
			alert("Telephone (Area Code) should not exceed 6 characters.");
			Form.ph_area.focus();
			return false;
		}
	}

	if (((Form.ph_no.value =='Phone Number') || (Form.ph_no.value.length == 0 )) && ((Form.mobile.value == 'Mobile / Cell Phone Number') || (Form.mobile.value.length == 0)))
	{
		alert ("Kindly enter either Phone Number or Mobile Number.");
		Form.ph_no.focus();
		return false;
	}
	
	var mobile_val = Form.mobile.value;
	if(mobile_val != 'Mobile / Cell Phone Number')
	{
		var check_numeric=/(^\d+$)|(^\d+\.\d+$)/;
		if(!(check_numeric.test(mobile_val)))
		{
			alert ("Kindly enter numeric value in Mobile Number.");
			Form.mobile.focus();
			return false;
		}
	}

	if ((Form.captcha_text) && Form.captcha_text.value.length == 0)  {
			alert ("Kindly enter the code as appearing in the Image.");
			Form.captcha_text.focus();
			return false;
	}


	if (Form.first_name.value.length  > 20)
	{
		alert("First Name should not exceed 20 characters.");
		Form.first_name.focus();
		return false;
	}

	if (Form.email.value.length > 100)
	{
		alert("Email should not exceed 100 characters.");
		Form.email.focus();
		return false;
	}
	
	if(Form.country_name.value.length > 40) {
		alert("Country Name should not exceed 40 characters.");
		Form.country_name.focus();
		return false;
	}
	if(Form.ph_country.value.length > 6) {
		alert("Telephone (Country Code) should not exceed 6 characters.");
		Form.ph_country.focus();
		return false;
	}

	

	

	if(Form.ph_no.value.length > 35) {
		alert("Telephone (Number) should not exceed 35 characters.");
		Form.ph_no.focus();
		return false;
	}
	
	if(Form.comp_name.value.length > 100) {
		alert("Company Name should not exceed 100 characters.");
		Form.comp_name.focus();
		return false;
	}

	if((Form.last_name) && (Form.last_name.value == 'Last Name'))
	{
		Form.last_name.value = '';
	}

	if((Form.ph_area) && (Form.ph_area.value == 'Area Code'))
	{
		Form.ph_area.value = '';
	}
	if ((Form.ph_no) && (Form.ph_no.value =='Phone Number'))
	{
		Form.ph_no.value = '';
	}
	if((Form.mobile) && (Form.mobile.value == 'Mobile / Cell Phone Number'))
	{
		Form.mobile.value = '';
	}


	return true;
}



