/////////////////////////////////////////////
//////// Javascript.js Functions
/////////////////////////////////////////////

function showTip1() {
 if (document.all){
  eval('document.all.products_gradient.style.pixelLeft = '+ ((document.body.clientWidth/2)+133));
}
 else {
  eval('document.getElementById("products_gradient").style.left = '+ ((document.body.clientWidth/2)+133));
 }
}


function showTip2() {
 if (document.all){
  eval('document.all.products_gradient2.style.pixelLeft = '+ ((document.body.clientWidth/2)+133));
 }
 else {
  eval('document.getElementById("products_gradient2").style.left = '+ ((document.body.clientWidth/2)+133));
 }
}



function rollOver(which,state) {
        if (document.images) {
                ext = which.src.substring(which.src.lastIndexOf("."));
                which.src = which.src.substring(0,which.src.lastIndexOf('-')) + "-" + state + ext;
        }
}

function newWindow(url,name,w,h,t,m,s,r,st,l,d,c) {
	var windowOptions = "width=" + w + "," +
	"height=" + h + "," +
	"toolbar=" + t + "," +
	"menubar=" + m +"," +
	"scrollbars=" + s + "," +
	"resizable=" + r + "," +
	"status=" + st + "," +
	"location=" + l + "," +
	"directories=" + d + "," +
	"copyhistory=" + c;
	window.open(url, name, windowOptions);
}

var coaches = new Array("jorge_cruise", "terry_savage", "kathy_peel", "chris_freytag");
function coachRollOver(which, state) {
	coachName = which.id.substring(0,which.id.lastIndexOf('_img'));
	if (state == 'on') {
		for (i=0; i<coaches.length; i++) {
			if (which.id != coaches[i]+"_img") {
				rollOver(document.getElementById(coaches[i]+"_img"), "off");
			}
		}
		document.getElementById("bubble_"+coachName).style.display = 'inline';
	}
	if (state == 'off') {
		for (i=0; i<coaches.length; i++) {
			rollOver(document.getElementById(coaches[i]+"_img"), "on");
		}
		document.getElementById("bubble_"+coachName).style.display = 'none';
	}
}
function coachRollOver_home(which, state) {
	coachName = which.id.substring(0,which.id.lastIndexOf('_img'));
	if (state == 'on') {
		for (i=0; i<coaches.length; i++) {
			if (which.id != coaches[i]+"_img") {
				rollOver(document.getElementById(coaches[i]+"_img"), "off");
			}
		}
		document.getElementById("bubble_"+coachName+"_home").style.display = 'inline';
	}
	if (state == 'off') {
		for (i=0; i<coaches.length; i++) {
			rollOver(document.getElementById(coaches[i]+"_img"), "on");
		}
		document.getElementById("bubble_"+coachName+"_home").style.display = 'none';
	}
}

function coachBubbles(which, show) {
	if (show) {
		document.getElementById(which).style.display = 'inline';
	}
	else {
		document.getElementById(which).style.display = 'none';
	}
}

function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

/////////////////////////////////////////////
//////// Page.js Functions
/////////////////////////////////////////////

function page_header(email) {
		header = '<div id="header">'; 
		header += '<div id="header_left"></div>'; 
		header += '<table cellpadding="0" cellspacing="0" id="header_table">';
		header += '<tr>';
		header += '<td valign="top" class="X middle">';
		header += '<table cellpadding="0" cellspacing="0" class="X">';
		header += '<tr><td valign="top" style="padding: 20 0 0 18px">';
		header += '<table cellpadding="0" cellspacing="0"><tr><td><a href="0_1.html?skip=1"><img src="/images/learnactlive/spacer.gif" width=300 height=45 border=0 alt="EVOLVE TO BETTER HEALTH"></a></td></tr></table>';
		header += '</td>';
		if (email){ //display email to a friend button
			header += '<td valign="top"><a href="#" onclick="newWindow(\'G1.html\',\'email\',635,500,0,0,1,0,0,0,0,0);"><img src="/images/learnactlive/btn-00-email.gif" alt="EMAIL TO A FRIEND" width="139" height="24" border="0" style="float: right; margin: 10px;"></a></td>';
		}
		header += '</tr></table>';
		header += '</td>';
		header += '</tr>';
		header += '</table>';
		header += '</div>'; 
	document.write(header);
}

function page_topnav() {
	pageID = page_topnav.arguments[0];
	topnav = '';
	topnav = '<div id="topnav">'; 
	topnav += '	<div id="topnav_left"></div>'; 
	topnav += '<table cellpadding="0" cellspacing="0" id="topnav_table">';
	topnav += '<tr>';
	topnav += '<td valign="top" class="X middle">';
	topnav += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="721" height="48" id="subnav" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/images/learnactlive/swf/subnav.swf';
	if (pageID != '') {
		topnav += '?pageID='+pageID;
	}
	topnav += '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="/images/learnactlive/swf/subnav.swf';
	if (pageID != '') {
		topnav += '?pageID='+pageID;
	}
	topnav += '" quality="high" bgcolor="#ffffff" width="721" height="48" name="subnav" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	topnav += '</td>';
	topnav += '</tr>';
	topnav += '</table>';
	topnav += '</div>'; 
	document.write(topnav);
}

function page_homenav() {
	homenav = '';
	homenav += '<div id="pre_homenav">'; 
	homenav += '<div id="pre_homenav_left"></div>'; 
	homenav += '<table cellpadding="0" cellspacing="0" id="pre_homenav_table">';
	homenav += '<tr>';
	homenav += '<td valign="top" class="X middle">';
	homenav += '<img src="/images/learnactlive/nav-0_1-wellness.gif" alt="" width="721" height="56">';
	homenav += '</td>';
	homenav += '</tr>';
	homenav += '</table>';
	homenav += '</div>'; 
	homenav += '<div id="homenav">'; 
	homenav += '<div id="homenav_left"></div>'; 
	homenav += '<table cellpadding="0" cellspacing="0" id="homenav_table">';
	homenav += '<tr>';
	homenav += '<td valign="top" class="X middle">';
	homenav += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="721" height="140" id="homenav" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/images/learnactlive/swf/homenav.swf?skip='+QueryString('skip')+'"/><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="/images/learnactlive/swf/homenav.swf?skip='+QueryString('skip')+'" quality="high" bgcolor="#ffffff" width="721" height="140" name="homenav" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	homenav += '</td>';
	homenav += '</tr>';
	homenav += '</table>';
	homenav += '</div>'; 
	document.write(homenav);
}

function page_footer(mult) {
	footer = '<table cellpadding="0" cellspacing="0" class="X grey1">';
	footer += '<tr>';
	footer += '<td valign="top" style="padding: 30 30 40 20px;">';
	footer += '© McNeil Consumer & Specialty Pharmaceuticals, a Division of McNeil PPC, Inc. 2005. All rights reserved.<br><br>';

	footer += 'This site is published by McNeil Consumer & Specialty Pharmaceuticals, a Division of McNeil PPC, Inc., which is solely responsible for its contents. It is intended for visitors from the USA. Questions or comments? Call 1-800-962-5357 (English) or 1-888-466-8746 (Spanish).<br><br>';

	if (mult) {
	//[INSERT THE FOLLOWING AS PART OF GLOBAL FOOTER WHENEVER MULT-BRAND PRODUCT SHOTS ARE SHOWN]
		footer += 'Tylenol®, Imodium® Advanced, Motrin® IB, Children’s Motrin®, Simply Sleep™, St. Joseph® 81 mg products are products of McNeil Consumer & Specialty Pharmaceuticals, a division of McNeil-PPC, Inc.; VIACTIV® products are products of McNeil Nutritionals, LLC. Maximum Strength Pepcid® AC, Pepcid® Complete and Mylanta® products are products of Johnson & Johnson • Merck Consumer Pharmaceuticals Co.; The PEPCID trademark is owned by Merck & Co., Inc. <br><br>';
	}

	footer += 'Johnson & Johnson * Merck Consumer Pharmaceuticals Co. is a U.S.-based 50/50 joint venture formed to develop and market nonprescription products derived primarily from Merck & Co., Inc. prescription medicines, as well as products licensed and acquired from outside sources.<br><br>';

	footer += '</td>';
	footer += '<td valign="top" class="nowrap blue1" style="padding: 30 20 0 0px;">';
	footer += '<a href="#" class="blue1" onclick="newWindow(\'F1.html\',\'privacy\',635,550,0,0,1,0,0,0,0,0);">Privacy Policy</a> | <a href="#" class="blue1" onclick="newWindow(\'F2.html\',\'legal\',635,550,0,0,1,0,0,0,0,0);">Legal Notice</a>';
	footer += '</td>';
	footer += '</tr>';
	footer += '</table>';
	document.write(footer);
}

function QueryString(key) {
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++) {
		if (QueryString.keys[i]==key) {
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}

QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse() {
	var query = window.location.search.substring(1);
	var pairs = query.split("&");

	for (var i=0;i<pairs.length;i++) {
		var pos = pairs[i].indexOf('=');
		if (pos >= 0) {
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value; 
		}
	}
}

QueryString_Parse();
