//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 subsection 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("/");
	pos3 = urlString.indexOf("procell/");
	section = urlString.substring(pos3+9,pos2);
	subsection = urlString.substring(pos2+1,pos);
	url = urlString.substring(pos2+1,urlString.length);
	
    }

    else{
	pos = urlString.lastIndexOf("/");
	url = urlString.substring(pos+1,urlString.length);
	pos3 = urlString.indexOf("procell/");
	section = urlString.substring(pos3+9,pos);
	pos = url.indexOf(".");
	if (pos != -1){
	    subsection = url.substring(0,pos);
	}
	else {
	    subsection = "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 (subsection == document.images[i].name && subsection != "null"){
		document.images[subsection].src = "/procell/images/nav/subnav_" + subsection + "_on.gif";
	    }
	}
    }
}
// Selects the proper top-navigation image
function topimageSelect(){
    if (document.images){
	for (i=0;i<document.images.length;i++){
	    if (subsection == document.images[i].name && subsection != "null"){
		document.images[subsection].src = "/procell/images/nav/topnav_" + subsection + "_on.gif";
	    }
	}
    }
}

//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;
    }
}

//Subnav Rollover: On
function subnavOn(imgName){
  if(document.images){
    document.images[imgName].src = "/procell/images/nav/subnav_" + imgName + "_on.gif";
  }
}
//Subnav Rollover: Off
function subnavOff(imgName){
  if (document.images && subsection != imgName){
    document.images[imgName].src = "/procell/images/nav/subnav_" + imgName + ".gif";
  }
}
//Main Nav Rollover: On
function navOn(imgName){
  if(document.images){
    document.images[imgName].src = "/procell/images/nav/nav_" + imgName + "_on.gif";
  }
}
//Main Nav Rollover: Off
function navOff(imgName){
  if (document.images && subsection != imgName){
    document.images[imgName].src = "/procell/images/nav/nav_" + imgName + ".gif";
  }
}
//Topnav Rollover: On
function topnavOn(imgName){
  if(document.images){
    document.images[imgName].src = "/procell/images/nav/topnav_" + imgName + "_on.gif";
  }
}
//Topnav Rollover: Off
function topnavOff(imgName){
  if (document.images && subsection != imgName){
    document.images[imgName].src = "/procell/images/nav/topnav_" + imgName + ".gif";
  }
}
//Map Rollover: On
function mapRollOn(imgName,lastName){
	document.images[imgName].src = "/procell/images/contact_us/map_" + lastName + ".gif";
}
//Map Rollover: Off
function mapRollOff(imgName,lastName){
	document.images[imgName].src = "/procell/images/contact_us/map_" + imgName + ".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,"reader","width=700,height=500,scrollbars,directories=no,location=no,menubar=no,resizable,status,toolbar");
    if(IEN > 4 || indexNumber == -1){
	p.focus();
    }
}
// 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 displayImage(destination){
    IEN = 0;
    indexNumber = navigator.userAgent.indexOf("MSIE");
    if (indexNumber != -1){
	IEN = navigator.userAgent.slice(indexNumber+5,indexNumber+6);
    }
    p = window.open(destination,"reader","width=375,height=600,scrollbars,directories=no,location=no,menubar=no,resizable,status,toolbar");
    if(IEN > 4 || indexNumber == -1){
	p.focus();
    }
}
// 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 mapWin(destination){
    IEN = 0;
    indexNumber = navigator.userAgent.indexOf("MSIE");
    if (indexNumber != -1){
	IEN = navigator.userAgent.slice(indexNumber+5,indexNumber+6);
    }
    p = window.open(destination,"reader","width=800,height=475,scrollbars=no,directories=no,location=no,menubar=no,resizable,status,toolbar");
    if(IEN > 4 || indexNumber == -1){
	p.focus();
    }
}

// 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 resizeWin(destination,name,features){
    IEN = 0;
    indexNumber = navigator.userAgent.indexOf("MSIE");
    if (indexNumber != -1){
	IEN = navigator.userAgent.slice(indexNumber+5,indexNumber+6);
    }
    p = window.open(destination,name,features);
    if(IEN > 4 || indexNumber == -1){
	p.focus();
    }
}
// Pop up window for Procell flashlight.asp page
function CreateNewWindow(url) { window.open(url,"featureWindow","scrollbars=yes,resizable=yes,width=550,height=560,left=100,top=100")}
function CreateToyWindow(url) { window.open(url,"featureWindow","scrollbars=yes,resizable=yes,width=780,height=474,left=100,top=100")}
// POP-UP WINDOWS FOR procell flashlight.asp PAGES
function popUp(file) {
	popupWindow = window.open(file,'','scrollbars=yes,width=365,height=255');
}
// -->

// To open a new window same as current window
function openNewWindow(url) 
{ window.open(url,'')}
