function validateForm(){

var okSoFar =true
var errorMessage=""

if (document.frmUpload.File.value!=''){
 if (Right(document.frmUpload.File.value,3)!="csv" && Right(document.frmUpload.File.value,3)!="CSV" && Right(document.frmUpload.File.value,3)!="xls" && Right(document.frmUpload.File.value,3)!="XLS" && Right(document.frmUpload.File.value,4)!="xlsx" && Right(document.frmUpload.File.value,4)!="xlsx" && Right(document.frmUpload.File.value,3)!="zip" && Right(document.frmUpload.File.value,3)!="pdf" && Right(document.frmUpload.File.value,3)!="doc" && Right(document.frmUpload.File.value,4)!="docx" && Right(document.frmUpload.File.value,3)!="txt" && Right(document.frmUpload.File.value,3)!="TXT") {
    okSoFar=false
    errorMessage = "File Type not supported!"
    document.frmUpload.File.focus()
  }
}
if (okSoFar==true) {
    document.frmUpload.submit()
   }
  else 
   alert(errorMessage)
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

  function callsourcedetails(leadid) {
   props=window.open('callsourcedetails.asp?leadid='+leadid+'', 'poppage', 'toolbars=1, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=500, height=350, left = 400, top = 109');
  }
  
  function userlog(idUser) {
   props=window.open('userlog.asp?idUser='+idUser+'', 'poppage', 'toolbars=1, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=350, height=350, left = 400, top = 109');
  }
  function sendEmail(LeadID,idlettertype) {
   props=window.open('sendEmail_29.asp?idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=350, height=400, left = 400, top = 109');
  }



  function changeclose(LeadID) {
   props=window.open('/changeclose.asp?LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=250, height=200, left = 400, top = 109');
  }

  function sendEmail_allstate(LeadID,idlettertype) {
   props=window.open('sendEmail_196.asp?idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=600, left = 400, top = 109');
  }
  
  function sendEmail_allstateAttach(LeadID,idlettertype) {
   props=window.open('sendEmail_allstateAttach_196.asp?idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=600, left = 400, top = 109');
  }
  
  function sendEmail_98(LeadID,idlettertype) {
   props=window.open('sendEmail_98.asp?idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=650, height=700, left = 400, top = 109');
  }

  function openCredit(LeadID,idlettertype,strReportType,number) {
   props=window.open('retreivecredit.asp?strReportType='+strReportType+'&n='+number+'&idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=800, height=1000, left = 400, top = 109');
  }

  function newLeadfile(LeadID,idlettertype) {
   props=window.open('/newLeadFile.asp?idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=200, left = 300, top = 109');
  }
  
  function newJobfile(idjob,filetypeid) {
   props=window.open('/newJobFile.asp?idjob='+idjob+'&filetypeid='+filetypeid+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=200, left = 300, top = 109');
  }

  function newlogo(intClientID) {
   props=window.open('newlogo.asp?intClientID='+intClientID+'', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=150, left = 300, top = 109');
  }
  function leadlog(LeadID,idlettertype) {
   props=window.open('/leadlog.asp?idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=350, height=350, left = 400, top = 109');
  }

  function editComment(LeadID,idlettertype,intClientID,idComment) {
   props=window.open('/editcomment.asp?idlettertype='+idlettertype+'&idComment='+idComment+'&intClientID='+intClientID+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=300, left = 300, top = 109');
  }

  function newComment(LeadID,iduser) {
   props=window.open('newcomment.asp?iduser='+iduser+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=300, left = 300, top = 109');
  }

  function managerComment(idjob) {
   props=window.open('jobcomments.asp?idjob='+idjob+'', 'poppage', 'toolbars=1, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=500, height=500, left = 300, top = 109');
  }
  function addnewfile(idP) {
   props=window.open('newfile.asp?idP='+idP+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=200, left = 300, top = 109');
  }

  function newLetterType(){
  props=window.open('newLetterType.asp', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=180, left = 300, top = 109');
  }

  function newCategory(){
  props=window.open('newCategory.asp', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=220, left = 300, top = 109');
  }
  function newOption(){
  props=window.open('newOption.asp', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=220, left = 300, top = 109');
  }
  function editProcess(idOption){
  props=window.open('editOption.asp?idOption='+idOption+'', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=240, left = 300, top = 109');
  }
  function newProcess(){
  props=window.open('newOption.asp', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=240, left = 300, top = 109');
  }
  function newBranch(){
  props=window.open('newBranch.asp', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=220, left = 300, top = 109');
  }
  function reassign(LeadID,idlettertype) {
   props=window.open('/reassignlead.asp?idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=350, height=400, left = 400, top = 109');
  }
  function newComm(){
  props=window.open('newComm.asp', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=380, left = 300, top = 109');
  }
  function replaceDoc(idDocument){
  props=window.open('replacedocument.asp?idDocument='+idDocument+'', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=200, left = 300, top = 109');
  }
  function edtCategory(idCategory){
  props=window.open('editcategory.asp?idCategory='+idCategory+'', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=220, left = 300, top = 109');
  }


  function newBill(intClientID){
  props=window.open('newBill.asp?intClientID='+intClientID+'', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=430, left = 300, top = 109');
  }

  function newFaq(idCategory){
  props=window.open('newfaq.asp?idCategory='+idCategory+'', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=430, left = 300, top = 109');
  }
  function edtfaq(idfaq){
  props=window.open('editfaq.asp?idfaq='+idfaq+'', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=450, height=430, left = 300, top = 109');
  }

  function faqhelp(idCategory){
  props=window.open('/helpfaq.asp?idCategory='+idCategory+'', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=480, height=450, left = 300, top = 109');
  }

  function CheckMaxLength(Object, MaxLen)  {
   if(Object.value.length > MaxLen){     
    Object.value = Object.value.substring(0, MaxLen);
   }
  }

function confirmSubmit()
{
var agree=confirm("Are you sure you want to delete this item?");
if (agree)
	return true ;
else
	return false ;
}

// -->



var NS4 = (document.layers);    // Which browser? 
var IE4 = (document.all); 

var win = window;    // window to search. 
var n   = 0; 

function functiondef(str) { 

  var txt, i, found; 

  if (str == "") 
    return false; 

  // Find next occurance of the given string on the page, wrap around to the 
  // start of the page if necessary. 

  if (NS4) { 

    // Look for match starting at the current point. If not found, rewind 
    // back to the first match. 

    if (!win.find(str)) 
      while(win.find(str, false, true)) 
        n++; 
    else 
      n++; 

    // If not found in either direction, give message. 

    if (n == 0) 
      alert("Not found."); 
  } 

  if (IE4) { 
    txt = win.document.body.createTextRange(); 

    // Find the nth match from the top of the page. 

    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { 
      txt.moveStart("character", 1); 
      txt.moveEnd("textedit"); 
    } 

    // If found, mark it and scroll it into view. 

    if (found) { 
      txt.moveStart("character", -1); 
      txt.findText(str); 
      txt.select(); 
      txt.scrollIntoView(); 
      n++; 
    } 

    // Otherwise, start over at the top of the page and find first match. 

    else { 
      if (n > 0) { 
        n = 0; 
        functiondef(str); 
      } 

      // Not found anywhere, give message. 

      else 
        alert("\""+ str +"\" was not found on this page!"); 
    } 
  } 

  return false; 
} 

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

var xmlHttp

function viewer(myurl,str) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url=myurl;
	url=url+"?"+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("viewer").innerHTML=xmlHttp.responseText;
	}
}

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;
}
