﻿$(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); }
		);
	});
};

var countries;

$(document).ready(function(){
    //Get the CountryLanguage json string which is in jsonValueServer (set in MainMenu.ascx)
    var jsonValue = 'data =' + jsonValueServer;
    eval(jsonValue);
	countries = data.countries;
	$.each(countries, function(i,c){    
		$('#countries').append($('<option></option>').val(c.code).html(c.name));
	});        
});

function FilterLanguages(o)
{
	$('#languages').find('option').remove().end();
	var selval = o.options[o.selectedIndex].value;
		$('#languages').append($('<option></option>').html("--Select a Language--"));
	if (selval != "") {
		$.each(countries, function(i,c){   
			if (c.code == selval)
			{
				$.each(c.lang, function(j,l){
					$('#languages').append($('<option></option>').val(l.code).html(l.name));
				});
			}
		});        
	}
}


function OpenWindow(URL, title, query, w, h)
{
    var setting = "left=" + (screen.width-w)/2 + ",top=" + (screen.height-h)/3 +",menubar=no,width=" + w + ",height=" + h +",location=yes,toolbar=no,scrollbars=no,resizable=yes,status=yes";
    URL=URL + "?" + query;
    var win = window.open(URL, '', setting);
    win.focus();
}
function OpenWindow2(URL, title, query, w, h)
{
    var setting = "left=" + (screen.width-w)/2 + ",top=" + (screen.height-h)/3 +",menubar=no,width=" + w + ",height=" + h +",location=yes,toolbar=no,scrollbars=yes,resizable=yes,status=yes";
    URL=URL + "?" + query;
    var win = window.open(URL, '', setting);
    win.focus();
}

function LeaveWyeth(id, url,width, height){
    try{
        scroll(0,0);
        url = escape(url)
        var oWnd = radopen("/LeaveWyeth.aspx?id=" + id + "&url=" + url);
        oWnd.setSize(350,320);
        oWnd.set_title("ThermaCare&reg;:: Leave Wyeth Notice");
        oWnd.moveTo(screen.width/3,screen.height/5);
    } catch(err) {
    }
}

function DisplayContent(type, id, width, height){
    try{
        scroll(0,0);
        var oWnd = radopen("/ContentLoader.aspx?type=" + type + "&id=" + id );
            oWnd.setSize(width,height);
            oWnd.set_title("ThermaCare&reg;");
            oWnd.moveTo(screen.width/3,screen.height/5);
    } catch(err) {
    }
}

function DisplayPage(page, title, query, width, height){
    try{
        scroll(0,0);
        var oWnd = radopen("/" + page + "?" + query);
        oWnd.setSize(width,height);
        oWnd.set_title(title);
        oWnd.moveTo(screen.width/3,screen.height/5);
    } catch(err) {
    }
}

function DisplayVideo(vid, width, height){
    try{
        scroll(0,0);
        var oWnd = radopen("/VideoPlayer.aspx?video=" + vid);
        oWnd.setSize(width,height);
        oWnd.set_title("ThermaCare&reg;");
        oWnd.moveTo(screen.width/3,screen.height/5);
    } catch(err) {
    }
}

function LoadProductLabeling(product, width, height){
    try{
        scroll(0,0);
        var oWnd = radopen("/ProductLabeling.aspx?productname=" + product);
        oWnd.setSize(width,height);
        oWnd.set_title("ThermaCare&reg;");
        oWnd.moveTo(200,100);
    } catch(err) {
    }
}

function switchObj(showid, hideid, imgpath)
{
    document.getElementById("img" + showid).src = imgpath + showid + "_on.jpg";
    document.getElementById("div" + showid).style.display= "block";

    document.getElementById("img" + hideid).src = imgpath + hideid + "_off.jpg";
    document.getElementById("div" + hideid).style.display= "none";
}

var NavIdSelected = "";
function MainMenuOver(ControlId){
    var src = ControlId.src;
    if (src.indexOf("_on.gif")>0) 
        NavIdSelected = ControlId.id
    else
        ControlId.src = src.replace(".gif","_on.gif");
}

function MainMenuOut(ControlId){
    var src = ControlId.src;
    if (NavIdSelected!=ControlId.id)
        ControlId.src = src.replace("_on.gif",".gif");
}
function CountryNotice(){
    var x = 450;
    var y = 300;
    OpenWindow("http://www.wyeth.com/countrynotice", "CountryResidency", "", x,y)
}

function GoWholesaler(){
    var x = 860;
    var y = 575;
    OpenWindow("http://www.wyethport.com", "WyethPort", "", x, y)
}
function PrintPage() {
    window.print();
}
function EmailPage(prod){
    switch (prod)
    {
        case "muscle": OpenWindow('/EmailFriend.aspx', '', 'id=product&type=muscle&txt=Muscle and Joint Relief', 350, 540); break;
        case "menstrual": OpenWindow('/EmailFriend.aspx', '', 'id=product&type=menstrual&txt=Menstrual Relief', 350, 540); break;
        case "arthritis": OpenWindow('/EmailFriend.aspx', '', 'id=product&type=arthritis&txt=Joint and Arthritis Relief', 350, 540); break;
    }
}
function SetListStyle(flag)
{
    if (flag) {
        document.getElementById('listitem').style.top='25px'
        document.getElementById('listitem').style.left='-40px'
        document.getElementById('listlink').style.background = "url(/images/mainmenu/country_over.jpg)";
    }
    else {
        if (window.event && 
            window.event.srcElement && 
            (window.event.srcElement.id=="countries" ||
             window.event.srcElement.id=="languages" ||
             window.event.srcElement.id=="MainMenu_ibGo")) return;
        document.getElementById('listitem').style.top='-999em'
        document.getElementById('listitem').style.left=''
        document.getElementById('listlink').style.background = "url(/images/mainmenu/country.jpg)";
    }

}
function RedirectSite()
{
    var selcountry = document.getElementById('countries');
    if (selcountry.selectedIndex<=0)
        return;
    var sellanguage = document.getElementById('languages');
   if (sellanguage.selectedIndex<=0)
       return;
    document.getElementsByTagName( 'form' )[0].submit(); 
}