//The following is javascript that gets executed on every page.
//It "turns on" the proper subnavigation image based on the filename.
//If there are any third level pages, an underscore ("_") separates
//  the section name from the page name.
//  Ex: womenscancersprog_connection.asp
//Do NOT place an underscore in main level pages, or secondary pages.

bVer = parseFloat(navigator.appVersion);

if (bVer >= 4){
    urlString = document.location.href;

    if(urlString.lastIndexOf("_") != -1){
	pos = urlString.lastIndexOf("_");
	pos2 = urlString.lastIndexOf("/");
	section = urlString.substring(pos2+1,pos);
	url = urlString.substring(pos2+1,urlString.length);
    }

    else{
	pos = urlString.lastIndexOf("/");
	url = urlString.substring(pos+1,urlString.length);
	pos = url.indexOf(".");
	if (pos != -1){
	    section = url.substring(0,pos);
	}
	else {
	    section = "null";
	}
    }

    if (url.lastIndexOf("#") >= 0){
	pos = url.lastIndexOf("#");
	url = url.substring(0,pos);
    }
}

//Ignores the query portion of the URL.  This is for pages that use the query string
function ignoreQuery(){
    if (document.images){
	if (url.lastIndexOf("?") >= 0){
	    pos = url.lastIndexOf("?");
	    url = url.substring(0,pos);
	}
    }
}

// Selects the proper sub-navigation image
function imageSelect(){
    if (document.images){
   	for (i=0;i<document.images.length;i++){
      if (section == document.images[i].name && section != "null"){
		  document.images[section].src = "/tw/images/shared/oralbsn_" + section + ".jpg";
	    }
    }
  }
}

//This ends the automatic select of the subnav images---------------------

//Will Pre-cache an image
function preCache(image){
    if (document.images){
	pic = new Image();
	pic.src = image;
    }
}
//End Pre-cache 

//Rollover JS

//Main Nav Rollover: On
function navOn(imgName){
  if(document.images){
    document.images[imgName].src = "/tw/images/shared/oralbn_" + imgName + "_over.jpg";
  }
}

//Main Nav Rollover: Off
function navOff(imgName){
  if (document.images && section != imgName){
    document.images[imgName].src = "/tw/images/shared/oralbn_" + imgName + ".jpg";
  }
}
  
//Subnav Rollover: On
function subnavOn(imgName){
  if(document.images){
    document.images[imgName].src = "/tw/images/shared/oralbsn_" + imgName + "_over.jpg";
  }
}

//Subnav Rollover: Off
function subnavOff(imgName){
  if (document.images && section != imgName){
    document.images[imgName].src = "/tw/images/shared/oralbsn_" + imgName + ".jpg";
  }
}

//Subnav Rollover INSIDE: On
function subnavInsideOn(imgName){
  if(document.images){
    document.images[imgName].src = "/tw/images/shared/oralbsn_" + imgName + ".jpg";
  }
}

//Subnav Rollover INSIDE: Off
function subnavInsideOff(imgName){
  if (document.images && section != imgName){
    document.images[imgName].src = "/tw/images/shared/oralbsn_" + imgName + "_over.jpg";
  }
}



//General Rollover: On and Off
function genRoll(path,page,state){
  if (document.images){
    document.images[page].src = path + page + "_" + state + ".gif";
  }
}

//Checking the Pulldown menus and submitting
function checkForm(whichPullDown){
    if (document.images){
	if (document.theForm[whichPullDown].value != "line"){
	    document.theForm.submit();
	}
    }
}

function newPage(whichPullDown){
    if (document.images){
	place = document.theForm[whichPullDown][document.theForm[whichPullDown].selectedIndex].value;
	if (place != "line"){
	    if (((place.indexOf("http://") >= 0) && (place.indexOf("http://ir.ccbn.com") == -1) && (place.indexOf("http://www.corporate-ir.net") == -1)) || (place.indexOf("ticker=G&script=1900&layout=0") >= 0)){
		openWin(place);
	    }
	    else{
		location.href = place;
	    }
	}
    }
}

// Pops all new windows in a daughter window.  HREF in html to point to the desired page,
// with the TARGET="daughter" and the onClick event triggering the openWin function.
// This ensures the links open, even if there is no javascript.
function openWin(destination){
    IEN = 0;
    indexNumber = navigator.userAgent.indexOf("MSIE");
    if (indexNumber != -1){
	IEN = navigator.userAgent.slice(indexNumber+5,indexNumber+6);
    }
    p = window.open(destination,"daughter","width=701,height=480,scrollbars,directories=no,location=no,menubar=no,resizable,status,toolbar");
    if(IEN > 4 || indexNumber == -1){
	p.focus();
    }
}

function CreateNewWindow(url) { window.open(url,"displayWindow","toolbar=yes,location=20,20,directories=0,status=0,menubar=0,scrollbars=yes,resizeable=yes,width=750,height=500")}
