/* Functions for pop-up Window */

function newWin(WinURL, WinNAME, WinWIDTH, WinHEIGHT, WinRESIZE, WinSCROLL, WinTOOLBAR)
			{	
				/*	variables passed by the link calling the function	*/
				var URL = WinURL;
				var WINDOW_NAME = WinNAME;
				var POPUP_WIDTH = WinWIDTH;
				var POPUP_HEIGHT = WinHEIGHT;
				var POPUP_RESIZE = WinRESIZE;
				var POPUP_SCROLL = WinSCROLL;
				var POPUP_TOOLBAR = WinTOOLBAR;
			
				/*	window properties that determine the window attributes depending on what values are passed by the link calling the function	*/
				var window_toolbar = POPUP_TOOLBAR;
				var window_resize = POPUP_RESIZE;
				var window_scroll = POPUP_SCROLL;
				var window_width = POPUP_WIDTH;
				var window_height = POPUP_HEIGHT;
				var screen_balance_w = ((screen.width)-(window_width))/2;
				var screen_balance_h = ((screen.height)-(window_height))/2;
				var set_top = screen_balance_h;
				var set_left = screen_balance_w;	
			
				win = window.open(URL,WINDOW_NAME,'resizable=' + window_resize + ',toolbar=' + window_toolbar + ',scrollbars=' + window_scroll + ',width=' + window_width + ',height=' + window_height + ',top=' +  set_top + ',left=' + set_left + '');
				win.focus();
			}

/* Functions for Product Page DIV's */

dd=document;NS=(dd.layers)?1:0;IE=(dd.all)?1:0;DOM=(dd.getElementById)?1:0
function showLayer(L){ 
if(NS)dd.layers[L].display='show'; 
else if (IE)obg=dd.all[L]; 
else obg=dd.getElementById(L); 
if(!NS)obg.style.display='block' 
}

function hideLayer(L){ 
if(NS)dd.layers[L].display='hide'; 
else if (IE)obg=dd.all[L]; 
else obg=dd.getElementById(L); 
if(!NS)obg.style.display='none' 
}

function div_overview()
{
showLayer('overview')
hideLayer('availability')
hideLayer('directions')
hideLayer('ingredients')
hideLayer('warnings')
hideLayer('other')
}

function div_availability()
{
showLayer('availability')
hideLayer('overview')
hideLayer('directions')
hideLayer('ingredients')
hideLayer('warnings')
hideLayer('other')
}

function div_directions()
{
showLayer('directions')
hideLayer('overview')
hideLayer('availability')
hideLayer('ingredients')
hideLayer('warnings')
hideLayer('other')
}

function div_ingredients()
{
showLayer('ingredients')
hideLayer('overview')
hideLayer('availability')
hideLayer('directions')
hideLayer('warnings')
hideLayer('other')
}

function div_warnings()
{
showLayer('warnings')
hideLayer('overview')
hideLayer('availability')
hideLayer('directions')
hideLayer('ingredients')
hideLayer('other')
}

function div_other()
{
showLayer('other')
hideLayer('overview')
hideLayer('availability')
hideLayer('directions')
hideLayer('ingredients')
hideLayer('warnings')
}

/* Array contains the top px value used to position the white arrow */
var arrProductNavArrow = new Array(5);
arrProductNavArrow[0] = "137";
arrProductNavArrow[1] = "221";
arrProductNavArrow[2] = "305";
arrProductNavArrow[3] = "389";
arrProductNavArrow[4] = "473";

/* Array contain the copy for each product within divUsesContent */
var arrUses = new Array(5);
arrUses[0] = "This website contains the most current Drug Facts labeling information, and may differ from labels on product packaging you may have.  If there are any differences between this website labeling and product package labeling, this website labeling should be regarded as the most current.<br /><br />Uses: Temporarily relieves minor aches and pains due to: <ul style=\"padding-left:15px;\"><li>Headache</li><li>Muscular aches</li><li>Minor pain of arthritis</li><li>Toothache</li><li>Backache</li><li>The common cold</li><li>Menstrual cramps</li></ul>Temporarily reduces fever"
arrUses[1] = "This website contains the most current Drug Facts labeling information, and may differ from labels on product packaging you may have.  If there are any differences between this website labeling and product package labeling, this website labeling should be regarded as the most current.<br /><br />Uses: Temporarily: <ul style=\"padding-left:15px;\"><li>Relieves minor aches and pains due to the common cold, flu, sore throat, headache and toothache</li><li>Reduces fever</li></ul>";
arrUses[2] = "This website contains the most current Drug Facts labeling information, and may differ from labels on product packaging you may have.  If there are any differences between this website labeling and product package labeling, this website labeling should be regarded as the most current.<br /><br />Uses: Temporarily relieves these cold, sinus and flu symptoms: <ul style=\"padding-left:15px;\"><li>Nasal and sinus congestion</li><li>Stuffy nose</li><li>Headache</li><li>Sore throat</li><li>Minor body aches and pains</li><li>Fever</li></ul>";
arrUses[3] = "This website contains the most current Drug Facts labeling information, and may differ from labels on product packaging you may have.  If there are any differences between this website labeling and product package labeling, this website labeling should be regarded as the most current.<br /><br />Uses: Temporarily: <ul style=\"padding-left:15px;\"><li>Reduces fever</li><li>Relieves minor aches and pains due to the common cold, flu, sore throat, headache and toothache</li></ul>";
arrUses[4] = "This website contains the most current Drug Facts labeling information, and may differ from labels on product packaging you may have.  If there are any differences between this website labeling and product package labeling, this website labeling should be regarded as the most current.<br /><br />Uses: Temporarily: <ul style=\"padding-left:15px;\"><li>Reduces fever</li><li>Relieves minor aches and pains due to the common cold, flu, sore throat, headache and toothache</li></ul>";

/* Preload global images */
if (document.images) { 
	var images = new Array ("btn_0_0_buynow","btn_0_0_buynowa","btn_0_0_send","btn_0_0_nav_01","btn_0_0_nav_02","btn_0_0_nav_03","btn_0_0_subnav_01","btn_0_0_subnav_02","btn_0_0_subnav_03","btn_0_0_subnav_04","btn_0_0_subnav_05");
	var ImageObjects = new Array(); 
	for (i = 0; i < images.length; i++) { 
		name = images[i]; 
		ImageObjects[name] = new ImageObject(name); 
	} 
}

function ImageObject(name) { 
	this.on = new Image; 
	this.on.src = "/images/motrin/"+ name + "_ro.gif"; 
	this.off = new Image; 
	this.off.src = "/images/motrin/" + name + "_off.gif"; 
} 

/* Used to store value for which product you are viewing */
var strProductImgOn = "";

/* Used to display the product rollover for the left nav */
function showProductNav(status, whichProduct) {
	if (status){
		document.getElementById('divProductNavClear').style.visibility = "visible";
		eval("document.btn_0_0_subnav_0" + whichProduct + ".src = ImageObjects['btn_0_0_subnav_0' + whichProduct].on.src");
		document.getElementById('divProductNavArrow').style.top = arrProductNavArrow[whichProduct - 1] + "px";
		document.getElementById('divProductNavArrow').style.visibility = "visible";
		document.getElementById('divProductNavShadow').style.visibility = "visible";
		document.getElementById('divProductNav').style.visibility = "visible";
		document.prodnavhdr.src = "/images/motrin/hdr_1_1_boxele_0" + whichProduct + ".gif";
		document.prodnavbox.src = "/images/motrin/prd_1_1_boxele_0" + whichProduct + ".gif"
		document.getElementById('divUsesContent').innerHTML = arrUses[whichProduct - 1];
		document.getElementById('divChartContent' + whichProduct).style.display = "block";
		for (x=1; x<7; x++) {
			document.getElementById('prodnavlink' + x).setAttribute("href","/page.jhtml?id=/motrin/products/" + "1_" + whichProduct + "_" + x + ".inc");
		}
		for (x=7; x<9; x++) {
			document.getElementById('prodnavlink' + x).setAttribute("href","javascript:openWin('/generic.jhtml?id=/motrin/products/1_" + whichProduct + "_" + x + ".inc','popup','width=620,height=600,scrollbars=1');");
		}
		strProductImgOn = whichProduct;
	} else {
		document.getElementById('divProductNavClear').style.visibility = "hidden";
		document.getElementById('divProductNavShadow').style.visibility = "hidden";
		document.getElementById('divProductNavArrow').style.visibility = "hidden";
		document.getElementById('divProductNav').style.visibility = "hidden";
		eval("document.btn_0_0_subnav_0" + strProductImgOn + ".src = ImageObjects['btn_0_0_subnav_0' + strProductImgOn].off.src");
		document.getElementById('divChartContent' + strProductImgOn).style.display = "none";
	}		
}

/* Image rollover */
function rollover(whichImage, status) {
	eval("document." + whichImage + ".src = ImageObjects[whichImage]." + status + ".src"); 
}

/* Pain profiler */
function ddlProfiler1_onchange(optionvalue) {
	if (optionvalue != "") {
		document.ico_0_0_pprofiler_1.src = "/images/motrin/ico_0_0_pprofiler_1_off.gif";
		document.ico_0_0_pprofiler_2.src = "/images/motrin/ico_0_0_pprofiler_2_on.gif";
		
		var strURL = "/profiler/" + optionvalue + ".txt";
		sendRequest('2', strURL);

		document.getElementById('ddlRow2').style.visibility = "visible";
		document.getElementById('ddlRow3').style.visibility = "hidden";
		document.getElementById('ddlRow4').style.visibility = "hidden";
	} else {
		document.ico_0_0_pprofiler_1.src = "/images/motrin/ico_0_0_pprofiler_1_on.gif";
		document.getElementById('ddlRow2').style.visibility = "hidden";
		document.getElementById('ddlRow3').style.visibility = "hidden";
		document.getElementById('ddlRow4').style.visibility = "hidden";
	}
}

function ddlProfiler2_onchange(optionvalue) {
	if (optionvalue.substring(0,1) == "f") {
		ddlProfiler_submit(optionvalue.substring(1,optionvalue.length));
	} else if (optionvalue != "") {
		document.ico_0_0_pprofiler_2.src = "/images/motrin/ico_0_0_pprofiler_2_off.gif";
		document.ico_0_0_pprofiler_3.src = "/images/motrin/ico_0_0_pprofiler_3_on.gif";

		var strURL = "/profiler/" + optionvalue + ".txt";
		sendRequest('3', strURL);

		document.getElementById('ddlRow3').style.visibility = "visible";
		document.getElementById('ddlRow4').style.visibility = "hidden";
	} else {
		document.ico_0_0_pprofiler_2.src = "/images/motrin/ico_0_0_pprofiler_2_on.gif";
		document.getElementById('ddlRow3').style.visibility = "hidden";
		document.getElementById('ddlRow4').style.visibility = "hidden";
	}
}

function ddlProfiler3_onchange(optionvalue) {
	if (optionvalue.substring(0,1) == "f") {
		ddlProfiler_submit(optionvalue.substring(1,optionvalue.length));
	} else if (optionvalue != "") {
		document.ico_0_0_pprofiler_3.src = "/images/motrin/ico_0_0_pprofiler_3_off.gif";
		document.ico_0_0_pprofiler_4.src = "/images/motrin/ico_0_0_pprofiler_4_on.gif";

		var strURL = "/profiler/" + optionvalue + ".txt";
		sendRequest('4', strURL);

		document.getElementById('ddlRow4').style.visibility = "visible";
	} else {
		document.ico_0_0_pprofiler_3.src = "/images/motrin/ico_0_0_pprofiler_3_off.gif";
		document.getElementById('ddlRow4').style.visibility = "hidden";
	}
}

function ddlProfiler_submit(optionvalue) {
	document.location = "/page.jhtml?id=/motrin/profiler/" + optionvalue + ".inc";
}

/* Window opener */
function openWin(theURL, windowName, features) {
	newWin = window.open(theURL, windowName, features);
	newWin.focus();
}

/* Print page */
function printPage() {
    var agt = navigator.userAgent.toLowerCase(); 
    var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    var is_mac    = (agt.indexOf("mac")!=-1);
    var macos  = (is_mac && ((agt.indexOf("mac os") != -1) || (agt.indexOf("macos") != -1) || this.ie));
    var macosx = (macos && ((agt.indexOf("os x") != -1) || (agt.indexOf("osx") != -1)));

	if(macosx || is_win ){
		window.print();
	} else {
		alert("To print this page, press 'command+P'.")
	}
}