

var imagesLoaded = false;

var isDHTML = (document.layers || document.all) ? 1 : 0;
var isNavigator = (navigator.appName.indexOf("Netscape") >= 0) ? 1 : 0;
var isWindows = (navigator.appVersion.indexOf("Win") >= 0) ? 1 : 0;

var docObj = (isNavigator) ? 'document.' : 'document.all.'; 
var styleObj = (isNavigator) ? '' : '.style';


if (isNavigator && isDHTML)
{ onResize = reloadPage(true);
  document.captureEvents(Event.MOUSEOVER, Event.MOUSEOUT);
}


function loadImage(fileName)
{ newImage = new Image();
  newImage.src = fileName;
  return newImage;
}


function preloadImages()
{ if(document.images) 
   {  

// ----------------------------------------------------------------
// if images need to be preloaded (for rollovers, etc.) use the following syntax:
// ----------------------------------------------------------------

//    imagename_off = loadImage(img_folder + "imagename_off.gif");
//    imagename_on = loadImage(img_folder + "imagename_on.gif");

imagename_off = loadImage(img_folder = "tab_1_blue.gif");
imagename_on = loadImage(img_folder = "tab_1_white.gif");

imagename_off = loadImage(img_folder = "tab_2_blue.gif");
imagename_on = loadImage(img_folder = "tab_2_white.gif");

imagename_off = loadImage(img_folder = "tab_3_blue.gif");
imagename_on = loadImage(img_folder = "tab_3_white.gif");

imagename_off = loadImage(img_folder = "tab_4_blue.gif");
imagename_on = loadImage(img_folder = "tab_4_white.gif");

imagename_off = loadImage(img_folder = "tab_5_blue.gif");
imagename_on = loadImage(img_folder = "tab_5_white.gif");

imagename_off = loadImage(img_folder = "tab_6_blue.gif");
imagename_on = loadImage(img_folder = "tab_6_white.gif");

imagename_off = loadImage(img_folder = "tab_7_blue.gif");
imagename_on = loadImage(img_folder = "tab_7_white.gif");

imagename_off = loadImage(img_folder = "tab_8_blue.gif");
imagename_on = loadImage(img_folder = "tab_8_white.gif");

imagename_off = loadImage(img_folder = "tab_9_blue.gif");
imagename_on = loadImage(img_folder = "tab_9_white.gif");

imagename_off = loadImage(img_folder = "tab_10_blue.gif");
imagename_on = loadImage(img_folder = "tab_10_white.gif");

imagename_off = loadImage(img_folder = "tab_11_blue.gif");
imagename_on = loadImage(img_folder = "tab_11_white.gif");

imagename_off = loadImage(img_folder = "tab_12_blue.gif");
imagename_on = loadImage(img_folder = "tab_12_white.gif");

imagename_off = loadImage(img_folder = "tab_13_blue.gif");
imagename_on = loadImage(img_folder = "tab_13_white.gif");

// Don't delete the following statement 
    imagesLoaded = true;
  }
}

// Define the swap() function to change the tab color
function swap(id, newsrc)
{var theImage = locateImage(id);
if (theImage) {
	theImage.src = newsrc;
	}
}

//Define the locateImage() function
function locateImage(name)
{var theImage = false;
if (document.images) {
	theImage = document.images[name];
	}
	if (theImage) {
		return theImage;
	}
	return (false);
}

function changeImage(imageIn, imageSrc)
{if (!imagesLoaded || !document.images)
    return;

  currImage = eval("document." + imageIn);
  if (!currImage)
  { if (isNavigator)
    { var foundImage = false;
      for (i = 0; 1 < document.layers.length; i++)
      { currImage = eval("document.layers[" + i + "].document." + imageIn);
        if (currImage)
        { foundImage = true;
          break
        }
      }
      if (!foundImage)
        return;
    }
    else
      return;
  }
  currImage.src = eval(imageSrc + ".src");
}


function openWin(fileIn, width, height)
{ window.open(fileIn,'BellSouth','toolbar=no,width=' + width + ',height=' + height + ',left=0,top=0,status=no,scrollbars=no,resize=no');
  return false;
}

function openWin2(fileIn, width, height)
{ Scenarios = window.open(fileIn,'Scenarios','toolbar=yes,width=' + width + ',height=' + height + ',left=0,top=0,status=yes,scrollbars=yes,resize=yes');
  Scenarios.focus();
  return false;
}

function openExtFrames(btm) {
  // open external page in bottom frame of  frameset.html
  var theURL = root_folder + "frameset.html?ext=" + btm;
  window.open(theURL,'tcframe','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
  return false;
}

function openSmWin(btm) {
  // open page in small window (alerts, errors, etc.)
  var theURL = root_folder + "frameset_small.html?ext=" + btm;
  window.open(theURL,'smWin','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=300');
  return false;
}

function popWin(url,winName,theWidth,theHeight) {
  window.open(url, winName, 'toolbar=no,location=no,status=no,menubar=no,scrollbars="yes",resizable="yes",width=' + theWidth + ',height=' + theHeight);
}


function reloadPage(init)
{  //reloads the window if Nav4 resized
  if (init == true)
  { document.pageW = innerWidth;
    document.pageH = innerHeight;
    onresize = reloadPage;
  }
  else if (innerWidth != document.pageW || innerHeight != document.pageH)
    location.reload();
}

// Format phone number routine. Use onKeyUp="jm_phonemask(this)" in the input field.
function jm_phonemask(t)
{var patt1 = /(\d{3}).*(\d{3}).*(\d{4})/;
var patt2 = /^\((\d{3})\).(\d{3})-(\d{4})$/;
var str = t.value;
var result;
if (!str.match(patt2))
{result = str.match(patt1);
if (result!= null)
{t.value = t.value.replace(/[^\d]/gi,'');
str = '(' + result[1] + ') ' + result[2] + '-' + result[3];
t.value = str;
}else{
if (t.value.match(/[^\d]/gi))
t.value = t.value.replace(/[^\d]/gi,'');
}}}

// Format date routine. Use onKeyUp="jm_datemask(this)" in the input field.
function jm_datemask(t)
{var donepatt = /^(\d{2})\/(\d{2})\/(\d{4})$/;
var patt = /(\d{2}).*(\d{2}).*(\d{4})/;
var str = t.value;
if (!str.match(donepatt))
{result = str.match(patt);
if (result!= null)
{t.value = t.value.replace(/[^\d]/gi,'');
str = result[1] + '/' + result[2] + '/' + result[3];
t.value = str;
}else{
if (t.value.match(/[^\d]/gi))
t.value = t.value.replace(/[^\d]/gi,'');

}}}

// Routine used by validateForm.
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;
}

// Email validation. Use onBlur="MM_validateForm('email_address','','NisEmail')" on email input field.
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

// Change text area properties. Use onClick="MM_changeProp('textfield2','','rows','15','TEXTAREA')" value="+"
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

// Goto a specific URL based on the click status of a button
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]+"'");
}

// Window opener function
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// open panel in window
function toggleNewsDiv(id) {
    if (document.getElementById('news_'+id).style.display=='block')  {
        document.getElementById('news_'+id).style.display='none'
        document.getElementById('news_img_'+id).src ='images/plussign.gif'
    }
    else {
        document.getElementById('news_'+id).style.display='block'
        document.getElementById('news_img_'+id).src ='images/minussign.gif'
    }
}

function OpenChildWin(nurl,nwidth,nheight,nleft,ntop) {
  popupWin = window.open(nurl, 'newwin', 'scrollbars=no,titlebar=no,resizable=no,menubar=no,toolbar=no,status=no,location=no,width=' + nwidth +',height=' + nheight)
  popupWin.moveTo(nleft,ntop);

}
function popcal(vCaption, vField, vDate){ 
    var nW = window.open("", "calendar", 
        "resizable=no,scrollbars=no,width=300,height=320"); 
    nW.location.href = "popcalendar.asp?caption=" + 
        escape(vCaption) + 
          "&field=" + vField + "&date=" + vDate; 
    nW = null; 
}
