

if (typeof(redirect) != "string")			var redirect = "";
if (typeof(highlight_field) != "string")	var highlight_field = "";

function AttachOnload(MyFunction) {
	if (window.attachEvent) { window.attachEvent("onload",MyFunction); }
	else if (window.addEventListener) { window.addEventListener("load",MyFunction,false); }
}

// attach functions to run on an object's (OBJ) event (EVT)
function AttachEvent(obj, evt, MyFunction) 
{
	if (typeof(obj) == "string") obj = document.getElementById(obj); 

	evt = evt.replace(/^on/i,"");

	if (obj.attachEvent)
		obj.attachEvent("on" + evt, MyFunction);
	else if (obj.addEventListener)
		obj.addEventListener(evt, MyFunction, false);
}

// Check for targetblank
function makeLinksPopup() {
	convertLinks("a");	// Links
	convertLinks("area");	// Image Maps
}


function convertLinks(tagType) {
	var targets = document.getElementsByTagName(tagType); 
	if (targets) {
		for (var i = 0; i < targets.length; i++) {
			if (targets[i].rel) {
				if ((targets[i].rel == "targetblank") || (targets[i].rel == "lightbox")) {
					targets[i].target = "_blank";
				}
			}
		}
	}
}

function splitBrowsers(id) {
	if (typeof(document.styleSheets[id].cssRules) == "object") {
		return document.styleSheets[id].cssRules;
	}
	else {
		return document.styleSheets[id].rules;
	}
}

function getStyleBySelector( selector ) {
   var sheetList = document.styleSheets;
   var ruleList;
   var i, j;

   /* look through stylesheets in reverse order that they appear in the document */
   for (i=sheetList.length-1; i >= 0; i--) {
	   ruleList = splitBrowsers(i);
	   for (j=0; j<ruleList.length; j++) {
		   if (ruleList[j].selectorText == selector) {
				return ruleList[j].style;
		   }   
	   }
   }
   return null;
}

// Alternative to m.offsetLeft as some browsers take their offsets from the body while others take it from the parent element
function FindPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) { curleft += obj.x; }
	return curleft;
}

// Alternative to m.offsetTop as some browsers take their offsets from the body while others take it from the parent element
function FindPosY(obj, relativeTo) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;

			if (relativeTo && relativeTo == obj.id) break;
		}
	}
	else if (obj.y) { curtop += obj.y; }
	return curtop;
}

// get the height of the window
function GetWindowHeight() {
	if (window.innerHeight) 
		var window_height = window.innerHeight;
	else {
		if (document.documentElement.clientHeight)
			var window_height = document.documentElement.clientHeight;
		else
			var window_height = document.body.clientHeight;
	}
	return window_height;
}

// get the position of the scroll bar
function GetScrollTop() {
	if (window.pageYOffset)
		var window_top = window.pageYOffset;
	else {
		if (document.documentElement.scrollTop)
			var window_top = document.documentElement.scrollTop;
		else
			var window_top = document.body.scrollTop;
	}
	return window_top;
}

function writeThickboxCSS() {
	var obj1=getStyleBySelector("#TB_overlay");
	if (obj1!=null) {
		obj1.Opacity="0.6";
		obj1.MozOpacity="0.6";
		obj1.filter="alpha(opacity=60)";
	}

	var obj2=getStyleBySelector("#TB_HideSelect");
	if (obj2!=null) {
		obj2.Opacity="0";
		obj2.MozOpacity="0";
		obj2.filter="alpha(opacity=0)";
	}

	var obj3=getStyleBySelector(".clearfix");
	if (obj3!=null) obj3.Display="inline-block";
}

// Attaches a style to the page e.g. AttachStyle("#wrapper", "width:500px");
function AttachStyle(to, what) {

	// IE of course needs its own version
		if (document.createStyleSheet) {
			var obj = document.createStyleSheet();
			return obj.addRule(to, what);
		}

	// for the good browsers
		var head = document.getElementsByTagName("head")[0];
		var obj = document.createElement("STYLE");

		if (obj && head) {
			obj.setAttribute("type", "text/css");

			var entry = document.createTextNode(to + " { " + what + " }");

			if (obj.appendChild && head.appendChild) {
				obj.appendChild(entry);
				head.appendChild(obj);
			}
		}
}

// attaches a stylesheet to the page
function AttachStyleSheet(src, media) {

	var head = document.getElementsByTagName("head")[0];
	var obj = document.createElement("link");


	if (obj && head) {
		obj.setAttribute("type", "text/css");
		obj.setAttribute("rel", "stylesheet");
		obj.setAttribute("href", src);
		if (media) obj.setAttribute("media", media);

		if (head.appendChild) head.appendChild(obj);
	}
}

// sorts out IE valigns, converts the DIVs (for validation) to SPANs
function GetValignDivs()
{
	var divs = document.getElementsByTagName("div");

	for (var i = 0; i < divs.length; i++) {
		var div = divs[i];
		var className = String(div.className);

		if (className.match(/ie_valign/i)) {
			var innerHTML = div.innerHTML;

			var span = document.createElement("span");
			span.className = "ie_valign";
			span.innerHTML = innerHTML;

			div.parentNode.replaceChild(span, div);
		}
	}
}

function ChangeMarket(obj) 
{
	window.location.href = obj.value + "index.htm";
}


function CheckRedirect() 
{
	if (redirect != "") setTimeout('window.location.href="' + redirect + '"',1000);
}

function CheckHighlight() 
{
	if (highlight_field)
	{
		var field = document.getElementById(highlight_field); 

		if (field)
		{
			field.style.borderColor = "#C00000";
			field.style.backgroundColor = "#EBD9D9";

			/*try
			{
				field.focus();
			}
			catch(e) {  }*/
		}

	}
}

AttachOnload(CheckHighlight);
AttachOnload(CheckRedirect);

AttachOnload(makeLinksPopup);
AttachOnload(writeThickboxCSS);
if (false /*@cc_on || true @*/) AttachOnload(GetValignDivs);



var scrollbar_config_mousedown = false;
var scrollbar_config_dragging = "";


function Scrollbar(instance, id, step, w_bar) 
{
	this.instance = instance;
	this.id = id;
	this.step = step || 10;
	this.w_bar = w_bar || 30;

	this.margin = new Array();
	this.padding = new Array();
	this.width = 0;
	this.height = 0;
	this.innerHTML = "";

	this.Setup();
}

Scrollbar.prototype.KEY_TB = 9;
Scrollbar.prototype.KEY_EN = 13;
Scrollbar.prototype.KEY_SP = 32;
Scrollbar.prototype.KEY_UP = 38;
Scrollbar.prototype.KEY_DN = 40;
Scrollbar.prototype.KEY_PU = 33;
Scrollbar.prototype.KEY_PD = 34;

Scrollbar.prototype.OperaCleanUp = function (obj, prop, style) 
{
	if (prop.match(/width/))
	{
		var width = parseInt(style) || 0;
		var paddingRight = parseInt(this.getStyle(obj, "padding-right")) || 0;
		var paddingLeft = parseInt(this.getStyle(obj, "padding-left")) || 0;

		var style = (width - paddingRight - paddingLeft) + "px";
	}
	else
	{
		var height = parseInt(style) || 0;
		var paddingBottom = parseInt(this.getStyle(obj, "padding-bottom")) || 0;
		var paddingTop = parseInt(this.getStyle(obj, "padding-top")) || 0;

		var style = (height - paddingBottom - paddingTop) + "px";
	}

	return style;
}


Scrollbar.prototype.FindPosY = function(obj, relativeTo)
{
	var top = obj.offsetTop;

	while (obj.offsetParent)
	{
		obj = obj.offsetParent;
		if (relativeTo && relativeTo == obj.id) break;

		top+= obj.offsetTop;
	}
	
	return top;
}

Scrollbar.prototype.getStyle = function(obj, prop) 
{
	var prop2 = prop;

	if (prop.match(/float/i))
		prop2 = "styleFloat";
	else if (prop.match(/\-/))
	{
		prop2 = prop.replace(/\-/, " ");
		prop2 = prop2.ucwords();
		prop2 = prop2.charAt(0).toLowerCase() + prop2.substr(1, prop2.length - 1);
	}
	else
	{
		prop2 = prop.replace(/([A-Z])/,"-$1");
		prop2 = prop2.toLowerCase();
	}

	var style = obj.style[prop];
	var style1 = obj.style[prop2];

	// decent browsers
		if (document.defaultView && document.defaultView.getComputedStyle)
		{
			style = document.defaultView.getComputedStyle(obj,null).getPropertyValue(prop);
			style2 = document.defaultView.getComputedStyle(obj,null).getPropertyValue(prop2);
		}
		else if (window.getComputedStyle)
		{
			style = window.getComputedStyle(obj,null).getPropertyValue(prop);
			style2 = window.getComputedStyle(obj,null).getPropertyValue(prop2);
		}
	// IE
		else if (obj.currentStyle)
		{
			style = obj.currentStyle[prop];
			style2 = obj.currentStyle[prop2];
		}

	if ((!style || style.match(/^auto|0px$/i)) && style2) style = style2;

	// opera is silly, includes padding in width and height
		if (String(navigator.userAgent).match(/opera/i) && prop.match(/width|height/i) && style)
			style = this.OperaCleanUp(obj, prop, style);
		
	// base case
		return style;
}

Scrollbar.prototype.GetExtWidth = function()
{
	var width = parseInt(this.width);

	var margin = parseInt(this.margin[1]) || 0;
	margin+= parseInt(this.margin[3]) || 0;
	margin = 0;

	var padding = parseInt(this.padding[1]) || 0;
	padding+= parseInt(this.padding[3]) || 0;

	return width + margin + padding;
}

Scrollbar.prototype.GetExtHeight = function()
{
	var height = parseInt(this.height);
	var margin = parseInt(this.margin[0]) || 0;
	margin+= parseInt(this.margin[2]) || 0;

	margin = 0;

	var padding = parseInt(this.padding[0]) || 0;
	padding+= parseInt(this.padding[2]) || 0;

	return height + margin + padding;
}

Scrollbar.prototype.GetClipHeight = function()
{
	var height = parseInt(this.height) || 0;

	var paddingBottom = parseInt(this.padding[2]) || 0;

	return height - paddingBottom;
}

Scrollbar.prototype.Setup = function() 
{
	if (!document.createElement) return false;

	// quit if safari - pain in the arse
		if (String(navigator.userAgent).match(/safari/i)) return false;

	// quit if NS7 Windows - doesn't understand absolute positioning properly
			if (String(navigator.userAgent).match(/windows.*netscape[\/ ]7/i)) return false;

	// get scrollbar div
		var obj = document.getElementById(this.id);

		if (!obj) return false;

	// remember DIV properties
		this.margin = [this.getStyle(obj, "margin-top"), this.getStyle(obj, "margin-right"), this.getStyle(obj, "margin-bottom"), this.getStyle(obj, "margin-left")];
		this.padding = [this.getStyle(obj, "padding-top"), this.getStyle(obj, "padding-right"), this.getStyle(obj, "padding-bottom"), this.getStyle(obj, "padding-left")];

		this.width = parseInt(this.getStyle(obj, "width")) || 0;
		this.width-= this.w_bar;
		this.width+= "px";

		this.height = this.getStyle(obj, "height");

		this.innerHTML = obj.innerHTML;

//alert("container captured");

	// clear DIV properties
		obj.className = "div_scrollbar";
		obj.style.overflow = "hidden";
		obj.style.padding = "0";
		obj.style.paddingRight = this.w_bar + "px";
		obj.style.width = this.GetExtWidth() + "px";
		obj.style.height = this.GetExtHeight() + "px";
		obj.innerHTML = "";

//alert("reformatted container");
	this.CreateBar();
//alert("bars created");
	this.CreateInners();
//alert("scroller initialised");
}

Scrollbar.prototype.CreateInners = function () 
{
	var container = document.getElementById(this.id);
	var shell = document.createElement("div");
	var content = document.createElement("div");

	// format shell
		var width = parseInt(this.width) || 0;
		var height = this.GetClipHeight();
		var paddingTop = parseInt(this.padding[0]) || 0;

		shell.id = this.id + "_shell";
		shell.className = "div_scrollbar_shell";
		shell.style.margin = "0px";

		shell.style.paddingTop = "0px";
		shell.style.paddingRight = this.padding[1];
		shell.style.paddingBottom = this.padding[2];
		shell.style.paddingLeft = this.padding[3];

		shell.style.marginTop = paddingTop + "px";
		shell.style.width = width + "px";
		shell.style.height = height + "px";

		shell.style.overflow = "hidden";
		//shell.style.clip = "rect(" + paddingTop + " " + width + " " + height + " 0)";
		
		container.appendChild(shell);

	// format content
		content.id = this.id + "_content";
		content.className = "div_scrollbar_content";
		content.style.margin = "0px";
//		content.style.padding = this.padding.implode(" ");
		content.style.padding = "0px";
		content.style.width = this.width;
		content.innerHTML = this.innerHTML;

		eval("var c_wheel = function (e) { " + this.instance + ".MouseWheel(e); }");
		eval("var c_tab = function (e) { " + this.instance + ".HandleTabFocus(e); }");

		if (content.attachEvent)
		{
			content.attachEvent("onmousewheel", c_wheel);
			content.attachEvent("onkeyup", c_tab);
		}
		else if (content.addEventListener)
		{
			content.addEventListener("DOMMouseScroll", c_wheel, false);
			content.addEventListener("keyup", c_tab, false);
		}


		shell.appendChild(content);
}


Scrollbar.prototype.CreateBar = function () 
{
	var container = document.getElementById(this.id);

	var bar = document.createElement("div");
	var scroller = document.createElement("div");
	var scrollup = document.createElement("div");
	var scrolldown = document.createElement("div");

	// create scrollbar
		bar.id = this.id + "_bar";
		bar.className = "scrollbar_bar";

		eval("var oc = function (e) { " + this.instance + ".MoveScrollBar(e); }");
		eval("var ku = function (e) { " + this.instance + ".ScrollStop(); }");
		eval("var kd = function (e) { " + this.instance + ".ScrollKB(e); }");

		bar.onclick = oc;
		//bar.onkeydown = kd;
		//bar.onkeyup = ku;

		container.appendChild(bar);

	// create scroll up
		scrollup.id = this.id + "_up";
		scrollup.className = "scrollbar_up";
		scrollup.innerHTML = '<a href="javascript:void(0)" onmousedown="return ' + this.instance + '.ScrollUp();" onmouseup="return ' + this.instance + '.ScrollStop();" onkeydown="return ' + this.instance + '.ScrollKB(event, -1);" onkeyup="return ' + this.instance + '.ScrollStop();"></a>';

		bar.appendChild(scrollup);

	// create scroll down
		scrolldown.id = this.id + "_down";
		scrolldown.className = "scrollbar_down";
		scrolldown.innerHTML = '<a href="javascript:void(0)" onmousedown="return ' + this.instance + '.ScrollDown();" onmouseup="return ' + this.instance + '.ScrollStop();" onkeydown="return ' + this.instance + '.ScrollKB(event, 1);" onkeyup="return ' + this.instance + '.ScrollStop();"></a>';

		bar.appendChild(scrolldown);

	// create scroller
		scroller.id = this.id + "_scroller";
		scroller.className = "scrollbar_scroller";
//		scroller.innerHTML = '<a href="javascript:void(0)" onmousedown="' + this.instance + '.StartScrollDrag();" onmouseup="' + this.instance + '.StopScrollDrag();" onmouseout="' + this.instance + '.StopScrollDrag();"></a>';

		eval("var md = function () { " + this.instance + ".StartScrollDrag(); }");
		eval("var mu = function () { " + this.instance + ".StopScrollDrag(); }");

		scroller.onmousedown = md;
		scroller.onmouseup = mu;

		bar.appendChild(scroller); 
}

Scrollbar.prototype.PositionScroller = function () 
{
	var content = document.getElementById(this.id + "_content");
	var shell = document.getElementById(this.id + "_shell");

	var text_top = parseInt(content.style.top) || 0;
	var text_height = content.offsetHeight;

	var shell_height = shell.offsetHeight;

	var movement = 0;

	// if the text needs to be scrolled
		if (text_height >= shell_height)
		{
			// work out the movement area...
				var movement_area = Math.abs(text_height - shell_height);

			// work out how far into the movement area the text box has gone
				movement = Math.abs(text_top / movement_area);
		}


	// get scrollbar
		var bar = document.getElementById(this.id + "_bar");

	// get height of scrollbar
		var scrollbar_height = parseInt(this.getStyle(bar, "height")) || 0;

	// need to offset the height of the scrollbar by the heights of the up and down arrows
		var scrollup_height = document.getElementById(this.id + "_up").offsetHeight; 
		var scrolldown_height = document.getElementById(this.id + "_down").offsetHeight;

		scrollbar_height-= (scrollup_height + scrolldown_height);

	// work out where to put scroller...
		var y_scroller = Math.max(Math.min(Math.round(movement * scrollbar_height), scrollbar_height), 0);

	// need to alter y value by initial offset of up arrow
		y_scroller+= scrollup_height;

	// need to alter y value by height of the scroller so that its "top" is the middle of the scroller
		var scroller = document.getElementById(this.id + "_scroller");
		var scroller_height = scroller.offsetHeight;

		y_scroller-= parseInt(scroller_height / 2);

	// set scroller height
		scroller.style.top = y_scroller + "px";

}

Scrollbar.prototype.Scroll = function (abs, amount, doDefault)
{
	var ret = false;
	if (!doDefault) doDefault = false;

	var content = document.getElementById(this.id + "_content");
	var shell = document.getElementById(this.id + "_shell");

	var text_top = parseInt(content.style.top) || 0;
	var text_height = content.offsetHeight;

	var shell_height = shell.offsetHeight;

	// quit if text is too small
		if (shell_height > text_height) return false;

	var step = amount || this.step;

	// work out new top
		var top = text_top - (abs * step);

		// make sure its never bigger than 0
			if (top > 0)
			{
				top = 0;
				ret = ret || doDefault;
			}
		
		// make sure it anchors at the bottom
			if ((top + text_height) < shell_height)
			{
				top = 0 - (text_height - shell_height);
				ret = ret || doDefault;
			}

	// position the text
		content.style.top = top + "px";

	// position the scroller
		this.PositionScroller();

	// run it again if the mouse is still down
		if (scrollbar_config_mousedown && !amount) setTimeout(this.instance + ".Scroll(" + abs + ")", 100);

	return ret;
}


// wrapper functions
	Scrollbar.prototype.ScrollUp = function (amount)
	{
		scrollbar_config_mousedown = true;
		return this.Scroll(-1, amount);
	}

	Scrollbar.prototype.ScrollDown = function (amount)
	{
		scrollbar_config_mousedown = true;
		return this.Scroll(1, amount);
	}

	Scrollbar.prototype.ScrollKB = function (e, dir) 
	{
		var key = e.which || e.keyCode;

		if (!dir)
		{
			if (key == this.KEY_DN || key == this.KEY_PD) return this.Scroll(1, this.step);
			if (key == this.KEY_UP || key == this.KEY_PU) return this.Scroll(-1, this.step);
		}
		else if (dir > 0)
		{
			if (key == this.KEY_UP || key == this.KEY_PU)
				return this.Scroll(-1, this.step);
			else if (key == this.KEY_SP || key == this.KEY_EN || key == this.KEY_DN || key == this.KEY_PD)
				return this.Scroll(1, this.step);
		}
		else
		{
			if (key == this.KEY_DN || key == this.KEY_PD)
				return this.Scroll(1, this.step);
			else if (key == this.KEY_SP || key == this.KEY_EN || key == this.KEY_UP || key == this.KEY_PU)
				return this.Scroll(-1, this.step);
		}

		return true;
	}

Scrollbar.prototype.ScrollStop = function() 
{
	scrollbar_config_mousedown = false;
	return false;
}

Scrollbar.prototype.StartScrollDrag = function() 
{
	scrollbar_config_dragging = this.instance;
	return false;
}

Scrollbar.prototype.StopScrollDrag = function() 
{
	// need to do this because click event on bar fires before mouseup event on scroller so resets to top
		window.setTimeout("scrollbar_config_dragging = '';",1);
	
	return true;
}

Scrollbar.prototype.PositionContent = function (top, min, max) 
{
	var content = document.getElementById(this.id + "_content");
	var shell = document.getElementById(this.id + "_shell");

	var text_top = parseInt(content.style.top) || 0;
	var text_height = content.offsetHeight;

	var shell_height = shell.offsetHeight;

	var offset = 0;

	// if the text needs to be scrolled
		if (text_height >= shell_height)
		{
			// work out the movement area...
				var movement_area = Math.abs(text_height - shell_height);

			top-= min;
			max-= min;

			// work out how far into the movement area the text box has gone
				movement = Math.abs(top / max);

			offset = Math.max(Math.min(Math.round(movement * movement_area), movement_area), 0);
		}

	content.style.top = (0 - offset) + "px";

}

Scrollbar.prototype.TrackMouse = function(e) 
{
	e = e || window.event;

	var y = e.pageY || e.clientY;

	// need to offset IE by the page scrolltop because its crap
		if (0 /*@cc_on || 1 @*/) y+= document.documentElement.scrollTop;

//document.title+= ", " + y;

	if (scrollbar_config_dragging)
	{
		var instance = eval(scrollbar_config_dragging);
//		var instance = scrollbar;

		if (!instance) return;

		var content = document.getElementById(instance.id + "_content");
		var shell = document.getElementById(instance.id + "_shell");

		var text_top = parseInt(content.style.top) || 0;
		var text_height = content.offsetHeight;

		var shell_height = shell.offsetHeight;

		// quit if text is too small
			if (shell_height > text_height) return false;

		// get scrollbar
			var bar = document.getElementById(instance.id + "_bar");
			var scrollbar_top = instance.FindPosY(bar);
			var scrollbar_height = parseInt(instance.getStyle(bar, "height")) || 0;

		// get top offset
			var scrollup_height = document.getElementById(instance.id + "_up").offsetHeight;
			var scrolldown_height = document.getElementById(instance.id + "_down").offsetHeight;
			var scroller = document.getElementById(instance.id + "_scroller");
			var scroller_height = scroller.offsetHeight;

		// calculate new top of scroller
			var new_top = y - scrollbar_top;

		var debug_this = false;

		if (debug_this) document.title = new_top + ", " + scroller_height;

		// adjust by scroller height
			new_top-= parseInt(scroller_height / 2);

		if (debug_this) document.title+= ", " + new_top;

		// make sure it lies within range
			var min_top = scrollup_height;
			min_top-= parseInt(scroller_height / 2);
			var max_top = scrollbar_height + min_top;
			max_top-= scrollup_height + scrolldown_height;

		if (debug_this) document.title+= ", " + min_top;
		if (debug_this) document.title+= ", " + max_top;

			new_top = Math.max(new_top, min_top);
			new_top = Math.min(new_top, max_top);

		if (debug_this) document.title+= ", " + new_top;

		scroller.style.top = new_top + "px";

		instance.PositionContent(new_top, min_top, max_top);
		//instance.PositionScroller();
	}
}

Scrollbar.prototype.MoveScrollBar = function(evt) 
{
	evt = evt || window.event; 

	if (scrollbar_config_dragging && !scrollbar_config_mousedown) return true;

	var source = evt.srcElement || evt.currentTarget || evt.target;

	var content = document.getElementById(this.id + "_content");
	var shell = document.getElementById(this.id + "_shell");

	var text_top = parseInt(content.style.top) || 0;
	var text_height = content.offsetHeight;

	var shell_height = shell.offsetHeight;

	// quit if text is too small
		if (shell_height > text_height) return false;

	var y = evt.layerY || evt.offsetY;
	y = parseInt(y) || 0;

	// get scrollbar
		var bar = document.getElementById(this.id + "_bar");
		var scrollbar_top = this.FindPosY(bar);
		var scrollbar_height = parseInt(this.getStyle(bar, "height")) || 0;

	// get top offset
		var scrollup_height = document.getElementById(this.id + "_up").offsetHeight;
		var scrolldown_height = document.getElementById(this.id + "_down").offsetHeight;
		var scroller = document.getElementById(this.id + "_scroller");
		var scroller_height = scroller.offsetHeight;

	// calculate new top of scroller
		var new_top = y;// - scrollbar_top;

	// adjust by scroller height
		new_top-= parseInt(scroller_height / 2);

	// make sure it lies within range
		var min_top = scrollup_height;
		min_top-= parseInt(scroller_height / 2);
		var max_top = scrollbar_height + min_top;
		max_top-= scrollup_height + scrolldown_height;

		if (new_top > max_top || new_top < min_top)
			return;

	scroller.style.top = new_top + "px";

	this.PositionContent(new_top, min_top, max_top);
}

Scrollbar.prototype.MouseWheel = function (e) 
{
	e = e || window.event;
	if (!e) return;

	var value = 0;

	if (e.detail)
		value = 0 - (parseInt(e.detail / 3) || 0);
	else if (e.wheelDelta)
		value = parseInt(e.wheelDelta / 120) || 0;

	if (!value) return;

	value*= 10;

	if (value < 0)
		var result = this.Scroll(1, Math.abs(value), true);
	else
		var result = this.Scroll(-1, Math.abs(value), true);

	if (!result)
	{
		if (e.preventDefault) e.preventDefault();
		e.returnValue = false;
		return false;
	}

	return true;
}


Scrollbar.prototype.HandleSelect = function () 
{
	if (scrollbar_config_dragging)
		return false;
	else
		return true;
}

Scrollbar.prototype.HandleTabFocus = function (e) 
{
	e = e || window.event;
	if (!e) return;

	var key = e.which || e.keyCode;

	if (key == this.KEY_TB) {
		var obj = e.target || e.srcElement;

		if (!obj) return;

		var shell = document.getElementById(this.id + "_shell");
		var content = document.getElementById(this.id + "_content");

		var text_top = parseInt(content.style.top) || 0;
		var text_height = content.offsetHeight;

		var shell_height = shell.offsetHeight;
		var y = this.FindPosY(obj, this.id + "_content") - parseInt(shell_height / 2);

		// if the text needs to be scrolled
			if (text_height >= shell_height)
			{
				var max = text_height - shell_height;

				y = Math.max(0, Math.min(max, y));
				content.style.top = (0 - y) + "px";
			}
			else
				content.style.top = 0 + "px";

			shell.scrollTop = 0;
			this.PositionScroller();
	}
	else
		return this.ScrollKB(e);

	return true;
}


if (typeof(String.prototype.ucwords) != "function")
{
	String.prototype.ucwords = function () 
	{
		var bits = this.split(/ /);
		var style = "";

		for (var i = 0; i < bits.length; i++)
		{
			style+= bits[i].charAt(0).toUpperCase() + bits[i].substr(1, bits[i].length - 1);
		}

		return style;
	}
}

if (typeof(Array.prototype.implode) != "function")
{
	Array.prototype.implode = function(delim)
	{
		if (this.length == 0)
			return "";
		else
		{
			var d = "";
			var str = "";

			for (var i in this)
			{
				if (typeof(this[i]) != "function")
				{

					str += d + this[i];
					d = delim;
				}
			}

			return str;
		}
	}
}


AttachEvent(document, "onmouseup", Scrollbar.prototype.StopScrollDrag);
AttachEvent(document, "onmousemove", Scrollbar.prototype.TrackMouse);

/*@cc_on  AttachEvent(document,"onselectstart", Scrollbar.prototype.HandleSelect);  @*/


var scrollbar = null;
function CreateScrollbar() { scrollbar = new Scrollbar("scrollbar", "scrollbar", 25); }
$(document).ready(CreateScrollbar);

var timeout_selectboxes = null;

// Show or hide all select boxes on a page
function ToggleSelectBoxes(hide) {
	
	var objects = document.getElementsByTagName("select");
	for (var i = 0; i < objects.length; i++) objects[i].style.visibility = hide ? "hidden" : "visible";

	/*var objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++) objects[i].style.visibility = hide ? "hidden" : "visible";*/
}


// makes the menu list IE compatible
function sfHover()
{

	var nav = document.getElementById("nav");
	if (!nav) return;
	
	var li = nav.getElementsByTagName("LI");

	for (var i = 0; i < li.length; i++)
	{
		li[i].onmouseover = function()	{ this.className+= " sfhover"; ToggleSelectBoxes(1); }
		li[i].onmouseout = function()	{ this.className = this.className.replace(new RegExp(" sfhover\\b"), ""); ToggleSelectBoxes(0); }
	}
}

// Firefox only likes next line an NOT AttachOnload(sfHover) (makes sub menus stick)
//if (window.attachEvent) window.attachEvent("onload", sfHover);

var menu_hide_id = 0;
var timeout_menu_hide = new Array();

function MenuMouseOverIE(obj) 
{
	// only add sfhover class if its not already added
		if (!String(obj.className).match(/ sfhover/)) obj.className+= " sfhover";

	// make sure item has id
		if (!obj.id) obj.id = "sfhover" + menu_hide_id++;

	// quit if IE7
		if (0 /*@cc_on || (@_jscript_version >= 5.7) @*/) return true;
	
	// clear any hide timeouts that may exist
		var id = obj.id;
		
		if (timeout_menu_hide[id])
		{
			window.clearTimeout(timeout_menu_hide[id]);
			timeout_menu_hide[id] = null;
		}

	ToggleSelectBoxes(1);
}

function MenuMouseOutIE(obj) 
{
	// get id number if obj
		var id = obj.id;

	// don't bother with timeouts if IE7
		if (0 /*@cc_on || (@_jscript_version >= 5.7) @*/) return DoMenuMouseOutIE(id);

	timeout_menu_hide[id] = window.setTimeout("DoMenuMouseOutIE('" + id + "')",25);
}

// to stop flickering in IE6
function DoMenuMouseOutIE(id) 
{
	var obj = document.getElementById(id);

	// remove sfhover from the class
		obj.className = obj.className.replace(new RegExp(" sfhover\\b"), "");

	 // quit if IE7
		if (0 /*@cc_on || (@_jscript_version >= 5.7) @*/) return true;

	// clear the timeout if there is one
		if (timeout_menu_hide[id]) window.clearTimeout(timeout_menu_hide[id]);
		timeout_menu_hide[id] = null;

	if (obj.firstChild.className.match(/top/i)) ToggleSelectBoxes(0);

	return true;
}


function MenuHover() 
{
	var nav = document.getElementById("nav");
	if (!nav) return;

	// get position of wrapper left
		var wrapper_left = document.getElementById("wrapper_left"); 
		
		// decent browsers
			if (document.defaultView && document.defaultView.getComputedStyle)
				var position = document.defaultView.getComputedStyle(wrapper_left,null).getPropertyValue("position");
			else if (window.getComputedStyle)
				var position = window.getComputedStyle(wrapper_left,null).getPropertyValue("position");
		// IE
			else if (wrapper_left.currentStyle)
				var position = wrapper_left.currentStyle["position"];
		// base case
			else
				var position = "relative";

	// if its not absolutely positioned then style sheets not loaded therefore don't offset menu
		var do_offsetting = position.match(/absolute/i);

	var li = nav.getElementsByTagName("LI");

	for (var i = 0; i < li.length; i++)
	{
		if (1 || !do_offsetting)
		{
			if (0 /*@cc_on || 1 @*/)
			{
				li[i].onmouseover = function() { 
					MenuMouseOverIE(this);
					//if (typeof(HideFlashVideo) == "function") HideFlashVideo();
				}

				li[i].onmouseout = function() { 
					MenuMouseOutIE(this);
				}
			}
			else
			{
				li[i].onmouseover = function() { 
					//if (typeof(HideFlashVideo) == "function") HideFlashVideo();
				}
			}
		}
		else
		{
			li[i].onmouseover = function()
			{
				if (0 /*@cc_on || 1 @*/) MenuMouseOverIE(this);

				// position sub menu more accurately
					if (do_offsetting && this.hasChildNodes())
					{
						// find child lists and then change their margin-top value to the height of the current list item
							var kids = this.childNodes;
							
							for (var k = 0; k < kids.length; k++)
							{
								var child = kids[k];
								var tag = String(child.tagName).toLowerCase();

								if (tag == "ul" /*@cc_on && (@_jscript_version < 5.7) @*/) 
								{
									child.style.marginTop = (-5 - this.offsetHeight) + "px";
								}
							}
						
					}
			}

			if (0 /*@cc_on || 1 @*/)
			{
				li[i].onmouseout = function() { 
					MenuMouseOutIE(this);
					//if (0 /*@cc_on || (@_jscript_version >= 5.7) @*/) child.style.left = "-999em";
				}
			}
		}
	}
}

AttachOnload(MenuHover);


function AttachMenuCurves() 
{
	return;
	AttachStyleSheet(BASE_HREF + "style_menu_curves.css");
}

/*if (1 /*@cc_on && (@_jscript_version >= 5.7) @/)*/ AttachOnload(AttachMenuCurves);

/*
 * Interface elements for jQuery - http://interface.eyecon.ro
 *
 * Copyright (c) 2006 Stefan Petre
 * Dual licensed under the MIT (MIT-LICENSE.txt) 
 * and GPL (GPL-LICENSE.txt) licenses.
 */
 eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('6.15={3o:d(e){7 x=0;7 y=0;7 1Q=1A;7 A=e.L;8(6(e).H(\'Q\')==\'U\'){1E=A.1a;2y=A.O;A.1a=\'1F\';A.Q=\'1Y\';A.O=\'2e\';1Q=26}7 4=e;2P(4){x+=4.3B+(4.1I&&!6.3p.41?F(4.1I.2X)||0:0);y+=4.3x+(4.1I&&!6.3p.41?F(4.1I.2Z)||0:0);4=4.4e}4=e;2P(4&&4.4a&&4.4a.39()!=\'V\'){x-=4.1D||0;y-=4.1s||0;4=4.2x}8(1Q){A.Q=\'U\';A.O=2y;A.1a=1E}q{x:x,y:y}},4E:d(4){7 x=0,y=0;2P(4){x+=4.3B||0;y+=4.3x||0;4=4.4e}q{x:x,y:y}},35:d(e){7 w=6.H(e,\'1T\');7 h=6.H(e,\'36\');7 1e=0;7 1o=0;7 A=e.L;8(6(e).H(\'Q\')!=\'U\'){1e=e.1z;1o=e.2s}u{1E=A.1a;2y=A.O;A.1a=\'1F\';A.Q=\'1Y\';A.O=\'2e\';1e=e.1z;1o=e.2s;A.Q=\'U\';A.O=2y;A.1a=1E}q{w:w,h:h,1e:1e,1o:1o}},4P:d(4){q{1e:4.1z||0,1o:4.2s||0}},58:d(e){7 h,w,22;8(e){w=e.2a;h=e.29}u{22=D.Y;w=2z.3c||2N.3c||(22&&22.2a)||D.V.2a;h=2z.31||2N.31||(22&&22.29)||D.V.29}q{w:w,h:h}},3P:d(e){7 t,l,w,h,1J,1R;8(e&&e.2E.39()!=\'V\'){t=e.1s;l=e.1D;w=e.3j;h=e.3e;1J=0;1R=0}u{8(D.Y&&D.Y.1s){t=D.Y.1s;l=D.Y.1D;w=D.Y.3j;h=D.Y.3e}u 8(D.V){t=D.V.1s;l=D.V.1D;w=D.V.3j;h=D.V.3e}1J=2N.3c||D.Y.2a||D.V.2a||0;1R=2N.31||D.Y.29||D.V.29||0}q{t:t,l:l,w:w,h:h,1J:1J,1R:1R}},3L:d(e,1U){7 4=6(e);7 t=4.H(\'2j\')||\'\';7 r=4.H(\'2k\')||\'\';7 b=4.H(\'2n\')||\'\';7 l=4.H(\'2l\')||\'\';8(1U)q{t:F(t)||0,r:F(r)||0,b:F(b)||0,l:F(l)};u q{t:t,r:r,b:b,l:l}},56:d(e,1U){7 4=6(e);7 t=4.H(\'3w\')||\'\';7 r=4.H(\'3u\')||\'\';7 b=4.H(\'3s\')||\'\';7 l=4.H(\'3t\')||\'\';8(1U)q{t:F(t)||0,r:F(r)||0,b:F(b)||0,l:F(l)};u q{t:t,r:r,b:b,l:l}},4Z:d(e,1U){7 4=6(e);7 t=4.H(\'2Z\')||\'\';7 r=4.H(\'3G\')||\'\';7 b=4.H(\'3y\')||\'\';7 l=4.H(\'2X\')||\'\';8(1U)q{t:F(t)||0,r:F(r)||0,b:F(b)||0,l:F(l)||0};u q{t:t,r:r,b:b,l:l}},3T:d(2i){7 x=2i.53||(2i.52+(D.Y.1D||D.V.1D))||0;7 y=2i.51||(2i.54+(D.Y.1s||D.V.1s))||0;q{x:x,y:y}},3h:d(12,3g){3g(12);12=12.3F;2P(12){6.15.3h(12,3g);12=12.5a}},59:d(12){6.15.3h(12,d(4){S(7 1j 1q 4){8(2R 4[1j]===\'d\'){4[1j]=20}}})},57:d(4,27){7 1b=$.15.3P();7 3l=$.15.35(4);8(!27||27==\'4Y\')$(4).H({X:1b.t+((1i.3S(1b.h,1b.1R)-1b.t-3l.1o)/2)+\'K\'});8(!27||27==\'4Q\')$(4).H({N:1b.l+((1i.3S(1b.w,1b.1J)-1b.l-3l.1e)/2)+\'K\'})},4O:d(4,3U){7 3V=$(\'3q[@2u*="2w"]\',4||D),2w;3V.1V(d(){2w=k.2u;k.2u=3U;k.L.4M="4N:4R.4S.4W(2u=\'"+2w+"\')"})}};[].4i||(4V.4U.4i=d(v,n){n=(n==20)?0:n;7 m=k.1m;S(7 i=n;i<m;i++)8(k[i]==v)q i;q-1});6.3A=d(e){8(/^4T$|^4L$|^5b$|^5c$|^5t$|^5s$|^5r$|^5q$|^5u$|^V$|^5v$|^5z$|^5y$|^5x$|^5w$|^5p$|^5o$/i.2q(e.2E))q 1A;u q 26};6.E.5h=d(e,1p){7 c=e.3F;7 1d=c.L;1d.O=1p.O;1d.2j=1p.18.t;1d.2l=1p.18.l;1d.2n=1p.18.b;1d.2k=1p.18.r;1d.X=1p.X+\'K\';1d.N=1p.N+\'K\';e.2x.4f(c,e);e.2x.5g(e)};6.E.5f=d(e){8(!6.3A(e))q 1A;7 t=6(e);7 A=e.L;7 1Q=1A;7 J={};J.O=t.H(\'O\');8(t.H(\'Q\')==\'U\'){1E=t.H(\'1a\');A.1a=\'1F\';A.Q=\'\';1Q=26}J.32=6.15.35(e);J.18=6.15.3L(e);7 2Y=e.1I?e.1I.4g:t.H(\'5d\');J.X=F(t.H(\'X\'))||0;J.N=F(t.H(\'N\'))||0;7 3J=\'5e\'+F(1i.5i()*4p);7 1x=D.5j(/^3q$|^5n$|^5m$|^5l$|^5k$|^5A$|^2V$|^4u$|^4y$|^4z$|^4x$|^4v$|^4s$|^4H$/i.2q(e.2E)?\'4J\':e.2E);6.1j(1x,\'4F\',3J);1x.3X=\'4B\';7 R=1x.L;7 X=0;7 N=0;8(J.O==\'33\'||J.O==\'2e\'){X=J.X;N=J.N}R.Q=\'U\';R.X=X+\'K\';R.N=N+\'K\';R.O=J.O!=\'33\'&&J.O!=\'2e\'?\'33\':J.O;R.2K=\'1F\';R.36=J.32.1o+\'K\';R.1T=J.32.1e+\'K\';R.2j=J.18.t;R.2k=J.18.r;R.2n=J.18.b;R.2l=J.18.l;8(6.3p.4G){R.4g=2Y}u{R.4D=2Y}e.2x.4f(1x,e);A.2j=\'1M\';A.2k=\'1M\';A.2n=\'1M\';A.2l=\'1M\';A.O=\'2e\';A.4C=\'U\';A.X=\'1M\';A.N=\'1M\';8(1Q){A.Q=\'U\';A.1a=1E}1x.4A(e);R.Q=\'1Y\';q{J:J,4I:6(1x)}};6.E.2f={4K:[0,B,B],4r:[3E,B,B],4w:[4l,4l,4t],4X:[0,0,0],60:[0,0,B],6P:[3H,42,42],6O:[0,B,B],6N:[0,0,1L],6L:[0,1L,1L],6M:[3b,3b,3b],6Q:[0,6R,0],6W:[6V,6U,4k],6S:[1L,0,1L],6T:[6K,4k,47],6J:[B,3I,0],6B:[6A,50,6z],6x:[1L,0,0],6Y:[6C,6D,6I],6H:[6G,0,2U],6E:[B,0,B],6F:[B,6X,0],7a:[0,1v,0],7j:[75,0,7i],7f:[3E,3v,3I],7e:[7h,7l,3v],7g:[3r,B,B],7c:[4c,7d,4c],72:[2U,2U,2U],71:[B,70,74],76:[B,B,3r],7b:[0,B,0],79:[B,0,B],77:[1v,0,0],78:[0,0,1v],6Z:[1v,1v,0],73:[B,3H,0],7k:[B,2I,6y],6v:[1v,0,1v],5V:[B,0,0],5U:[2I,2I,2I],5T:[B,B,B],5R:[B,B,0]};6.E.1w=d(16,3z){8(6.E.2f[16])q{r:6.E.2f[16][0],g:6.E.2f[16][1],b:6.E.2f[16][2]};u 8(M=/^1N\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)$/.2A(16))q{r:F(M[1]),g:F(M[2]),b:F(M[3])};u 8(M=/1N\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)$/.2A(16))q{r:Z(M[1])*2.55,g:Z(M[2])*2.55,b:Z(M[3])*2.55};u 8(M=/^#([a-1H-1B-9])([a-1H-1B-9])([a-1H-1B-9])$/.2A(16))q{r:F("1C"+M[1]+M[1]),g:F("1C"+M[2]+M[2]),b:F("1C"+M[3]+M[3])};u 8(M=/^#([a-1H-1B-9]{2})([a-1H-1B-9]{2})([a-1H-1B-9]{2})$/.2A(16))q{r:F("1C"+M[1]),g:F("1C"+M[2]),b:F("1C"+M[3])};u q 3z==26?1A:{r:B,g:B,b:B}};6.E.4n={3y:1,2X:1,3G:1,2Z:1,5S:1,5B:1,36:1,N:1,5W:1,5X:1,2n:1,2l:1,2k:1,2j:1,62:1,2T:1,61:1,6w:1,1f:1,5Y:1,5Z:1,3s:1,3t:1,3u:1,3w:1,38:1,5Q:1,X:1,1T:1,2O:1};6.E.49={5P:1,5G:1,5H:1,5F:1,5E:1,16:1,5C:1};6.E.25=[\'5D\',\'5I\',\'5J\',\'5O\'];6.E.3k={\'3d\':[\'24\',\'3W\'],\'2B\':[\'24\',\'3f\'],\'2D\':[\'2D\',\'\'],\'2C\':[\'2C\',\'\']};6.3Q.4b({5N:d(1h,1G,P,2v){q k.2d(d(){7 2t=6.1G(1G,P,2v);7 e=28 6.4m(k,2t,1h)})},37:d(1G,2v){q k.2d(d(){7 2t=6.1G(1G,2v);7 e=28 6.37(k,2t)})},5M:d(14){q k.1V(d(){8(k.1n)6.3m(k,14)})},5K:d(14){q k.1V(d(){8(k.1n)6.3m(k,14);8(k.2d&&k.2d[\'E\'])k.2d.E=[]})}});6.4b({37:d(C,o){7 z=k,4o;z.14=d(){8(6.43(o.2M))o.2M.3Z(C)};z.2h=3O(d(){z.14()},o.1k);C.1n=z},P:{4q:d(p,n,4j,4d,1k){q((-1i.5L(p*1i.63)/2)+0.5)*4d+4j}},4m:d(C,o,1h){7 z=k,4o;7 y=C.L;7 44=6.H(C,"2K");7 1O=6.H(C,"Q");7 G={};z.2L=(28 46()).48();o.P=o.P&&6.P[o.P]?o.P:\'4q\';z.2Q=d(I,W){8(6.E.4n[I]){8(W==\'2H\'||W==\'2G\'||W==\'3N\'){8(!C.1r)C.1r={};7 r=Z(6.1y(C,I));C.1r[I]=r&&r>-4p?r:(Z(6.H(C,I))||0);W=W==\'3N\'?(1O==\'U\'?\'2H\':\'2G\'):W;o[W]=26;G[I]=W==\'2H\'?[0,C.1r[I]]:[C.1r[I],0];8(I!=\'1f\')y[I]=G[I][0]+(I!=\'2O\'&&I!=\'34\'?\'K\':\'\');u 6.1j(y,"1f",G[I][0])}u{G[I]=[Z(6.1y(C,I)),Z(W)||0]}}u 8(6.E.49[I])G[I]=[6.E.1w(6.1y(C,I)),6.E.1w(W)];u 8(/^2D$|2C$|24$|2B$|3d$/i.2q(I)){7 m=W.1t(/\\s+/g,\' \').1t(/1N\\s*\\(\\s*/g,\'1N(\').1t(/\\s*,\\s*/g,\',\').1t(/\\s*\\)/g,\')\').64(/([^\\s]+)/g);6n(I){2b\'2D\':2b\'2C\':2b\'3d\':2b\'2B\':m[3]=m[3]||m[1]||m[0];m[2]=m[2]||m[0];m[1]=m[1]||m[0];S(7 i=0;i<6.E.25.1m;i++){7 1l=6.E.3k[I][0]+6.E.25[i]+6.E.3k[I][1];G[1l]=I==\'2B\'?[6.E.1w(6.1y(C,1l)),6.E.1w(m[i])]:[Z(6.1y(C,1l)),Z(m[i])]}3R;2b\'24\':S(7 i=0;i<m.1m;i++){7 3n=Z(m[i]);7 2r=!6m(3n)?\'3W\':(!/6l|U|1F|6j|6k|6o|6p|6u|6t|6s|6q/i.2q(m[i])?\'3f\':1A);8(2r){S(7 j=0;j<6.E.25.1m;j++){1l=\'24\'+6.E.25[j]+2r;G[1l]=2r==\'3f\'?[6.E.1w(6.1y(C,1l)),6.E.1w(m[i])]:[Z(6.1y(C,1l)),3n]}}u{y[\'6r\']=m[i]}}3R}}u{y[I]=W}q 1A};S(p 1q 1h){8(p==\'L\'){7 1c=6.30(1h[p]);S(1P 1q 1c){k.2Q(1P,1c[1P])}}u 8(p==\'3X\'){8(D.2S)S(7 i=0;i<D.2S.1m;i++){7 1K=D.2S[i].1K||D.2S[i].6i||20;8(1K){S(7 j=0;j<1K.1m;j++){8(1K[j].6h==\'.\'+1h[p]){7 1X=28 69(\'\\.\'+1h[p]+\' {\');7 1g=1K[j].L.68;7 1c=6.30(1g.1t(1X,\'\').1t(/}/g,\'\'));S(1P 1q 1c){k.2Q(1P,1c[1P])}}}}}}u{k.2Q(p,1h[p])}}y.Q=1O==\'U\'?\'1Y\':1O;y.2K=\'1F\';z.14=d(){7 t=(28 46()).48();8(t>o.1k+z.2L){4h(z.2h);z.2h=20;S(p 1q G){8(p=="1f")6.1j(y,"1f",G[p][1]);u 8(2R G[p][1]==\'2V\')y[p]=\'1N(\'+G[p][1].r+\',\'+G[p][1].g+\',\'+G[p][1].b+\')\';u y[p]=G[p][1]+(p!=\'2O\'&&p!=\'34\'?\'K\':\'\')}8(o.2G||o.2H)S(7 p 1q C.1r)8(p=="1f")6.1j(y,p,C.1r[p]);u y[p]="";y.Q=o.2G?\'U\':(1O!=\'U\'?1O:\'1Y\');y.2K=44;C.1n=20;8(6.43(o.2M))o.2M.3Z(C)}u{7 n=t-k.2L;7 2c=n/o.1k;S(p 1q G){8(2R G[p][1]==\'2V\'){y[p]=\'1N(\'+F(6.P[o.P](2c,n,G[p][0].r,(G[p][1].r-G[p][0].r),o.1k))+\',\'+F(6.P[o.P](2c,n,G[p][0].g,(G[p][1].g-G[p][0].g),o.1k))+\',\'+F(6.P[o.P](2c,n,G[p][0].b,(G[p][1].b-G[p][0].b),o.1k))+\')\'}u{7 2W=6.P[o.P](2c,n,G[p][0],(G[p][1]-G[p][0]),o.1k);8(p=="1f")6.1j(y,"1f",2W);u y[p]=2W+(p!=\'2O\'&&p!=\'34\'?\'K\':\'\')}}}};z.2h=3O(d(){z.14()},13);C.1n=z},3m:d(C,14){8(14)C.1n.2L-=67;u{2z.4h(C.1n.2h);C.1n=20;6.65(C,"E")}}});6.30=d(1g){7 1c={};8(2R 1g==\'66\'){1g=1g.39().40(\';\');S(7 i=0;i<1g.1m;i++){1X=1g[i].40(\':\');8(1X.1m==2){1c[6.45(1X[0].1t(/\\-(\\w)/g,d(m,c){q c.6a()}))]=6.45(1X[1])}}}q 1c};6.1u={3K:d(o){q k.1V(d(){7 4=k;4.f={10:6(o.10,k),23:6(o.23,k),21:6.15.3o(k),T:o.T,2p:o.2p,1Z:o.1Z,3Y:o.3Y,17:o.17,2T:o.2T};6.1u.2J(4,0);6(2z).2F(\'6b\',d(){4.f.21=6.15.3o(4);6.1u.2J(4,0);6.1u.3i(4)});6.1u.3i(4);4.f.10.2F(\'6g\',d(){6(4.f.2p,k).1S(0).L.Q=\'1Y\'}).2F(\'6f\',d(){6(4.f.2p,k).1S(0).L.Q=\'U\'});6(D).2F(\'6e\',d(e){7 2g=6.15.3T(e);7 19=0;8(4.f.17&&4.f.17==\'3M\')7 2o=2g.x-4.f.21.x-(4.1z-4.f.T*4.f.10.1W())/2-4.f.T/2;u 8(4.f.17&&4.f.17==\'38\')7 2o=2g.x-4.f.21.x-4.1z+4.f.T*4.f.10.1W();u 7 2o=2g.x-4.f.21.x;7 3D=1i.3C(2g.y-4.f.21.y-4.2s/2,2);4.f.10.1V(d(2m){11=1i.6c(1i.3C(2o-2m*4.f.T,2)+3D);11-=4.f.T/2;11=11<0?0:11;11=11>4.f.1Z?4.f.1Z:11;11=4.f.1Z-11;3a=4.f.2T*11/4.f.1Z;k.L.1T=4.f.T+3a+\'K\';k.L.N=4.f.T*2m+19+\'K\';19+=3a});6.1u.2J(4,19)})})},2J:d(4,19){8(4.f.17)8(4.f.17==\'3M\')4.f.23.1S(0).L.N=(4.1z-4.f.T*4.f.10.1W())/2-19/2+\'K\';u 8(4.f.17==\'N\')4.f.23.1S(0).L.N=-19/4.f.10.1W()+\'K\';u 8(4.f.17==\'38\')4.f.23.1S(0).L.N=(4.1z-4.f.T*4.f.10.1W())-19/2+\'K\';4.f.23.1S(0).L.1T=4.f.T*4.f.10.1W()+19+\'K\'},3i:d(4){4.f.10.1V(d(2m){k.L.1T=4.f.T+\'K\';k.L.N=4.f.T*2m+\'K\'})}};6.3Q.6d=6.1u.3K;',62,456,'||||el||jQuery|var|if|||||function||fisheyeCfg|||||this||||options||return||||else||||||es|255|elem|document|fx|parseInt|props|css|tp|oldStyle|px|style|result|left|position|easing|display|wrs|for|itemWidth|none|body|vp|top|documentElement|parseFloat|items|distance|nodeEl||step|iUtil|color|halign|margins|toAdd|visibility|clientScroll|newStyles|cs|wb|opacity|styles|prop|Math|attr|duration|nmp|length|animationHandler|hb|old|in|orig|scrollTop|replace|iFisheye|128|parseColor|wr|curCSS|offsetWidth|false|F0|0x|scrollLeft|oldVisibility|hidden|speed|fA|currentStyle|iw|cssRules|139|0px|rgb|oldDisplay|np|restoreStyle|ih|get|width|toInteger|each|size|rule|block|proximity|null|pos|de|container|border|cssSides|true|axis|new|clientHeight|clientWidth|case|pr|queue|absolute|namedColors|pointer|timer|event|marginTop|marginRight|marginLeft|nr|marginBottom|posx|itemsText|test|sideEnd|offsetHeight|opt|src|callback|png|parentNode|oldPosition|window|exec|borderColor|padding|margin|nodeName|bind|hide|show|192|positionContainer|overflow|startTime|complete|self|zIndex|while|getValues|typeof|styleSheets|maxWidth|211|object|pValue|borderLeftWidth|oldFloat|borderTopWidth|parseStyle|innerHeight|sizes|relative|fontWeight|getSize|height|pause|right|toLowerCase|extraWidth|169|innerWidth|borderWidth|scrollHeight|Color|func|traverseDOM|positionItems|scrollWidth|cssSidesEnd|windowSize|stopAnim|floatVal|getPosition|browser|img|224|paddingBottom|paddingLeft|paddingRight|230|paddingTop|offsetTop|borderBottomWidth|notColor|fxCheckTag|offsetLeft|pow|posy|240|firstChild|borderRightWidth|165|140|wid|build|getMargins|center|toggle|setInterval|getScroll|fn|break|max|getPointer|emptyGIF|images|Width|className|valign|apply|split|opera||isFunction|oldOverflow|trim|Date||getTime|colorCssProps|tagName|extend|144|delta|offsetParent|insertBefore|styleFloat|clearInterval|indexOf|firstNum|107|245|fxe|cssProps|values|10000|linear|azure|dl|220|iframe|ul|beige|table|button|form|appendChild|fxWrapper|listStyle|cssFloat|getPositionLite|id|msie|ol|wrapper|div|aqua|td|filter|progid|fixPNG|getSizeLite|horizontally|DXImageTransform|Microsoft|tr|prototype|Array|AlphaImageLoader|black|vertically|getBorder||pageY|clientX|pageX|clientY||getPadding|centerEl|getClient|purgeEvents|nextSibling|tbody|caption|float|w_|buildWrapper|removeChild|destroyWrapper|random|createElement|select|hr|input|br|meta|optgroup|colgroup|col|tfoot|thead|th|header|option|frameset|frame|script|textarea|fontSize|outlineColor|Top|borderTopColor|borderRightColor|borderBottomColor|borderLeftColor|Right|Bottom|stopAll|cos|stop|animate|Left|backgroundColor|textIndent|yellow|bottom|white|silver|red|letterSpacing|lineHeight|outlineOffset|outlineWidth|blue|minHeight|maxHeight|PI|match|dequeue|string|100000000|cssText|RegExp|toUpperCase|resize|sqrt|Fisheye|mousemove|mouseout|mouseover|selectorText|rules|dotted|dashed|transparent|isNaN|switch|solid|double|outset|borderStyle|inset|ridge|groove|purple|minWidth|darkred|203|204|153|darkorchid|233|150|fuchsia|gold|148|darkviolet|122|darkorange|85|darkcyan|darkgrey|darkblue|cyan|brown|darkgreen|100|darkmagenta|darkolivegreen|183|189|darkkhaki|215|darksalmon|olive|182|lightpink|lightgrey|orange|193||lightyellow|maroon|navy|magenta|green|lime|lightgreen|238|lightblue|khaki|lightcyan|173|130|indigo|pink|216'.split('|'),0,{}))


/**
 * Interface Elements for jQuery
 * Fisheye menu
 * 
 * http://interface.eyecon.ro
 * 
 * Copyright (c) 2006 Stefan Petre
 * Dual licensed under the MIT (MIT-LICENSE.txt) 
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 */

/**
 * Build a Fisheye menu from a list of links
 *
 * @name Fisheye
 * @description Build a Fisheye menu from a list of links
 * @param Hash hash A hash of parameters
 * @option String items items selection
 * @option String container container element
 * @option Integer itemWidth the minimum width for each item
 * @option Integer maxWidth the maximum width for each item
 * @option String itemsText selection of element that contains the text for each item
 * @option Integer proximity the distance from element that make item to interact
 * @option String valign vertical alignment
 * @option String halign horizontal alignment
 *
 * @type jQuery
 * @cat Plugins/Interface
 * @author Stefan Petre
 */
jQuery.iFisheye = {
	
	build : function(options)
	{
	
		return this.each(
			function()
			{
				var el = this;

				el.fisheyeCfg = {
					items : jQuery(options.items, this),
					container: jQuery(options.container, this),
					pos : jQuery.iUtil.getPosition(this),
					itemWidth: options.itemWidth,
					itemsText: options.itemsText,
					proximity: options.proximity,
					valign: options.valign,
					halign: options.halign,
					maxWidth : options.maxWidth
				};

				jQuery.iFisheye.positionContainer(el, 0);

				jQuery(window).bind(
					'resize',
					function()
					{
						el.fisheyeCfg.pos = jQuery.iUtil.getPosition(el);
						jQuery.iFisheye.positionContainer(el, 0);
						jQuery.iFisheye.positionItems(el);
					}
				);

				jQuery.iFisheye.positionItems(el);

				el.fisheyeCfg.items
					.bind(
						'mouseover',
						function()
						{
							//jQuery(el.fisheyeCfg.itemsText, this).get(0).style.display = 'block';
						}
					)
					.bind(
						'mouseout',
						function()
						{
							//jQuery(el.fisheyeCfg.itemsText, this).get(0).style.display = 'none';
						}
					);

				jQuery(document).bind(
					'mousemove',
					function(e)
					{
						var pointer = jQuery.iUtil.getPointer(e);

						// get top position of wrapper_products
							var wrapper_products = document.getElementById("wrapper_products");
							if (wrapper_products)
							{
								var w_top = wrapper_products.offsetTop + wrapper_products.offsetHeight;

								if (pointer.y > w_top) pointer.y+= 800;
							}

						var toAdd = 0;

						if (el.fisheyeCfg.halign && el.fisheyeCfg.halign == 'center')
							var posx = pointer.x - el.fisheyeCfg.pos.x - (el.offsetWidth - el.fisheyeCfg.itemWidth * el.fisheyeCfg.items.size())/2 - el.fisheyeCfg.itemWidth/2;
						else if (el.fisheyeCfg.halign && el.fisheyeCfg.halign == 'right')
							var posx = pointer.x - el.fisheyeCfg.pos.x - el.offsetWidth + el.fisheyeCfg.itemWidth * el.fisheyeCfg.items.size();
						else 
							var posx = pointer.x - el.fisheyeCfg.pos.x;

						//var posy = Math.pow(pointer.y - el.fisheyeCfg.pos.y - el.offsetHeight/2,2);
						var posy = Math.pow(pointer.y - el.fisheyeCfg.pos.y,2); // make it less sensitive to mouse position on y axis

						el.fisheyeCfg.items.each(
							function(nr)
							{
								distance = Math.sqrt(
									Math.pow(posx - nr*el.fisheyeCfg.itemWidth, 2)
									+ posy
								);

								distance -= el.fisheyeCfg.itemWidth/2;
								
								distance = distance < 0 ? 0 : distance;
								distance = distance > el.fisheyeCfg.proximity ? el.fisheyeCfg.proximity : distance;
								distance = el.fisheyeCfg.proximity - distance;

								extraWidth = el.fisheyeCfg.maxWidth * distance/el.fisheyeCfg.proximity;

								// if we're fully zoomed out on the image, revert to the smaller image
									if (1 /*@cc_on && (@_jscript_version >= 5.7) @*/)
									{
										if (this.hasChildNodes)
										{
											img = this.childNodes[0];

											if (!extraWidth && img.src.match(/_0\./))
												img.src = img.src.replace(/_0t?\./,'_0t.');
											else if (extraWidth && img.src.match(/_0t\./))
												img.src = img.src.replace(/_0t?\./,'_0.');
										}
									}
								
								this.style.width = el.fisheyeCfg.itemWidth + extraWidth + 'px';
								this.style.left = el.fisheyeCfg.itemWidth * nr + toAdd + 'px';
								toAdd += extraWidth;
							}
						);
						jQuery.iFisheye.positionContainer(el, toAdd);
					}
				);
			}
		)
	},
	
	positionContainer : function(el, toAdd)
	{
		if (el.fisheyeCfg.halign)
			if (el.fisheyeCfg.halign == 'center')
				el.fisheyeCfg.container.get(0).style.left = (el.offsetWidth - el.fisheyeCfg.itemWidth * el.fisheyeCfg.items.size())/2 - toAdd/2 + 'px';
			else if (el.fisheyeCfg.halign == 'left')
				el.fisheyeCfg.container.get(0).style.left =  - toAdd/el.fisheyeCfg.items.size() + 'px';
			else if (el.fisheyeCfg.halign == 'right')
				el.fisheyeCfg.container.get(0).style.left =  (el.offsetWidth - el.fisheyeCfg.itemWidth * el.fisheyeCfg.items.size()) - toAdd/2 + 'px';
		el.fisheyeCfg.container.get(0).style.width = el.fisheyeCfg.itemWidth * el.fisheyeCfg.items.size() + toAdd + 'px';
	},
	
	positionItems : function(el)
	{
		el.fisheyeCfg.items.each(
			function(nr)
			{
				this.style.width = el.fisheyeCfg.itemWidth + 'px';
				this.style.left = el.fisheyeCfg.itemWidth * nr + 'px';
			}
		);
	}
};

jQuery.fn.Fisheye = jQuery.iFisheye.build;

var cached_dock_images = new Array();
var prodIDs = new Array();


$(document).ready(
	function()
	{
		$('#dock').Fisheye(
			{
				maxWidth: 40, // how many pixels to add on to each image
				items: 'a',
				itemsText: 'span',
				container: '.dock-container',
				itemWidth: 85,
				proximity: 90,
				alignment : 'left',
				valign: 'bottom',
				halign : 'center'
			}
		)

		// cache smaller images
			for (var k = 0; k < prodIDs.length; k++) {
				i = prodIDs[k];
				cached_dock_images[i] = new Image(); cached_dock_images[i].src = BASE_HREF + "images/products/" + i + "_0t.png";
			}

		// fire mousemove event so menu switches to smaller, anti-aliased images
			if (document.fireEvent)
				document.fireEvent("onmousemove");
			else if (document.dispatchEvent && document.createEvent)
			{
				var mousemove = document.createEvent("MouseEvents");
				mousemove.initEvent("mousemove", true, true);
				document.dispatchEvent(mousemove);
			}

		if (document.getElementById("dock_loading")) document.getElementById("dock_loading").style.visibility = "hidden";
		if (document.getElementById("dock")) document.getElementById("dock").style.visibility = "visible";
	}
);


function CurvedBorder(id) 
{
	this.CreateBorder(id);
}


CurvedBorder.prototype.CreateBorder = function (id) 
{
	if (!document.createElement) return false;

	// get div
		var container = document.getElementById(id);

		if (!container) return false;

	// get first node
		if (container.hasChildNodes())
		{
			var children = container.childNodes;
			var firstChild = children[0];

			container.className+= " box";

			var divs = ["t","r","b","l","lt","rt","rb","lb"];

			for (var i = 0; i < divs.length; i++)
			{
				var div = document.createElement("div");
				div.className = "box_" + divs[i];
				
				//alert("");
				container.insertBefore(div, firstChild);
			}
		}
}





function AddOnClicks() {
	AttachEvent("type_camera","onclick",RefreshAdapterForm);
	AttachEvent("type_lens","onclick",RefreshAdapterForm);
}
function RefreshAdapterForm() {
	var frm_adapter = document.getElementById("frm_adapter");
	frm_adapter.submit();
}
function RefreshModels()
{
	document.getElementById("reset_cameraID").value = 1;
	RefreshAdapterForm();
}
$(document).ready(AddOnClicks);