//preload images
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];}}
}

// rolover functions
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];}
}
//////////////

//window opener
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//keep session from timing out
function keepAlive() {
	
  if(window.XMLHttpRequest) {
	xhr = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
	xhr = new ActiveXObject("Microsoft.XMLHTTP");
  } 

  xhr.open("GET","keepAlive.asp",true); //MUST be an ASP page

  xhr.onreadystatechange=function(){
	  if(xhr.readyState==4){
		sessionMon(); //start the clock again
	  }
  }

  xhr.send("");  
}

//keeps the session active in 15 minute increments 900000
function sessionMon() {
	setTimeout("keepAlive();",900000); 
}

//form submiter
function submitIt(){
	document.forms[0].submit();
}

function direction(dir){
	document.forms[0].direction.value = dir;
}

// iframe chart changer
function changeframe() {
	window.frames['chart'].location.href="chart_dealpartbydist.asp?reg="+document.forms[0].reg.value;
	}
	
// characters remaining counter
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) {// if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
}
else {
countfield.value = maxlimit - field.value.length;
}
}
//end char remain counter

//lock and unlock custom copy field
function unlock() {
	if (document.forms[0].text1){
	document.forms[0].text1.readOnly=false;
	}
}

function restore(){
	if (document.forms[0].text1){
	document.forms[0].text1.value=document.forms[0].textfield1.value;
	document.forms[0].remLen.value="0";
	document.forms[0].text1.readOnly=true;
	
	}
}
// end lock and unlock custom copy

// unlock a field
function unlockIt(formField) {
	if (formField){
	formField.readOnly=false;
	}
}
// restore a text field to some other value, reset counter field
function restoreIt(formField1, formField2){
	if (formField1){
	formField1.value=formField2.value;
	document.forms[0].remLen.value="0";
	formField1.readOnly=true;
	
	}
}
// end unlock a field and restore a field to some other value

//mailing info functions
function checkallAPL(){
	if (document.forms[0].allavail.checked==true){
		document.forms[0].active.checked=true;
		document.forms[0].prospect.checked=true;
		document.forms[0].lost.checked=true;
	}
}
function uncheckAPL(){
		document.forms[0].allavail.checked=false;
}
function checksic7532(){
	document.forms[0].sic75320000.checked=true;
	document.forms[0].sic75320400.checked=true;
	document.forms[0].sic75320401.checked=true;
	document.forms[0].sic75320403.checked=true;
	document.forms[0].sic75320404.checked=true;
}
function unchecksic7532(){
	document.forms[0].sic7532.checked=false;
}
function checksic7538(){
	document.forms[0].sic75380000.checked=true;
	document.forms[0].sic75380102.checked=true;
	document.forms[0].sic75380103.checked=true;
	document.forms[0].sic753899.checked=true;
}
function unchecksic7538(){
	document.forms[0].sic7538.checked=false;
}
function checksic7533(){
	document.forms[0].sic75330000.checked=true;
	document.forms[0].sic75339902.checked=true;
}
function unchecksic7533(){
	document.forms[0].sic7533.checked=false;
}

function switcher(){

if  (document.forms[0].mailinglist2[0].checked == true ){
	document.forms[0].mailinglist1[0].checked=true;
	document.forms[0].mailinglist1[1].disable=true;

}
}
function switcherRev(){

if  (document.forms[0].mailinglist1[1].checked == true ){
	document.forms[0].mailinglist2[1].checked=true;
	document.forms[0].mailinglist2[0].disable=true;
}
}
// end mailing info functions

//fourQorder scripts
function message(themessage){
alert(themessage);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
// end fourQorderscripts

//call javascript
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

// table stripe script
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);
    if (! table) { return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
    
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

	    // avoid rows that have a class attribute
        // or backgroundColor style
	    if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
 
         // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
	        if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
        
		      mytd.style.backgroundColor = even ? evenColor : oddColor;
              
            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }
 /// end table stripe script