﻿// JScript File
function silentErrorHandler() {return true;}
window.onerror=silentErrorHandler;

var server = window.location.hostname
var ProductFontSlider
var NavSelected
var IsSaving = false
var FontSize
var radFont
var start = ""
if(server.indexOf("localhost") > -1){
    start = "http://10.229.232.148"
} else if(server.indexOf("10.") > -1){
    start = "http://10.229.232.148"
} else if(server.indexOf("staging.") > -1){
    start = "http://staging.wyethallbrands.com"
} else {
    start = "http://www.wyethallbrands.com"
}
var cVisible = false
var ConfiguratorFlash = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='290' height='316' id='centrum_configurator' align='top'><param name='wmode' value='transparent' /><param name='base' value='/flash/xml' /><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/flash/configurator.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='/flash/configurator.swf' quality='high' bgcolor='#fffff' wmode='transparent' width='290' height='316' name='centrum_configurator' align='top' allowScriptAccess='sameDomain' base='/flash/xml' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>"
$(document).ready(function(){
	$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

$(document).ready(function () {
	$('#basicModal input.basic, #basicModal a.basic').click(function (e) {
		e.preventDefault();
		$('#basicModalContent').modal();
	});
});
			
function main()
{
   mainProgramLogic();
   useLoadThisFunctionsAndObject();
}
function CentrumNavigate(NavId){
    switch(NavId){
        case 1:
            window.location.href = "/default.aspx";
            break;
        case 2:
            window.location.href = "/producthub.aspx";
            break;
        case 3:
            window.location.href = "/healthcenter.aspx";
            break;
        case 4:
            window.location.href = "/contact.aspx";
            break;
        case 5:
            window.location.href = "/buynow.aspx";
            break;
        default:
            window.location.href = "/productdetail.aspx?BrandProductId=" + NavId;
            break;
    }
}
function MainMenuOver(ControlId,ImageId){
    if(ImageId != NavSelected){
        ControlId.src = "/images/mainmenu/" + ImageId + "Over.jpg";
    }    
}
function MainMenuOut(ControlId,ImageId){
    if(ImageId != NavSelected){
        ControlId.src = "/images/mainmenu/" + ImageId + ".jpg";
    }
}
function AddToBreadCrumb(BrandProductName){
    BrandProductName = BrandProductName.replace("~*~","'");
    BrandProductName = BrandProductName.replace("Tablets","");
    if(BrandProductName.indexOf("Silver") > -1){
        BrandProductName = BrandProductName.replace("Silver","Silver<sup class='regsmall'>&reg;</sup>");
    }
    if(BrandProductName.indexOf("Performance") > -1 || BrandProductName.indexOf("Cardio") > -1){
        document.getElementById("BreadcrumbLinks").innerHTML = document.getElementById("BreadcrumbLinks").innerHTML + "&nbsp;&nbsp;|&nbsp;&nbsp;Centrum " + BrandProductName + "<sup class='regsmall'>&reg;</sup>";
    } else if(BrandProductName.indexOf("Kids:") > -1) {
        document.getElementById("BreadcrumbLinks").innerHTML = document.getElementById("BreadcrumbLinks").innerHTML + "&nbsp;&nbsp;|&nbsp;&nbsp;Centrum Kids<sup class='regsmall'>&reg;</sup>";
    } else {
        document.getElementById("BreadcrumbLinks").innerHTML = document.getElementById("BreadcrumbLinks").innerHTML + "&nbsp;&nbsp;|&nbsp;&nbsp;Centrum<sup class='regsmall'>&reg;</sup> " + BrandProductName;
    }    
}
function AddToBreadCrumbArticle(ArticleTitle){
    ArticleTitle = ArticleTitle.replace("~*~","'");
    document.getElementById("BreadcrumbLinks").innerHTML = document.getElementById("BreadcrumbLinks").innerHTML + "&nbsp;&nbsp;|&nbsp;&nbsp;" + ArticleTitle;
}
function HideBreadCrumb(){
    document.getElementById("BreadcrumbLinks").innerHTML = ""
    document.getElementById("BreadcrumbLinks").style.height = "2px"
}
function LoadProduct(BrandProductName){
    BrandProductName = BrandProductName.replace("~*~","'");
    window.location.href = "/productdetail.aspx?BrandProductName=" + BrandProductName;
}
function PrintThisPage(){
    window.print();
}
function GetCardioQuiz(){
    var x, y;
    x = 960;
    y = 475;
    OpenWindow("/pdfs/printquiz.pdf", x, y);
}
function CardioRebate(){
    var x, y;
    x = 960;
    y = 475;
    OpenWindow("/pdfs/Centrum_Cardio_rebate.pdf", x, y);
}
function WhiteCardRebate(){
    var x, y;
    x = 960;
    y = 475;
    OpenWindow("/pdfs/Centrum_rebate.pdf", x, y);
}
function GetHealthCenter(){
    window.location.href = "/healthcenter.aspx";
}
function LeaveWyeth(Section,ID){
    try{
        var oWnd = radopen("/leave_wyeth.aspx?Section=" + Section + "&ID=" + ID, "");
        oWnd.center;
    } catch(err) {
        window.location.href = window.location.href;
    }
}
function ShowIE6Warning(){
    var oWnd = radopen("/ie6.aspx" , "");
    oWnd.center;
}
function ViewProductLabeling(BrandProductId){
    try {
        var oWnd = radopen("/productlabeling.aspx?BrandProductId=" + BrandProductId , "");
        oWnd.setSize(800,500);
        oWnd.set_title("Centrum&reg;:: Product Labeling");
        document.getElementById("CentrumTop").focus()
        oWnd.moveTo(100,50);
        //oWnd.center();
    } catch(err) {
        window.location.href = window.location.href
    }
}
function LoadVideo(VideoId){
    try{
        var oWnd = radopen("/video_player.aspx?VTL=" + VideoId, "");
        oWnd.setSize(695,615);
        oWnd.set_title("Centrum&reg;:: Video Player");
        document.getElementById("CentrumTop").focus()
        //oWnd.moveTo(110,30);
        oWnd.center();        
    } catch(err) {
        window.location.href = window.location.href
    }
}
function CompareProduct(BrandProductId){
    try{
        var oWnd = radopen("/productcompare.aspx?BrandProductId=" + BrandProductId, "");
        oWnd.setSize(780,720);
        oWnd.set_title("Centrum&reg;:: Product Comparison");
        document.getElementById("CentrumTop").focus()
        oWnd.moveTo(100,50);
    } catch(err) {
        window.location.href = window.location.href
    }
}
function VitaminGuide(){
    try{
        var oWnd = radopen("/vitaminguide.aspx", "");
        oWnd.setSize(630,670);
        oWnd.set_title("Centrum&reg;:: Vitamin & Mineral Guide");
        document.getElementById("CentrumTop").focus()
        oWnd.moveTo(100,50);
    } catch(err) {
        window.location.href = window.location.href
    }
}
function ProductTellAFriend(ProductName, PageName, Code){
    LoadTellAFriend("productdetail.aspx?BrandProductName=" + ProductName, PageName, Code);
}
function LoadTellAFriend(TheAddress, PageName, Code){
     try{
        var oWnd = radopen("/tellafriend.aspx?Address=" + TheAddress + "&PageName=" + PageName + "&Code=" + Code, "");
        oWnd.setSize(420,510);
        oWnd.set_title("Centrum&reg;:: Tell A Friend");
        document.getElementById("CentrumTop").focus()
        oWnd.moveTo(100,50);
    } catch(err) {
        window.location.href = window.location.href;
    }
}
function GoWholesaler(){
    var x, y;
    x = 860;
    y = 575;
    OpenWindow("http://www.wyethport.com", x, y)
}
function WyethAllBrands(OfferNumber){
    OfferNumber = URLEncode(OfferNumber);
    var x, y;
    x = 880;
    y = 475;
    OpenWindow(start + "/coupon_registration.aspx?OfferNumber=" + OfferNumber, x, y)
}
function URLEncode(OfferNumber)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = OfferNumber;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return  encoded;
};
function OriginCoupon(URL){
    var x, y;
    x = 870;
    y = 475;
    OpenWindow(URL, x, y)
}
function CountryNotice(){
    var x, y;
    x = 500;
    y = 300;
    OpenWindow("http://www.wyeth.com/countrynotice",x,y)
}
function OpenWindow(URL,x,y){
    var NewWindow
    NewWindow = window.open(URL, "Centrum_Link", "left=" + (screen.width-x)/2 + ",top=" + (screen.height-y)/3 +",menubar=no,width=" + x + ",height=" + y +",locationbar=no,toolbar=no,scrollbars=yes,resizable=yes")
    NewWindow.window.focus();
}
function ShowContent(ElementId) {
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(ElementId).style.visibility = "";
    } else {
        if (document.layers) { // Netscape 4
            document.ElementId.visibility= "";
        } else { // IE 4
            document.all.ElementId.style.visibility = "";
        }
    }
}
function HideContent(ElementId) {
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(ElementId).style.visibility = "hidden";
    } else {
        if (document.layers) { // Netscape 4
            document.ElementId.visibility= "hidden";
        } else { // IE 4
            document.all.ElementId.style.visibility = "hidden";
        }
    }
}

function LoadConfigurator(){
    if(cVisible == false){
        var x = findPosY(document.getElementById("ProdLineFooter"));
        document.getElementById("OverlayConfigurator").style.top = (x - 281) + "px";
        document.getElementById("OverlayConfigurator").style.marginLeft = "-7px";
        document.getElementById("OverlayConfigurator").innerHTML = ConfiguratorFlash;
        document.getElementById("btnGo").src = "/images/global/btnCloseFormula.gif";
        cVisible = true;
    } else {
        document.getElementById("OverlayConfigurator").innerHTML = "";
        document.getElementById("btnGo").src = "/images/global/modGoBtnFormula.gif";
        cVisible = false;
    }
}
function findPosY(obj){
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}
function findPosX(obj){
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}