Lib.Utils.EventUtils.addEvent(window, 'load', function() { addRowColor(); });
Lib.Utils.EventUtils.addEvent(window, 'load', function() { P7_initPM(1,0,1,-20,10) });
//Lib.Utils.EventUtils.addEvent(window, 'load', function() { new Menus });

//Set parameters for language, then reload window.
function setParams(id, value) {
	var curUrl = parent.location.href;
    curUrl = curUrl.replace("&lang=english", "");
    curUrl = curUrl.replace("&lang=french", "");
	var stop = curUrl.indexOf("?");
	var newUrl = curUrl.substr(0,stop);

    if (curUrl.indexOf('?lang=english') != -1) {
        window.location =  (newUrl + '?' + id + '=' + value);
    } else if (curUrl.indexOf('?lang=french') != -1) {
    	window.location =  (newUrl + '?' + id + '=' + value);
    } else if (curUrl.indexOf('?') != -1) {
        window.location =  (curUrl + '&' + id + '=' + value);
    } else {
    	window.location =  (newUrl + '?' + id + '=' + value);
    }
}

//After user selects Region from cboBox, go to appropriate homepage for that region.
function goToHome(value) {
    curUrl = parent.location.href;
    var stop = curUrl.indexOf("/asp/");
    var baseUrl = curUrl.substr(0,stop);
    //alert (newUrl);
    switch (value) {
    case "west": { /*window.location = baseUrl + "/asp/main.asp?goTo=west"; break;*/window.location = baseUrl + "/asp/west/default.asp?region=west"; break; }
    case "east": { window.location = baseUrl + "/asp/east/default.asp?region=east"; break; }
    default: { return false; break; }
    }
}

// Loop through all rows.  If current row is equal to previous row "id" then use the current row should use the previous row's classname.
// If current row does not equal previous row then check to see if the previous row's classname is equal to "alternateRow".  
// If it is then, do not set a className, else set the current row's className to "alternateRow".
function addRowColor() {
	var table = document.getElementById('product_family_tbl_body');
    var isCorn = document.getElementById('hidCorn');
	if (typeof table != 'undefined' && table != null)  {
        if (typeof isCorn != 'undefined' && isCorn != null)  {
			var rows = table.getElementsByTagName('TR');
			for (var i = 0; i < rows.length; i++) {
				if (i > 0) {
					if (rows[i].id == rows[i-1].id) {
						rows[i].className = rows[i-1].className;
					}
					else {
						if (rows[i-1].className == "alternateRow") {
							rows[i].className = "";
						} else {
						    rows[i].className = "alternateRow";
						}
                }
					}
				}
			}
	    }	
}

function generatePrinterFriendly() {
    var curUrl = parent.location.href;
	//var stop = curUrl.indexOf("?");
	//var newUrl = curUrl.substr(0,stop);
    
    if (curUrl.indexOf('id') != -1 || curUrl.indexOf('prodTypeId') != -1 || curUrl.indexOf('newsId') != -1 || curUrl.indexOf('lang') != -1) {
        window.location = curUrl + "&print=yes";
    }
    else {
        window.location = curUrl + "?print=yes";
    }
    
}

/* Legacy Spawn Window 
---------------------------------------------------------------------- */
	
var spawnWin = null
var winCount = 0
var winName = "spawnWin"

function openSpawn(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
	var d_winLeft = 20
	var d_winTop = 20 
	winName = "spawnWin" + winCount++ 
	closePopWin()
	if (openSpawn.arguments.length>= 4)
		winFeatures = "," + winFeatures
	else
		winFeatures = ""
	if (openSpawn.arguments.length == 6)
		winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
	else
		winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
		spawnWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures)
	self.name = "parent"
}

/* Win Features
toolbar,scrollbars,location,statusbar,menubar,resizable
*/

function closePopWin(){
	if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion)>=4) 
	if (spawnWin != null) if(!spawnWin.closed) spawnWin.close()
}

function getLocation(winWidth, winHeight, winLeft, winTop){
	return ""
}

function getLocation(winWidth, winHeight, winLeft, winTop){
	var winLocation = ""
	if (winLeft < 0) winLeft = screen.width - winWidth + winLeft
	if (winTop < 0) winTop = screen.height - winHeight + winTop
	if (winTop == "cen") winTop = (screen.height - winHeight)/2
	if (winLeft == "cen") winLeft = (screen.width - winWidth)/2
	if (winLeft>0 & winTop>0) winLocation =  ",screenX=" + winLeft + ",left=" + winLeft + ",screenY=" + winTop + ",top=" + winTop
	else winLocation = ""
	return winLocation
}

function newsletterRegUrl(region, lang) {
	var url = "http://w3dom-d01.monsanto.com/CA/Dekalb/Registration.nsf/Registeration?OpenForm"
	if (lang == "fr") {
			
	} else {
		
	}
	openSpawn(url, 600, 575, 'scrollbars,resizable', 'cen', 'cen');
}
