var textNav =  new Object();

function swapClassImage(elementId, element2Id, toClassname, elementIdLHS, imageLHS, elementIdRHS, imageRHS) {
    if ((textNav[elementIdLHS].noSwitch || textNav[elementIdRHS].noSwitch))  {
      if ((textNav[elementIdLHS].noSwitch) && (imageLHS.indexOf("clear.gif") <0)) {
       imageName=imageLHS;
       newImageName1=imageName.substring(0,imageName.indexOf("sep_")+4);
       newImageName2 = imageName.substring(imageName.lastIndexOf("_"));
       imageType = imageName.substring(imageName.indexOf("sep_")+4,imageName.indexOf("sep_")+6);
        if (IsNull(textNav[elementIdLHS].switched) || (textNav[elementIdLHS].switched != "onon")) {
	 textNav[elementIdLHS].switched = "onon";
	 if (textNav[elementIdRHS].noSwitch) textNav[elementIdLHS].switched = "ofon"
	 if (imageType == "nu") textNav[elementIdLHS].switched = "nuon";
        } else {
	 textNav[elementIdLHS].switched = "onof";
	 if (imageType == "nu") textNav[elementIdLHS].switched = "nuof";
	}
       newImageName = newImageName1 + textNav[elementIdLHS].switched + newImageName2;
       imageLHS=newImageName;
      }
      if ((textNav[elementIdRHS].noSwitch) && (imageRHS.indexOf("clear.gif") <0)){
       imageName=imageRHS;
       newImageName1=imageName.substring(0,imageName.indexOf("sep_")+4);
       newImageName2 = imageName.substring(imageName.lastIndexOf("_"));
       imageType = imageName.substring(imageName.indexOf("sep_")+6,imageName.indexOf("sep_")+8);
       if (IsNull(textNav[elementIdRHS].switched) || (textNav[elementIdRHS].switched != "onon")) {
         textNav[elementIdRHS].switched = "onon"
	 if (textNav[elementIdLHS].noSwitch) textNav[elementIdRHS].switched = "onof"
	 if (imageType == "nu") textNav[elementIdRHS].switched = "onnu";
        } else {
	 textNav[elementIdRHS].switched = "ofon"
	 if (imageType == "nu") textNav[elementIdRHS].switched = "ofnu";
	}
       newImageName = newImageName1 + textNav[elementIdRHS].switched + newImageName2;
       imageRHS=newImageName;
      }
    }
    swapImage(elementIdLHS,imageLHS, elementIdRHS,imageRHS);
    swapClass(elementId,element2Id, toClassname);
}

function swapClass(elementId,elementId2, toClassname) {
if (!IsNull(textNav[elementId].noSwitch) && !textNav[elementId].noSwitch) findObj(elementId).className=toClassname;
if (!IsNull(textNav[elementId2].noSwitch) && !textNav[elementId2].noSwitch) findObj(elementId2).className=toClassname;
}

function swapImage(elLHS,imageLHS, elRHS, imageRHS)  {
// We know there are only two image to change therefore
LHSImage = findObj(elLHS);
LHSImage.src = imageLHS;
RHSImage = findObj(elRHS);
RHSImage.src = imageRHS;
//  var i,j=0,x,a=swapImage.arguments; 
//  document.image_sr=new Array; 
//  for(i=0;i<(a.length-1);i+=2) {
//   if (!IsNull(a[i])) {
//    if ((x=findObj(a[i]))!=null){
//     document.image_sr[j++]=x; 
//     x.src=a[i+1];
//    }
//   }
//  }
}

function setupNavigation(elementId,elementId2,onClass,offClass,href) {
  createNavigation(elementId);createNavigation(elementId2);
  if (isActive(href)) {
    swapClass(elementId,elementId2, onClass);
    textNav[elementId].noSwitch = true;textNav[elementId2].noSwitch = true;
    return "on";
  } else {
    swapClass(elementId,elementId2, offClass)
    return "off";
  }
}

function setupNavigationImage(elementId,elementId2,onClass,offClass,href,elementIdLHS,imageLHS,elementIdRHS,imageRHS) {
  imageson = setupNavigation(elementId,elementId2,onClass,offClass,href);
  createNavigation(elementIdLHS);createNavigation(elementIdRHS);
  if (imageson == "on") {
    swapImage(elementIdLHS,imageLHS, elementIdRHS,imageRHS);
    textNav[elementIdLHS].noSwitch = true;textNav[elementIdRHS].noSwitch = true;
  }
}

function createNavigation(elementId) {
 if (!textNav[elementId]) {
  textNav[elementId] = new Object();
  textNav[elementId].noSwitch = false;
 }
}

function isActive(url) {
 pageHref = document.location.href;
 testHref = url;
 //Strip off page name from this 
 lastSlash = testHref.lastIndexOf("/")+1;
 testHref = testHref.substr(0,lastSlash);
 //does the testHref exist in pageHref
 //alert("pageHref::"+pageHref+"\ntestHref::"+testHref);
 exists = pageHref.indexOf(testHref);
 if (exists > 0) {
  return true;
 } else {
  return false;
 }
}

function preloadSepImages(siteRoot, sepType) {
 preloadImages(siteRoot + "/images/global_images/sep_nuof_"+sepType, siteRoot + "/images/global_images/sep_nuon_"+sepType, siteRoot + "/images/global_images/sep_ofof_"+sepType,siteRoot + "/images/global_images/sep_ofon_"+sepType,siteRoot + "/images/global_images/sep_onof_"+sepType,siteRoot + "/images/global_images/sep_ofnu_"+sepType,siteRoot + "/images/global_images/sep_onnu_"+sepType);
}


function MM_findObj(n, d) { //v3.0
  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); 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];}
}
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_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];}}
}