var webDBName;var fcstString;var setColor; function signIn(redirect){	var tForm=document.getElementById('signUp');	var uname = document.getElementById('username');	uname = uname.value;	var pwd = document.getElementById('password');	pwd = pwd.value;//	location.href='/basf/agprocan/WebSecureAuth.nsf?Login&username=' + uname + '&password=' + pwd + '&redirectTo=/basf/agprocan/WebSecureAuth.nsf/redirect.html';//		location.href='/basf/agprocan/WebSecureAuth.nsf?Login&username=' + uname + '&password=' + pwd + '&redirectTo=' + location.href;//location.href='/basf/agprocan/WebSecureAuth.nsf?Login&username=' + uname + '&password=' + pwd + '&redirectTo=/basf/agprocan/WebSecureAuth.nsf/SecureLoginRedirect?OpenNavigator%26section=Home&';location.href='/basf/agprocan/WebSecureAuth.nsf?Login&username=' + uname + '&password=' + pwd + '&redirectTo=/basf/agprocan/WebSecureAuth.nsf/SecureLoginRedirect?OpenNavigator%26section=' + redirect + '&';}     function getCommodityData(html){		var findStr = 'Mouse over contract for more info'	var pos = html.indexOf(findStr, 0);	html = Left(html, pos + findStr.length) + '</font></td></tr></table>';	html = html.replace('CANADIAN DOLLAR', 'CD');	html = html.replace('<table width="100%"', '<table ');	html = html.replace('Change', 'Chg');	html = html.replace('Canola/Rseed', 'Canola');	html = html.replace('Canola/Rseed', 'Canola');	html = html.replace('Commodity', 'Symbol');	var commData = document.getElementById("commData");	commData.innerHTML = html}function Left(str, n){	if (n <= 0)	    return "";	else if (n > String(str).length)	    return str;	else	    return String(str).substring(0,n);}   function getWeatherData(myXML)	{	var cdnProv = "NS,NU,ON,PE,SK,AB,NL,,NT,YT,NB,QC,BC,MB";	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday", "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");	var frm = document.forms[0];	if (myXML == "" | myXML == "\n") // The \n comes though no matter what is the fomatting of the form, so we will test for it.		{		//	No data found - hide weather display fields and display a prompt. It has not yet been determined if the same promot should appear when user changes the zip to an invalid code - currently the same.		document.getElementById("currentDiv").style.display="none";		document.getElementById("ltForecast").style.display="none";		document.getElementById("invalidDiv").style.display="";		fcstString = "";		return;		}		document.getElementById("invalidDiv").style.display="none"; //Code explicitly, in case it was visible previously.	document.getElementById("currentDiv").style.display="";	document.getElementById("ltForecast").style.display="";	/*	No longer use the parser, which is not handling some characters correctly. myJsonObject=xml2json.parser(myXML);	var wxQueryRow =  myJsonObject.wxquery_row; //Note: All lower case for the json names, even though the XML values are upper case	*/		var repCity = getXMLValue("reporting_city", myXML);	var cityName = getXMLValue("city", myXML);	document.getElementById("cityName").innerHTML = cityName;	document.getElementById("observation").src="/basf/agprocan/agsolutions/weather.nsf/" + getXMLValue("observation", myXML) + ".gif";	document.getElementById("NewZip").value= getXMLValue("zip", myXML);	document.getElementById("maxToday").innerHTML= getXMLValue("maxday1", myXML);	document.getElementById("minToday").innerHTML= getXMLValue("minday1", myXML);	// Determine variables that will be different for Cda and US - temperature and wind speed.	if (cdnProv.indexOf(getXMLValue("state", myXML)) > -1)	{		var deg = "C";		var wnd = "km/h";	}	else	{		var deg = "F";		var wnd = "m/h";	}	document.getElementById("maxTodayDeg").innerHTML=deg;	document.getElementById("minTodayDeg").innerHTML=deg;	// Wind - wind speed is reported in MPH for both US & Canada - convert to KM/H for Canada.	windSpd = new Number(getXMLValue("wind_sp", myXML));	if (windSpd.NaN)		{windSpd = 0;}	else if (cdnProv.indexOf(getXMLValue("state", myXML)) > -1)		{windSpd = windSpd * 1.609}	else		{windSpd = windSpd;}	document.getElementById("wind").innerHTML= getXMLValue("wind_dir", myXML) + " " + windSpd.toFixed(0) + " " + wnd;	// Evaluate long term forecast data - Create the query_String that will be passed to the page that will present forecast data.	// Format dayName\u00A5IconCode\u00A5Min\u00A5Max for each Day# parameter, plus degr parameter for degree symbol.	var todayDate = new Date();	var todayDay = todayDate.getDay();	 fcstString = "&day2=" + dayNames[todayDay + 1] + "\u00A5" +  getXMLValue("wxday2", myXML) + "\u00A5" + getXMLValue("maxday2", myXML)  + "\u00A5" + getXMLValue("minday2", myXML);	fcstString = fcstString + "&day3=" + dayNames[todayDay + 2] + "\u00A5" + getXMLValue("wxday3", myXML)  + "\u00A5" + getXMLValue("maxday3", myXML)  + "\u00A5" + getXMLValue("minday3", myXML);	fcstString = fcstString + "&day4=" + dayNames[todayDay + 3] + "\u00A5" +  getXMLValue("wxday4", myXML) + "\u00A5" + getXMLValue("maxday4", myXML)  + "\u00A5" + getXMLValue("minday4", myXML);	fcstString = fcstString + "&day5=" + dayNames[todayDay + 4] + "\u00A5" +  getXMLValue("wxday5", myXML) + "\u00A5" + getXMLValue("maxday5", myXML)  + "\u00A5" + getXMLValue("minday5", myXML);	fcstString = fcstString + "&degr=" + deg;	fcstString = fcstString + "&city=" + cityName;		}	function setNewZip()// *****setNewZip() *****	{		reg = /\s/;		newZip = document.getElementById("NewZip");		if (newZip.value == "")	{	alert("Please enter a new postal code");	return;	}	// Set the cookie.	var expirydate = new Date();	expirydate.setYear(2011);	document.cookie = "PCode=" + newZip.value.replace(reg,'') + "; expires=" + expirydate.toGMTString();	     getWeather(newZip.value);//	location.href = newHRef;	}function longTermFor(lang)   {    showPopFrame('popUpDef', 430, 230, '/' + webDBName +'/LTForecast?OpenNavigator&color='+setColor+fcstString+'&LG='+lang);  } function getXMLValue(xName, xmlString)	{	// Parses the value of the passed ame inside the passed xmlString	xName = xName.toUpperCase();	var startLoc = xmlString.indexOf("<"+ xName);	var charLoc = xmlString.charAt(xName.length + startLoc + 1);	if (!(xmlString.charAt(xName.length + startLoc + 1) == ">")) // Is there a > at the end of the tag? (does it have text?)		{return "";}	// The rest of the function is only used when there is data inside the tags.	var endLoc = xmlString.indexOf("</"+ xName + ">");	return xmlString.substring(xName.length + startLoc + 2, endLoc);			}