﻿// JScript File

/*
	parseUri 1.2.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT License
*/

function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};



//Opens weather feed window
function ShowDetailedWeather(postal) {
	//window.alert(postal);
	// height was 480
	
	var x = parseUri(window.location);
	window.open('http://' + x.authority + '/pioneer/weatheroffice.aspx?p=' + postal, 'weatheroffice', 'toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=730,height=590px');
    }


function ShowDefaultWeather(stationID) {
	//window.alert(postal);
    var x = parseUri(window.location);
    
    if (window.location.href.indexOf('/oilseed/') > 0) {
        stationID = stationID + '&Int=1';
    }
    
	window.open('http://' + x.authority + '/pioneer/weatherbugdetails.aspx?stationid=' + stationID, 'weatheroffice', 'toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=730,height=690px');
}
