function validateForm(){

var okSoFar =true
var errorMessage=""


 if (Right(document.frmUpload.File.value,3)!="csv" && Right(document.frmUpload.File.value,3)!="CSV") {
    okSoFar=false
    errorMessage = "Input File must be CSV!"
    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 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 notification(LeadID,idlettertype) {
   props=window.open('/sendnotification.asp?idlettertype='+idlettertype+'&LeadID='+LeadID+'', 'poppage', 'toolbars=1, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=350, height=350, left = 400, 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 newComment(LeadID,idlettertype,intClientID) {
   props=window.open('newcomment.asp?idlettertype='+idlettertype+'&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 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 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 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;
}
