/*var gonow
        var workie4
        workie4 = navigator.appVersion;
        work = workie4.indexOf("MSIE 4",17);
        if (work == 17) {
        gonow = true;
        }*/

//Establish  Browser Version.
var n = (navigator.appName == "Netscape")
var n4 = (document.layers) ? 1:0
var ie = (navigator.appName == "Microsoft Internet Explorer")
var ie4 = (document.all) ? 1:0
var n6 = (!document.all && document.getElementById) ? 1 : 0
var browserName = navigator.appName;
var rolloversOK = 0;
browserVer = parseInt(navigator.appVersion);
//Commented by Amar Raut as per Anchal Request on date 07-12-2007
/*if (n && browserVer >= 3) rolloversOK = 1;
else if (ie && browserVer >= 4) rolloversOK = 1;

if (n4) {
// Test for Unix NS4 version and don't allow DHTML elements in it
        if (navigator.appVersion.indexOf("X11") >= 0) {
                n4 = 0;
        }
}
else if (ie4) {
 // Test for Mac IE4 version and don't allow DHTML elements in it
        if ((navigator.appVersion.indexOf("Macintosh") >= 0) || (navigator.appVersion.indexOf("Mac_") >= 0)) {
                ie4 = 0;
        }
}*/
//Added by Amar Raut as per Anchal Request on date 07-12-2007
if (n && browserVer >= 0) rolloversOK = 1;
else if (ie && browserVer >= 0) rolloversOK = 1;

if (n4) {
// Test for Unix NS4 version and don't allow DHTML elements in it
        if (navigator.appVersion.indexOf("X11") >= 0) {
                n4 = 0;
        }
}
else if (ie4) {
 // Test for Mac IE4 version and don't allow DHTML elements in it
        if ((navigator.appVersion.indexOf("Macintosh") >= 0) || (navigator.appVersion.indexOf("Mac_") >= 0)) {
                ie4 = 0;
        }
}

//More Variables
timegap=500					// The time delay for menus to remain visible on mouse off
followspeed=5				// Follow Scrolling speed (higher number makes the scrolling smoother but slower)
followrate=40				// Follow Scrolling Rate (use a minimum of 40 or you may experience problems)

var theTimeout = setTimeout("","1");
var subTheTimeout = setTimeout("","1");
var version = "no";
var top_adjust = 0;
//var subtop_adjust = 0;
var offset;
var browserWidth;
var browserOffset;
var pageWidth = 800;

//if (n4) {
        version = "ok";
        top_adjust = 2;
//}

//else if (ie4) {
 //       version = "ok";
 //       top_adjust = 2;
//}


// The Popup Menu Variables
var totalMenus = 1;
var menuPosX = 1;
var menuPosY = new Array(totalMenus);
var itemsOnMenu = new Array(totalMenus);
var menuItems = new Array(totalMenus);
var urlLinks = new Array(totalMenus);
var lastMenu = -99;
var lastHotItem = -99;
var moveOver = 3;

//tr that changes
var bgHot = "#000099";
var bgNormal = "#ffffff";
menuPosY[1] = 90  + top_adjust;
itemsOnMenu[1] = 5;

menuItems[1] = new Array(itemsOnMenu[1]);
urlLinks[1] = new Array(itemsOnMenu[1]);

//TRY AND BUY NAV
menuItems[1][0] = "&nbsp;&nbsp;&nbsp;Try & Buy";           
menuItems[1][1] = "&nbsp;&nbsp;&nbsp;Share Your Thoughts"; 
menuItems[1][2] = "&nbsp;&nbsp;&nbsp;Sweepstakes & Newsletters";                             
menuItems[1][3] = "&nbsp;&nbsp;&nbsp;US Product Information";
menuItems[1][4] = "&nbsp;&nbsp;&nbsp;Everyday Solutions";

urlLinks[1][0] = "/products/try_buy.shtml";
urlLinks[1][1] = "/redirects/recipio.html";
urlLinks[1][2] = "/sweepstakes/sectionmain.shtml";
urlLinks[1][3] = "/products/usa_product_facts.shtml";
urlLinks[1][4] = "/everyday_solutions/sectionmain.shtml";

menuPosY[2] =  90 + top_adjust;
itemsOnMenu[2] = 5;

menuItems[2] = new Array(itemsOnMenu[2])
urlLinks[2] = new Array(itemsOnMenu[2])

//INVESTORS NAV

menuItems[2][0] = "&nbsp;&nbsp;&nbsp;&nbsp;Main Page";             
menuItems[2][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Stock Price";                 
menuItems[2][2] = "&nbsp;&nbsp;&nbsp;&nbsp;Stock History";                       
menuItems[2][3] = "&nbsp;&nbsp;&nbsp;&nbsp;Shareholder Contacts";                 
menuItems[2][4] = "&nbsp;&nbsp;&nbsp;&nbsp;Stock Purchase";                       
menuItems[2][5] = "&nbsp;&nbsp;&nbsp;&nbsp;Investor Tools"; 

urlLinks[2][0] = "/investors/sectionmain.shtml";
urlLinks[2][1] = "javascript:stockpop('http://www.shareholder.com/visitorsnew/mini-quote-pg.cfm?companyid=pg');";
urlLinks[2][2] = "/investors/stock_history.shtml";
urlLinks[2][3] = "/investors/fast_facts/features.shtml";
urlLinks[2][4] = "/investors/stock_purchase.shtml";
urlLinks[2][5] = "/investors/investor_tools.shtml";


//JOBS NAV
menuPosY[3] = 90 + top_adjust
itemsOnMenu[3] = 3
menuItems[3] = new Array(itemsOnMenu[3])
urlLinks[3] = new Array(itemsOnMenu[3])

//JOBS NAV
menuItems[3][0] = "&nbsp;&nbsp;&nbsp;&nbsp;To Apply to P&G";  
menuItems[3][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Corporate Information";        
menuItems[3][2] = "&nbsp;&nbsp;&nbsp;&nbsp;Career Advice Center"; 

urlLinks[3][0] = "/jobs/sectionmain.shtml";
urlLinks[3][1] = "/jobs/corporate_info/corp_info.shtml";
urlLinks[3][2] = "http://www.pgcareeradvicecenter.com/";


menuPosY[4] = 90 + top_adjust
itemsOnMenu[4] = 7

menuItems[4] = new Array(itemsOnMenu[4])
urlLinks[4] = new Array(itemsOnMenu[4])

//NEWS NAV
menuItems[4][0] = "&nbsp;&nbsp;&nbsp;&nbsp;Main Page";                 
menuItems[4][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Photo Gallery";                       
menuItems[4][2] = "&nbsp;&nbsp;&nbsp;&nbsp;News Archive";                                  
menuItems[4][3] = "&nbsp;&nbsp;&nbsp;&nbsp;Financial Information";                 
menuItems[4][4] = "&nbsp;&nbsp;&nbsp;&nbsp;Corporate Information";                       
menuItems[4][5] = "&nbsp;&nbsp;&nbsp;&nbsp;Worldwide Operations"; 
menuItems[4][6] = "&nbsp;&nbsp;&nbsp;&nbsp;Product Information";

urlLinks[4][0] = "/news/sectionmain.shtml";
urlLinks[4][1] = "/news/photogallery.shtml";
urlLinks[4][2] = "/news/XMLSearch_news.shtml";
urlLinks[4][3] = "/investors/financial_reports/category_main.shtml?toolbar=/includes/ltb_news_mini.shtml";
urlLinks[4][4] = "/news/executive_bio.shtml";
urlLinks[4][5] = "/about_pg/worldwide_operations.shtml";
urlLinks[4][6] = "/products/pg_products.shtml";

menuPosY[5] = 90 + top_adjust
itemsOnMenu[5] = 7

menuItems[5] = new Array(itemsOnMenu[5])
urlLinks[5] = new Array(itemsOnMenu[5])

//ABOUT NAV
menuItems[5][0] = "&nbsp;&nbsp;Main Page";                 
menuItems[5][1] = "&nbsp;&nbsp;Overview & Facts";                       
menuItems[5][2] = "&nbsp;&nbsp;Community Center";                 
menuItems[5][3] = "&nbsp;&nbsp;Sustainability";    
menuItems[5][4] = "&nbsp;&nbsp;R & D";                       
menuItems[5][5] = "&nbsp;&nbsp;Product Information"; 
menuItems[5][6] = "&nbsp;&nbsp;Worldwide Operations";

urlLinks[5][0] = "/about_pg/sectionmain.shtml";
urlLinks[5][1] = "/about_pg/overview_facts/category_main.shtml";
urlLinks[5][2] = "/about_pg/corporate/community/community_submain.shtml";
urlLinks[5][3] = "/about_pg/corporate/sustainability/substain_catmain.shtml";
urlLinks[5][4] = "/about_pg/science_tech/research_development/category_main.shtml";
urlLinks[5][5] = "/products/pg_products.shtml";
urlLinks[5][6] = "/about_pg/worldwide_operations.shtml";

 // POPUP MENU FUNCTIONS

function doPopup (whichMenu, whichHotItem) {
        //if (version != "ok") {return}
                
//Moves menu over from left of window
        if (whichMenu == 0) { moveOver = 5; }
        else if (whichMenu == 1) { moveOver = 270; }
        else if (whichMenu == 2) { moveOver = 415; }
        else if (whichMenu == 3) { moveOver = 505; }
        else if (whichMenu == 4) { moveOver = 572; }
		else if (whichMenu == 5) { moveOver = 640; }
//       	else if (whichMenu == 6) { moveOver = 592; }
//		else if (whichMenu == 7) { moveOver = 634; }
//Clears the HidePopup timeout
        clearTimeout(theTimeout);

// DO WE HAVE TO RE-DRAW THE MENU?
        newMenu = 0
        if (whichMenu != lastMenu) {
                lastMenu = whichMenu
                newMenu = 1 
        }
        else if (whichHotItem != lastHotItem) {
                newMenu = 1
        }

// RE-DO THE POPUP TABLE, IF NECESSARY
        if (newMenu) {
                lastHotItem = whichHotItem;
                popupWidth = "100"; insideWidth = "98";
//Adjusts the size of each of the popup menus according to the size of text
                 if ((whichMenu == 0)) { popupWidth = "150"; insideWidth = "148"; }
                 if ((whichMenu == 1)) { popupWidth = "180"; insideWidth = "178"; }
                 if ((whichMenu == 2)) { popupWidth = "160"; insideWidth = "158"; }
                 if ((whichMenu == 3)) { popupWidth = "150"; insideWidth = "148"; }
                 if ((whichMenu == 4)) { popupWidth = "150"; insideWidth = "148"; }
                 if ((whichMenu == 5)) { popupWidth = "132"; insideWidth = "130"; }
//				 if ((whichMenu == 6)) { popupWidth = "150"; insideWidth = "148"; }
//				 if ((whichMenu == 7)) { popupWidth = "140"; insideWidth = "138"; }
//the size of the height of each tr (leave alone)
                                popupHeight = (itemsOnMenu[whichMenu] * 15)
//theTable is a variable that holds the string of the entire table of the Popups
                                theTable  = '<table width=' + popupWidth + ' cellpadding=0 cellspacing=0 border=1><tr><td>\n'
                                theTable += '<table align="center" width=' + insideWidth + ' height=' + popupHeight + ' bgcolor=' + bgNormal + ' cellspacing=0 cellpadding=0 border=0>\n'
                               //theTable += '<tr><td width="100%" height=1></td></tr>\n' 
                for (x = 0; x < itemsOnMenu[whichMenu]; x++ ) {
                        bg2Use = bgNormal; class2Use = "notHot";
                        if (x == whichHotItem) { bg2Use = bgHot; class2Use = "Hot"; }
                        theTable += '<tr bgcolor=' + bg2Use + '><td><a href="' + urlLinks[whichMenu][x] + '" class="' + class2Use + '" onMouseOver="doPopup(' + whichMenu + ',' + x + ');" onMouseOut="hideTime();">' + menuItems[whichMenu][x] + '</a></td></tr>\n'
                       //aif (x != itemsOnMenu[whichMenu]) { theTable += '<tr><td width="100%" height=1></td></tr>\n' }
                }
                theTable += '</table>\n</td></tr></table>\n'
//Check for N4 and writes to the Layer tag
                if (n4) 
                {
                        browserWidth = window.innerWidth;
                        browserOffset = 20;
                        offset = (browserWidth - pageWidth)/2 + moveOver - 2;
                        menuPosX = 0 + moveOver;
        
                        whichLayer = "nsPopup"
                        document.layers[whichLayer].visibility = 'hide'
                        document.layers[whichLayer].document.write(theTable)
                        document.layers[whichLayer].document.close()
                        if (whichHotItem == -1) 
                        {
                                document.layers["nsBuffer"].visibility = 'hide'
                                document.layers["nsBuffer"].document.write(theTable)
                                document.layers["nsBuffer"].document.close()
                                document.layers["nsBuffer"].moveTo(menuPosX, menuPosY[whichMenu])
                                document.layers["nsBuffer"].visibility = 'show'
                        }
                        document.layers[whichLayer].moveTo(menuPosX, menuPosY[whichMenu])
                        document.layers[whichLayer].visibility = 'show'
                }
//Checks for IE4 and writes to the Div tag
                else if (ie4)
                     {
                        browserWidth = parseInt(document.body.offsetWidth);
                        browserOffset = 20;

						      offset = (browserWidth - pageWidth)/2 + moveOver;
                        menuPosX = 0 + moveOver;

                        whichLayer = "iePopup"
                        document.all[whichLayer].innerHTML = theTable
                        document.all[whichLayer].style.posLeft = menuPosX
                        document.all[whichLayer].style.posTop = menuPosY[whichMenu]
                        document.all[whichLayer].style.visibility = 'visible'
                    }
                    else if (n6)
                    {
									//alert("n6 1");
									browserWidth = parseInt(document.body.offsetWidth);
									browserOffset = 20;
									offset = (browserWidth - pageWidth)/2 + moveOver;
									menuPosX = 0 + moveOver;
									whichLayer = "nsPopup"           
									document.getElementById("nsBuffer").style.visibility = 'hidden'
									document.getElementById("nsBuffer").innerHTML=theTable
									document.getElementById("nsBuffer").style.left=menuPosX
									document.getElementById("nsBuffer").style.top=menuPosY[whichMenu]
									document.getElementById("nsBuffer").style.visibility = 'visible'
                    }
                }
             
        }

        
function hideTime() {

        if (version != "ok") {

        }

        else {
        
        if (n4 | n6){theTimeout = setTimeout("hidePopups()", "600");}
        
     
        else {

                theTimeout = setTimeout("hidePopups()", "40");

	     }
	}

}


function hidePopups() {

                lastMenu = -99
                lastHotItem = -99
                
        if (n4) {
                document.layers["nsPopup"].visibility = "hide";
                document.layers["nsBuffer"].visibility = "hide";
        }

                else if (ie4) { 
                 document.all["iePopup"].style.visibility = 'hidden';
        }
        else if (n6)
		 {
		       // alert("n6 4");
		        document.getElementById("nsPopup").style.visibility = 'hidden'
		        document.getElementById("nsBuffer").style.visibility = 'hidden'
        }
        
}


//--------Stock Price Popup
function stockpop(URL) {
	remote = window.open(URL,"pop","scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0,width=340,height=130,screenX=0,screenY=0,left=200,top=250");
	remote.focus();
	if (remote.opener == null) remote.opener = self;
}