var myLastLI = '';
var myLastLeftLI = '';
var myLastSubLeftLI = '';

function emailpage() {
	temploc='http://www.marathonpetroleum.com/About_Us/Contact_Us/Email_Page/?myURL=';
	temploc = temploc + window.location.href.gsub(/\&/, '%26').escapeHTML().gsub(/\?/, '%3F');
	window.location.href = temploc;
}

function clearSearchField() {
	if (document.search.search2.value == 'Search')
		{
			document.search.search2.value = '';
		}
}

function linkoutside(url) {
	window.open(url,'mywindow');
	return false;
}

function primaryOver(myDIV) {
	allPrimaryOff();
	myPrimaryImage = 'primaryAnchor' + myDIV;
	myPrimaryLayer = 'primaryOn' + myDIV;
	mySecondaryLayer = 'secondaryOn' + myDIV;
	myX = BZ_getAbsImageX(myPrimaryImage);
	myY = BZ_getAbsImageY(myPrimaryImage);
	Element.setStyle(myPrimaryLayer, {top:myY-17, left:myX-10, visibility:'visible'});
	Element.setStyle(mySecondaryLayer, {top:myY+2, left:myX-11, visibility:'visible'});
}

function leftSecondaryOver(myDIV) {
	allOff();
	myLastLeftLI = myDIV;
	myLayer = 'leftNav' + myDIV;
	myLayerA = 'leftNavA' + myDIV;
	Element.addClassName(myLayer, 'leftNav1Over');
	x = $(myLayer);
	Element.setStyle($(myLayer).down(), { color: '#ffffff' });
	Element.addClassName(myLayer, 'leftNav1Over A');
}

function leftSecondarySubOver(myDIV) {
	allOff();
	myLastSubLeftLI = myDIV;
	myLayer = 'leftNav' + myDIV;
	myLayerA = 'leftNavA' + myDIV;
	Element.setStyle($(myLayer), { backgroundColor: '#f9ffff' });
}

function secondaryOverDD(myLI) {
	if(myLastLI!='') {
		myLastSecondaryLI = 'secondary'+myLastLI+'dd';
		Element.setStyle(myLastSecondaryLI, {backgroundColor:'#FFFFFF'});
		Element.setStyle($(mySecondaryLI).firstDescendant(), {color:'#000000'});
	}
	myLastLI = myLI;
	mySecondaryLI = 'secondary'+myLI+'dd';
	Element.setStyle(mySecondaryLI, {backgroundColor:'#003399'});
	Element.setStyle($(mySecondaryLI).firstDescendant(), {color:'#ffffff'});
}

function allPrimaryOff() {
	for(i=373;i<379;i++) {
		myPrimaryLayer = 'primaryOn' + i;
		mySecondaryLayer = 'secondaryOn' + i;
		Element.setStyle(myPrimaryLayer, {visibility:'hidden'});
		Element.setStyle(mySecondaryLayer, {visibility:'hidden'});
	}
	if(myLastLeftLI!='') {
		myLastLeftNavLI = 'leftNav'+myLastLeftLI;
		Element.removeClassName(myLastLeftNavLI, 'leftNav1Over');
		Element.setStyle($(myLastLeftNavLI).down(0), { color: '#372B27' });
	}
	if(myLastSubLeftLI!='') {
		myLastSubLeftNavLI = 'leftNav'+myLastSubLeftLI;
		Element.setStyle($(myLastSubLeftNavLI), { backgroundColor: '#DBE2F1' });
	}
	if(myLastLI!='') {
		myLastSecondaryLI = 'secondary'+myLastLI+'dd';
		Element.setStyle(myLastSecondaryLI, {backgroundColor:'#FFFFFF'});
		Element.setStyle($(mySecondaryLI).firstDescendant(), {color:'#000000'});
	}
}

function allOff() {
	allPrimaryOff();
	if(myLastLI!='') {
		myLastSecondaryLI = 'secondary'+myLastLI+'dd';
		Element.setStyle(myLastSecondaryLI, {backgroundColor:'#FFFFFF'});
	}
	if(myLastLeftLI!='') {
		myLastLeftNavLI = 'leftNav'+myLastLeftLI;
		Element.removeClassName(myLastLeftNavLI, 'leftNav1Over');
		Element.setStyle($(myLastLeftNavLI).down(0), { color: '#372B27' });
	}
	if(myLastSubLeftLI!='') {
		myLastSubLeftNavLI = 'leftNav'+myLastSubLeftLI;
		Element.setStyle($(myLastSubLeftNavLI), { backgroundColor: '#DBE2F1' });
	}
}

function onLoadObserveCalls() {
	Event.observe('primary373td', 'mouseover', function(e){ primaryOver(373); });
	Event.observe('primary374td', 'mouseover', function(e){ primaryOver(374); });
	Event.observe('primary375td', 'mouseover', function(e){ primaryOver(375); });
	Event.observe('primary376td', 'mouseover', function(e){ primaryOver(376); });
	Event.observe('primary377td', 'mouseover', function(e){ primaryOver(377); });
	Event.observe('primary378td', 'mouseover', function(e){ primaryOver(378); });
	Event.observe('bodydiv', 'mouseover', function(e){ allOff(); });
}


function PPalert(url){
   if(confirm("You are leaving the website maintained by Marathon Petroleum Company. This link is provided for your convenience. Collection of information on the following website is performed by a third party. Third party sites may provide different information privacy policies than the Marathon web site. Please review the privacy and security policies of a website before you provide personal or confidential information.  To return to the Marathon website, click cancel. ")){
      window.open(url);
   }
}
	