//	Copyright © Coretomic, 2005

//*********************************************
//*  переменные и функции "среды окружения"   *
//*********************************************

dom = (document.getElementById) ? true : false;
nn4 = (document.layers) ? true : false;
nn6 = (navigator.userAgent.indexOf("Gecko")!=-1);
ie = (document.all) ? true : false;
ie4 = ie && !dom;
ie5 = ie && !ie4;
Mac = (navigator.appVersion.indexOf("Mac") != -1);
ie4mac = ie4 && Mac;
opera = (navigator.userAgent.indexOf("Opera")!=-1);
Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);
function empty() {}

var stdMouseX = -1, stdMouseY = -1;
var MouseMoved = 0;
var stdHint="";
var MouseMove = empty;
var Init = empty;

if (nn4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = stdMouseMove;

function stdMouseMove(e) {
//	stdMouseX = (nn4) ? (e.pageX):(event.x + document.body.scrollLeft);
//	stdMouseY = (nn4) ? (e.pageY):(event.y + document.body.scrollTop);
	MouseMoved++;
	MouseMove(e);
	HintMouseMove();
}

function HintMouseMove() {
	if (stdHint)moveElem(stdHint, stdMouseX+10, stdMouseY+10);
}

function stdInit() {
	Init();
}

//*********************************************
//* элементарные функции для работы со слоями *
//*********************************************

function showElem(elemId) {
if (dom) document.getElementById(elemId).style.visibility = "visible";
	else if (ie4) document.all[elemId].style.visibility = "visible";
		else if (nn4) document.layers[elemId].visibility = "show";
}

function hideElem(elemId) {
if (dom) document.getElementById(elemId).style.visibility = "hidden";
	else if (ie4) document.all[elemId].style.visibility = "hidden";
		else if (nn4) document.layers[elemId].visibility = "hide";
}

function putElem(elemId) {
if (dom) document.getElementById(elemId).style.display = "block";
	else if (ie4) document.all[elemId].style.display = "block";
}

function removeElem(elemId) {
if (dom) document.getElementById(elemId).style.display = "none";
	else if (ie4) document.all[elemId].style.display = "none";
}

function moveElem(idname,x,y) {
if (dom)
	with (eval(idname)) {
		style.left = x;
		style.top = y;
	}
else if (nn4) {
		document.layers[idname].left=x;
		document.layers[idname].top=y;
	}
}

function changeElem(elemId) {
if (dom)
	if (document.getElementById(elemId).style.display == "block")
		document.getElementById(elemId).style.display = "none"
	else
		document.getElementById(elemId).style.display = "block"

else if (ie4)
	if (document.all[elemId].style.display == "block")
		document.all[elemId].style.display = "none";
	else
		document.all[elemId].style.display = "block";
}

function exchangeElem(elemId) {
if (dom)
	if (document.getElementById(elemId).style.visibility == "hidden")
		document.getElementById(elemId).style.visibility= "visible"
	else
		document.getElementById(elemId).style.visibility= "hidden"

else if (ie4)
	if (document.all[elemId].style.visibility== "hidden")
		document.all[elemId].style.visibility= "visible";
	else
		document.all[elemId].style.visibility= "hidden";
else if (nn4)
	if (document.layers[elemId].visibility=="hide")
		document.layers[elemId].visibility="show";
	else
		document.layers[elemId].visibility="hide";
}

function relPosX(which) {
if (nn4) {
return document.layers[which].pageX;
} else {
var elem = (dom)? document.getElementById(which) : document.all[which];
var pos = elem.offsetLeft;
while (elem.offsetParent != null) {
elem = elem.offsetParent;
pos += elem.offsetLeft;
if (elem.tagName == 'BODY') break;
} return pos;
}
}

function relPosY(which) {
if (nn4) {
return document.layers[which].pageY;
} else {
var elem = (dom)? document.getElementById(which) : document.all[which];
var pos = elem.offsetTop;
while (elem.offsetParent != null) {
elem = elem.offsetParent;
pos += elem.offsetTop;
if (elem.tagName == 'BODY') break;
} return pos;
}
}

//*********************************************
//*           стандартные функции             *
//*********************************************

function iLayer(nameid,width,text) {
if (!width)width=1;
if (!text)text='';
if (nn4)
document.write("<ilayer name='"+nameid+"'width='"+width+"'>"+text+"</ilayer>")
else
document.write("<span id='"+nameid+"' style='position: relative; width: "+width+"px;'>"+text+"</span>")
}

function checkmail(email) {
if (email == "") return (false);
 if (email.indexOf(".") == -1) return (false);
 dog = email.indexOf("@");
 if (dog == -1) return (false);
 if ((dog < 1) || (dog > email.length - 5))return (false);
 if ((email.charAt(dog - 1) == '.') || (email.charAt(dog + 1) == '.')) return (false);
 if (email.charAt(email.length - 1) == '.') return (false);
 return true;
}

function startHint(nameid) {
	if (stdHint)hideElem(stdHint);
	stdHint=nameid;
	moveElem(stdHint, stdMouseX+10, stdMouseY+10);
	showElem(stdHint);
}

function stopHint() {
	hideElem(stdHint);
	stdHint="";
}

// Added

function CheckCount(value) {
	var re = new RegExp("^\\d+$");
	return (value.match(re) && parseInt(value) > 0);
}

function VCartAction(form_name) {
	var form = document[form_name];
	form.submit();
}

function SelectVProduct(form_name, vCartID) {
//	try	{
	var form = document[form_name];
	var added_params = form["added_params"];
	var price;
	var price = (added_params.selectedIndex >= 0) ? added_params[added_params.selectedIndex].value : added_params.value;

	if (!CheckCount(form["_count"].value)) {
		alert("Please select correct count.");
		form["_count"].focus();
	} else {
		var item = "" + vCartID +"^" + price + "^" + form["_count"].value;
		form["item"].value = item;
		form.submit();
	}
/*	} catch (err) {
		alert(err.description);
	}*/
}

function ShowLarge(id) {
	window.open('/home/product/' + id + '.html', null, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=499,height=530');
}

function setLocation(NH) {
	var _href;
	if (ie) {
		_href='results03d2.html?q='+(NH.substring(NH.indexOf('?')+3,NH.indexOf('&')))+NH.substring(NH.indexOf('&'),NH.length);
		location.href=_href;
	} else {
		_href='results03d2.html?q='+(NH.substring(NH.indexOf('?')+3,NH.indexOf('&')))+NH.substring(NH.indexOf('&'),NH.length);
		location.href=_href;
	}
}

/************************ RESIZE CONTENT IMAGES **************************/
	function getResizeImages(a)
	{
		aImage = document.getElementsByName(a);
		for(var i = 0; i < aImage.length; i++)
		{
			setTimeout(returnedClosure(i),1000);
		}
	}

	function returnedClosure(indx)
	{
		return function()
		{
			setImageSize(aImage[indx]);
		}
	}

	function setImageSize(obj)
	{
		if (!obj)
		{
			setTimeout(function(){setImageSize(obj)},100);
			return;
		}
		if (obj.offsetWidth > imageSize)
			obj.width = imageSize;
	}
/************************ /RESIZE CONTENT IMAGES **************************/
//	Copyright © Coretomic, 2005

var MENU_STYLE_DROP_RIGHT = 1;
var MENU_STYLE_DROP_LEFT = 2;
var MENU_STYLE_DROP_DOWN = 3;

Menu.prototype.addItem = m_addItem;
Menu.prototype.restoreItem = m_restoreItem;
Menu.prototype.mouseOver = m_mouseOver;
Menu.prototype.mouseOut = m_mouseOut;
Menu.prototype.hideNow = m_hideNow;
Menu.prototype.hideAll = m_hideAll;
Menu.prototype.menuLeft = m_menuLeft;
Menu.prototype.menuTop = m_menuTop;
Menu.prototype.hideElements = m_hideElements;
Menu.prototype.showElements = m_showElements;

function Menu(name) {
	this.name = name;
	this.container_id = new Array();
	this.items = new Array();
	this.elements = new Array();
	this.count = -1;
	this.timer = 0;
	this.dom = (document.getElementById) ? (true) : (false);
	this.ie = (document.all) ? (true) : (false);
	this.ie4 = this.ie && !this.dom;
	this.nn4 = (document.layers) ? (true) : (false);
	this.nn6 = (navigator.userAgent.indexOf("Gecko") != -1);
	this.visible = 'block';	//(nn4) ? ('show') : ('visible');
	this.hidden = 'none';	//(nn4) ? ('hide') : ('hidden');
	this.invert_style = false;
	this.invert_style_id = 0;
}

function getElementById(id) {
	var element;
	if (!id) return;
	if (this.dom) element = document.getElementById(id);
	else if (this.ie4) element = document.all[id];
	else if (this.nn4) element = document.layers[id];

	return element;
}

function getElementByIdFromParent(id, parent) {
	var element = null;

	if (parent) {
		for (var i = 0; i < parent.childNodes.length; i++) {
			var child = parent.childNodes.item(i);

			if (child.id) {
				if (child.id == id) {
					element = child;
					break;
				}
			}

			child = getElementByIdFromParent(id, child);

			if (child) {
				if (child.id) {
					if (child.id == id) {
						element = child;
						break;
					}
				}
			}
		}
	}

	return element;
}

function m_addItem(id, containerId, className, iconId, iconSrc, imageId, imageSrc, backgroundId, backgroundSrc) {
	this.items[this.items.length] = new Array(id, containerId, className, iconId, iconSrc, imageId, imageSrc, backgroundId, backgroundSrc);
}

function m_restoreItem(i) {
	var element = getElementById(this.items[i][0]);
	element.className = this.items[i][2];

	if (this.items[i][4] != '') {
		var icon = getElementById(this.items[i][3]);
		if (icon) {
			icon.src = this.items[i][4];
		}
	}
	if (this.items[i][6] != '') {
		var image = getElementById(this.items[i][5]);
		if (image) {
			image.src = this.items[i][6];
		}
	}
	if (this.items[i][8] != '') {
		var background = getElementById(this.items[i][7]);
		if (background) {
			background.style.backgroundImage = 'url(' + this.items[i][8] + ')';
		}
	}
}

function m_mouseOver(id, a, containerId, offset_x, offset_y, style, parent_position) {
	if (!style) {
		// Set default style.
		style = MENU_STYLE_DROP_RIGHT;
	}
	if (this.invert_style) {
		// Invert menu drop style.
		if ((style & MENU_STYLE_DROP_LEFT) == MENU_STYLE_DROP_LEFT) {
			style &= ~MENU_STYLE_DROP_LEFT;
			style |= MENU_STYLE_DROP_RIGHT;
		}
		if ((style & MENU_STYLE_DROP_RIGHT) == MENU_STYLE_DROP_RIGHT) {
			style &= ~MENU_STYLE_DROP_RIGHT;
			style |= MENU_STYLE_DROP_LEFT;
		}
	}

	if (this.timer) {
		clearTimeout(this.timer);
		this.timer = 0;
	}

	// Close containers till current or till container to open.
	while (this.count > -1) {
		if ((this.container_id[this.count] == id) || (this.container_id[this.count] == containerId)) {
			break;
		}
		this.hideNow(this.container_id[this.count]);
		this.count--;
	}

	// Restore class names and images for all items in same container.
	for (var i = 0; i < this.items.length; i++) {
		if (this.items[i][1] == id || this.items[i][1] == containerId) {
			this.restoreItem(i);
		}
	}

	// Show SELECTs.
	this.showElements("SELECT");

	// Open new popup.
	var open = getElementById(id);
	if (!open) return;
	var open_style;
	if (!this.nn4) open_style = open.style;

	if (a) {
		var left = this.menuLeft(id, a);
		var top = this.menuTop(id, a);
		if (containerId == "") {
			left += offset_x;
			top += offset_y;
		}
		else {
			var container = getElementById(containerId);
			if (container) {
				if ((style & MENU_STYLE_DROP_RIGHT) == MENU_STYLE_DROP_RIGHT) {
					left += container.offsetWidth;
				}
				if ((style & MENU_STYLE_DROP_LEFT) == MENU_STYLE_DROP_LEFT) {
					left -= container.offsetWidth;
				}
				if ((style & MENU_STYLE_DROP_DOWN) == MENU_STYLE_DROP_DOWN) {
					top += container.offsetHeight;
				}
			}
		}
		/*******************************************/
		// alert(parent_position);
		if (!parent_position) open_style.left = left + "px";
		open_style.top = top + "px";
	}
	open_style.display = this.visible;

	// Correct menu position.
	if ((left + open.offsetWidth) > (document.documentElement.scrollLeft + document.documentElement.clientWidth)) {
		left = (document.documentElement.scrollLeft + document.documentElement.clientWidth - open.offsetWidth);
		if (!parent_position) open_style.left = left + "px";

		// Invert menu style.
		this.invert_style = true;
		this.invert_style_id = id;
	}
	if ((top + open.offsetHeight) > (document.documentElement.scrollTop + document.documentElement.clientHeight)) {
		top = (document.documentElement.scrollTop + document.documentElement.clientHeight - open.offsetHeight);
		open_style.top = top + "px";
	}

	if (this.container_id[this.count] != id) {
		this.count++;
		this.container_id[this.count] = id;
	}

	// Hide SELECTs.
	this.hideElements("SELECT");
}

function m_mouseOut() {
	this.timer = setTimeout(this.name + '.hideAll()', 1000);
}

function m_hideNow(id) {
	var hide = getElementById(id);
	if (!hide) return;
	if (!this.nn4) hide = hide.style;

	hide.display = this.hidden;

	if (this.invert_style) {
		if (id == this.invert_style_id) {
			this.invert_style = false;
		}
	}
}

function m_hideAll() {
	while (this.count > -1) {
		this.hideNow(this.container_id[this.count]);
		this.count--;
	}
	this.timer = 0;

	// Restore all class names and images.
	for (var i = 0; i < this.items.length; i++) {
		this.restoreItem(i);
	}

	// Show SELECTs.
	this.showElements("SELECT");
}

function m_menuLeft(id, a) {
	if (this.nn4) return document.layers['x' + id].pageX;
	else {
		var pos = a.offsetLeft;
		while (a.offsetParent != null) {
			a = a.offsetParent;
			pos += a.offsetLeft;
			if (a.tagName == 'BODY') break;
		}
		return pos;
	}
}

function m_menuTop(id,a) {
	if (this.nn4) return document.layers['x' + id].pageY;
	else {
		var pos = a.offsetTop;
		while (a.offsetParent != null) {
			a = a.offsetParent;
			pos += a.offsetTop;
			if (a.tagName == 'BODY') break;
		}
		return pos;
	}
}

function m_hideElements(tagName) {
	if (this.nn6) return;
	// For all opened DIVs.
	for (var j = 0; j <= this.count; j++) {
		var elDiv = getElementById(this.container_id[j]);

		var divLeft = elDiv.offsetLeft;
		var divRight = divLeft + elDiv.offsetWidth;
		var divTop = elDiv.offsetTop;
		var divBottom = divTop + elDiv.offsetHeight;

		// For all specified elements.
		var els = document.all.tags(tagName);
		for (var i = 0; i < els.length; i++) {
			var el = els.item(i);
			var elParent = el;

			var left = 0;
			var top = 0;
			var width = elParent.offsetWidth;
			var height = elParent.offsetHeight;
			while (elParent) {
				left += elParent.offsetLeft
				top += elParent.offsetTop
				elParent = elParent.offsetParent
			}

			if ((left < divRight) && (left + width > divLeft) && (top < divBottom) && (top + height > divTop)) {
				// Hide element.
				el.style.visibility = (nn4) ? ('hide') : ('hidden');

				// Find and store hidden element.
				var found = false;
				var free_index = this.elements.length;
				for (var k = 0; k < this.elements.length; k++) {
					if (this.elements[k] == 0) {
						free_index = k;
					}
					if (this.elements[k] == el) {
						found = true;
						break;
					}
				}
				if (!found) {
					this.elements[free_index] = el;
				}
			}
		}
	}
}

function m_showElements(tagName) {
	if (this.nn6) return;
	// For all hidden elements.
	for (var i = 0; i < this.elements.length; i++) {
		var el = this.elements[i];
		if (el) {
			var elParent = el;

			var left = 0;
			var top = 0;
			var width = elParent.offsetWidth;
			var height = elParent.offsetHeight;
			while (elParent) {
				left += elParent.offsetLeft
				top += elParent.offsetTop
				elParent = elParent.offsetParent
			}

			var show = true;
			// For all opened DIVs.
			for (var j = 0; j <= this.count; j++) {
				var elDiv = getElementById(this.container_id[j]);

				var divLeft = elDiv.offsetLeft;
				var divRight = divLeft + elDiv.offsetWidth;
				var divTop = elDiv.offsetTop;
				var divBottom = divTop + elDiv.offsetHeight;

				if ((left < divRight) && (left + width > divLeft) && (top < divBottom) && (top + height > divTop)) {
					show = false;
				}
			}
			if (show) {
				// Show element.
				el.style.visibility = (nn4) ? ('show') : ('visible');

				// Find and remove hidden element.
				for (var k = 0; k < this.elements.length; k++) {
					if (this.elements[k] == el) {
						this.elements[k] = 0;
						break;
					}
				}
			}
		}
	}
}
//	Copyright © Coretomic, 2005

function Is () {
	// convert all characters to lowercase to simplify testing
	var agt=navigator.userAgent.toLowerCase()

	// --- BROWSER VERSION ---
	this.major = stringToNumber(navigator.appVersion)
	this.minor = parseFloat(navigator.appVersion)

	this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
				&& (agt.indexOf('compatible') == -1)))
	this.nav2 = (this.nav && (this.major == 2))
	this.nav3 = (this.nav && (this.major == 3))
	this.nav4 = (this.nav && (this.major == 4))

	//Netscape 6
	this.nav5 =	(this.nav && (this.major == 5))
	this.nav6 = (this.nav && (this.major == 5))
	this.gecko = (this.nav && (this.major >= 5))

	this.ie  = (agt.indexOf("msie") != -1)
	this.ie3 = (this.ie && (this.major == 2))
	this.ie4 = (this.ie && (this.major == 3))
	this.ie5 = (this.ie && (this.major == 4))

	this.opera = (agt.indexOf("opera") != -1)

	this.nav4up = this.nav && (this.major >= 4)
	this.ie4up  = this.ie  && (this.major >= 4)
}

var is = new Is();

function dw(str, minVersion, maxVersion) {
	if (((dw.arguments.length < 3) || (is.major <= maxVersion))
		&& ((dw.arguments.length < 2) || (is.major >= minVersion)))
	document.write(str)
}

function dwb (str, aBoolean) {
	if ((dwb.arguments.length < 2) || aBoolean)
	document.write(str)
}

function sv(str, minVersion, maxVersion) {
	if (((sv.arguments.length < 3) || (is.major <= maxVersion))
		&& ((sv.arguments.length < 2) || (is.major >= minVersion)))
	return str;
	else return "";
}

function sb (str, aBoolean) {
	if ((sb.arguments.length < 2) || aBoolean)
	return str;
	else return "";
}

function layerClipOrder (cssClipString) {
	var commaPos = cssClipString.lastIndexOf(",");
	return (cssClipString.substring(commaPos+1) + "," + cssClipString.substring(0,commaPos));
}

function genElt (name, content, left, top, z, width, height, visibility,
				 backgroundColor, backgroundImage, clip, relative,
				 hideEltOnOlderBrowsers, useDivInsteadOfLayer, classname) {
	var markup = "";
	if (is.gecko) {
		markup = '<DIV ID="' + name + '"' +
				((classname)?' CLASS="' + classname + '"':'') +
				' STYLE="position:' + ((relative)?'relative;':'absolute;') +
				' overflow:none;' +
				((left)?' left:' + left + 'px;':'') +
				((top)?' top:' + top + 'px;':'') +
				((height)?' height:' + height + 'px;':'') +
				((width)?' width:' + width + 'px;':'') +
				((visibility && (visibility!='')) ? ' visibility:' + visibility + ';' : '') +
				((z)?' z-index:' + z + ';':'') +
				((backgroundColor)?' background-color:' + backgroundColor + ';':'') +
				((backgroundImage)?' background-image:url("' + backgroundImage + '");':'') +
				((clip)?' clip:rect("' + clip + '");':'') +
				'">' + ((content)?content:'') + '</DIV>';
	}

	else if (is.nav && (is.major == 4 || !hideEltOnOlderBrowsers) &&
			!useDivInsteadOfLayer) {
		var tagname = (relative)?'ILAYER':'LAYER';
		if (visibility && (visibility!='')) {
			if (visibility=="hidden") visibility = "hide";
			else if (visibility=="visible") visibility = "show";
		}
		markup = '<' + tagname + ' ID="' + name + '"' + ((classname)?' CLASS="' +
				classname + '"':'') + ((left)?' LEFT="' + left + '"':'') +
				((top)?' TOP="' + top + '"':'') + ((width)?' WIDTH="' + width + '"':'') +
				((height)?' HEIGHT="' + height + '"':'') +
				((visibility && (visibility!='')) ? ' VISIBILITY="' + visibility + '"' : '') +
				((z)?' Z-INDEX="' + z + '"':'') +
				((backgroundColor)?' BGCOLOR="' + backgroundColor + '"':'') +
				((backgroundImage)?' BACKGROUND="' + backgroundImage + '"':'') +
				((clip)?' CLIP="' + layerClipOrder(clip) + '"':'') +
				'>' + ((content)?content:'') + '</' + tagname + '>';
	}

	else if ((is.ie || (is.nav && useDivInsteadOfLayer)) && (is.major>=4 || !hideEltOnOlderBrowsers)) {
		markup = '<DIV ID="' + name + '"' +
				((classname)?' CLASS="' + classname + '"':'') +
				' STYLE="position:' + ((relative)?'relative;':'absolute;') +
				' overflow:none;' +
				((left)?' left:' + left + 'px;':'') +
				((top)?' top:' + top + 'px;':'') +
				((height)?' height:' + height + 'px;':'') +
				((width)?' width:' + width + 'px;':'') +
				((visibility && (visibility!='')) ? ' visibility:' + visibility + ';' : '') +
				((z)?' z-index:' + z + ';':'') +
				((backgroundColor)?' background-color:' + backgroundColor + ';':'') +
				((backgroundImage)?' background-image:url("' + backgroundImage + '");':'') +
				((clip)?' clip:rect("' + clip + '");':'') +
				'">' + ((content)?content:'') + '</DIV>';
	}

	return markup;
}

function writeElt (name, content, left, top, z, width, height, visibility,
				   backgroundColor, backgroundImage, clip, relative,
				   hideEltOnOlderBrowsers, useDivInsteadOfLayer, classname) {
	if (writeElt.arguments.length < 15) classname = false;
	if (writeElt.arguments.length < 14) useDivInsteadOfLayer = false;
	if (writeElt.arguments.length < 13) hideEltOnOlderBrowsers = false;
	if (writeElt.arguments.length < 12) relative = false;
	if (writeElt.arguments.length < 11) clip = false;
	if (writeElt.arguments.length < 10) backgroundImage = false;
	if (writeElt.arguments.length < 9) backgroundColor = false;
	if (writeElt.arguments.length < 8) visibility = false;
	if (writeElt.arguments.length < 7) height = false;
	if (writeElt.arguments.length < 6) width = false;
	if (writeElt.arguments.length < 5) z = false;
	if (writeElt.arguments.length < 4) top = false;
	if (writeElt.arguments.length < 3) left = false;
	if (writeElt.arguments.length < 2) content = false;
	document.write (genElt (name, content, left, top, z, width, height, visibility,
							backgroundColor, backgroundImage, clip, relative,
							hideEltOnOlderBrowsers, useDivInsteadOfLayer, classname));
}

function getElt () {
	if (is.nav4) {
		var currentLayer = document.layers[getElt.arguments[0]], cl;
		for (var i=1; i<getElt.arguments.length && currentLayer; i++) {
currentLayer = currentLayer.document.layers[getElt.arguments[i]];
		}
		return currentLayer;
	}
	else if (document.getElementById && document.getElementsByName) {
		var name = getElt.arguments[getElt.arguments.length-1];
		if (document.getElementById(name))	//First try to find by id
			return document.getElementById(name);
		else if (document.getElementsByName(name))	//Then if that fails by name
			return document.getElementsByName(name)[0];
	}
	else if (is.ie4up) {
		//var elt = eval('document.all.' + getElt.arguments[getElt.arguments.length-1]);
		var elt = document.all[getElt.arguments[getElt.arguments.length-1]];
		return (elt);
	}
}

function showElt(elt) {
	setEltVisibility(elt,'visible');
}

function hideElt(elt) {
	setEltVisibility(elt, 'hidden');
}

function setEltVisibility (elt, value) {
	if (is.nav4) elt.visibility = value;
	else if (elt.style) elt.style.visibility = value;
}

function getEltVisibility (elt) {
	if (is.nav4) {
		var value = elt.visibility;
		if (value == "show") return "visible";
		else if (value == "hide") return "hidden";
		else return value;
	}
	else if (elt.style) return elt.style.visibility;
}

function moveEltTo (elt, x, y) {
	if (is.nav4) {
		elt.moveTo(x, y);
	} else if (is.ie4up || is.opera) {
		elt.style.pixelLeft = x;
		elt.style.pixelTop  = y;
	} else if (is.gecko) {
		elt.style.left = x + "px";
		elt.style.top  = y + "px";
	}
}

function moveEltBy (elt, x, y) {
	if (is.nav4) elt.moveBy(x, y);
	else if (is.ie4up) {
		elt.style.pixelLeft += x;
		elt.style.pixelTop  += y;
	}
	else if (is.gecko) {
		elt.style.left = (stringToNumber(elt.style.left) + x + "px");
		elt.style.top  = (stringToNumber(elt.style.top)  + y + "px");
	}
}

function getEltPageLeft(elt) {
	var x;

	if (is.nav4)
		return elt.pageX;
	if (is.ie4up || is.opera) {
		x = 0;
		while (elt.offsetParent != null) {
			x += elt.offsetLeft;
			elt = elt.offsetParent;
		}
		x += elt.offsetLeft;
		return x;
	}
	if (is.gecko) {
		x = 0;
		while (elt.offsetParent != null) {
			x += elt.offsetLeft;
			elt = elt.offsetParent;
		}
		x += elt.offsetLeft;
		return x;
	}
	return -1;
}

/* xbrowser pageY equivalent */
function getEltPageTop(elt) {
	var y;

	if (is.nav4)
		return elt.pageY;
	if (is.ie4up || is.opera) {
		y = 0;
		while (elt.offsetParent != null) {
			y += elt.offsetTop;
			elt = elt.offsetParent;
		}
		y += elt.offsetTop;
		return y;
	}
	if (is.gecko) {
		y = 0;
		while (elt.offsetParent != null) {
			y += elt.offsetTop;
			elt = elt.offsetParent;
		}
		y += elt.offsetTop;
		return y;
	}
	return -1;
}

/* Sets position of left edge of elt in pixels. */
function setEltLeft (elt, x) {
	if (is.nav4) elt.left=x;
	else if (is.ie4up) elt.style.pixelLeft=x;
	else if (is.gecko) elt.style.left = (x + "px");
}

/* Returns left edge of elt in pixels. */
function getEltLeft (elt) {
	if (is.nav4) return (elt.left);
	else if (is.ie4up) return (elt.style.pixelLeft);
	else if (is.gecko) return stringToNumber(elt.style.left);
}

/* Sets top edge of elt in pixels. */
function setEltTop (elt, y) {
	if (is.nav4) elt.top=y;
	else if (is.ie4up) elt.style.pixelTop=y;
	else if (is.gecko) elt.style.top= (y + "px");
}

/* Returns top edge of elt in pixels. */
function getEltTop (elt) {
	if (is.nav4) return (elt.top);
	else if (is.ie4up) return (elt.style.pixelTop);
	else if (is.gecko) return stringToNumber(elt.style.top);
}

/* Returns width of elt in pixels. */
function getEltWidth(elt) {
	if (is.nav4) {
		if (elt.document.width)
			return elt.document.width;
		else
			return elt.clip.right - elt.clip.left;
	}
	if (is.ie4up || is.opera) {
		if (elt.style.pixelWidth)
			return elt.style.pixelWidth;

		else
			return elt.offsetWidth;
	}
	if (is.gecko) {
		if (elt.style.width)
			return stringToNumber(elt.style.width);
		else
			return stringToNumber(elt.offsetWidth);
	}
	return -1;
}

/* set width of elt in pixels */
function setEltWidth(elt,wdth) {
	if (is.nav4) {
		elt.document.width = wdth;
	}
	else if (elt.style) {
		elt.style.width = wdth;
	}
}

/* Returns height of elt in pixels. */
function getEltHeight(elt) {
	if (is.nav4) {
		if (elt.document.height)
			return elt.document.height;
		else
			return elt.clip.bottom - elt.clip.top;
	}
	if (is.ie4up || is.opera) {
		if (elt.style.pixelHeight)
			return elt.style.pixelHeight;
		else
			return elt.clientHeight;
	}
	if (is.gecko) {
		if (elt.style.height)
			return stringToNumber(elt.style.height);
		else
			return stringToNumber(elt.offsetHeight);
	}
	return -1;
}

/* set width of elt in pixels */
function setEltHeight(elt,hght) {
	if (is.nav4) {
		elt.document.height = hght;
	}
	else if (elt.style) {
		elt.style.height = hght;
	}
}

function setEltClip (elt, cliptop, clipright, clipbottom, clipleft) {
	if (is.nav4) {
		elt.clip.left   = clipleft;
		elt.clip.top    = cliptop;
		elt.clip.right  = clipright;
		elt.clip.bottom = clipbottom;
	}
	else if (is.ie4up) elt.style.clip = 'rect(' + cliptop + ' ' +
		clipright + ' ' + clipbottom + ' ' + clipleft +')';
	else if (is.gecko) elt.style.clip = 'rect(' + cliptop + ' ' +
		clipright + ' ' + clipbottom + ' ' + clipleft +')';
}

function tempClipObj (elt) {
	var clipStr = elt.style.clip;

	clipStr = clipStr.substring (clipStr.indexOf("(") + 1);
	this.top = stringToNumber(clipStr);
	clipStr = clipStr.substring (clipStr.indexOf(" ") + 1);
	this.right = stringToNumber(clipStr);
	clipStr = clipStr.substring (clipStr.indexOf(" ") + 1);
	this.bottom = stringToNumber(clipStr);
	clipStr = clipStr.substring (clipStr.indexOf(" ") + 1);
	this.left = stringToNumber(clipStr);
}

/* Returns left edge of clipping area of elt in pixels. */
function getEltClipLeft (elt) {
	if (is.nav4) return (elt.clip.left);
	else if (elt.style) {
	var tempClip = new tempClipObj (elt);
		return tempClip.left;
	}
}

/* Returns top edge of clipping area of elt in pixels. */
function getEltClipTop (elt) {
	if (is.nav4) return (elt.clip.top);
	else if (elt.style) {
	var tempClip = new tempClipObj (elt);
		return tempClip.top;
	}
}

/* Returns right edge of clipping area of elt in pixels. */
function getEltClipRight (elt) {
	if (is.nav4) return (elt.clip.right);
	else if (elt.style) {
	var tempClip = new tempClipObj (elt);
		return tempClip.right;
	}
}

/* Returns bottom edge of clipping area of elt in pixels. */
function getEltClipBottom (elt) {
	if (is.nav4) return (elt.clip.bottom);
	else if (elt.style) {
		var tempClip = new tempClipObj (elt);
		return tempClip.bottom;
	}
}

/* Returns width of clipping area of elt in pixels. */
function getEltClipWidth (elt) {
	return (getEltClipRight(elt) - getEltClipLeft(elt));
}

/* Returns height of clipping area of elt in pixels. */
function getEltClipHeight (elt) {
	return (getEltClipBottom(elt) - getEltClipTop(elt));
}

/* Returns width of current window content area in pixels. */
function getCurrentWinWidth() {
	if (is.nav4) return (window.innerWidth);
	else if (is.ie4up) return (document.body.clientWidth);
	else if (is.gecko || is.opera) return (window.innerWidth);
}

/* Returns height of current window content area in pixels. */
function getCurrentWinHeight() {
	if (is.nav4) return (window.innerHeight);
	else if (is.ie4up) return (document.body.clientHeight);
	else if (is.gecko) return (window.innerHeight);
}

function getEltZIndex (elt) {
	if (is.nav4) return (elt.zIndex);
	else if (elt.style) return (elt.style.zIndex);
}

function setEltZIndex (elt, z) {
	if (is.nav4) elt.zIndex = z;
	else if (elt.style) elt.style.zIndex = z;
}

function setEltBackgroundImage (elt, imageFilePath) {
	if (is.nav4) elt.background.src = imageFilePath;
	else if (is.ie4up) elt.style.backgroundImage = "url(" + imageFilePath + ")";
	else if (is.gecko) elt.style.backgroundImage = "url(" + imageFilePath + ")";
}

function getEltBackgroundImage (elt) {
	if (is.nav4) return (elt.background.src);
	else if (elt.style) {
		var theURL = elt.style.backgroundImage;
		if (typeof(theURL) == "string") {
			var URLlen = theURL.length;
			return (theURL.substring (4, URLlen-1));
		}
		else return (theURL);
	}
}

function setEltBackgroundColor (elt, colorNumber) {
	if (is.nav4) elt.bgColor = colorNumber;
	else if (elt.style) elt.style.backgroundColor = colorNumber;
}

function setEltColor (elt, colorNumber) {
	if (is.nav4) elt.color = colorNumber;
	else if (elt.style) elt.style.color = colorNumber;
}

var colorNameString = "aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white";
var colorNames = new Array ("aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "purple", "red", "silver", "teal", "yellow", "white");
var colorNumbers = new Array (0xffff, 0, 0xff, 0xff00ff, 0x808080, 0x8000, 0xff00, 0x800000, 0x80, 0x808000, 0x800080, 0xff0000, 0xc0c0c0, 0x8080, 0xffff00, 0xffffff);

function isColorName (aString) {
	return ((typeof(aString) == "string") && (colorNameString.indexOf(aString) != -1));
}

function colorNameToNumber (colorName) {
	for (var i=0; i<16; i++) if (colorNames[i]==colorName) return colorNumbers[i];
	// Return string name unchanged if not found.
	// This handles IE4 non-CSS1-standard color names gracefully.
	return colorName;
}

function colorNumberToName (colorNumber) {
	for (var i=0; i<16; i++) if (colorNumbers[i]==colorNumber) return colorNames[i];
	return null;
}

function getEltBackgroundColor (elt) {
	if (is.nav4) return (elt.bgColor);
	else if (is.ie4up) {
		var colorVal = elt.style.backgroundColor;
		if (isColorName(colorVal)) return colorNameToNumber (colorVal);
		else if (typeof(colorVal) == "string")
			return (("0x" + colorVal.substring(1)) - 0);
		else return colorVal;
	}
	else if (is.gecko) {
		var colorVal = elt.style.backgroundColor;

		if (typeof(colorVal) == "string") {
			if (isColorName(colorVal)) {
				return colorNameToNumber (colorVal);
			}
			else if (colorVal.indexOf(["rgb"]) != -1) {
				var sR,sG,sB;
				var iR,iG,iB;
				var i=0;

				ColorString = (elt.style.backgroundColor);
				//ColorString = "rgb(255,20,255)";
				ColorString = ColorString.slice(4,-1);

				while (ColorString[i] != ',' && i < 20) {i++;}
				sR = ColorString.slice(0,-(ColorString.length - i));
				i++;
				j = i;
				while (ColorString[j] != ',' && j < 20) {j++;}
				sG = ColorString.slice(i,0-(ColorString.length - j));
				j++;
				sB = ColorString.slice(j);
				iR = stringToNumber(sR);
				iG = stringToNumber(sG);
				iB = stringToNumber(sB);
				sR = iR.toString(16);if (sR.length < 2)sR = "0" + sR;if (sR.length < 2)sR = "0" + sR;
				sG = iG.toString(16);if (sG.length < 2)sG = "0" + sG;if (sG.length < 2)sG = "0" + sG;
				sB = iB.toString(16);if (sB.length < 2)sB = "0" + sB;if (sB.length < 2)sB = "0" + sB;

				sRGB = sR.toUpperCase()+sG.toUpperCase()+sB.toUpperCase();
				return (("0x" + sRGB)-0);
			}
		}
		else return colorVal;
	}
}

/* A version of stringToNumber that returns 0 if there is NaN returned, or number is part of a string, like 100px... */
function stringToNumber(s) {
	return parseInt(('0' + s), 10)
}
//	Copyright © Coretomic, 2005

var curScreenDim;
var idTimeOut;

function updateTemplates() {
	if (templates) {
		for (var i = 0; i < templates.length; i++) {
			checkAppearance(templates[i]);
		}
	}
	if (is.opera) {
		idTimeOut = setTimeout("isScreenDimChange()", 1000);
	}
}

function checkAppearance(baseName) {
	var i = 0;
	var j = 0;
	var blockId = baseName + "-" + i + "-" + j;
	var elt = getElt(blockId);
	while (elt) {
		var rowWidth = 0;
		while (elt) {
			if ((elt.className != 'canDisappear' || !isEmpty(blockId)) && elt.width.indexOf('%') != -1) {
				rowWidth += 1 * elt.width.replace('%', '');
			}
			j++;
			blockId = baseName + "-" + i + "-" + j;
			elt = getElt(blockId);
		}
		j = 0;
		blockId = baseName + "-" + i + "-" + j;
		elt = getElt(blockId);
		while (elt) {
			if (elt.className == 'canDisappear' && isEmpty(blockId)) {
				elt.style.display = 'none';
			}
			else {
				if (elt.width.indexOf('%') != -1) {
					var width = 1 * elt.width.replace('%', '') / rowWidth * 100;
					elt.width = width + '%';
				}
				checkAppearance(blockId);
			}

			j++;
			blockId = baseName + "-" + i + "-" + j;
			elt = getElt(blockId);
		}
		i++;
		j = 0;
		blockId = baseName + "-" + i + "-" + j;
		elt = getElt(blockId);
	}
}

function isEmpty(baseName) {
	var i = 0;
	var j = 0;
	var blockId = baseName + "-" + i + "-" + j;
	var elt = getElt(blockId);
	var baseElt = getElt(baseName);
	if (!elt) {
		var childElement = baseElt.firstChild;
		if (baseElt.innerHTML.length == 0 || (childElement && childElement.tagName == 'DIV' && childElement.className == 'canDisappear' && childElement.innerHTML.length == 0)) {
			return true;
		}
		else {
			return false;
		}
	}
	else {
		var empty = true;
		while (elt) {
			while (elt) {
				empty &= isEmpty(blockId);
				j++;
				blockId = baseName + "-" + i + "-" + j;
				elt = getElt(blockId);
			}
			i++;
			j = 0;
			blockId = baseName + "-" + i + "-" + j;
			elt = getElt(blockId);
		}
		return empty;
	}
}

function isScreenDimChange() {
	tempScreenDim = getCurrentWinWidth();
	clearTimeout(idTimeOut);
	if (curScreenDim != tempScreenDim) {
		curScreenDim = tempScreenDim;
		idTimeOut = setTimeout("updateTemplates()", 1000);
	}
	else {
		idTimeOut = setTimeout("isScreenDimChange()", 1000);
	}
}/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	if (window.opera || !document.all) return;
	var objects = document.getElementsByTagName("OBJECT");
	for (var i=0; i < objects.length; i++) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in fp9 see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
deconcept.SWFObjectUtil.prepUnload = function() {
	__flash_unloadHandler = function(){};
	__flash_savedUnloadHandler = function(){};
	if (typeof window.onunload == 'function') {
		var oldUnload = window.onunload;
		window.onunload = function() {
			deconcept.SWFObjectUtil.cleanupSWFs();
			oldUnload();
		}
	} else {
		window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
	}
}
if (typeof window.onbeforeunload == 'function') {
	var oldBeforeUnload = window.onbeforeunload;
	window.onbeforeunload = function() {
		deconcept.SWFObjectUtil.prepUnload();
		oldBeforeUnload();
	}
} else {
	window.onbeforeunload = deconcept.SWFObjectUtil.prepUnload;
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;