
  function Printhis(theurl)
   {
     var thefilename="view_print.asp?fname="+ theurl;
     window.open(thefilename,'','height=600,width=700,resizable=0,toolbars=no,scrollbars=no');  
   }

  function Tell_Associate(theurl)
  {
    thefilename="tell_a_associate.asp?fname="+ theurl;
	window.open(thefilename,'','height=600,width=700,resizable=0,toolbars=no,scrollbars=no');
  }

//**************************************************************************
// FUNCTION TO VALIDATE EMAIL FOR HEADER NEWSLETTER
//**************************************************************************
 function Newslettervalidate()
  {
    var nemail=document.getElementById("nemail").value;
 
    if(nemail.value=="")
	{
	  alert("Enter the Email ID");
	   return false;
    }
    else if(checkemail(document.getElementById("nemail")))
    {      
     return false;
    }	  
	else
	{
	  var theurl="newsletter_submit.asp?email="+ nemail;
	  window.open(theurl,'','height=150,width=480,resizable=0,toolbars=no,scrollbars=no'); 
	}	
  }  
  

 //**************************************************************************
// FUNCTION TO CHECK FOR REQUEST PRODUCT INFORMATION
//**************************************************************************
  function requestvalidate()
  {
	var contname=document.form1.contname.value;
    var compname=document.form1.compname.value;
	var phone=document.form1.phone.value;
	var email=document.form1.email.value;
	var email1=document.form1.email1.value;	
    var comments=document.form1.comments.value;
	var hearabout=document.form1.hearabout.value;
	var hearother=document.form1.hearother.value;	
	 if(contname=="")
	{
	  alert("Enter the Name");
	  document.form1.contname.focus();
	  return false;
	} 
	else if(compname=="")
	{
	  alert("Enter the company name");
	  document.form1.compname.focus();
	  return false;
	} 
		else if(phone=="")
	{
	  alert("Enter the Phone Number");
	  document.form1.phone.focus();
	  return false;
	} 
 	else if(email=="")
	{
	  alert("Enter the correct and valid email id");
	  document.form1.email.focus();
	  return false;
	} 
    else if(checkemail(document.form1.email))
    {
   return false;
   } 
  	else if(email1=="")
	{
	  alert("Enter the correct and valid email id");
	  document.form1.email1.focus();
	  return false;
	} 
    else if(checkemail(document.form1.email1))
    {
    document.form1.email1.focus();
    return false;
   }    
   else if(email!=email1)
	{
	  alert("Re-enter the correct and valid email id");
	  document.form1.email1.focus();
	  return false;
	}  
	else if((hearabout=="Others")&&(hearother==""))
	{
	  alert("How did you hear about in other way");
	  document.form1.hearother.focus();
	  return false;	
	}	
	else if(comments=="")
	{
	  alert("Enter the comments/feedback");
	  document.form1.comments.focus();
	  return false;
	} 	
}


  
 //**************************************************************************
// FUNCTION TO CHECK FOR REQUEST INFORMATION
//**************************************************************************
function infovalidate()
{
	var contname=document.form1.contname.value;
    var compname=document.form1.compname.value;
	var phone=document.form1.phone.value;
	var email=document.form1.email.value;
	var email1=document.form1.email1.value;	
    var comments=document.form1.comments.value;
	var csubject=document.form1.csubject.value;
	var hearabout=document.form1.hearabout.value;
	var subjectother=document.form1.subjectother.value;	
	var hearother=document.form1.hearother.value;	
	
		
    if(contname=="")
	{
	  alert("Enter the Name");
	  document.form1.contname.focus();
	  return false;
	} 
	else if(compname=="")
	{
	  alert("Enter the company name");
	  document.form1.compname.focus();
	  return false;
	} 
		else if(phone=="")
	{
	  alert("Enter the Phone Number");
	  document.form1.phone.focus();
	  return false;
	} 
 	else if(email=="")
	{
	  alert("Enter the correct and valid email id");
	  document.form1.email.focus();
	  return false;
	} 
    else if(checkemail(document.form1.email))
    {
   return false;
   } 
  	else if(email1=="")
	{
	  alert("Enter the correct and valid email id");
	  document.form1.email1.focus();
	  return false;
	} 
    else if(checkemail(document.form1.email1))
    {
    document.form1.email1.focus();
    return false;
   }    
   else if(email!=email1)
	{
	  alert("Re-enter the correct and valid email id");
	  document.form1.email1.focus();
	  return false;
	}  
	else if(csubject==0)
	{
	  alert("Select the subject of contact");
	  document.form1.csubject.focus();
	  return false;
	} 
	else if((csubject=="Other")&&(subjectother==""))
	{
	  alert("Please specify the Other Subject");
	  document.form1.subjectother.focus();
	  return false;	
	}
	else if((hearabout=="Others")&&(hearother==""))
	{
	  alert("How did you hear about in other way");
	  document.form1.hearother.focus();
	  return false;	
	}	
	else if(comments=="")
	{
	  alert("Enter the Comments/Questions");
	  document.form1.comments.focus();
	  return false;
	}
 	
}


//**************************************************************************
// FUNCTION TO CHECK FOR CONTENT MANAGEMENT
//**************************************************************************
function Uptproductvalidation()
{
  var txt1=document.form1.textarea1.value;
  var txt2=document.form1.textarea2.value;
  var txt3=document.form1.textarea3.value; 
  var txt4=document.form1.textarea4.value;
  
  if(txt1=="")
  {
    alert("Enter the product Short description");
    document.form1.textarea1.focus();
	return false;
  }
  else if(txt2=="")
  {
    alert("Enter the product Long description");
	document.form1.textarea2.focus();
	return false;	
  }
  else if(txt3=="")
  {
    alert("Enter the product specification");
	document.form1.textarea3.focus();
	return false;	
  }
  else if(txt4=="")
  {
     alert("Enter the product application");
	document.form1.textarea4.focus();
	return false;	 
  }       
}  
	


//**************************************************************************
// FUNCTION TO CHECK FOR CONTENT MANAGEMENT
//**************************************************************************
function LinkValidation()
{
  var linkmenu=document.form1.mlinks.value;
  var sublinkmenu=document.form1.slinks.value;  
  var linktxt=document.form1.textarea1.value;
  var ed_length=document.form1.textarea1.value.length;   
  if(linkmenu=="")
  {
    alert("Select the Main Menu");
	document.form1.mlinks.focus();
	return false;	
  }
    if(sublinkmenu=="")
  {
    alert("Select the Sub Menu");
	document.form1.slinks.focus();
	return false;	
  }
   else if(linktxt=="")
  {
    alert("Enter More Content");
	//document.form1.textarea1.focus();
	return false;	
  }  
   else if(ed_length=0)
  {
    alert("Enter More Content");
	//document.form1.textarea1.focus();
	return false;	
  }  
  
}
//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************

//**************************************************************************
//  FUNCTION FOR SET COMBO
//**************************************************************************
 function setcombo(obj,val)
 {
   if(val.length>0)
    {
	 for(i=0;i<obj.options.length;i++)
	  {
	    if(obj.options[i].value==val) 
		obj.options[i].selected=true;
	  }
	 }	
	    else	
    	obj.options[0].selected=true;
  } 
//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************
//**************************************************************************
//  Validation for Select All Checkbox
//**************************************************************************

function selectall(a,b)
{
  var checked=false;
  if(a.checked)
     checked=true;
  var i=0;	 
  var v=b.length;
  for(i=0;i<v;i++)
  {
     b[i].checked=checked;
  } 
  if (i==0)
    b.checked=checked;
}
//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************
//**************************************************************************
//  FUNCTION TO CHECK FOR THE VALID EMAIL ID
//**************************************************************************

function checkemail(obj)
 {
  if(!isEmailAddr(obj.value))
    {
	  alert("Enter the Correct and valid Email ID");
	  obj.value="";
	  obj.focus();
	  return true;
	}
	else
	return false; 
 }
 function isEmailAddr(email)
 {
  var result=false;
  var thestr=new String(email);
   var index= thestr.indexOf("@");
  if(index>0)
   {
    var pindex=thestr.indexOf(".",index);
	if((pindex>index+1)&&(thestr.length>pindex+1))
	   result=true;
	}
	return result;
 }	      	    
//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************
//**************************************************************************
//  FUNCTION TO CHECK FOR LOGIN
//**************************************************************************
function LoginCheck()
{
  var user=document.form1.username.value;
  var pass=document.form1.password.value 
  
  if(user=="")
  {
    alert("Enter the Username");
	document.form1.username.focus();
	return false;
  }
  if(pass=="")
  {
    alert("Enter the Password");
	document.form1.password.focus();
	return false;
  }  
}
//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************
//**************************************************************************
//  FUNCTION FOR AJAX IMPLEMENTATION
//**************************************************************************

var xmlHttp

function showContent(str,theurl)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url=theurl;
url=url+"?q="+str;
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
 
function showContent1(str,theurl)
{ 
 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url=theurl;
url=url+"?sublink="+str;
 
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged1;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 
 
function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}

function stateChanged1() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("txtContent").innerHTML=xmlHttp.responseText;
  generate_wysiwyg('textarea1');
}
}
 
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************
//**************************************************************************
//  FUNCTION FOR USERNAME/ PASSWORD CHANGE ADMIN
//**************************************************************************
 function UserChange()
 {
   var user=document.form1.username.value;
   var nuser=document.form1.nusername.value;   
   var cuser=document.form1.cusername.value 
  
  if(user=="")
  {
    alert("Enter the Current Username");
	document.form1.username.focus();
	return false;
  }
  else if(nuser=="")
  {
    alert("Enter the New Username");
	document.form1.nusername.focus();
	return false;
  }
  else if(cuser=="")
  {
    alert("Confirm the New Username");
	document.form1.cusername.focus();
	return false;
  } 
    else if(nuser!=cuser)
  {
    alert("New Username and Confrim Username are different");
	document.form1.cusername.focus();
	return false;
  }     
 }
 
 function PassChange()
 {
   var pass=document.form2.password.value;
   var npass=document.form2.npassword.value;   
   var cpass=document.form2.cpassword.value 
  
  if(pass=="")
  {
    alert("Enter the Current Password");
	document.form2.password.focus();
	return false;
  }
  else if(npass=="")
  {
    alert("Enter the New Password");
	document.form2.npassword.focus();
	return false;
  }
  else if(cpass=="")
  {
    alert("Confirm the New Password");
	document.form2.cpassword.focus();
	return false;
  } 
    else if(npass!=cpass)
  {
    alert("New Password and Confrim Password are different");
	document.form2.cpassword.focus();
	return false;
  }     
 }
//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************
//**************************************************************************
//  FUNCTION FOR SEARCH OF REQUEST FOR CALL BACK
//**************************************************************************

function SearchCallback()
{
  var searchby=document.form1.searchby.value;
  var txtsearch=document.form1.texttosearch.value;
  if(searchby=="")
  {
    alert("Select option to search by");
	document.form1.searchby.focus();
	return false;
  }
  else if(txtsearch=="")
  {
    alert("Enter the text to search");
	document.form1.texttosearch.focus();
	return false;
  }
}
//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************
//**************************************************************************
//  FUNCTION FOR MULTIPLE DELETE ALERT FOR DELETING REQUEST FOR CALL BACK
//**************************************************************************
 function checkvalidate()
   { 
	flag=0;
	var v=form2.jobno.length;	
	for(i=0;i<v;i++)
     {
      if(document.form2.jobno[i].checked)
       {
          flag=flag+1;		  	 
       }
     }     
      if ((flag==0) && (document.form2.jobno.checked))
	  flag++;	   
      if(flag==0)
	{
	  alert("You must choose atleast one record to Delete");
   	  return false;
	}
	else
	{
	 if(confirm("Are you sure of deleteing " +  flag + " records"))
	   return true;
	 else
	   return false;
       }
    }  
//**************************************************************************
//  END OF FUNCTION  
//**************************************************************************
//**************************************************************************
//  FUNCTION FOR  VALIDATING THE REQUEST CAL BACK
//**************************************************************************
function callbackvalidate()
{
    var region=document.form1.region.value;
    var contname=document.form1.contname.value;
	var compname=document.form1.compname.value;
	var country=document.form1.country.value;
	var phone=document.form1.phone.value;	
    var email=document.form1.email.value;
	var datetocall=document.form1.datetocall.value;
	var timetocall=document.form1.timetocall.value;
	var reasonofcalling=document.form1.reasonofcalling.value;	
	 		
  if(region=="")
	{
	  alert("Please select the region");
	  document.form1.region.focus();
	  return false;
	} 
 else if(contname=="")
	{
	  alert("Please enter the contact name");
	  document.form1.contname.focus();
	  return false;
	} 
	else if(compname=="")
	{
	  alert("Please enter the company name");
	  document.form1.compname.focus();
	  return false;
	} 
		else if(country=="")
	{
	  alert("Please enter the country name");
	  document.form1.country.focus();
	  return false;
	}
  else if(phone=="")
	{
	  alert("Please enter the phone number");
	  document.form1.phone.focus();
	  return false;
	}
 	else if(email=="")
	{
	  alert("Enter the correct and valid email id");
	  document.form1.email.focus();
	  return false;
	} 
    else if(checkemail(document.form1.email))
    {
   return false;
   } 
   
    
    else if(datetocall=="")
	{
	  alert("Please enter the Date to Call");
	  document.form1.datetocall.focus();
	  return false;
	} 
    else if(timetocall=="")
	{
	  alert("Please enter the Time to Call");
	  document.form1.timetocall.focus();
	  return false;
	} 	
    else if(reasonofcalling=="")
	{
	  alert("Please enter reason of calling");
	  document.form1.reasonofcalling.focus();
	  return false;
	} 		
	 		
}
