﻿//Initialize Fusion namespace
if (window.Fusion === undefined) window.Fusion = {};
if (window.Fusion.webApp === undefined) window.Fusion.webApp = "/";
if (window.Fusion.protocol === undefined) window.Fusion.protocol = "//";
if (window.Fusion.warnings === undefined) window.Fusion.warnings = [];
if (window.Fusion.parameters === undefined) window.Fusion.parameters = {};
if (window.Fusion.affiliate === undefined) window.Fusion.affiliate = undefined;
if (window.Fusion.discardStatistics === undefined) window.Fusion.discardStatistics = false;
if (window.Fusion.ATTR_PAYLOAD === undefined) window.Fusion.ATTR_PAYLOAD = "Payload";
if (window.Fusion.ATTR_SHOWN === undefined) window.Fusion.ATTR_SHOWN = "Shown";

/**
 * Adds a warning if a field in window.Fusion doesn't exist.
 */
window.Fusion.assertFieldExists = function(field) {
	if (window.Fusion[field] === undefined) {
		window.Fusion.warnings.push("Assertion failed: Field \"" + field + "\" is undefined");
		return false;
	} else return true;
}

/**
 * Shows all warnings.
 */
window.Fusion.showWarnings = function(){
	var w, msg = window.Fusion.warnings.length ? window.Fusion.warnings.length + " warning/s:\n" + window.Fusion.warnings.join("\n") : "No warnings.";
	if (!window.Fusion.warnings.length || !(w = window.open("about:blank", "_blank", "width=800,height=600"))) alert(msg);
	else {
		w.document.open("text/plain");
		w.document.writeln(msg);
		w.document.close();
	}
}

/**
 * Randomizes a number in the interval [low, high)
§§§ */
window.Fusion.randomInterval = function (low, high){ return Math.floor((Math.random() * (high - low)) + low); }

/**
 * Randomizes a string (character a-z) of length len.
 */
window.Fusion.randomAsciiString = function (len){
	var ret = "";
	while (len-- > 0)
		ret += String.fromCharCode(window.Fusion.randomInterval('a'.charCodeAt(0), 'z'.charCodeAt(0) + 1));
	return ret;
}

/**
 * Does a minimal HTML encoding of a string.
 */
window.Fusion.htmlEncode = function (s) {
	return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\'/g, "&#39;").replace(/\"/g, "&quot;");
}

/**
 * Expands special symbols in a component attribute.
 */
window.Fusion.expandAttribute = function (comp, attr, visited) {
	if (!visited) visited = [];
	var funcs = { "htmlEncode": window.Fusion.htmlEncode, "uriEncode": encodeURIComponent };
	return comp.attributes[attr].replace(/(\{{1,2})%([^%]+)%\}/g, function(match, braces, content){
		if (braces.length == 2) return "{%" + content + "%}"; // double braces quote
		var parts = content.split(":");
		var content = parts.pop().replace(/^([^\.]+)\.?(.*)$/, function (match2, prefix, suffix){
			switch (prefix){
				case "Fusion": 
					if (window.Fusion[suffix] === undefined) {
						window.Fusion.warnings.push("Tried to expand unknown Fusion attribute: " + suffix);
						return "Fusion." + suffix;
					} else return window.Fusion[suffix].toString();
				case "attribute":
					for (var vindex = 0; vindex < visited.length; ++vindex) {
						if (visited[vindex] == suffix){
							window.Fusion.warnings.push("Expanding attribute '" + attr + 
									"' causes infinite recursion. Stack is " + visited);
							return match2;
						}
					} 
					visited.push(suffix);
					var ret = window.Fusion.expandAttribute(comp, visited);
					visited.pop();
					return ret;
				case "r": return window.Fusion.randomAsciiString(suffix ? parseInt(suffix, 10) : 5);
				case "eventUrl": return window.Fusion.getAdvertEventUrl(comp.ad, suffix);
				case "parameters": return window.Fusion.getParameters();
				case "adId": return comp.ad.toString();
				default: window.Fusion.warnings.push("Tried to expand unknown macro: " + match2); return match2;
			}
		});
		while (parts.length > 0) {
			var funcName = parts.pop();
			var f = funcs[funcName];
			if (f === undefined) window.Fusion.warnings.push("Bad macro function: " + funcName);
			else content = f(content);
		}
		return content;
	});
}

window.Fusion.getComponent = function(placementName, attribute) {
    if (attribute === undefined)
        attribute = window.Fusion.ATTR_PAYLOAD;
    if (window.Fusion.assertFieldExists("adComponents")) {
        var components = window.Fusion.adComponents[placementName];
        var component = null;
        if (!(components instanceof Array) || components.length === 0) {
            //window.Fusion.warnings.push("Tried to show ad for non-existing placement " + placementName);
            return null;
        } else if (typeof ((component = components.shift()).attributes[attribute]) != typeof ("")) {
            window.Fusion.warnings.push("Component on placement " + placementName +
					" for ad " + component.ad + " missing " + attribute + " attribute");
            return null;
        } else {
            //DanChr: we will need that later for checking, which ads were displayed
            component.attributes[window.Fusion.ATTR_SHOWN] = true;
            return window.Fusion.expandAttribute(component, attribute);
        }
    } else return null;
}

/**
* Checks which spaces displayed ads.
*/
window.Fusion.checkAds = function() {

    var url = window.Fusion.getUrlToFile("report");
    // Add mandatory params
    url += "/" + window.Fusion.randomAsciiString(5);
    url += "/" + encodeURIComponent(window.Fusion.mediaZone);
    url += "/" + encodeURIComponent(window.Fusion.layout);
    // Add affiliate, if one is specified
    if (window.Fusion.affiliate !== undefined)
        url += "/" + encodeURIComponent(window.Fusion.affiliate);
    // Add optional params

    var query = "Fusion.CountersTimeStamp=" + encodeURIComponent(window.Fusion.CountersTimeStamp);
    for (var param in window.Fusion.parameters) {
        if (!window.Fusion.parameters.hasOwnProperty(param))
            continue;
        var values = (window.Fusion.parameters[param] instanceof Array) ? window.Fusion.parameters[param] : [window.Fusion.parameters[param]];
        for (var idx = 0; idx < values.length; ++idx) {
            if (query.length > 0)
                query += "&";
            query += encodeURIComponent(param) + "=" + encodeURIComponent(values[idx] + "");
        }
    }
    var urlLocal = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
    if (query.length > 0)
        query += "&";
    query += "Fusion.Url=" + encodeURI(urlLocal);
    var sendRequest = false;
    if (window.Fusion.adComponents !== undefined) {
        for (var space in window.Fusion.adComponents) {
            if (window.Fusion.adComponents[space].length > 0) {
                var component = window.Fusion.adComponents[space].shift();
                if (component.attributes[window.Fusion.ATTR_SHOWN] === undefined) {
                    //For now just add it to wornings
                    window.Fusion.warnings.push("There is an ad(id:" + component.ad + ") for space(name:" + space + ") which is not displayed on the page.");
                    if (query.length > 0)
                        query += "&";
                    query += "Fusion.AdID=" + component.ad;
                    query += "&";
                    query += "Fusion.Flags=" + component.flags;

		    if(!sendRequest)
			sendRequest = true;
                }
            }
        }
    }
    //Later on, send it to reactor
    if (sendRequest) {
        url += "?" + query;
       //Call script
       var scriptElement = document.createElement("script");
       scriptElement.setAttribute("type", "text/javascript");
       scriptElement.setAttribute("src", url);
       document.body.appendChild(scriptElement);
    }
}

/**
 * Constructs a parameter list in URL format from window.Fusion.parameters.
 */
window.Fusion.getParameters = function (){
	var parameterString = "";
	var prefix = "";
	var prm = window.Fusion.parameters;
	for (var p in prm) {
		if (!prm.hasOwnProperty(p)) continue;	
	var allValues;
		if (window.Fusion.parameters[p] instanceof Array)
		{
			allValues = window.Fusion.parameters[p];
		}
		else
		{
			allValues = [window.Fusion.parameters[p]];
		}		
		for (var j = 0; j < allValues.length; ++j)
		{
			parameterString += prefix + p + "=" + allValues[j];
			// prefix has been used once, set to &
			prefix = "&";
		}
	}
	return parameterString;
}

/**
 * Constructs the base URL for an advert event call.
 * @param advertId The advert for which the event happened.
 * @param eventName The name of the event
 * @param redirectUrl Optional. If provided, the event counter will redirect the request to this URL. 
 */
window.Fusion.getAdvertEventUrl = function (advertId, eventName, redirectUrl){
	var url = window.Fusion.getUrlToFile("event");
	url += "/" + window.Fusion.randomAsciiString(5);
	url += "/" + encodeURIComponent(window.Fusion.mediaZone);
	url += "/" + encodeURIComponent(advertId);
	url += "/" + encodeURIComponent(eventName)
	if (window.Fusion.affiliate !== undefined)
		url += "/" + encodeURIComponent(window.Fusion.affiliate);
	if (redirectUrl !== undefined)
		url += "?url=" + encodeURIComponent(redirectUrl);
	return url;
}

/**
 * Notify the ad server that an event has occurred for an ad.
 *
 * Please note that adding a call to this function in, e.g., a 
 * link's onclick event doesn't always work as it doesn't capture 
 * clicks from right-clicks or middle-clicks.
 * 
 * @param advertId The ID of the advert
 * @param eventName The name of the event (e.g., "click")
 * @param redirectUrl The URL to redirect the user to. If this parameter
 * is unspecified, response from the servlet is "204 no content".
 * @param target The name of the window to open (equivalent to the "target"
 * attribute in HTML anchors). Defaults to "_blank".
 */
window.Fusion.countAdvertEvent = function (advertId, eventName, redirectUrl, target) {
	var url = window.Fusion.getAdvertEventUrl(advertId, eventName, redirectUrl);
	if (redirectUrl !== undefined) {
		// target defined? if not, use a new window
		if (target === undefined) target = "_blank";
		// acrobatics to get around popup blockers
		if (!window.open(url, target)) location.href = url;
	} else {
		// No redirect, do an asynchronous call and ignore whatever 
		// response there is (since it will be a 204). Add a random
		// string to prevent caching.
		var img = new Image();
		img.src = url;
	}
}

/**
 * This has been extended to include parameters in the call.
 */
window.Fusion.countAdvertEventWithParameters = function (advertId, eventName, redirectUrl, target) {
	var parameters = "YES";
	var url = window.Fusion.getAdvertEventUrl(advertId, eventName, redirectUrl, parameters);
	if (redirectUrl !== undefined) {
		// target defined? if not, use a new window
		if (target === undefined) target = "_blank";
		// acrobatics to get around popup blockers
		if (!window.open(url, target)) location.href = url;
	} else {
		// No redirect, do an asynchronous call and ignore whatever 
		// response there is (since it will be a 204). Add a random
		// string to prevent caching.
		var img = new Image();
		img.src = url;
	}
}

/**
 * Shows an ad for a placement.
 */
window.Fusion.space = function(placementName) {
	if (window.Fusion.adComponents !== undefined) { 
		var componentContent = window.Fusion.getComponent(placementName);
		if ((typeof componentContent) == (typeof "")) document.writeln(componentContent);
	} else window.Fusion.warnings.push("No ads loaded when trying to show space " + placementName);
}

/**
 * Performs an ad call, and shows the sole ad from that call.
 */
window.Fusion.SingleSpace = function (layout) {
	if (layout === undefined){ 
		window.Fusion.warnings.push("Missing layout in SingleSpace");
		return;
	}
	this.mediaZone = window.Fusion.mediaZone;
	this.affiliate = window.Fusion.affiliate;
	this.parameters = {};
	var prm = window.Fusion.parameters;
	// make deep copy of parameters
	for (var p in prm){
		if (!prm.hasOwnProperty(p)) continue;
		this.parameters[p] = (prm[p] instanceof Array)? prm[p].slice(0) : prm[p];
	}
	this.show = function () {
		this.url = window.Fusion.getJsUrl(
				this.mediaZone || window.Fusion.mediaZone, 
				layout, 
				this.affiliate || window.Fusion.affiliate, 
				this.parameters || window.Fusion.parameters);
		window.Fusion.onAdsLoaded = function (ads, timestamp) {
			window.Fusion.CountersTimeStamp = timestamp;
			var ncomponents = 0;
			var payload = undefined, component = undefined;
			for (var i in ads){
				if (!ads.hasOwnProperty(i)) continue;
				if ((ncomponents += ads[i].length) > 1){
					window.Fusion.warnings.push("SingleSpace call returned more than one component");
					return;
				} else if (ads[i].length > 0) payload = (component = ads[i][0]).attributes[window.Fusion.ATTR_PAYLOAD];
			}
			if (payload === undefined) {
				window.Fusion.warnings.push(ncomponents > 0 
						? "None of the " + ncomponents + " components found had attribute " +  window.Fusion.ATTR_PAYLOAD
						: "No components found for SingleSpace call");
			} else document.write(window.Fusion.expandAttribute(component, window.Fusion.ATTR_PAYLOAD));
		} // onAdsLoaded(ads)
		document.writeln("<script type=\"text/javascript\" src=\"" + window.Fusion.htmlEncode(this.url) + "\"></script>");
	} // show()
}

/**
 * Gets an absolute URL to a "file" in the Fusion webapp.
 */ 
window.Fusion.getUrlToFile = function (file) {
	window.Fusion.assertFieldExists("protocol");
	window.Fusion.assertFieldExists("webApp");
	window.Fusion.assertFieldExists("adServer");
	return window.Fusion.protocol + window.Fusion.adServer + Fusion.webApp + file;
}

window.Fusion.getJsUrl = function(mediaZone, layout, affiliate, params){
	var servletName = window.Fusion.discardStatistics ? "jsds" : "js";
	var baseUrl = window.Fusion.getUrlToFile(servletName);
	// Add mandatory params
	baseUrl += "/" + window.Fusion.randomAsciiString(5);
	baseUrl += "/" + encodeURIComponent(mediaZone);
	baseUrl += "/" + encodeURIComponent(layout);
	// Add affiliate, if one is specified
	if (affiliate !== undefined)
		baseUrl += "/" + encodeURIComponent(affiliate);
	// Add optional params
	var queryString = "";
	for (var i in params){
		if (!params.hasOwnProperty(i)) continue;
		var allValues = (params[i] instanceof Array)? params[i] : [params[i]];
		for (var j = 0; j < allValues.length; ++j){
			if (queryString.length > 0) queryString += "&";
			queryString += encodeURIComponent(i) + "=" + encodeURIComponent(allValues[j] + "");
		}
	}
	if (queryString.length > 0) queryString = "?" + queryString;
	return baseUrl + queryString;
}

/**
 * Makes a smarttag call.
 */
window.Fusion.loadAds = function (loadByDom, onloadCallback) {
	window.Fusion.assertFieldExists("mediaZone");
	window.Fusion.assertFieldExists("layout");
	window.Fusion.adScriptUrl = window.Fusion.getJsUrl(
			window.Fusion.mediaZone, window.Fusion.layout, 
			window.Fusion.affiliate, window.Fusion.parameters);
	window.Fusion.onAdsLoaded = function (ads, timestamp) { 
		window.Fusion.adComponents = ads;
		window.Fusion.CountersTimeStamp = timestamp;
		if (onloadCallback !== undefined) onloadCallback();
		// window.Fusion.addOnPageLoad(window.Fusion.checkAds);
	};
	if (loadByDom) {
		var scriptElement = document.createElement("script");
		scriptElement.setAttribute("type", "text/javascript");
		scriptElement.setAttribute("src", window.Fusion.adScriptUrl);
		var scriptParent = document.getElementsByTagName("head")[0];
		if (!scriptParent) scriptParent = document; // no head, enter panic mode
		scriptParent.appendChild(scriptElement);
	} else { 
		document.writeln("<script type=\"text/javascript\" src=\"" + 
				window.Fusion.htmlEncode(window.Fusion.adScriptUrl) + "\">");
		document.writeln("</script>");
	}
}

/**
 * Thin cross-browser abstraction to run an onload function.
 */
window.Fusion.addOnPageLoad = function (onLoadFunc){
	if (window.addEventListener){ // DOM events
		window.addEventListener("load", function(){
			onLoadFunc();
			window.removeEventListener("load", arguments.callee, false);
		}, false);
	} else if (window.attachEvent){ // IE
		window.attachEvent("onload", function(){
			onLoadFunc();
			window.detachEvent("onload", arguments.callee);
		});
	} else { // Unsafe intrinsic events
		var oldOnLoad = window.onload;
		window.onload = 
			(typeof(oldOnLoad) != "function") ? 
				onLoadFunc : function(){
					var ret = oldOnLoad.apply(this, arguments);
					onLoadFunc();
					return ret;
				}; 
	}
}

/**
 * If there are any ad components left in the components argument,
 * appropriate action is taken.
 */
window.Fusion.verifyTagging = function(components){
	var neglected = [];
	for (var placement in components){
		if (!components.hasOwnProperty(placement)) continue;
		if (components[placement] instanceof Array && components[placement].length > 0){
			neglected.push({
				placement: placement, count: components[placement].length,
				toString: function(){ 
					return "Placement '" + this.placement + "' is missing " + this.count + " tag(s)"; 
				}
			});
		}
	}
	if (neglected.length > 0) 
		window.Fusion.warnings.push("Not all spaces in layout have been tagged:\n\t" + neglected.join("\n\t"));
}

/**
 * Handlers for the metadata information sent to fireOnAdsLoaded
 */
window.Fusion.adSelectionMetaDataHandlers = {
	"warnings" : function (warnings) {
		for (var i = 0; i < warnings.length; ++i)
			window.Fusion.warnings.push(warnings[i]);
	},
	"diagnostics" : function (root) {
		function indent(n){ var r = ""; while (n-- > 0) r += "    "; return r; }
		function entry2html(entry, depth){
			var cls = "status-" + window.Fusion.htmlEncode(entry.status.toLowerCase());
			var msg = window.Fusion.htmlEncode(entry.message);
			if (entry.subEntries.length == 0){
				return indent(depth) + "<li class=\"" + cls + "\">" + msg + "</li>\n";
			} else {
				return (indent(depth) + "<li class=\"" + cls + "\">\n" + 
					indent(depth + 1) + msg + "\n" + 
					entries2html(entry.subEntries, depth + 1) + "\n" + 
					indent(depth) + "</li>\n");
			}
		}
		function entries2html(entries, depth){
			var items = [];
			for (var i = 0; i < entries.length; ++i) 
				items.push(entry2html(entries[i], depth + 1));
			if (items.length > 0){
				items.unshift(indent(depth) + "<ul>\n");
				items.push(indent(depth) + "</ul>\n");
			}
			return items.join("");
		}
		var win = window.open("about:blank", "_blank");
		if (win) {
			var oldProtocol = window.Fusion.protocol;
			window.Fusion.protocol = "http://";
			with (win.document){
				open("text/html");
				writeln("<html><head>");
				writeln(indent(1) + "<title>Selection diagnostics</title>");
				writeln(indent(1) + "<link rel=\"stylesheet\" href=\"" + 
						window.Fusion.htmlEncode(window.Fusion.getUrlToFile("util/diagnostics.css")) + "\" />");
				writeln(indent(1) + "<script type=\"text/javascript\" src=\"" + 
						window.Fusion.htmlEncode(window.Fusion.getUrlToFile("util/sorttable.js")) + "\"></script>");
				writeln("</head><body>");
				if (root.table){
					writeln("<table class=\"sortable\">");
					writeln(indent(1) + "<caption>Inspected ads</caption>");
					writeln(indent(1) + "<thead>");
					writeln(indent(2) + "<tr>");
					var headers = root.table.headers; 
					for (var i = 0; i < headers.length; ++i)
						writeln(indent(3) + "<th>" + window.Fusion.htmlEncode(headers[i]) + "</th>");
					writeln(indent(2) + "</tr>");
					writeln(indent(1) + "</thead>");
					writeln(indent(1) + "<tbody>");
					for (var i = 0; i < root.table.rows.length; ++i){
						writeln(indent(2) + "<tr>");
						var row = root.table.rows[i];
						for (var j = 0; j < row.length; ++j){
							var c = window.Fusion.htmlEncode(row[j].status.toLowerCase());
							var m = window.Fusion.htmlEncode(row[j].message);
							writeln(indent(3) + "<td class=\"status-" + c + "\">" + m + "</td>");
						}
						writeln(indent(2) + "</tr>");
					}
					writeln(indent(1) + "</tbody>");
					writeln("</table>");
				}
				if (root.tree){
					writeln("<ul>");
					writeln(indent(1) + "<li>");
					writeln(indent(2) + "Selection log:");
					writeln(entries2html(root.tree.subEntries, 3));
					writeln(indent(1) + "</li>");
					writeln("</ul>");
				}
				writeln("</body></html>");
				close();
			}
			window.Fusion.protocol = oldProtocol;
		} else alert("You browser's popup blocker stopped diagnostics window from showing.");
	}
};

/**
 * Called when the ads have finished loading.
 */
window.Fusion.fireOnAdsLoaded = function(ads, metadata, timestamp){

	if (window.Fusion.assertFieldExists("onAdsLoaded")) {
		window.Fusion.onAdsLoaded(ads, timestamp);
		delete window.Fusion.onAdsLoaded;
	}
	if (typeof metadata != "object") return;
	var handlers = window.Fusion.adSelectionMetaDataHandlers;
	for (var i in metadata){
		if (!metadata.hasOwnProperty(i)) continue;
		if (handlers[i] !== undefined) handlers[i](metadata[i]);
	}
}

// -- compatibility issues below

if (typeof(window.encodeURIComponent) != typeof(function(){})) {
	// Unicode URL encoding for old browsers
	window.encodeURIComponent = function(s){
		var unicodeEscapes = [
			"%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", 
			"%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", 
			"%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", 
			"%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", 
			"%20", "!", "%22", "%23", "%24", "%25", "%26", "\'", 
			"(", ")", "*", "%2B", "%2C", "-", ".", "%2F", 
			"0", "1", "2", "3", "4", "5", "6", "7", 
			"8", "9", "%3A", "%3B", "%3C", "%3D", "%3E", "%3F", 
			"%40", "A", "B", "C", "D", "E", "F", "G", 
			"H", "I", "J", "K", "L", "M", "N", "O", 
			"P", "Q", "R", "S", "T", "U", "V", "W", 
			"X", "Y", "Z", "%5B", "%5C", "%5D", "%5E", "_", 
			"%60", "a", "b", "c", "d", "e", "f", "g", 
			"h", "i", "j", "k", "l", "m", "n", "o", 
			"p", "q", "r", "s", "t", "u", "v", "w", 
			"x", "y", "z", "%7B", "%7C", "%7D", "~", "%7F", 
			"%C2%80", "%C2%81", "%C2%82", "%C2%83", "%C2%84", "%C2%85", "%C2%86", "%C2%87", 
			"%C2%88", "%C2%89", "%C2%8A", "%C2%8B", "%C2%8C", "%C2%8D", "%C2%8E", "%C2%8F", 
			"%C2%90", "%C2%91", "%C2%92", "%C2%93", "%C2%94", "%C2%95", "%C2%96", "%C2%97", 
			"%C2%98", "%C2%99", "%C2%9A", "%C2%9B", "%C2%9C", "%C2%9D", "%C2%9E", "%C2%9F", 
			"%C2%A0", "%C2%A1", "%C2%A2", "%C2%A3", "%C2%A4", "%C2%A5", "%C2%A6", "%C2%A7", 
			"%C2%A8", "%C2%A9", "%C2%AA", "%C2%AB", "%C2%AC", "%C2%AD", "%C2%AE", "%C2%AF", 
			"%C2%B0", "%C2%B1", "%C2%B2", "%C2%B3", "%C2%B4", "%C2%B5", "%C2%B6", "%C2%B7", 
			"%C2%B8", "%C2%B9", "%C2%BA", "%C2%BB", "%C2%BC", "%C2%BD", "%C2%BE", "%C2%BF", 
			"%C3%80", "%C3%81", "%C3%82", "%C3%83", "%C3%84", "%C3%85", "%C3%86", "%C3%87", 
			"%C3%88", "%C3%89", "%C3%8A", "%C3%8B", "%C3%8C", "%C3%8D", "%C3%8E", "%C3%8F", 
			"%C3%90", "%C3%91", "%C3%92", "%C3%93", "%C3%94", "%C3%95", "%C3%96", "%C3%97", 
			"%C3%98", "%C3%99", "%C3%9A", "%C3%9B", "%C3%9C", "%C3%9D", "%C3%9E", "%C3%9F", 
			"%C3%A0", "%C3%A1", "%C3%A2", "%C3%A3", "%C3%A4", "%C3%A5", "%C3%A6", "%C3%A7", 
			"%C3%A8", "%C3%A9", "%C3%AA", "%C3%AB", "%C3%AC", "%C3%AD", "%C3%AE", "%C3%AF", 
			"%C3%B0", "%C3%B1", "%C3%B2", "%C3%B3", "%C3%B4", "%C3%B5", "%C3%B6", "%C3%B7", 
			"%C3%B8", "%C3%B9", "%C3%BA", "%C3%BB", "%C3%BC", "%C3%BD", "%C3%BE", "%C3%BF"];
		var ret = "";
		for (var i = 0; i < s.length; ++i)
			ret += unicodeEscapes[s.charCodeAt(i)];
		return ret;
	} // encodeURIComponent
} // if not encodeURIComponent


/**
 * Browser detect code
 *
 */

// Initialize Fusion.Detect namespace
 if(!window.Fusion.Detect) window.Fusion.Detect = {};
 if(!window.Fusion.Detect.values) window.Fusion.Detect.values = {};
 if(!window.Fusion.Detect.agent) window.Fusion.Detect.agent = navigator.userAgent.toLowerCase();
 if(!window.Fusion.Detect.appVer) window.Fusion.Detect.appVer = navigator.appVersion.toLowerCase();	

 var flashVersion = 10;
 var hasFlashPlayer = false;
 var mediaPlayerVersion = 0;
 var hasWindowsMediaPlayer = false;
 var hasRealPlayerG2 = false;
 var hasRealPlayer4 = false;
 var hasRealPlayer5 = false;
 var hasSilverlight = false;
 var qtPlayerVersion = 0;
 var hasQTPlayer = false;

window.Fusion.Detect.doDetect = function()
{
	window.Fusion.Detect.detectBrowser();
	window.Fusion.Detect.detectOS();
	window.Fusion.Detect.detectPlugins();
	window.Fusion.Detect.detectResolution();
	window.Fusion.Detect.detectDateTime();
	window.Fusion.Detect.getPlugins();
	window.Fusion.Detect.addToParameters();
}

// Add detected values to smarttag call parameters
window.Fusion.Detect.addToParameters = function()
{
	for (var i in window.Fusion.Detect.values)
	{
		if (!window.Fusion.Detect.values.hasOwnProperty(i)) continue;
		var allValues;
		if (window.Fusion.Detect.values[i] instanceof Array)
		{
			allValues = window.Fusion.Detect.values[i];
		}
		else
		{
			allValues = [window.Fusion.Detect.values[i]];
		}
		
		for (var j = 0; j < allValues.length; ++j)
		{
			window.Fusion.parameters[i] = allValues[j];
		}
	}
}

window.Fusion.Detect.detectBrowser = function()
{
	window.Fusion.Detect.BrowserDetect.init();
	window.Fusion.Detect.values["browserName"] = window.Fusion.Detect.BrowserDetect.browser;
	window.Fusion.Detect.values["browserVersion"] = window.Fusion.Detect.BrowserDetect.version;	
	window.Fusion.Detect.values["browser"] = window.Fusion.Detect.BrowserDetect.browser + window.Fusion.Detect.BrowserDetect.version;
	
}



window.Fusion.Detect.detectOS = function()
{
	var isWin = (window.Fusion.Detect.agent.indexOf('win') != -1);
	var os = "";
	if ((window.Fusion.Detect.agent.indexOf('windows nt 6.0') != -1) && isWin)
	{
		os = "winvista";
	}
	else if ((window.Fusion.Detect.agent.indexOf('nt') != -1) && (window.Fusion.Detect.agent.indexOf('5.1') != -1) && isWin)
	{
		os = "winxp";
	}
	else if (((window.Fusion.Detect.agent.indexOf('win 9x 4.90') != -1) || (window.Fusion.Detect.agent.indexOf('windows me') != -1)) && isWin)
	{
		os = "winme";
	}
	else if ((window.Fusion.Detect.agent.indexOf('nt 5.0') != -1) && isWin)
	{
		os = "win2000";
	}
	else if ((window.Fusion.Detect.agent.indexOf('nt') != -1) && isWin)
	{
		os = "winnt";
	}
	else if ((window.Fusion.Detect.agent.indexOf('98') != -1) && isWin)
	{
		os = "win98";
	}
	else if ((window.Fusion.Detect.agent.indexOf('95') != -1) && isWin)
	{
		os = "win95";
	}
	else if (window.Fusion.Detect.agent.indexOf('macintosh') != -1)
	{
		os = "mac";
	}
	else if(window.Fusion.Detect.agent.indexOf('linux') != -1)
	{
		os = "linux";
	}
	else
	{
		os = "other";
	}
	
	window.Fusion.Detect.values["OS"] = os;
	
}

window.Fusion.Detect.detectResolution = function()
{
	var resolution = "";
	
	if(window.screen)
	{
		var height = window.screen.height;
		var width = window.screen.width;
	    window.Fusion.Detect.values["screenRes"] = width + "x" + height;
		window.Fusion.Detect.values["screenWidth"]  = width;
		window.Fusion.Detect.values["screenHeight"] = height;
	}
	else
	{
		window.Fusion.Detect.values["screenRes"] = "n/a";
	}
	
	//Browser size
	var browserWidth = 0, browserHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
	  //Non-IE
	  browserWidth = window.innerWidth;
	  browserHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
	  //IE 6+ in 'standards compliant mode'
	  browserWidth = document.documentElement.clientWidth;
	  browserHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
	  //IE 4 compatible
	  browserWidth = document.body.clientWidth;
	  browserHeight = document.body.clientHeight;
	}
 	window.Fusion.Detect.values["browserWidth"] = browserWidth;
	window.Fusion.Detect.values["browserHeight"] = browserHeight;
	
}

window.Fusion.Detect.detectDateTime = function()
{
	var date = new Date();
	var dayStrings = new Array("sunday","monday","tuesday","wednesday","thursday","friday","saturday");
	var hours = date.getHours().toString();
	var minutes = date.getMinutes().toString();
	var day = dayStrings[date.getDay()];
	
	if (hours.length < 2)
		hours = "0" + hours;
		
	if (minutes.length < 2)
		minutes = "0" + minutes;	
		
	window.Fusion.Detect.values["time"] = hours + minutes;	
	window.Fusion.Detect.values["weekDay"] = day;
}

window.Fusion.Detect.detectPlugins = function()
{
	
	if ((navigator.plugins != null) && (navigator.plugins.length > 0)) 
	{
		var mplayer =  (navigator.mimeTypes && 
						navigator.mimeTypes["application/x-mplayer2"] &&
					 	navigator.mimeTypes["application/x-mplayer2"].enabledPlugin) ?
					 	navigator.mimeTypes["application/x-mplayer2"].enabledPlugin : 0;
    	
    	if(mplayer) { window.Fusion.Detect.values["wm"] = 6; }
    	else { window.Fusion.Detect.values["wm"] = 0; }
		
		var rvplayer = 	(navigator.mimeTypes &&
						 navigator.mimeTypes['audio/x-pn-realaudio-plugin'] &&
				  		 navigator.mimeTypes['audio/x-pn-realaudio-plugin'].enabledPlugin) ?
				  		 navigator.mimeTypes['audio/x-pn-realaudio-plugin'].enabledPlugin : 0;

		if (rvplayer)
		{
			window.Fusion.Detect.values["rv"] = 6;
		}
		else
		{
			window.Fusion.Detect.values["rv"] = 0;
		}
		
		var silverlight = (navigator.mimeTypes &&
						 navigator.mimeTypes['application/x-silverlight'] &&
				  		 navigator.mimeTypes['application/x-silverlight'].enabledPlugin) ?
				  		 navigator.mimeTypes['application/x-silverlight'].enabledPlugin : 0;
		if(silverlight)
		{
			window.Fusion.Detect.values["silverlight"] = 1;
		}
	
		var quickPlugin = navigator.plugins['Quicktime'];
		if (typeof(quickPlugin) == 'object')
		{
			window.Fusion.Detect.values["qt"] = 5;
		}
		else
		{
			window.Fusion.Detect.values["qt"] = 0;
		}
	
		var flash =    (navigator.mimeTypes && 
                    navigator.mimeTypes["application/x-shockwave-flash"] &&
                    navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) ?
                    navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

		if (flash && flash.description) 
		{
			var numStart = flash.description.indexOf(".");
			while (/^\d$/.test(flash.description.charAt(--numStart)));
			++numStart;
			window.Fusion.Detect.values["flash"] = parseInt(flash.description.substring(numStart));
		}
		else
		{
			window.Fusion.Detect.values["flash"] = "0";
		}
	}
	else if((window.Fusion.Detect.agent.indexOf('win') != -1) && (window.Fusion.Detect.agent.indexOf('opera') == -1))
	{
		
		document.write(
		'\x3cSCRIPT LANGUAGE=VBScript\x3e\n'+
			'on error resume next\n'+
			'hasWindowsMediaPlayer = IsObject(CreateObject("WMPlayer.OCX"))\n'+
			'hasRealPlayerG2 = IsObject(CreateObject("rmocx.RealPlayer G2 Control"))\n'+
			'hasRealPlayer5 = IsObject(CreateObject("RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)"))\n'+
			'hasRealPlayer4  = IsObject(CreateObject("RealVideo.RealVideo(tm) ActiveX Control (32-bit)"))\n'+
			'hasSilverlight = IsObject(CreateObject("AgControl.AgControl"))\n'+
			
         	'Do While flashVersion > 0' + '\n' +
            	'On Error Resume Next' + '\n' +
            	'hasFlashPlayer = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & flashVersion)))' + '\n' +
            	'If hasFlashPlayer = true Then Exit Do' + '\n' +
            	'flashVersion = flashVersion - 1' + '\n' +
         	'Loop' + '\n' +
			'\x3c/SCRIPT\x3e\n');
	}
}

window.Fusion.Detect.getPlugins = function()
{
	if(hasFlashPlayer)
	{ 
		window.Fusion.Detect.values["flash"] = flashVersion; 
	}  

	if(hasWindowsMediaPlayer)
	{	
		window.Fusion.Detect.values["wm"] = 9;
	}

	if(hasRealPlayerG2)
	{
		window.Fusion.Detect.values["rv"] = 3;
	}
	if(hasRealPlayer4)
	{
		window.Fusion.Detect.values["rv"] = 4;
	}
	if(hasRealPlayer5)
	{
		window.Fusion.Detect.values["rv"] = 5;
	}
	
	if(hasSilverlight)
	{
		window.Fusion.Detect.values["silverlight"] = 1;
	}
}

window.Fusion.Detect.printParameters = function()
{
	for(var i in window.Fusion.Detect.values)
	 {
		if (!window.Fusion.Detect.values.hasOwnProperty(i)) continue;
		document.write(i + ":" + window.Fusion.Detect.values[i] + "<br/>")
	}
	document.write(navigator.userAgent + "<br/><br/>");
	document.write(navigator.appVersion + "<br/><br/>");	
}
window.Fusion.Detect.BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "unknown";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "1337";
		this.OS = this.searchString(this.dataOS) || "unknown";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			versionSearch: "Chrome/",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.userAgent,
			subString: "Windows NT 6.0",
			identity: "Vista"
		},
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
window.Fusion.Detect.doDetect();


/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");
AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);
u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
