moListStyle = "vertical";
var iwmandp, ihmandp, ihbmandp, ihmiddle = 0, iwmiddle = 0, iheight, iwidth, mapSize, iadheight;
var multipleMaps;
try {
	if (typeof(moListStyle) == "undefined" || typeof(moDays) == "undefined" || typeof(moColourScheme) == "undefined" || typeof(moFSSI) == "undefined" || typeof(moDomain) == "undefined" || typeof(moMapDisplay) == "undefined" || typeof(moMapsRequired) == "undefined" || typeof(moTemperatureUnits) == "undefined" || typeof(moSpeedUnits) == "undefined" || typeof(moShowWind) == "undefined") {
		throw("Parameters missing in loader");
	}
	if (moListStyle !== "horizontal" && moListStyle !== "vertical") {
		throw("Invalid orientation in loader");
	}
	if (typeof(moDays) != "number" || Math.floor(moDays) != moDays || moDays < 1 || moDays > 5) {
		throw("Invalid days in loader");
	}
	if (moColourScheme !== "default" && moColourScheme !== "green" && moColourScheme !== "blue" && moColourScheme !== "yellow") {
		throw("Invalid colour scheme in loader");
	}
	if (typeof(moFSSI) != "number" || Math.floor(moFSSI) != moFSSI || moFSSI < 1) {
		throw("Invalid FSSI in loader");
	}
	if (moMapDisplay !== "side" && moMapDisplay !== "bottom" && moMapDisplay !== "none") {
		throw("Invalid map display position in loader");
	}
	if (typeof(moMapsRequired) != "string") {
		throw("Invalid map list in loader");
	}
	if (moTemperatureUnits !== "C" && moTemperatureUnits !== "F") {
		throw("Invalid temperature units in loader");
	}
	if (moSpeedUnits !== "M" && moSpeedUnits !== "K" && moSpeedUnits !== "N") {
		throw("Invalid speed units in loader");
	}
	if (moShowWind !== "true" && moShowWind !== "false") {
		throw("Invalid wind display flag in loader");
	}

	iwmandp = 26;	// margins and padding width
	ihmandp = 13 + 18 + 7 + 22 + 5 + 8 + 5;	// margins, padding, static text on height
	iadheight = 32;
	ihbmandp = (10 + 15 + 10 + 13 + iadheight);	// padding + copyright + more detail + bottom margin and padding + advert
	if (moListStyle === "horizontal") {
	// days stacked next to each other 
		iwmiddle += (moDays * 50);	// amount for n days next to each other
		iwmiddle = (iwmiddle < 159 ? 159 : iwmiddle);	//
		ihmiddle += 130;				// amount for static single height of a block of daily data
	} else {
	// days stacked on top of each other 
		ihmiddle += (moDays * 38);	// amount for n days on top of one other
		iwmiddle += 182;				// amount for a single width of a block of daily data.
	}
	multipleMaps = (moMapsRequired.split(",").length > 1);
	if (moMapDisplay == "side") {
		iwmap = 10 + 150 + ((multipleMaps) ? 19 : 10);	// width allocated for map = spacing + map + 2 x 11px controls (if more than one map)
		ihmap = 150 + 22 + 15 + 20 + 31; // height allocated formap = height of map + title + subtitle + spacing + warning gif;
		iheight = Math.max(ihmandp + ihmiddle - iadheight + 10, ihmap);	// height is then changed to use minimum space possible
		iwidth = iwmandp + iwmiddle + iwmap  +2;			// width is fixed: margins + the weather space + the map space
	} else if (moMapDisplay == "bottom") { 
		iwmap = 150 + ((multipleMaps) ? 24 : 0); // width allocated for map = 150 + 2 x 11px controls (if more than one map)
		ihmap = 150 + 22 + 15 + 10; // height of map + title + subtitle + spacing;
		iheight = ihmandp + ihmiddle + ihmap;			// height is fixed: margins, etc. + weather space + map
		iwidth = iwmandp + Math.max(iwmiddle, iwmap) +2 ;	// width is changed to use minimum space possible.  
	} else {
		// if no maps shown, height and width are both = margins, borders + the space allocated to weather.   
		iheight = ihmandp + ihmiddle;					
		iwidth = iwmandp + iwmiddle +2;
	}
	iheight += ihbmandp -80;	// always need to add the bottom margin and border space.   
	var iframeURL = "http://" + moDomain + "/public/pws/components/yoursite/component.html?cp=" + escape(top.document.location.href) + "&moListStyle=" + moListStyle + "&moDays=" + moDays + "&moColourScheme=" + moColourScheme + "&moFSSI=" + moFSSI + "&moDomain=" + moDomain + "&h=" + iheight + "&w=" + iwidth + "&moMapDisplay=" + moMapDisplay + "&moMapsRequired=" + moMapsRequired + "&moTemperatureUnits=" + moTemperatureUnits + "&moSpeedUnits=" + moSpeedUnits + "&moShowWind=" + moShowWind;
}
catch(error) {
	var iheight = 300;
	var iwidth = 240;
	var iframeURL = "http://" + moDomain + "/public/pws/components/yoursite/error.html?cp=" + escape(top.document.location.href) + "&h=" + iheight + "&w=" + iwidth;
}

var iframe = "<ins style=\"border: medium none ; margin: 0pt; padding: 0pt; display: inline-table; height: " + iheight + "px; position: relative; visibility: visible; width: " + iwidth + "px;\">" +
	"<ins style=\"border: medium none ; margin: 0pt; padding: 0pt; display: block; height: " + iheight + "px; position: relative; visibility: visible; width: " + iwidth + "px;\">" +
	"<iframe id=\"mowxpane\" scrolling=\"no\" height=\"" + iheight + "\" frameborder=\"0\" width=\"" + iwidth + "\" vspace=\"0\" style=\"left: 0pt; position: absolute; top: 0pt;\" src=\"" + iframeURL + "\" name=\"mowxpane\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" allowtransparency=\"true\">" + 
	"</iframe>" + 
	"</ins>" + 
	"</ins>";
if (typeof(moNoScript) == "undefined") {
	document.write(iframe); 
}

