﻿//Project: Chapstick Redesign
// JScript File
$(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 server = window.location.hostname
var NavSelected
var ProductFontSlider
var FontSize
var radFont
var IsSaving = false
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"
}

	
function main()
{
   mainProgramLogic();
   useLoadThisFunctionsAndObject();
}

function ChapstickNavigate(NavId){
    switch(NavId){
        case 1:
            window.location.href = "/default.aspx";
            break;
        case 2:
            window.location.href = "/producthub.aspx";
            break;
        case 3:
            window.location.href = "/lifestyle.aspx";
            break;
        case 4:
            window.location.href = "/faq.aspx";
            break;
        case 5:
            window.location.href = "/contact.aspx";
            break;
        case 6:
            window.location.href = "/buynow.aspx";
            break;
        default:
            window.location.href = "/productdetail.aspx?BrandProductId=" + NavId;
            break;
    }
}

function OpenWindow(URL,x,y){
    var NewWindow
    NewWindow = window.open(URL, "ChapStick_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 OpenWindow2(URL,x,y){
    var NewWindow
    NewWindow = window.open(URL, "ChapStick_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,statusbar=yes")
    NewWindow.window.focus();
}

function MainMenuOver(ControlId,ImageId){
    if(ImageId != NavSelected){
        ControlId.src = "/images/mainmenu/" + ImageId + "Over.gif";
    }    
}

function MainMenuOut(ControlId,ImageId){
    if(ImageId != NavSelected){
        ControlId.src = "/images/mainmenu/" + ImageId + ".gif";
    }
}

function AddToBreadCrumb(BrandProductName){
    BrandProductName = BrandProductName.replace("~*~","'");
    document.getElementById("BreadcrumbLinks").innerHTML = document.getElementById("BreadcrumbLinks").innerHTML + "&nbsp;&nbsp;|&nbsp;&nbsp;Chapstick&reg; " + BrandProductName;
}

function HideBreadCrumb(){
    document.getElementById("BreadcrumbLinks").className = "breadcrumbHide";
    HideContent("BreadcrumbLinks");
}

/*
focusElement = just an elements id where I want the dress the stick to load next to.
*/
function LeaveWyeth(Section,ID,focusElement){
    try{
        var oWnd = radopen("/leave_wyeth.aspx?Section=" + Section + "&ID=" + ID, "");
            oWnd.setSize(580,360);
            oWnd.set_title("Chapstick&reg;:: Leave Wyeth Notice");
            oWnd.moveTo(200,250);
        if(focusElement == ""){
            //nothing
        } else {
            document.getElementById(focusElement).focus()
            
        }
        
    } catch(err) {
        window.location.href = window.location.href;
    }
}


function IE6Notice(){
    try{
        var oWnd = radopen("/ie6.aspx","");
        oWnd.setSize(381,577);
        oWnd.set_title("Chapstick&reg;:: Internet Explorer 6 Notice");
        oWnd.moveTo(200,250);
    } catch(err) {
        window.location.href = window.location.href;
    }
}

/*****************************
used for the loading of the Dress the Stick component within multiple locations
focusElement = just an elements id where I want the dress the stick to load next to.
******************************/

function LoadDressTheStick(focusElement){
    try{
        var oWnd = radopen("/dressthestick.aspx", "");
        oWnd.center;
        oWnd.setSize(430,385);
        oWnd.set_title("Chapstick&reg;:: Dress The Stick");
        document.getElementById(focusElement).focus()
    } catch(err) {
        window.location.href = window.location.href
    }
}



/*****************************
Tell A Friend
******************************/

//Address = url page that the link within e-mail will bring the user back to
//PageInfo = Page Name, Article, or Product Name
//pCode = eMail Promotional Code located in wchtaf database
//XMLNode = XMLNode within xml file
function LoadTellAFriend(PageURL, PageInfo, XMLNode){
     try{
        OpenWindow2("taf.aspx?PageURL=" + PageURL + "&PageInfo=" + PageInfo + "&XMLNode=" + XMLNode,370, 700)
//        var oWnd = radopen("taf.aspx?PageURL=" + PageURL + "&PageInfo=" + PageInfo + "&XMLNode=" + XMLNode, "");
//        oWnd.setSize(370,600);
//        oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);
//        oWnd.set_title("Chapstick®:: Tell A Friend");
//        document.getElementById("ChapstickTop").focus();
//        oWnd.set_status("Secure");
//        oWnd.moveTo(400,135);
    } catch(err) {
        //window.location.href = window.location.href;
    }
}
 
 
 function LoadVideoTellAFriend(PageName, vidName){
     try{
        var pagetitle = window.location.href
        OpenWindow2("/UserControls/Resources/tellafriend.aspx?Address=" + pagetitle + "&PageName=" + PageName + "&Code=1" + "&vidName=" + vidName,370, 600)
//        var oWnd = radopen("/UserControls/Resources/tellafriend.aspx?Address=" + pagetitle + "&PageName=" + PageName + "&Code=1" + "&vidName=" + vidName, "");
//        //oWnd.setSize(400,400);
//        oWnd.setSize(430,385);
//        oWnd.set_title("Chapstick®:: Tell A Friend");
//        document.getElementById("ChapstickTop").focus()
//        oWnd.moveTo(100,50);
    } catch(err) {
        
    }
}

/*
Chapstick video on labling page
*/
function ShowLatestCommercialLG(CommercialName) {
    try {
        var oWnd = radopen("/latestcommercial.aspx?CommercialName=" + CommercialName , "");
        oWnd.setSize(650,510);
        oWnd.set_title("Chapstick&reg;:: Latest Commercial");
        oWnd.moveTo(100,50);
    } catch(err) {
     
    }
}

function vidPlayerSM(xmlNodeId) {
    try {
        var oWnd = radopen("/vidplayerSM.aspx?xmlNodeId=" + xmlNodeId , "");
        oWnd.setSize(400,400);
        oWnd.set_title("Chapstick&reg;:: Video Commercial");
        oWnd.moveTo(100,50);
    } catch(err) {
     
    }
}

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";
        }
    }
}

/*
used for the opening of the product labeling page
*/
function ViewProductLabeling(BrandProductName){
    try {
        var oWnd = radopen("/productlabeling.aspx?BrandProductName=" + BrandProductName , "");
        oWnd.setSize(800,500);
        oWnd.set_title("Chapstick&reg;:: Product Labeling");
        document.getElementById("ChapstickTop").focus()
        oWnd.moveTo(100,50);
    } catch(err) {
     
    }
}

function ShowHistoryModule() {
    try {
        var oWnd = radopen("/history.aspx" , "");
        oWnd.setSize(330,385);
        oWnd.set_title("Chapstick&reg;:: Century");
        oWnd.moveTo(100,50);
    } catch(err) {
     
    }
}
/*
United States COUNTRY RESIDENCY NOTICE
*/

function ViewCRN(){
    try {
        var oWnd = radopen("http://www.wyeth.com/irj/servlet/prt/portal/prtroot/com.wyeth.km.cm.document.GetDoc/wyeth_html/home/shared/footer/countrynotice.html", "");
        oWnd.setSize(800,500);
        oWnd.set_title("Chapstick&reg;:: COUNTRY RESIDENCY NOTICE");
        document.getElementById("ChapstickTop").focus()
        oWnd.moveTo(100,50);
    } catch(err) {
        window.location.href = window.location.href
    }
}


function CountryNotice(){
    var x, y;
    x = 500;
    y = 300;
    OpenWindow("http://www.wyeth.com/countrynotice",x,y)
}

/*
This function used on the classic flavor product detail page to change the background images.
*/
function ChangeBackground(Image) {
    document.getElementById(pdBackgroundId).style.backgroundImage= "url(/images/productdetails/" + Image + ")";
}
 
/*
print page funciton
*/
function PrintThisPage(){
    window.print();
}

/*

*/
function GoWholesaler(){
    var x, y;
    x = 860;
    y = 575;
    OpenWindow("http://www.wyethport.com", x, y)
}