function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
function openWindow(){
  	  	var text_value = document.getElementById("textfield").value;
  	     window.open("http://www.picosearch.com/cgi-bin/ts.pl?index=506385&query="+text_value,"CIMS2","location=Yes,directories=Yes,status=yes,menubar=Yes,scrollbars=Yes,resizable=yes,top=0,left=0,width="+(window.screen.availWidth-20)+",height="+(window.screen.availHeight-20));
  			
}
function getlength(max_val,fielname,msg){
	var desc = document.getElementById(fielname).value;
	if(desc.length > parseInt(max_val)){
		alert("You can enter maximum "+ max_val +" characters  in "+ msg+" field");
		return false;
	}else{
		return true;	
	}
			
}
function clear1(id,txt){
	if(document.getElementById(id).value==txt){
		document.getElementById(id).value="";
	}	
}
function setValue(id,txt){
	if(document.getElementById(id).value==""){
		document.getElementById(id).value=txt;
	}	
}
function cleararea(id,txt){
	if(document.getElementById(id).innerHTML==txt){
		document.getElementById(id).innerHTML="";
	}	
}
function settextArear(id,txt){
	if(document.getElementById(id).innerHTML==""){
		document.getElementById(id).innerHTML=txt;
	}	
}
function frm_submit(){
	if(document.getElementById("textfield2").value=="Name:" || isBlank(document.getElementById("textfield2").value)){
		alert("Please enter a Name field");
		return false;
	}else if((document.getElementById("textfield3").value).length!=11){
		alert("Mobile Number should be 11 digits.");
		return false;
	}else if(!getlength(255,"textarea","Comments")){
		return false;
	}else if(!getlength(50,"textfield2","Name")){
		return false;
	}else if(!getlength(15,"textfield5","Business No")){
		return false;
	}else{
		r = confirm("Do you  want to submit contact details? ");
		if(r){
			document.getElementById("frmcontact").submit();
		}	
	}	
}
function getKeyCode(e)
{
 if (window.event)
        return window.event.keyCode;
 else if (e)
    return e.which;
 else
    return null;
}
function imposeMaxLength(Object, MaxLen,event)
{
  var keyvalue = getKeyCode(event);
  if(keyvalue==8 || keyvalue==0 || keyvalue==1){
	return true;
  }else{			
	  return (Object.value.length <= MaxLen);
  }	
}


function frm_reset(){
	document.frmcontact.reset();
}


function isBlank(s){
	var st = String(s)
	if( s == 'null' || trimAll(st).length == 0 || s == null ){
		return true;
	}	
	return false;
}
function trimAll(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);
	}
	
	sString = removeSpaces(sString);
	return sString;
}