//Post Form Javascripts

// $Id: $
// $HeadURL: $


// // Start of on focus js
function tes(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("testimonial").getElementsByTagName("div"); 
		
			for (var i=0; i<ar.length; i++){
				if(ar[i].className == "hepl_test") {
					ar[i].className = "hepl_test_off";
				}
			}
		document.getElementById(obj).className = "hepl_test";
	}
}


function hide_t(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("testimonial").getElementsByTagName("div"); 
		
			for (var i=0; i<ar.length; i++){
				if(ar[i].className == "hepl_test_off") {
					ar[i].className = "hepl_test_off";
				}
			}
		document.getElementById(obj).className = "hepl_test_off";
	}
}


function t_description()
{
	if(document.dataform.Description.value=='Provide key information like product specifications, estimated quantity, delivery instructions, packaging details etc.')
	{
		document.dataform.Description.value='';
		document.dataform.Description.className="txt-input3";
	}
}

function settext()
{
	if(document.dataform.Description.value=='')
	{
		document.dataform.Description.value='Provide key information like product specifications, estimated quantity, delivery instructions, packaging details etc.';
		
		document.dataform.Description.className="txt-input2";
	}
}	

function get()
{
	if(document.dataform.Description.value=='Provide key information like product specifications, estimated quantity, delivery instructions, packaging details etc.')
	{
		document.dataform.Description.className="txt-input2";
	}
	else
	{
		document.dataform.Description.className="txt-input3";
	}

	if( (cookie = getCookie("newImeshCTL")) > "")
	{
		Values = cookie.split("|");

		if (Values.length >= 9)
		{
			if (document.dataform.email.value.length == 0)
				document.dataform.email.value = Values[0];
			if(Values[1] == 'Mr.')
			{
				document.dataform.salute.selectedIndex=0;
			}
			else
			{
				document.dataform.salute.selectedIndex=1;
			}
			if (document.dataform.first_name.value.length == 0)
				document.dataform.first_name.value=Values[2];
/*			if (document.dataform.last_name.value.length == 0)
				document.dataform.last_name.value=Values[3];*/
			if (document.dataform.comp_name.value.length == 0)
				document.dataform.comp_name.value=Values[3];
			if (document.dataform.website.value.length == 0)
				document.dataform.website.value=Values[4];

			for (i=0;i<document.getElementById('country_len').value;i++)
			{
				if (document.dataform.country.options[i].value.toUpperCase() == Values[5].toUpperCase()) {
				break;
				}
			}
			if (i == document.getElementById('country_len').value)
			{
				if (document.dataform.country.selectedIndex == 0)
					document.dataform.country.selectedIndex=0;
			}
			else
			{
				if (document.dataform.country.selectedIndex == 0)
					document.dataform.country.selectedIndex=i;
			}

			if (document.dataform.ph_country.value.length == 0)
				document.dataform.ph_country.value=Values[6];
			if (document.dataform.ph_area.value.length == 0)
				document.dataform.ph_area.value=Values[7];
			if (document.dataform.ph_no.value.length == 0)
				document.dataform.ph_no.value=Values[8];

			document.dataform.country_name.value=document.dataform.country.options[document.dataform.country.selectedIndex].text;
		}
	}
return true;
}

function getCookie(Name)
{
	var search = Name + "="
	if (document.cookie.length > 0)
	{ // if there are any cookies
		offset = document.cookie.indexOf(search)
		if (offset != -1)
		{ // if cookie exists
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset)
			// set index of end of cookie value
			if (end == -1) end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}

	return "";
}


function productcode()
{
	//Getting parameter name from url starts
	var is_input = document.URL.indexOf('?');

	var code = '';
	if (is_input != -1)
	{
		addr_str = document.URL.substring(is_input+1, document.URL.length);
		strarr = addr_str.split("&");
		var param_nam = unescape((strarr[0].split("="))[0]);
		if(param_nam == "code")
		{
			code = unescape((strarr[0].split("="))[1]);
			code = code.replace(/\+/g," ");
		}
	}
	//Getting parameter name from url ends
	//End
	if(code)
	{
		document.dataform.title.value = code;
	}
}



function addEvent( obj, type, fn ){ 
   if (obj.addEventListener){ 
	  obj.addEventListener( type, fn, false );
   }
   else if (obj.attachEvent){ 
	  obj["e"+type+fn] = fn; 
	  obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
	  obj.attachEvent( "on"+type, obj[type+fn] ); 
   } 

}

addEvent(window, 'load', get);