/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
*
* Version: 3.0.2
* 
* Requires: 1.2.2+
*/
(function(c) { var a = ["DOMMouseScroll", "mousewheel"]; c.event.special.mousewheel = { setup: function() { if (this.addEventListener) { for (var d = a.length; d; ) { this.addEventListener(a[--d], b, false) } } else { this.onmousewheel = b } }, teardown: function() { if (this.removeEventListener) { for (var d = a.length; d; ) { this.removeEventListener(a[--d], b, false) } } else { this.onmousewheel = null } } }; c.fn.extend({ mousewheel: function(d) { return d ? this.bind("mousewheel", d) : this.trigger("mousewheel") }, unmousewheel: function(d) { return this.unbind("mousewheel", d) } }); function b(f) { var d = [].slice.call(arguments, 1), g = 0, e = true; f = c.event.fix(f || window.event); f.type = "mousewheel"; if (f.wheelDelta) { g = f.wheelDelta / 120 } if (f.detail) { g = -f.detail / 3 } d.unshift(f, g); return c.event.handle.apply(this, d) } })(jQuery);

/* Copyright (c) 2006 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* 
* See http://kelvinluck.com/assets/jquery/jScrollPane/
* $Id: jScrollPane.js 1567 2007-03-23 01:34:29Z kelvin $
*/
jQuery.jScrollPane = { active: [] }; jQuery.fn.jScrollPane = function(settings) { settings = jQuery.extend({ scrollbarWidth: 10, scrollbarMargin: 5, wheelSpeed: 18, showArrows: false, arrowSize: undefined, animateTo: false, dragMinHeight: 1, dragMaxHeight: 99999 }, settings); return this.each(function() { var $this = jQuery(this); if (jQuery(this).parent().is('.jScrollPaneContainer')) { var $c = jQuery(this).parent(); var paneWidth = $c.innerWidth(); var paneHeight = $c.outerHeight(); var trackHeight = paneHeight; if ($c.unmousewheel) { $c.unmousewheel() } jQuery('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown', $c).remove(); $this.css({ 'top': 0 }) } else { this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft'); this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0); var paneWidth = $this.innerWidth(); var paneHeight = $this.innerHeight(); var trackHeight = paneHeight; $this.wrap(jQuery('<div>').attr({ 'className': 'jScrollPaneContainer' }).css({ 'height': paneHeight + 'px', 'width': paneWidth + 'px' })) } var p = this.originalSidePaddingTotal; $this.css({ 'height': 'auto', 'width': paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p + 'px', 'paddingRight': settings.scrollbarMargin + 'px' }); var contentHeight = $this.outerHeight(); var percentInView = paneHeight / contentHeight; if (percentInView < .98) { var $container = $this.parent(); $container.append(jQuery('<div>').attr({ 'className': 'jScrollPaneTrack' }).css({ 'width': settings.scrollbarWidth + 'px' }).append(jQuery('<div>').attr({ 'className': 'jScrollPaneDrag' }).css({ 'width': settings.scrollbarWidth + 'px' }).append(jQuery('<div>').attr({ 'className': 'jScrollPaneDragTop' }).css({ 'width': settings.scrollbarWidth + 'px' }), jQuery('<div>').attr({ 'className': 'jScrollPaneDragBottom' }).css({ 'width': settings.scrollbarWidth + 'px' })))); var $track = jQuery('>.jScrollPaneTrack', $container); var $drag = jQuery('>.jScrollPaneTrack .jScrollPaneDrag', $container); if (settings.showArrows) { var currentArrowButton; var currentArrowDirection; var currentArrowInterval; var currentArrowInc; var whileArrowButtonDown = function() { if (currentArrowInc > 4 || currentArrowInc % 4 == 0) { positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier) } currentArrowInc++ }; var onArrowMouseUp = function(event) { jQuery('body').unbind('mouseup', onArrowMouseUp); currentArrowButton.removeClass('jScrollActiveArrowButton'); clearInterval(currentArrowInterval) }; var onArrowMouseDown = function() { jQuery('body').bind('mouseup', onArrowMouseUp); currentArrowButton.addClass('jScrollActiveArrowButton'); currentArrowInc = 0; whileArrowButtonDown(); currentArrowInterval = setInterval(whileArrowButtonDown, 100) }; $container.append(jQuery('<a>').attr({ 'href': 'javascript:;', 'className': 'jScrollArrowUp' }).css({ 'width': settings.scrollbarWidth + 'px' }).html('Scroll up').bind('mousedown', function() { currentArrowButton = $(this); currentArrowDirection = -1; onArrowMouseDown(); this.blur(); return false }), jQuery('<a>').attr({ 'href': 'javascript:;', 'className': 'jScrollArrowDown' }).css({ 'width': settings.scrollbarWidth + 'px' }).html('Scroll down').bind('mousedown', function() { currentArrowButton = $(this); currentArrowDirection = 1; onArrowMouseDown(); this.blur(); return false })); if (settings.arrowSize) { trackHeight = paneHeight - settings.arrowSize - settings.arrowSize; $track.css({ 'height': trackHeight + 'px', top: settings.arrowSize + 'px' }) } else { var topArrowHeight = jQuery('>.jScrollArrowUp', $container).height(); trackHeight = paneHeight - topArrowHeight - jQuery('>.jScrollArrowDown', $container).height(); $track.css({ 'height': trackHeight + 'px', top: topArrowHeight + 'px' }) } } var $pane = jQuery(this).css({ 'position': 'absolute', 'overflow': 'visible' }); var currentOffset; var maxY; var mouseWheelMultiplier; var dragPosition = 0; var dragMiddle = percentInView * paneHeight / 2; var getPos = function(event, c) { var p = c == 'X' ? 'Left' : 'Top'; return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0 }; var ignoreNativeDrag = function() { return false }; var initDrag = function() { ceaseAnimation(); currentOffset = $drag.offset(false); currentOffset.top -= dragPosition; maxY = trackHeight - $drag[0].offsetHeight; mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight }; var onStartDrag = function(event) { initDrag(); dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top; jQuery('body').bind('mouseup', onStopDrag).bind('mousemove', updateScroll); if (jQuery.browser.msie) { jQuery('body').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag) } return false }; var onStopDrag = function() { jQuery('body').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll); dragMiddle = percentInView * paneHeight / 2; if (jQuery.browser.msie) { jQuery('body').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag) } }; var positionDrag = function(destY) { destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY); dragPosition = destY; $drag.css({ 'top': destY + 'px' }); var p = destY / maxY; $pane.css({ 'top': ((paneHeight - contentHeight) * p) + 'px' }) }; var updateScroll = function(e) { positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle) }; var dragH = Math.max(Math.min(percentInView * paneHeight, settings.dragMaxHeight), settings.dragMinHeight); $drag.css({ 'height': dragH + 'px' }).bind('mousedown', onStartDrag); var trackScrollInterval; var trackScrollInc; var trackScrollMousePos; var doTrackScroll = function() { if (trackScrollInc > 8 || trackScrollInc % 4 == 0) { positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2))) } trackScrollInc++ }; var onStopTrackClick = function() { clearInterval(trackScrollInterval); jQuery('body').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove) }; var onTrackMouseMove = function(event) { trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle }; var onTrackClick = function(event) { initDrag(); onTrackMouseMove(event); trackScrollInc = 0; jQuery('body').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove); trackScrollInterval = setInterval(doTrackScroll, 100); doTrackScroll() }; $track.bind('mousedown', onTrackClick); if ($container.mousewheel) { $container.mousewheel(function(event, delta) { initDrag(); ceaseAnimation(); var d = dragPosition; positionDrag(dragPosition - delta * mouseWheelMultiplier); var dragOccured = d != dragPosition; return !dragOccured }, false) } var _animateToPosition; var _animateToInterval; function animateToPosition() { var diff = (_animateToPosition - dragPosition) / 3; if (diff > 1 || diff < -1) { positionDrag(dragPosition + diff) } else { positionDrag(_animateToPosition); ceaseAnimation() } } var ceaseAnimation = function() { if (_animateToInterval) { clearInterval(_animateToInterval); delete _animateToPosition } }; var scrollTo = function(pos) { ceaseAnimation(); var destDragPosition = -pos / (paneHeight - contentHeight) * maxY; if (settings.animateTo) { _animateToPosition = destDragPosition; _animateToInterval = setInterval(animateToPosition, 100) } else { positionDrag(destDragPosition) } }; $this[0].scrollTo = scrollTo; $this[0].scrollBy = function(delta) { var currentPos = -parseInt($pane.css('top')) || 0; scrollTo(currentPos + delta) }; initDrag(); jQuery.jScrollPane.active.push($this[0]) } else { $this.css({ 'height': paneHeight + 'px', 'width': paneWidth - this.originalSidePaddingTotal + 'px', 'padding': this.originalPadding }) } }) }; jQuery(window).bind('unload', function() { var els = jQuery.jScrollPane.active; for (var i = 0; i < els.length; i++) { els[i].scrollTo = els[i].scrollBy = null } });
/*
* jquery.tools 1.0.2 - The missing UI library
* 
* [tools.tabs-1.0.1, tools.overlay-1.0.4, tools.expose-1.0.3]
* 
* Copyright (c) 2009 Tero Piirainen
* http://flowplayer.org/tools/
*
* Dual licensed under MIT and GPL 2+ licenses
* http://www.opensource.org/licenses
* 
* -----
* 
* Build: Fri Jun 12 15:17:16 GMT+00:00 2009
*/
(function(c) { c.tools = c.tools || { version: {} }; c.tools.version.tabs = "1.0.1"; c.tools.addTabEffect = function(d, e) { b[d] = e }; var b = { "default": function(d) { this.getPanes().hide().eq(d).show() }, fade: function(d) { this.getPanes().hide().eq(d).fadeIn(this.getConf().fadeInSpeed) }, slide: function(d) { this.getCurrentPane().slideUp("fast"); this.getPanes().eq(d).slideDown() }, horizontal: function(d) { if (!c._hW) { c._hW = this.getPanes().eq(0).width() } this.getCurrentPane().animate({ width: 0 }, function() { c(this).hide() }); this.getPanes().eq(d).animate({ width: c._hW }, function() { c(this).show() }) } }; function a(e, f, g) { var d = this; var h; function i(j, k) { c(d).bind(j, function(m, l) { if (k && k.call(this, l.index) === false && l) { l.proceed = false } }); return d } c.each(g, function(j, k) { if (c.isFunction(k)) { i(j, k) } }); c.extend(this, { click: function(k) { if (k === h) { return d } var m = d.getCurrentPane(); var l = e.eq(k); if (typeof k == "string") { l = e.filter("[href=" + k + "]"); k = e.index(l) } if (!l.length) { if (h >= 0) { return d } k = g.initialIndex; l = e.eq(k) } var j = { index: k, proceed: true }; c(d).triggerHandler("onBeforeClick", j); if (!j.proceed) { return d } l.addClass(g.current); b[g.effect].call(d, k); c(d).triggerHandler("onClick", j); e.removeClass(g.current); l.addClass(g.current); h = k; return d }, getConf: function() { return g }, getTabs: function() { return e }, getPanes: function() { return f }, getCurrentPane: function() { return f.eq(h) }, getCurrentTab: function() { return e.eq(h) }, getIndex: function() { return h }, next: function() { return d.click(h + 1) }, prev: function() { return d.click(h - 1) }, onBeforeClick: function(j) { return i("onBeforeClick", j) }, onClick: function(j) { return i("onClick", j) } }); e.each(function(j) { c(this).bind(g.event, function(k) { d.click(j); if (!g.history) { return k.preventDefault() } }) }); if (g.history) { e.history(function(j, k) { d.click(k || 0) }) } if (location.hash) { d.click(location.hash) } else { d.click(g.initialIndex) } f.find("a[href^=#]").click(function() { d.click(c(this).attr("href")) }) } c.fn.tabs = function(g, d) { var e = this.eq(typeof conf == "number" ? conf : 0).data("tabs"); if (e) { return e } var f = { tabs: "a", current: "current", onBeforeClick: null, onClick: null, effect: "default", history: false, initialIndex: 0, event: "click", api: false }; if (c.isFunction(d)) { d = { onBeforeClick: d} } c.extend(f, d); this.each(function() { var h = c(this).find(f.tabs); if (!h.length) { h = c(this).children() } var i = g.jquery ? g : c(g); e = new a(h, i, f); c(this).data("tabs", e) }); return f.api ? e : this } })(jQuery); (function(b) { var c, a; b.prototype.history = function(e) { var d = this; if (b.browser.msie) { if (!a) { a = b("<iframe />").hide().get(0); b("body").append(a); setInterval(function() { var f = a.contentWindow.document; var g = f.location.hash; if (c !== g) { b.event.trigger("hash", g); c = g } }, 100) } d.bind("click.hash", function(g) { var f = a.contentWindow.document; f.open().close(); f.location.hash = b(this).attr("href") }); d.eq(0).triggerHandler("click.hash") } else { setInterval(function() { var f = location.hash; if (d.filter("[href*=" + f + "]").length && f !== c) { c = f; b.event.trigger("hash", f) } }, 100) } b(window).bind("hash", e); return this } })(jQuery);
(function(b) { b.tools = b.tools || { version: {} }; b.tools.version.overlay = "1.0.4"; var c = []; function a(h, d) { var r = this, q = b(window), f, n, s, i, k, m, l; var e = d.expose && b.tools.version.expose; function p(o, t) { b(r).bind(o, function(v, u) { if (t && t.call(this) === false && u) { u.proceed = false } }); return r } b.each(d, function(o, t) { if (b.isFunction(t)) { p(o, t) } }); var j = d.target || h.attr("rel"); var g = j ? b(j) : null; if (!g) { g = h } else { k = h } q.load(function() { m = g.attr("overlay"); if (!m) { m = g.css("backgroundImage"); if (!m) { throw "background-image CSS property not set for overlay element: " + j } m = m.substring(m.indexOf("(") + 1, m.indexOf(")")).replace(/\"/g, ""); g.css("backgroundImage", "none"); g.attr("overlay", m) } s = g.outerWidth({ margin: true }); i = g.outerHeight({ margin: true }); n = b('<img src="' + m + '"/>'); n.css({ border: 0, position: "absolute", display: "none" }).width(s).attr("overlay", true); b("body").append(n); if (k) { k.bind("click.overlay", function(o) { r.load(o.pageY - q.scrollTop(), o.pageX - q.scrollLeft()); return o.preventDefault() }) } d.close = d.close || ".close"; if (!g.find(d.close).length) { g.prepend('<div class="close"></div>') } f = g.find(d.close); f.bind("click.overlay", function() { r.close() }); if (d.preload) { setTimeout(function() { var o = new Image(); o.src = m }, 2000) } }); b.extend(r, { load: function(w, v) { if (!n) { q.load(function() { r.load(w, v) }); return r } if (r.isOpened()) { return r } if (d.oneInstance) { b.each(c, function() { this.close() }) } var u = { proceed: true }; b(r).trigger("onBeforeLoad", u); if (!u.proceed) { return r } if (e) { n.expose(d.expose); l = n.expose().load() } w = w || d.start.top; v = v || d.start.left; var o = d.finish.top; var t = d.finish.left; if (o == "center") { o = Math.max((q.height() - i) / 2, 0) } if (t == "center") { t = Math.max((q.width() - s) / 2, 0) } if (!d.start.absolute) { w += q.scrollTop(); v += q.scrollLeft() } if (!d.finish.absolute) { o += q.scrollTop(); t += q.scrollLeft() } n.css({ top: w, left: v, width: d.start.width, zIndex: d.zIndex }).show(); n.animate({ top: o, left: t, width: s }, d.speed, function() { g.css({ position: "absolute", top: o, left: t }); var x = n.css("zIndex"); f.add(g).css("zIndex", ++x); g.fadeIn(d.fadeInSpeed, function() { b(r).trigger("onLoad") }) }); return r }, close: function() { if (!r.isOpened()) { return r } var u = { proceed: true }; b(r).trigger("onBeforeClose", u); if (!u.proceed) { return r } if (l) { l.close() } if (n.is(":visible")) { g.hide(); var t = d.start.top; var o = d.start.left; if (k) { u = k.offset(); t = u.top + k.height() / 2; o = u.left + k.width() / 2 } n.animate({ top: t, left: o, width: 0 }, d.closeSpeed, function() { b(r).trigger("onClose", u) }) } return r }, getBackgroundImage: function() { return n }, getContent: function() { return g }, getTrigger: function() { return k }, isOpened: function() { return g.is(":visible") }, getConf: function() { return d }, onBeforeLoad: function(o) { return p("onBeforeLoad", o) }, onLoad: function(o) { return p("onLoad", o) }, onBeforeClose: function(o) { return p("onBeforeClose", o) }, onClose: function(o) { return p("onClose", o) } }); b(document).keydown(function(o) { if (o.keyCode == 27) { r.close() } }); if (d.closeOnClick) { b(document).bind("click.overlay", function(o) { if (!g.is(":visible, :animated")) { return } var t = b(o.target); if (t.attr("overlay")) { return } if (t.parents("[overlay]").length) { return } r.close() }) } } b.fn.overlay = function(e) { var f = this.eq(typeof e == "number" ? e : 0).data("overlay"); if (f) { return f } var d = b(window); var g = { start: { top: Math.round(d.height() / 2), left: Math.round(d.width() / 2), width: 0, absolute: false }, finish: { top: 80, left: "center", absolute: false }, speed: "normal", fadeInSpeed: "fast", closeSpeed: "fast", close: null, oneInstance: true, closeOnClick: true, preload: true, zIndex: 9999, api: false, expose: null, target: null }; if (b.isFunction(e)) { e = { onBeforeLoad: e} } b.extend(true, g, e); this.each(function() { f = new a(b(this), g); c.push(f); b(this).data("overlay", f) }); return g.api ? f : this } })(jQuery);
(function(b) { b.tools = b.tools || { version: {} }; b.tools.version.expose = "1.0.3"; function a() { var e = b(window).width(); if (b.browser.mozilla) { return e } var d; if (window.innerHeight && window.scrollMaxY) { d = window.innerWidth + window.scrollMaxX } else { if (document.body.scrollHeight > document.body.offsetHeight) { d = document.body.scrollWidth } else { d = document.body.offsetWidth } } return d < e ? d + 20 : e } function c(g, h) { var e = this, d = null, f = false, i = 0; function j(k, l) { b(e).bind(k, function(n, m) { if (l && l.call(this) === false && m) { m.proceed = false } }); return e } b.each(h, function(k, l) { if (b.isFunction(l)) { j(k, l) } }); b(window).bind("resize.expose", function() { if (d) { d.css({ width: a(), height: b(document).height() }) } }); b.extend(this, { getMask: function() { return d }, getExposed: function() { return g }, getConf: function() { return h }, isLoaded: function() { return f }, load: function() { if (f) { return e } i = g.eq(0).css("zIndex"); if (h.maskId) { d = b("#" + h.maskId) } if (!d || !d.length) { d = b("<div/>").css({ position: "absolute", top: 0, left: 0, width: a(), height: b(document).height(), display: "none", opacity: 0, zIndex: h.zIndex }); if (h.maskId) { d.attr("id", h.maskId) } b("body").append(d); var k = d.css("backgroundColor"); if (!k || k == "transparent" || k == "rgba(0, 0, 0, 0)") { d.css("backgroundColor", h.color) } if (h.closeOnEsc) { b(document).bind("keydown.unexpose", function(n) { if (n.keyCode == 27) { e.close() } }) } if (h.closeOnClick) { d.bind("click.unexpose", function() { e.close() }) } } var m = { proceed: true }; b(e).trigger("onBeforeLoad", m); if (!m.proceed) { return e } b.each(g, function() { var n = b(this); if (!/relative|absolute|fixed/i.test(n.css("position"))) { n.css("position", "relative") } }); g.css({ zIndex: h.zIndex + 1 }); var l = d.height(); if (!this.isLoaded()) { d.css({ opacity: 0, display: "block" }).fadeTo(h.loadSpeed, h.opacity, function() { if (d.height() != l) { d.css("height", l) } b(e).trigger("onLoad") }) } f = true; return e }, close: function() { if (!f) { return e } var k = { proceed: true }; b(e).trigger("onBeforeClose", k); if (k.proceed === false) { return e } d.fadeOut(h.closeSpeed, function() { b(e).trigger("onClose"); g.css({ zIndex: b.browser.msie ? i : null }) }); f = false; return e }, onBeforeLoad: function(k) { return j("onBeforeLoad", k) }, onLoad: function(k) { return j("onLoad", k) }, onBeforeClose: function(k) { return j("onBeforeClose", k) }, onClose: function(k) { return j("onClose", k) } }) } b.fn.expose = function(d) { var e = this.eq(typeof d == "number" ? d : 0).data("expose"); if (e) { return e } var f = { maskId: null, loadSpeed: "slow", closeSpeed: "fast", closeOnClick: true, closeOnEsc: true, zIndex: 9998, opacity: 0.8, color: "#456", api: false }; if (typeof d == "string") { d = { color: d} } b.extend(f, d); this.each(function() { e = new c(b(this), f); b(this).data("expose", e) }); return f.api ? e : this } })(jQuery);


/* Telerik Grid scroll height adjust */
function GridCreated(sender, args) {

	var scrollArea = sender.GridDataDiv; //GridDataDiv wraps MasterTable

	var dataHeight = sender.get_masterTableView().get_element().clientHeight;
	if ((dataHeight < scrollArea.clientHeight) || (dataHeight < scrollArea.parentNode.clientHeight)) {
		scrollArea.style.height = (dataHeight) + "px";
		if (navigator.appName == 'Microsoft Internet Explorer')
			scrollArea.parentNode.style.height = (dataHeight) + "px";
	}

}

vars = {
	feedbackdropdownpath: "/pagetemplates/feedbackdropdown.html"
}

var feedback = {
	init: function() {

		// Dom Prep
		$("#globalnav li.feedback").append("<div class='feedback'><div class='content'></div></div>")


		// Load
		//commenting for now - uncomment when ready
		/*
		$("#globalnav li.feedback div.content").load(vars.feedbackdropdownpath, function() {
			// $("#globalnav li.feedback #feedbackclose").bind("click", feedback.closeDropDown);
		});
		*/


	},

	closeDropDown: function() {
		$("#globalnav li.feedback div.feedback").hide();
		return false;
	},

	thankyou: function() {
		$("#sgiframe").animate({ height: "50px" }, 500)
	}
}

$(document).ready(function() {
	//tooltips:set the title attribute and use hastooltip class.
	if (jQuery().qtip) {
		$(".hastooltip").qtip({
			style: { name: 'light', tip: true },
			adjust: { scroll: true },
			corner: { target: 'rightTop', tooltip: 'leftBottom' }
		});
	}



	/* Sidebar sliding modules */

	if (document.all) {
		$("#sidebar h4").hover(function() {
			if ($(this).is(".closed"))
				$(this).addClass("iehover");
		}, function() {
			$(this).removeClass("iehover");
		});

		/* IE6 fix for form elements appearing over overlay */

		$("#viewas").hover(function() {
			$("#sidebar").addClass("formhide");
		}, function() {
			$("#sidebar").removeClass("formhide");
		});
	}

	$("#sidebar h4.control").click(function() {

		$(this).toggleClass("closed");
		$(this).parent().find("div.content").slideToggle("fast");

		return false;
	});

	$("#sidebar ul li:first-child").addClass("nobg");


	$("div.scroller").jScrollPane({ scrollbarWidth: 15, scrollbarMargin: 0 });
	$('div.scrollerwrapper').jScrollPane({ scrollbarWidth: 15, scrollbarMargin: 0 });

	//a tag with class overlay call parent function to switch windows.
	$("div.overlay a.overlay").each(function() {
		$(this).bind("click", function() {
			parent.overlayClicks.simpleDetailClick($(this).attr("href"));
			return false;
		});
	});

	$("div.overlay #backtodetails").click(function() {
		parent.overlayClicks.simpleClick();
		return false;
	});



	//Equalize column widths
	var $scrollers = $("div.scroller table");
	$scrollers.each(function() {
		var tablebodyId = $(this).attr('id');
		var $cells = $("#" + tablebodyId + " tr:eq(0) td");
		$cells.each(function(i) {
			if (($cells.length - 1) != i)
				$("#" + tablebodyId + "_head tr:eq(0) th:eq(" + i + ")").width($(this).width());
		});
	});



	if ($("#wrapper.login").length == 1) {

		$("#markers li").hover(function() {
			$(this).addClass("selected");
			Cufon.replace("#markers li");

			$("#messaging h1").hide().eq($("#markers li").index(this) + 1).show()

		}, function() {
			$(this).removeClass("selected");
			Cufon.replace("#markers li");

			$("#messaging h1").hide().eq(0).show();
		});

		$("#news .cycle").cycle({
			fx: 'fade',
			speed: 200,
			timeout: 0,
			next: '#newscontrols a.next',
			prev: '#newscontrols a.previous'
		});

	}

	$("body").append("<div class=\"overlay\" id=\"overlay-715x430\"> \
			<div class=\"wrap\"></div> \
		</div> \
		<div class=\"overlay\" id=\"overlay-727x675\"> \
			<div class=\"wrap\"></div> \
		</div> \
		<div class=\"overlay\" id=\"overlay-787x702\"> \
			<div class=\"wrap\" ></div> \
		</div> \
		<div class=\"overlay\" id=\"overlay-927x530\"> \
			<div class=\"wrap\"></div> \
		</div> \
		<div class=\"overlay\" id=\"overlay-947x526\"> \
			<div class=\"wrap\"></div> \
		</div> \
		<div class=\"overlay\" id=\"overlay-947x620\"> \
			<div class=\"wrap\"></div> \
		</div> \
		<div class=\"overlay\" id=\"overlay-947x745\"> \
			<div class=\"wrap\"></div>  \
		</div>");
    //Overlay full screen
    $("body").append("<div class=\"overlay\" id=\"overlayfull\"> \
			<div class=\"wrap\"></div> \
		</div>");


	$("a[rel*=overlay],div[rel*=overlay]").overlay({
		closeOnClick: false,
		finish: {
			top: 10
		},
		expose: {
			color: '#2c3138',
			opacity: 0.8,
			closeOnClick: false
		},
		onBeforeLoad: function() {
			/* IE6 fix for form elements appearing over overlay */
			if (document.all) { $("#sidebar").addClass("formhide"); }
		},
		onLoad: function() {
			var wrap = this.getContent().find("div.wrap");
			//wrap.load(this.getTrigger().attr("href"));
			//alert(overlay947x526.replace("#####", this.getTrigger().attr("href")));
			//debugger;
			//alert(this.width);
			var myIframe = "<iframe width=\"{width}\" height=\"{height}\" scrolling=\"no\" frameborder=\"0\" src=\"{src}\"></iframe>";

			myIframe = myIframe.replace("{height}", this.getBackgroundImage().innerHeight() - 32);
			myIframe = myIframe.replace("{width}", this.getBackgroundImage().innerWidth() - 64);
			//alert(myIframe);

			wrap.html(myIframe.replace("{src}", this.getTrigger().attr("href")));
			/* IE6 fix for form elements appearing over overlay */
			if (document.all) { $("#sidebar").addClass("formhide"); }
		},
		onClose: function() {
			$("div.wrap").empty();
			if (document.all) { $("#sidebar").removeClass("formhide"); }
		}
	});
  
    $("div[rel*=overlayfull]").overlay({
        closeOnClick: false,
        finish: {
            top: 10
        },
        expose: {
            color: '#2c3138',
            opacity: 0.5,
            closeOnClick: false
        },
        onBeforeLoad: function() {
            /* IE6 fix for form elements appearing over overlay */
            if (document.all) { $("#sidebar").addClass("formhide"); }
        },
        onLoad: function() {
            var wrap = this.getContent().find("div.wrap");
            var myIframe = "<iframe scrolling=\"no\" frameborder=\"0\" allowTransparency=\"allowTransparency\" src=\"{src}\"></iframe>";

            //alert(myIframe);

            wrap.html(myIframe.replace("{src}", this.getTrigger().attr("href")));
            /* IE6 fix for form elements appearing over overlay */
            if (document.all) { $("#sidebar").addClass("formhide"); }
        },
        onClose: function() {
            $("div.wrap").empty();
            if (document.all) { $("#sidebar").removeClass("formhide"); }
        }
    });

	$(".type_text").focus(function() {
		if ($(this).attr("title") == $(this).val())
			$(this).val("");
		$(this).trigger("click");
	});

	$(".type_text").blur(function() {
		if ($(this).val() == "")
			$(this).val($(this).attr("title"));
	});

	feedback.init();


});

//print links
$('a.print').click(function() {
	window.print();
	return false;
});


function getSilverlightVersion() {
	var version = '';
	var container = null;
	try {
		var control = null;
		if (window.ActiveXObject) {
			control = new ActiveXObject('AgControl.AgControl');
		}
		else {
			if (navigator.plugins['Silverlight Plug-In']) {
				container = document.createElement('div');
				document.body.appendChild(container);
				container.innerHTML = '<embed type="application/x-silverlight" src="data:," />';
				control = container.childNodes[0];
			}
		}
		if (control) {
			if (control.isVersionSupported('3.0')) { version = 'Silverlight/3.0'; }
			else if (control.isVersionSupported('2.0')) { version = 'Silverlight/2.0'; }
			else if (control.isVersionSupported('1.0')) { version = 'Silverlight/1.0'; }
		}
	}
	catch (e) { }
	if (container) {
		document.body.removeChild(container);
	}
	return version;
}




