if (!Array.indexOf) {
    Array.prototype.indexOf = function (obj) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == obj) {
                return i;
            }
        }
        return -1;
    }
}

var timeOuts= new Array();
var activeSecondary;

fadeInSecondary = function(menu) {stopTimeOut();thisID = jQuery(menu).find("ul").attr("id");if (thisID != activeSecondary) {jQuery("#"+activeSecondary).fadeOut("fast");}
activeSecondary = jQuery(menu).find("ul").attr("id");jQuery(menu).find("ul").fadeIn(50);}
fadeOutSecondary = function(menu) {timeOuts["mouseOut"] = setTimeout("secondaryOff()",500);}
secondaryOff = function() {jQuery("#"+activeSecondary).fadeOut("fast");}
stopTimeOut = function() { for(key in timeOuts ){clearTimeout(timeOuts[key]);}}


initializePage = function (pageid) {
	switch (pageid) {
		case 1:
			
            break;
    }
    try {
    	//jQuery("#hometicker").load( 'https://www.marathonpetroleum.com/content/includes/AJAXtwister.asp?type=homequote' );
    	jQuery("#hometicker").load( 'http://www.marathonpetroleum.com:9999/content/includes/AJAXtwister.asp?type=homequote' );
    }
    catch(ex) {
    	var script   = document.createElement("script");
		script.type  = "text/javascript";
		script.src   = "https://www.marathonpetroleum.com/content/includes/AJAXtwister.asp?type=homequoteinjection";
		document.body.appendChild(script);
    }
    
	jQuery(".primaryNav>li").hover( function() { fadeInSecondary(this) }, function() {fadeOutSecondary(this);} );
	jQuery(".primaryNav>li").click( function() { window.location.href=jQuery(this).children("a").attr('href'); } );
}

function clearSearchField(isBlur) {
	if (isBlur) {
		if (document.search.search2.value == '') document.search.search2.value = 'Search';
	} else { 
		if (document.search.search2.value == 'Search') document.search.search2.value = '';
	}
}

function emailpage() {
	temploc='http://mpc.brandextract.com/staged/About_MPC/Contact_Us/Email_Page/?myURL=';
	temploc = temploc + window.location.href.replace(/\&/, '%26').replace(/\?/, '%3F');
	window.location.href = temploc;
}

