/* /sites/Fabry/_resources/js/global.js*/ /// <reference path="/_resources/js/jquery-1.2.6.min.js" />
/// <reference path="/_resources/js/universal.js" />
/* 
Fabry - global.js
*/

// IE6 flickering
try { document.execCommand("BackgroundImageCache", false, true); } catch (err) { }

$j(document).ready(function() {
	// Change all a.video tags to swf video player objects
	insertVideo();

	// Language Select drop down
	$j("#lang-select").click(function() {
		pullDownLang();
	});
	$j("#lang > ul > li > a").click(function() {
		pullDownLang();
	});
});   // document ready / end jquery


var insertVideo = function() {
	$j("a.video").each(function(i) {
		var $this = $j(this);
		var params = $this.attr("class").split(" ");

		// params[1] = height & params[2] = width
		var flashVars = {
			initialFLV: "/" + $this.attr("href"),
			bandwidthImage: "/~/media/Files/Fabry/Flash/bandwidthCheck.jpg"
		};
		var objectVars = {
			wmode: "transparent",
			salign: "TL",
			scale: "noscale",
			quality: "high"
		};

		// provide sane defaults if no size parameters are provided.
		var height = (1 in params) ? params[1] : 272;
		var width = (2 in params) ? params[2] : 330;
		swfobject.embedSWF("/~/media/Files/Fabry/Flash/videoplayer.swf", $this.attr("id"), width, height, "8", undefined, flashVars, objectVars, undefined);
	});
};

function pullDownLang() {
	var list = $j("#lang-list");
	if (list.length > 0) {
		if (list.attr('class').indexOf('pulled-out') != -1) {
			list.slideUp("slow").removeClass('pulled-out');
		} else {
			list.slideDown("slow").addClass('pulled-out');
		}
	}
}


// Text size widget
$j(window).load(function() {
	// Reset Font Size
	var originalFontSize = $j('html').css('font-size');
	$j("#regular").click(function() {
		$j('html').css({ fontSize: originalFontSize });
	});
	// Increase Font Size
	$j("#large").click(function() {
		var currentFontSize = $j('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum * 1.2;
		$j('html').css({ fontSize: newFontSize });
		return false;
	});
	// Decrease Font Size
	$j("#small").click(function() {
		var currentFontSize = $j('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum * 0.8;
		$j('html').css({ fontSize: newFontSize });
		return false;
	});
});
/* /sites/Fabry/_resources/js/ga_downloads.js*/ //	This javascript tags file downloads and external links in Google Analytics.
//	You need to be using the Google Analytics New Tracking Code (ga.js) 
//	for this script to work.
//	To use, place this file on all pages just above the Google Analytics tracking code.
//	All outbound links and links to non-html files should now be automatically tracked.

								

if (document.getElementsByTagName) {
        // Initialize external link handlers
        var hrefs = document.getElementsByTagName("a");
        for (var l = 0; l < hrefs.length; l++) {
				// try {} catch{} block added by erikvold VKI
			try{
	                //protocol, host, hostname, port, pathname, search, hash
	                if (hrefs[l].protocol == "mailto:") {
	                        startListening(hrefs[l],"click",trackMailto);
	                } else if (hrefs[l].hostname == location.host) {
	                        var path = hrefs[l].pathname + hrefs[l].search;
							var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|\&|\?)/);
	                        if (isDoc) {
	                                startListening(hrefs[l],"click",trackExternalLinks);
	                        }
	                } else {
	                        startListening(hrefs[l],"click",trackExternalLinks);
	                }
			}
			catch(e){
					continue;
			}
        }
}

function startListening (obj,evnt,func) {
        if (obj.addEventListener) {
                obj.addEventListener(evnt,func,false);
        } else if (obj.attachEvent) {
                obj.attachEvent("on" + evnt,func);
        }
}

function trackMailto (evnt) {
        var href = (evnt.srcElement) ? evnt.srcElement.href : this.href;
        var mailto = "/mailto/" + href.substring(7);
        if (typeof(pageTracker) == "object") pageTracker._trackPageview(mailto);
}

function trackExternalLinks (evnt) {
        var e = (evnt.srcElement) ? evnt.srcElement : this;
        while (e.tagName != "A") {
                e = e.parentNode;
        }
        var lnk = (e.pathname.charAt(0) == "/") ? e.pathname : "/" + e.pathname;
        if (e.search && e.pathname.indexOf(e.search) == -1) lnk += e.search;
        if (e.hostname != location.host) lnk = "/external/" + e.hostname + lnk;
        if (typeof(pageTracker) == "object") pageTracker._trackPageview(lnk); 
}

