//tinycarusel*********************************************************
(function($){$.fn.tinycarousel=function(options){var defaults={start:1,display:1,axis:'x',controls:true,pager:false,interval:false,intervaltime:3000,rewind:false,animation:true,duration:1000,callback:null};var options=$.extend(defaults,options);var oSlider=$(this);var oViewport=$('.viewport:first',oSlider);var oContent=$('.overview:first',oSlider);var oPages=oContent.children();var oBtnNext=$('.next:first',oSlider);var oBtnPrev=$('.prev:first',oSlider);var oPager=$('.pager:first',oSlider);var iPageSize,iSteps,iCurrent,oTimer,bPause,bForward=true,bAxis=options.axis=='x';return this.each(function(){initialize();});function initialize(){iPageSize=bAxis?$(oPages[0]).outerWidth(true):$(oPages[0]).outerHeight(true);var iLeftover=Math.ceil(((bAxis?oViewport.outerWidth():oViewport.outerHeight())/(iPageSize*options.display))-1);iSteps=Math.max(1,Math.ceil(oPages.length/options.display)-iLeftover);iCurrent=Math.min(iSteps,Math.max(1,options.start))-2;oContent.css(bAxis?'width':'height',(iPageSize*oPages.length));move(1);setEvents();}
function setEvents(){if(options.controls&&oBtnPrev.length>0&&oBtnNext.length>0){oBtnPrev.click(function(){move(-1);return false;});oBtnNext.click(function(){move(1);return false;});}if(options.interval){oSlider.hover(function(){clearTimeout(oTimer);bPause=true},function(){bPause=false;setTimer();});}if(options.pager&&oPager.length>0){$('a',oPager).click(setPager);}}
function setButtons(){if(options.controls){oBtnPrev.toggleClass('disable',!(iCurrent>0));oBtnNext.toggleClass('disable',!(iCurrent+1<iSteps));}if(options.pager){var oNumbers=$('.pagenum',oPager);oNumbers.removeClass('active');$(oNumbers[iCurrent]).addClass('active');}}
function setPager(oEvent){if($(this).hasClass('pagenum')){iCurrent=parseInt(this.rel)-1;move(1);}return false;}
function setTimer(){if(options.interval&&!bPause){clearTimeout(oTimer);oTimer=setTimeout(function(){iCurrent=!options.rewind&&(iCurrent+1==iSteps)?-1:iCurrent;bForward=iCurrent+1==iSteps?false:iCurrent==0?true:bForward;move((options.rewind?(bForward?1:-1):1));},options.intervaltime);}}
function move(iDirection){if(iCurrent+iDirection>-1&&iCurrent+iDirection<iSteps){iCurrent+=iDirection;var oPosition={};oPosition[bAxis?'left':'top']=-(iCurrent*(iPageSize*options.display));oContent.animate(oPosition,{queue:false,duration:options.animation?options.duration:0,complete:function(){if(typeof options.callback=='function')options.callback.call(this,oPages[iCurrent],iCurrent);}});setButtons();setTimer();}}};})(jQuery);
//scrollarea*****************************************************
var VSA_scrollAreas = new Array();

var VSA_default_imagesPath = "images";
var VSA_default_btnUpImage = "button-up.gif";
var VSA_default_btnDownImage = "button-down.gif";
var VSA_default_scrollStep = 10;
var VSA_default_wheelSensitivity = 10;
var VSA_default_scrollbarPosition = 'right';//'left','right','inline';
var VSA_default_scrollButtonHeight = 0;
var VSA_default_scrollbarWidth = 20;

var VSA_resizeTimer = 2000;

if (window.addEventListener)
	window.addEventListener("load", VSA_initScrollbars, false);
else if (window.attachEvent)
	window.attachEvent("onload", VSA_initScrollbars);

function VSA_initScrollbars()
{
	var scrollElements = VSA_getElements("scrollable", "DIV", document, "class");
	for (var i=0; i<scrollElements.length; i++)
	{
		VSA_scrollAreas[i] = new ScrollArea(i, scrollElements[i]);
	}
}

function ScrollArea(index, elem) //constructor
{
	this.index = index;
	this.element = elem;

	var attr = this.element.getAttribute("imagesPath");
	this.imagesPath = attr ? attr : VSA_default_imagesPath;

	attr = this.element.getAttribute("btnUpImage");
	this.btnUpImage = attr ? attr : VSA_default_btnUpImage;

	attr = this.element.getAttribute("btnDownImage");
	this.btnDownImage = attr ? attr : VSA_default_btnDownImage;

	attr = Number(this.element.getAttribute("scrollStep"));
	this.scrollStep = attr ? attr : VSA_default_scrollStep;

	attr = Number(this.element.getAttribute("wheelSensitivity"));
	this.wheelSensitivity = attr ? attr : VSA_default_wheelSensitivity;

	attr = this.element.getAttribute("scrollbarPosition");
	this.scrollbarPosition = attr ? attr : VSA_default_scrollbarPosition;
	
	attr = this.element.getAttribute("scrollButtonHeight");
	this.scrollButtonHeight = attr ? attr : VSA_default_scrollButtonHeight;

	attr = this.element.getAttribute("scrollbarWidth");
	this.scrollbarWidth = attr ? attr : VSA_default_scrollbarWidth;

	this.scrolling = false;

	this.iOffsetY = 0;
	this.scrollHeight = 0;
	this.scrollContent = null;
	this.scrollbar = null;
	this.scrollup = null;
	this.scrolldown = null;
	this.scrollslider = null;
	this.scroll = null;
	this.enableScrollbar = false;
	this.scrollFactor = 1;
	this.scrollingLimit = 0;
	this.topPosition = 0;

	//functions declaration
	this.init = VSA_init;
	this.scrollUp = VSA_scrollUp;
	this.scrollDown = VSA_scrollDown;
	this.createScrollBar = VSA_createScrollBar;
	this.scrollIt = VSA_scrollIt;

	this.init();
}


function VSA_init() {
	this.scrollContent = document.createElement("DIV");
	this.scrollContent.style.position = "absolute";
	this.scrollContent.style.overflow = "hidden";
	this.scrollContent.style.width = this.element.offsetWidth + "px";
	this.scrollContent.style.height = this.element.offsetHeight + "px";

	while(this.element.children.length) this.scrollContent.appendChild(this.element.children[0]);

	this.element.style.overflow = "hidden";
	this.element.style.display = "block";
	this.element.style.visibility = "visible";
	this.element.style.position = "relative";
	this.element.appendChild(this.scrollContent);

	this.scrollContent.className = 'scroll-content';

	this.element.index = this.index;
	this.element.over = false;
	
	var _this = this;
	this.element.onmouseover = function(){
		_this.element.over = true;
	};
	this.element.onmouseout = function(){
		_this.element.over = false;
	}

	if (document.all)
	{
		this.element.onscroll = VSA_handleOnScroll;
		this.element.onresize = VSA_handleResize;
	}
	else
	{
		window.onresize = VSA_handleResize;
	}
	
	this.createScrollBar();
	
	if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
        this.element.addEventListener('DOMMouseScroll', VSA_handleMouseWheel, false);
	/** IE/Opera. */
	this.element.onmousewheel = document.onmousewheel = VSA_handleMouseWheel;

}

function VSA_createScrollBar()
{

	if (this.scrollbar != null)
	{
		this.element.removeChild(this.scrollbar);
		this.scrollbar = null;
	}

	if (this.scrollContent.scrollHeight <= this.scrollContent.offsetHeight)
		this.enableScrollbar = false;
	else if (this.element.offsetHeight > 2*this.scrollButtonHeight)
		this.enableScrollbar = true;
	else
		this.enableScrollbar = false;

	if (this.scrollContent.scrollHeight - Math.abs(this.scrollContent.scrollTop) < this.element.offsetHeight)
		this.scrollContent.style.top = 0;

	if (this.enableScrollbar)
	{

		this.scrollbar = document.createElement("DIV");
		this.element.appendChild(this.scrollbar);		
		this.scrollbar.style.position = "absolute";
		this.scrollbar.style.top = "0px";
		this.scrollbar.style.height = this.element.offsetHeight+"px";
		this.scrollbar.style.width = this.scrollbarWidth + "px";

		this.scrollbar.className = 'vscroll-bar';

		if(this.scrollbarWidth != this.scrollbar.offsetWidth)
		{
			this.scrollbarWidth = this.scrollbar.offsetHeight;
		}
		
		this.scrollbarWidth = this.scrollbar.offsetWidth;

		if(this.scrollbarPosition == 'left')
		{
			this.scrollContent.style.left = this.scrollbarWidth + 5 + "px";			
			this.scrollContent.style.width = this.element.offsetWidth - this.scrollbarWidth - 5 + "px";			
		}
		else if(this.scrollbarPosition == 'right')
		{
			this.scrollbar.style.left = this.element.offsetWidth - this.scrollbarWidth  + "px";
			this.scrollContent.style.width = this.element.offsetWidth - this.scrollbarWidth - 5 + "px";			
		}


		//create scroll
		this.scroll = document.createElement("DIV");
		this.scroll.index = this.index;
		this.scroll.style.position = "absolute";
		this.scroll.style.zIndex = 0;
		this.scroll.style.textAlign = "center";
		this.scroll.style.top = this.scrollButtonHeight + "px";
		this.scroll.style.left = "0px";		
		this.scroll.style.width = this.scrollbarWidth + "px";
		
		var h = this.scrollbar.offsetHeight - 2*this.scrollButtonHeight;
		this.scroll.style.height = ((h > 0) ? h : 0) + "px";
		
		this.scroll.innerHTML = '';
		this.scroll.onclick = VSA_handleScrollbarClick;
		this.scrollbar.appendChild(this.scroll);
		this.scroll.style.overflow = "hidden";

		this.scroll.className = "vscroll-line";

		//create slider
		this.scrollslider = document.createElement("DIV");
		this.scrollslider.index = this.index;
		this.scrollslider.style.position = "absolute";
		this.scrollslider.style.zIndex = 1000;
		this.scrollslider.style.textAlign = "center";
		this.scrollslider.innerHTML = '<div id="scrollslider' + this.index + '" style="padding:0;margin:0;"><div class="scroll-bar-top"></div><div class="scroll-bar-bottom"></div></div>';
		this.scrollbar.appendChild(this.scrollslider);
		
		this.subscrollslider = document.getElementById("scrollslider"+this.index);		
		this.subscrollslider.style.height = Math.round((this.scrollContent.offsetHeight/this.scrollContent.scrollHeight)*(this.scrollbar.offsetHeight - 2*this.scrollButtonHeight)) + "px";
		
		this.scrollslider.className = "vscroll-slider";
		
		this.scrollHeight = this.scrollbar.offsetHeight - 2*this.scrollButtonHeight - this.scrollslider.offsetHeight;
		this.scrollFactor = (this.scrollContent.scrollHeight - this.scrollContent.offsetHeight)/this.scrollHeight;
		this.topPosition = getRealTop(this.scrollbar) + this.scrollButtonHeight;
		/* this.scrollbarHeight = this.scrollbar.offsetHeight - 2*this.scrollButtonHeight - this.scrollslider.offsetHeight; */

		this.scrollslider.style.top = /* 1 / this.scrollFactor * Math.abs(this.scrollContent.offsetTop) +*/ this.scrollButtonHeight + "px";
		this.scrollslider.style.left = "0px";
		this.scrollslider.style.width = "100%";
		this.scrollslider.onmousedown = VSA_handleSliderMouseDown;
		if (document.all)
			this.scrollslider.onmouseup = VSA_handleSliderMouseUp;
	}
	else
		this.scrollContent.style.width = this.element.offsetWidth + "px";
}

function VSA_handleBtnUpMouseDown()
{
	var sa = VSA_scrollAreas[this.index];
	sa.scrolling = true;
	sa.scrollUp();
}

function VSA_handleBtnUpMouseUp()
{
	VSA_scrollAreas[this.index].scrolling = false;
}

function VSA_handleBtnUpMouseOut()
{
	VSA_scrollAreas[this.index].scrolling = false;
}

function VSA_handleBtnDownMouseDown()
{
	var sa = VSA_scrollAreas[this.index];
	sa.scrolling = true;
	sa.scrollDown();
}

function VSA_handleBtnDownMouseUp()
{
	VSA_scrollAreas[this.index].scrolling = false;
}

function VSA_handleBtnDownMouseOut()
{
	VSA_scrollAreas[this.index].scrolling = false;
}

function VSA_scrollIt()
{
	this.scrollContent.scrollTop = this.scrollFactor * ((this.scrollslider.offsetTop + this.scrollslider.offsetHeight/2) - this.scrollButtonHeight - this.scrollslider.offsetHeight/2);
}

function VSA_scrollUp()
{
	if (this.scrollingLimit > 0)
	{
		this.scrollingLimit--;
		if (this.scrollingLimit == 0) this.scrolling = false;
	}
	if (!this.scrolling) return;
	if ( this.scrollContent.scrollTop - this.scrollStep > 0)
	{
		this.scrollContent.scrollTop -= this.scrollStep;
		this.scrollslider.style.top = 1 / this.scrollFactor * Math.abs(this.scrollContent.scrollTop) + this.scrollButtonHeight + "px";
	}
	else
	{
		this.scrollContent.scrollTop = "0";
		this.scrollslider.style.top = this.scrollButtonHeight + "px";
		return;
	}
	setTimeout("VSA_Ext_scrollUp(" + this.index + ")", 30);
}

function VSA_Ext_scrollUp(index)
{
	VSA_scrollAreas[index].scrollUp();
}

function VSA_scrollDown()
{
	if (this.scrollingLimit > 0)
	{
		this.scrollingLimit--;
		if (this.scrollingLimit == 0) this.scrolling = false;
	}
	if (!this.scrolling) return;


	this.scrollContent.scrollTop += this.scrollStep;
	this.scrollslider.style.top =  1 / this.scrollFactor * Math.abs(this.scrollContent.scrollTop) + this.scrollButtonHeight + "px";

	if (this.scrollContent.scrollTop >= (this.scrollContent.scrollHeight - this.scrollContent.offsetHeight))
	{
		this.scrollContent.scrollTop = (this.scrollContent.scrollHeight - this.scrollContent.offsetHeight);
		this.scrollslider.style.top = this.scrollbar.offsetHeight - this.scrollButtonHeight - this.scrollslider.offsetHeight + "px";
		return;
	}

	setTimeout("VSA_Ext_scrollDown(" + this.index + ")", 30);
}

function VSA_Ext_scrollDown(index)
{
	VSA_scrollAreas[index].scrollDown();
}

function VSA_handleMouseMove(evt)
{
	var sa = VSA_scrollAreas[((document.all && !window.opera) ? this.index : document.documentElement.scrollAreaIndex)];
	var posy = 0;
	if (!evt) var evt = window.event;
	
	if (evt.pageY)
		posy = evt.pageY;
	else if (evt.clientY)
		posy = evt.clientY;
			
		if (document.all && !window.opera)
		{
			posy += document.documentElement.scrollTop;
		}

	var iNewY = posy - sa.iOffsetY - getRealTop(sa.scrollbar) - sa.scrollButtonHeight;
		iNewY += sa.scrollButtonHeight;
		
	if (iNewY < sa.scrollButtonHeight)
		iNewY = sa.scrollButtonHeight;
	if (iNewY > (sa.scrollbar.offsetHeight - sa.scrollButtonHeight) - sa.scrollslider.offsetHeight)
		iNewY = (sa.scrollbar.offsetHeight - sa.scrollButtonHeight) - sa.scrollslider.offsetHeight;

	sa.scrollslider.style.top = iNewY + "px";

	sa.scrollIt();
}

function VSA_handleSliderMouseDown(evt)
{
	if (!(document.uniqueID && document.compatMode && !window.XMLHttpRequest))
	{
		document.onselectstart = function() { return false; }
		document.onmousedown = function() { return false; }
	}

	var sa = VSA_scrollAreas[this.index];
	if (document.all && !window.opera)
	{
		sa.scrollslider.setCapture()
		sa.iOffsetY = event.offsetY;
		sa.scrollslider.onmousemove = VSA_handleMouseMove;
	}
	else
	{
		if(window.opera)
		{
			sa.iOffsetY = event.offsetY;
		}
		else
		{
			sa.iOffsetY = evt.layerY;
		}
		document.documentElement.scrollAreaIndex = sa.index;
		document.documentElement.addEventListener("mousemove", VSA_handleMouseMove, true);
		document.documentElement.addEventListener("mouseup", VSA_handleSliderMouseUp, true);
	}
	return false;
}

function VSA_handleSliderMouseUp()
{
	if (!(document.uniqueID && document.compatMode && !window.XMLHttpRequest))
	{
		document.onmousedown = null;
		document.onselectstart = null;
	}

	if (document.all && !window.opera)
	{
		var sa = VSA_scrollAreas[this.index];
		sa.scrollslider.onmousemove = null;
		sa.scrollslider.releaseCapture();
		sa.scrollIt();
	}
	else
	{
		var sa = VSA_scrollAreas[document.documentElement.scrollAreaIndex];
		document.documentElement.removeEventListener("mousemove", VSA_handleMouseMove, true);
		document.documentElement.removeEventListener("mouseup", VSA_handleSliderMouseUp, true);
		sa.scrollIt();
	}
	return false;
}

function VSA_handleResize()
{
	if (VSA_resizeTimer)
	{
		clearTimeout(VSA_resizeTimer);
		VSA_resizeTimer = 0;
	}
	VSA_resizeTimer = setTimeout("VSA_performResizeEvent()", 100);
}

function VSA_performResizeEvent()
{
	for (var i=0; i<VSA_scrollAreas.length; i++)
		VSA_scrollAreas[i].createScrollBar();
}
function VSA_handleMouseWheel(event){
	if (this.index != null) {
		var sa = VSA_scrollAreas[this.index];
		
		if (sa.scrollbar == null) return;
		sa.scrolling = true;
		sa.scrollingLimit = sa.wheelSensitivity;
		
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                 
                /*if (window.opera)
                        delta = -delta;*/
        } else if (event.detail) { /** Mozilla case. */
                delta = -event.detail/3;
        }
        if (delta && sa.element.over) {
                if (delta > 0)
			        sa.scrollUp();
				else
			        sa.scrollDown();
				
                if (event.preventDefault)
                        event.preventDefault();
                event.returnValue = false;
        }
	}
}

function VSA_handleSelectStart()
{
	event.returnValue = false;
}

function VSA_handleScrollbarClick(evt)
{
	var sa = VSA_scrollAreas[this.index];
	var offsetY = (document.all ? event.offsetY : evt.layerY);

	if (offsetY < (sa.scrollButtonHeight + sa.scrollslider.offsetHeight/2))
		sa.scrollslider.style.top = sa.scrollButtonHeight + "px";
	else if (offsetY > (sa.scrollbar.offsetHeight - sa.scrollButtonHeight - sa.scrollslider.offsetHeight))
		sa.scrollslider.style.top = sa.scrollbar.offsetHeight - sa.scrollButtonHeight - sa.scrollslider.offsetHeight + "px";
	else
	{
		sa.scrollslider.style.top = offsetY + sa.scrollButtonHeight - sa.scrollslider.offsetHeight/2 + "px";
	}
	sa.scrollIt();
}

function VSA_handleOnScroll()
{
	//event.srcElement.doScroll("pageUp");
}

//--- common functions ----

function VSA_getElements(attrValue, tagName, ownerNode, attrName) //get Elements By Attribute Name
{
	if (!tagName) tagName = "*";
	if (!ownerNode) ownerNode = document;
	if (!attrName) attrName = "name";
	var result = [];
	var nl = ownerNode.getElementsByTagName(tagName);
	for (var i=0; i<nl.length; i++)
	{
	//	if (nl.item(i).getAttribute(attrName) == attrValue)
//		result.push(nl.item(i));
		if (nl.item(i).className.indexOf(attrValue) != -1)
		result.push(nl.item(i));
	}
	return result;
}



function getRealTop(obj) {
	var posTop = 0;
	while (obj.offsetParent) {
		posTop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return posTop;
}
// doubleTrackbar*******************************************
/*
*	Track � id of parent elenemt
*	Tracker � id of tracked element
*	OnUpdate � function whitch calls on each value change
*	OnComplete � function whitch calls on end of the drag
*	FingerOffset � distance between mouse pointer and corner tracker's edge
*	FormatNumbers � lead numders in hairlines with spaces
*	Min & Max � range of vaues
*	MinSpace � minimum difference between Min & Max
*	RoundTo � values will be rounded to this value
*	Margins � indent between Track & Tracker
*	AllowedValues � force Tracker to stick to the values
*
*	OnUpdate � function whitch called each time, when Tracker moved
*	OnComplete � function whitch called when user stop draging
*/
function cDoubleTrackBar(Track, Tracker, Settings) {
	switch(typeof Track){
		case 'string': this.Track = document.getElementById(Track); break;
		case 'object': this.Track = Track; break;
	}
	switch(typeof Tracker){
		case 'string': this.Tracker = document.getElementById(Tracker); break;
		case 'object': this.Tracker = Tracker; break;
	}
	if (!Track || !Tracker)
		return false;
	this.OnUpdate = Settings.OnUpdate;
	this.OnComplete = Settings.OnComplete;
	this.FingerOffset = Settings.FingerOffset || 0;
	this.FormatNumbers = Settings.FormatNumbers || false;
	this.Min = Settings.Min || 0;
	this.Max = Settings.Max || 100;
	this.MinSpace = Settings.MinSpace || 0;
	this.RoundTo = Settings.RoundTo || 1;
	this.Margins = Settings.Margins || 0;
	this.AllowedValues = Settings.AllowedValues || false;
	this.Disabled = (typeof Settings.Disabled != 'undefined') ? Settings.Disabled : false;

	if (this.Min >= this.Max)
		this.Max = this.Min +1;
	this.MinPos = this.Min;
	this.MaxPos = this.Max;
	if (this.Max - this.Min < this.MinSpace)
		this.MinSpace =  this.Max - this.Min;
	if (this.Max - this.Min < this.RoundTo)
		this.RoundTo =  this.Max - this.Min;
	this.MinSpace = Math.ceil(this.MinSpace/this.RoundTo)*this.RoundTo;


	this.Track.style.width = (this.Track.clientWidth || this.Track.offsetWidth) + 'px';
	this.OnTrackMouseDown = this.bindAsEventListener(this.TrackMouseDown);
	this.OnDocumentMouseMove = this.bindAsEventListener(this.DocumentMouseMove);
	this.OnDocumentMouseUp = this.bindAsEventListener(this.DocumentMouseUp);

	this.bindEvent(this.Track, 'mousedown', this.OnTrackMouseDown);

	this.TrackerLeft = 0;
	this.UpdateTracker(this.Track.offsetWidth + this.FingerOffset);
	if (typeof this.OnUpdate == 'function') {
		this.OnUpdate.call(this);
	}
}
cDoubleTrackBar.prototype = {

	TrackMouseDown: function(event) {
		this.TrackerLeft = this.Tracker.offsetLeft - this.Margins;
		this.TrackerRight = this.TrackerLeft + this.Tracker.offsetWidth;

		this.TrackerOffsets = this.getOffsets(this.Track);

		var X = event.clientX + document.documentElement.scrollLeft;
		X -= this.TrackerOffsets[0];

		this.Left = Math.abs(this.TrackerLeft-X+this.Margins) <= Math.abs(this.TrackerRight-X+this.Margins);

		if (typeof this.Disabled == 'function') {
			if ( this.Disabled.call(this) )
				return true;
		} else if ( this.Disabled )
			return true;
		
		this.UpdateTracker(X);

		this.bindEvent(document, 'mousemove', this.OnDocumentMouseMove);
		this.bindEvent(document, 'mouseup', this.OnDocumentMouseUp);

		return this.stopEvent(event);
	},
	DocumentMouseMove: function(event) {
		this.UpdateTracker(event.clientX + document.documentElement.scrollLeft - this.TrackerOffsets[0]);
		return this.stopEvent(event);
	},
	DocumentMouseUp: function(event) {
		this.unbindEvent(document, 'mousemove', this.OnDocumentMouseMove);
		this.unbindEvent(document, 'mouseup', this.OnDocumentMouseUp);

		if (typeof this.OnComplete == 'function') {
			this.OnComplete.call(this);
		}
		return this.stopEvent(event);
	},
	UpdateTracker: function(X){
		var _LogicWidth = this.Track.offsetWidth - this.Margins*2 - 1;
		var _minSpace = Math.floor(_LogicWidth*this.MinSpace/(this.Max-this.Min));
		var _oldMin = this.MinPos;
		var _oldMax = this.MaxPos;

		X -= this.Margins;
		if (this.Left) {
			X += this.FingerOffset;
			this.TrackerLeft = Math.max(0, Math.min(this.TrackerRight - _minSpace - 1, X));
			this.MinPos = Math.round((this.Min + this.TrackerLeft*(this.Max-this.Min)/_LogicWidth) / this.RoundTo) * this.RoundTo;
			if (this.MinSpace >= this.MaxPos - this.MinPos) {
				this.MinPos = this.MaxPos - this.MinSpace;
			}
			if (this.AllowedValues) {
				this.TrackerLeft = Math.round(_LogicWidth*(this.MinPos - this.Min)/(this.Max - this.Min));
			}
		} else {
			X -= this.FingerOffset;
			this.TrackerRight = Math.max(this.TrackerLeft + _minSpace + 1 , Math.min(_LogicWidth + 1, X));
			this.MaxPos = Math.round((this.Min + (this.TrackerRight-1)*(this.Max-this.Min)/_LogicWidth) / this.RoundTo) * this.RoundTo;
			if (this.MinSpace >= this.MaxPos - this.MinPos) {
				this.MaxPos = this.MinPos + this.MinSpace;
			}
			if (this.AllowedValues) {
				this.TrackerRight = Math.round(_LogicWidth*(this.MaxPos - this.Min)/(this.Max - this.Min))+1;
			}
		}
		this.Tracker.style.width = (this.TrackerRight - this.TrackerLeft) + 'px';
		this.Tracker.style.left = (this.Margins + this.TrackerLeft) + 'px';

		if (typeof this.OnUpdate == 'function')
			if ( !this.AllowedValues || (this.AllowedValues && (_oldMax!=this.MaxPos || _oldMin!=this.MinPos)) )
				this.OnUpdate.call(this);
	},
	
	AddHairline: function (pos) {
		var _Touch = this.Track.appendChild( document.createElement('div') );
		var _LogicWidth = this.Track.offsetWidth - this.Margins*2 - 1;
		
		_Touch.style.left = this.Margins + _LogicWidth/(this.Max-this.Min)*(pos-this.Min) + 'px';
		_Touch.className = 'touch';
		_Touch.innerHTML = "<span>" + (this.FormatNumbers ? this.leadSpaces(pos) : pos) + "</span>";
	},
	
	AutoHairline: function(num) {
		if (num >= 1)
			this.AddHairline(this.Min);
		if (num >= 2)
			this.AddHairline(this.Max);
		if (num >= 3) {
			num--;
			var diff = this.Max - this.Min;
			var roundTo = [10, 20, 50, 100, 250, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 250000, 500000, 1000000];
			var DoRound = 1;
			for (var i=0; roundTo[i]; i++) {
				DoRound = roundTo[i]/10;
				if (roundTo[i]>diff)
					break;
			}
			for (var i=1; i<num; i++) {
				var val = this.Min + diff/num*i;
				val = Math.round(val/DoRound)*DoRound;
				this.AddHairline(val);
			}
		}
	},
	
	
	getOffsets: function(element) {
	    var valueT = 0, valueL = 0;
	    do {
			valueT += element.offsetTop  || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
	    } while (element);
	    return [valueL, valueT];
	},
	leadSpaces: function(numb) {
		var res = '';
		numb = numb.toString();
		var l = numb.length;
		for (var i=l; i>0; i--)
			if ((l-i)%3==2)
				res = '&nbsp;'+numb.charAt(i-1)+res;
			else
				res = numb.charAt(i-1)+res;
		return res;
	},
	bindEvent: function(element, event, callBack){
		if (element.addEventListener) {
			element.addEventListener(event, callBack, false);
		} else {
			element.attachEvent('on' + event, callBack);
		}
	},
	unbindEvent: function(element, event, callBack){
		if (element.removeEventListener) {
			element.removeEventListener(event, callBack, false);
	    } else if (element.detachEvent) {
			element.detachEvent('on' + event, callBack);
	    }
	},
	bindAsEventListener: function (callBack) {
		var _object = this;
		return function(event) {
			return callBack.call(_object, event || window.event);
		}
	},
	stopEvent: function (event){
		if (event.preventDefault) {
			event.preventDefault();
			event.stopPropagation();
		} else {
			event.returnValue = false;
			event.cancelBubble = true;
		}
		return false;
	}
}
// slideBlock*******************************************
// page init
jQuery(function(){
	initOpenClose();
});

// open-close init
function initOpenClose() {
	jQuery('div.home').OpenClose({
		activeClass:'active',
		opener:'a.advanced-search',
		slider:'div.block',
		effect:'slide',
		animSpeed:500
	});
}

// open-close plugin
jQuery.fn.OpenClose = function(_options){
	// default options
	var _options = jQuery.extend({
		activeClass:'active',
		opener:'.opener',
		slider:'.slide',
		animSpeed: 400,
		animStart:false,
		animEnd:false,
		effect:'fade',
		event:'click'
	},_options);

	return this.each(function(){
		// options
		var _holder = jQuery(this);
		var _slideSpeed = _options.animSpeed;
		var _activeClass = _options.activeClass;
		var _opener = jQuery(_options.opener, _holder);
		var _slider = jQuery(_options.slider, _holder);
		var _animStart = _options.animStart;
		var _animEnd = _options.animEnd;
		var _effect = _options.effect;
		var _event = _options.event;
		if(_slider.length) {
			_opener.bind(_event,function(){
				if(!_slider.is(':animated')) {
					if(typeof _animStart === 'function') _animStart();
					if(_holder.hasClass(_activeClass)) {
						_slider[_effect=='fade' ? 'fadeOut' : 'slideUp'](_slideSpeed,function(){
							if(typeof _animEnd === 'function') _animEnd();
						});
						_holder.removeClass(_activeClass);
					} else {
						_holder.addClass(_activeClass);
						_slider[_effect=='fade' ? 'fadeIn' : 'slideDown'](_slideSpeed,function(){
							if(typeof _animEnd === 'function') _animEnd();
						});
					}
				}
				return false;
			});
			if(_holder.hasClass(_activeClass)) _slider.show();
			else _slider.hide();
		}
	});
}

function showMetroMap(cityId)
{
		var mapPath = "";
		var width = 0;
		var height = 0;

		switch (cityId)
		{
			case "1":
			case "1206":
				//mapPath = '/js/Moscow.html';
                mapPath = '/metro/order-moscow-metro';
				width = 902;
				height = 1616;
			break;
			case "2":
			case "1244":
				//mapPath = '/js/Spb.html';
                mapPath = '/metro/order-piter-metro';
				width = 717;
				height = 787;
			break;
		};

		if (mapPath == "")
		{
			//alert("В данный момент для этого города нет карты метро");
			return;
		}

		$.fancybox(
		{
			'href': mapPath,
			'width': width,
			'height': height,
			'autoScale': false,
			//'centerOnScroll': true,
			'onComplete': function()
			{
                //$("#fancybox-wrap").css({'top':'0px', 'bottom':'auto'});
				var stations = $("input[name='metro']");
                var stations_id = $("#metro_id");
                
				$.each(stations.val().split(","), function()
				{
					if (this != '')
					{
						$("a[title=" + this + "]").toggleClass('selected');
					}
				});

				$("a, div", "#metro_map").click(function()
				{
					$.each($(this).attr('title').split(","), function()
					{
						if (this != '')
						{
							$("a[title=" + this + "]").toggleClass('selected');
						}
					});

					stations.val("");
                    stations_id.val("");
					var isFirst = true;

					$("a.selected", "#metro_map").each(function()
					{
						if (stations.val().indexOf($(this).attr('title')) < 0 || stations_id.val().indexOf($(this).attr('title')) < 0)
						{
							stations.val(stations.val() + $(this).attr('title') + ",");
                            stations_id.val(stations_id.val() + $(this).attr('rel') + ",");
                            
							isFirst = false;
						}
					});

					return false;
			 	});
			}
		});
}
	
	
// tootip**********************************************
$(document).ready(function() {
  $('.toolTip').hover(
    function() {
    this.tip = this.title;
    $(this).append(
     '<div class="toolTipWrapper toolTipWrapper1">'
		+'<div class="toolTip-box">'
			+'<div class="r">'
		        +'<div class="toolTipMid">'
		          +this.tip
		        +'</div>'
			+'</div>'
		+'</div>'
      +'</div>'
    );
    this.title = "";
    this.width = $(this).width();
    $(this).find('.toolTipWrapper').css({left:this.width-22})
    $('.toolTipWrapper').fadeIn(300);
  },
    function() {
      $('.toolTipWrapper').fadeOut(100);
      $(this).children().remove();
        this.title = this.tip;
      }
  );
});
$(document).ready(function(){
	
	$(".feedback input[name='metro']").click(function()
	{
		var city = $("#city-holder-select").val();
		if ($("#cityfrom").val() && $("#cityfrom").val() == 'МОСКВА')
			showMetroMap("1");
		else if ($("#cityfrom").val() && $("#cityfrom").val() == 'САНКТ-ПЕТЕРБУРГ')
			showMetroMap("2");
		else if (!$("#cityfrom").val() && city)
			showMetroMap(city);	
	});
	
	

	$(".order-form input[name='metro']").click(function()
	{
		var city = $("#city_id").val();
		showMetroMap(city);
	});
	
	$("#phone").mask("8 (999) 999-99-99");
	
	$('.carusel').galleryScroll({
	});

	$('.carusel-tour').galleryScroll({
		holderList: '.recommend',
		slideNum:'span.s2'
	});

	$('.carusel-hotel').galleryScroll({
		holderList: '.recommend',
		slideNum:'span.s2'
	});

	$("a.zoom").fancybox();
	$("a.fancybox").fancybox();
	$("#thumbs-hotel a").fancybox({
		
		'onStart' : function() {
			//$('.gallery-block div.visual').hide();	
		}
			
	});
        $("ul[id^=thumbs-hotel-]").each(function(){
            $(this).find("a").attr('rel', 'gallery').fancybox();
        });
//	$("#thumbs-hotel-315020 a").attr('rel', 'gallery').fancybox();
        
	$("a.[rel=lightbox-tour]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
	});
	$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
	
	initCustomForms();
		
		
	$('a[tooltip]').each(function()
	{
		  $(this).qtip({
			  content: $('#' + $(this).attr('tooltip')).html(),
              position: {
                  corner: {
                     tooltip: 'bottomLeft', // Use the corner...
                     target: 'topRight' // ...and opposite corner
                  }
               },               
               style: {
                  border: {
                     width: 5,
                     radius: 10
                  },
                  padding: 10, 
                  textAlign: 'left',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'cream' // Style it according to the preset 'cream' style
               }
		  });
	});
	
	$('#hotel-price-search-paginator .page a').live('click', function(){
		page = $(this).attr('rel');
		$("#shp_page").val(page);
		$('#hotel-price-search-paginator .page a').each(function(n,element){
			$(this).removeClass('active');			
		});
		$(this).addClass('active');
		SearchHotelPrices();
		return false;
	});
			
	$('.serialonlynum').mask('9999',{placeholder:" "});	
	$('.numberonlynum').mask('999999',{placeholder:" "});		
	$('.dateonlynum').mask('99',{placeholder:" "});	
	$('.yearonlynum').mask('9999',{placeholder:" "});	
	
	$('.phone .hold').css('display', 'none');
		
	$('.dif.city-holder.outtaHere').change(function() {
		$('.phone .hold').css('display', 'none');
		var phone_id = 1215;
		if ($(this).val() == 1206  || $(this).val() == 1244)
			phone_id = $(this).val();
		$('#phone-' + phone_id).css('display', 'block');
        $('#phone-1').css('display', 'block');
		$('.city-info').css('display', 'none');
		$('#city-info-' + phone_id).css('display', 'block');
	});
	
	$('#foods-options .checkboxAreaChecked, #foods-options .checkboxArea').click(function() {
		$('#sf_session').val('');
	  	SearchTour();
	});
	
	$('.star-option .checkboxAreaChecked, .star-option .checkboxArea').click(function() {
		$('#sf_session').val('');
	  	SearchTour();
	});
	
			
	$('#email').focus(function() {
		if ($(this).val() == 'Ваш e-mail')
			$(this).val('');
	});
	$('#dates').focus(function() {
		if ($(this).val() == 'Ближайшие даты')
			$(this).val('');
	});
	$('#metro').focus(function() {
		if ($(this).val() == 'Станция метро')
			$(this).val('');
	});	
	$('#numberCard').focus(function() {
		if ($(this).val() == 'Номер карты')
			$(this).val('');
	});		
	
	$('#sort_panel li a').click(function() {
		$('#param_sort').val($(this).attr('rel'));
		$('#Hotels').submit();
	});
	
	$('#newscarousel').jcarousel();
	
	$('.dif.city-holder.outtaHere').change();
	
	/**
	 * Datepicker initialize
	 */

	$("a.spoiler_spo").click(function () {

		if ($(this).parent().next().is(":hidden")) {

			$(this).parent().next().slideDown(200);

		} else {

			$(this).parent().next().slideUp(200);

		}

	});
	$("a.spoiler_spo").each(function (i) {
		p = $(this).parent().next().hide();
	});
	
	$.datepicker.regional["ru"];
	$.datepicker.regional["ru"].monthNamesPas = ['Января','Февраля','Марта','Апреля','Мая','Июня','Июля','Августа','Сентября','Октября','Ноября','Декабря'];
	
	$('#sarea0,#sarea1,#sarea2,#sarea3').each(function() {
		$(this).click(function() {
			$('.datepicker-conteiner').css('display', 'none');
		});
	});
  
  $(document).click( function(event){
    if( $(event.target).closest(".datepicker-panel").length || 
        $(event.target).closest('.ui-datepicker-calendar').length ||
        $(event.target).closest('.ui-datepicker-header').length
        )
    return;

    $(".datepicker-conteiner").hide();
    event.stopPropagation();
  });

	$(".datepicker").datepicker({
		beforeShow: function(input) {
			$(input).css("background-color","#ff9");
		},
		minDate: 1,
		showOtherMonths: true,
		selectOtherMonths: true,
		onSelect: function(dateText, inst) {
      var datepicker_panel = $(this).parents('.datepicker-panel').first();
			$(this).css("background-color","red");
			
			var month_name = $.datepicker.regional['ru'].monthNamesPas[parseInt(inst.selectedMonth)];
			var date_text = inst.selectedDay + ' ' + month_name;
			var date_val = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay).getTime();
      
      var date_from = $('.date-from', datepicker_panel);
      var date_to = $('.date-to', datepicker_panel);
      var departure_date_value = $('.departure-date-value', datepicker_panel);
			
			if (date_from.val() && date_to.val()) {
				date_from.val('');
				date_to.val('');
				date_from.html('');
				date_to.html('');
			}
			
			if (!date_from.val()) {

				date_from.val(date_val);
				date_from.html(date_text);

			} else {
				date_to.val(date_val);
				date_to.html(date_text);
				
				if (parseInt(date_from.val()) > parseInt(date_to.val())) {
					var tmp_val = date_from.val();
					date_from.val(date_to.val());
					date_to.val(tmp_val);
					
					var tmp_text = date_from.html();
					date_from.html(date_to.html());
					date_to.html(tmp_text);
				}
			}
			
			var _date_from = _date_to = null;
			
			if (date_from.val()) {
				_date_from = new Date(parseInt(date_from.val()));
			}
			if (date_to.val()) {
				_date_to = new Date(parseInt(date_to.val()));
			}
			
			if (_date_from) {
				departure_date_value.val(addZero(_date_from.getDate()) + '/' + addZero(_date_from.getMonth()+1) + '/' + _date_from.getFullYear());

				if (_date_to) {
					departure_date_value.val(departure_date_value.val() + ' - ' + addZero(_date_to.getDate()) + '/' + addZero(_date_to.getMonth()+1) + '/' + _date_to.getFullYear());
				}
			}
	    },
	    onClose: function(dateText, inst) {
	      $(this).css("background-color","");
	    }
	});
	
	$('.departure-date-btn').click(
		function() {
      var el = $('.datepicker-conteiner', $(this).parent());
      var visible = el.is(':visible')
      $('.datepicker-conteiner').hide();
      if (visible) {
        el.hide();
      } else {
        el.show();
      }
			
		}
	);
	onClick="javascript:toPricesHotel();"
	 $(function() {
    
            $("#main").organicTabs({
                "speed": 50
            });
    
        });
	
	/**
	 * 
	 * Popup initialize
	 * 
	 */
	$(function () {
		
    $('.popup-hover').each(function () {
        var distance = 10;
        var time = 250;
        var hideDelay = 250;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var trigger = $('.open', this);
        var info = $('.popup', this).css('opacity', 0);


        $([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                // don't trigger the animation again
                return;
            } else {
                // reset position of info box
                beingShown = true;

                info.css({
                    top: 30,
                    left: 0,
                    display: 'block'
                }).animate({
                    top: '-=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }

            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    top: '-=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });

            }, hideDelay);

            return false;
        });
    });
});
});
// tabs price tour********************************************
(function($) {

    $.organicTabs = function(el, options) {
    
        var base = this;
        base.$el = $(el);
        base.$nav = base.$el.find(".nav-tab");
                
        base.init = function() {
        
            base.options = $.extend({},$.organicTabs.defaultOptions, options);
            
            // Accessible hiding fix
            $(".hide").css({
                "position": "relative",
                "top": 0,
                "left": 0,
                "display": "none"
            }); 
            
            base.$nav.delegate("li > a", "click", function() {
            
                // Figure out current list via CSS class
                var curList = base.$el.find("a.current").attr("href").substring(1),
                
                // List moving to
                    $newList = $(this),
                    
                // Figure out ID of new list
                    listID = $newList.attr("href").substring(1),
                
                // Set outer wrapper height to (static) height of current inner list
                    $allListWrap = base.$el.find(".list-wrap"),
                    curListHeight = $allListWrap.height();
                $allListWrap.height(curListHeight);
                                        
                if ((listID != curList) && ( base.$el.find(":animated").length == 0)) {
                                            
                    // Fade out current list
                    base.$el.find("#"+curList).fadeOut(base.options.speed, function() {
                        
                        // Fade in new list on callback
                        base.$el.find("#"+listID).fadeIn(base.options.speed);
                        
                        // Adjust outer wrapper to fit new list snuggly
                        var newHeight = base.$el.find("#"+listID).height();
                        $allListWrap.animate({
                            height: newHeight
                        });
                        
                        // Remove highlighting - Add to just-clicked tab
                        base.$el.find(".nav-tab li a").removeClass("current");
                        $newList.addClass("current");
                            
                    });
                    
                }   
                
                // Don't behave like a regular link
                // Stop propegation and bubbling
                return false;
            });
            
        };
        base.init();
    };
    
    $.organicTabs.defaultOptions = {
        "speed": 300
    };
    
    $.fn.organicTabs = function(options) {
        return this.each(function() {
            (new $.organicTabs(this, options));
        });
    };
    
})(jQuery);
// tabs********************************************
(function($) {

    $.organicTabs = function(el, options) {
    
        var base = this;
        base.$el = $(el);
        base.$nav = base.$el.find(".nav-tab");
                
        base.init = function() {
        
            base.options = $.extend({},$.organicTabs.defaultOptions, options);
            
            // Accessible hiding fix
            $(".hide").css({
                "position": "relative",
                "top": 0,
                "left": 0,
                "display": "none"
            }); 
            
            base.$nav.delegate("li > a", "click", function() {
                // Figure out current list via CSS class
                var curList = base.$el.find("a.current").attr("href").substring(1),

                // List moving to
                    $newList = $(this),

                // Figure out ID of new list
                    listID = $newList.attr("href").substring(1),

                // Set outer wrapper height to (static) height of current inner list
                    $allListWrap = base.$el.find(".list-wrap"),
                    curListHeight = $allListWrap.height();
                $allListWrap.height(curListHeight);

                if ((listID != curList) && ( base.$el.find(":animated").length == 0)) {

                    // Fade out current list
                    base.$el.find("#"+curList).fadeOut(base.options.speed, function() {

                        // Fade in new list on callback
                        base.$el.find("#"+listID).fadeIn(base.options.speed);

                        // Adjust outer wrapper to fit new list snuggly
                        var newHeight = base.$el.find("#"+listID).height();
                        $allListWrap.animate({
                            height: newHeight
                        });

                        // Remove highlighting - Add to just-clicked tab
                        base.$el.find(".nav-tab li a").removeClass("current");
                        $newList.addClass("current");

                    });

                }   
                // Don't behave like a regular link
                // Stop propegation and bubbling
                return false;
            });
            
        };
        base.init();
    };
    
    $.organicTabs.defaultOptions = {
        "speed": 300
    };
    
    $.fn.organicTabs = function(options) {
        return this.each(function() {
            (new $.organicTabs(this, options));
        });
    };
    
})(jQuery);
// Gallery ***********************************************************
$(document).ready(function(){
	eventsLoad();
	openSearch();
	
/*	$('.gallery-block').slideShow({		
		slideEl:'.block',		
		linkNext:'a.next',		
		linkPrev:'a.prev',		
		linkPause:'a.pause',		
		numElement:'ul.img-list a',		
		duration:300,		
		autoSlideShow:false,		
		switchTime:5000,
		noCicle:false,
		disableClass:'no-active',	
		currentEl:'span.cur',		
		allEl:'span.all',
		hideBeforeShow: true,
		hoverStopGallery:true
	});
*/	
	$('ul.ul_rate li a').click(function(){
		ulclass = $(this).parent().parent().attr('id');
		$('#'+ulclass+' li a').each(function(){
			$(this).removeClass('active');
		})
		$(this).addClass('active');
		$('#id_'+ulclass).val($(this).attr('rel'));
	});
	
	$('#topsearchpaginator .page a').live('click', function(){
		page = $(this).attr('rel');
		$("#sf_page").val(page);
		$('#topsearchpaginator .page a').each(function(n,element){
			$(this).removeClass('active');			
		});
		$(this).addClass('active');
		SearchTour();
		return false;
	});
	$('.ajax-plate').ajaxStart(function(){
		$(this).show();		
	});
	$('.ajax-plate').ajaxStop(function(){
			$(this).hide();
	});

	
});
// open search block ***********************************************************
function openSearch (){
	var _slideDuration = 300;
	$('.slide-block').each(function(){
		var _link = $('a.open-close', this),
			_slide = $('div.block', this),
			_holder = $(this);
		_slide.css({position: 'relative'}).hide();
		_holder.removeClass('active');
		
		_link.click(function(){
			if (_holder.hasClass('active')) {
				_holder.removeClass('active');
				_slide.slideUp(_slideDuration);
			} else {
				_holder.addClass('active');
				_slide.slideDown(_slideDuration);
			}
			return false;
		});
	});
}

// events load *****************************************************************
function eventsLoad (){
	$('div.block-wrapper').each(function(){
		var _eventsHolder = $('ul.events', this),
			_link = $('a.loadEvents', this),
			_counter = 1;
			
		var _limit = parseInt(_link.attr('rel'));
			
		_link.click(function(){
			var _url = this.href;
			if (!_limit || _limit >= _counter) {
				$.ajax({
					url:_url,
					success:function(_events){
						var _appendEvents = $(_events),
							_startH = _eventsHolder.height();
							
						_eventsHolder.append(_appendEvents);
						var _finishH = _eventsHolder.height();
						_eventsHolder.css('height',_startH).animate({'height':_finishH}, {duration:1000,complete:function(){
							_eventsHolder.css('height','auto');
						}});
						_counter++;
						if (_limit < _counter) _link.fadeTo(400, 0.5);
					}
				});
			}
			return false;
		});
	});	
}




/* 
* jQuery slideShow v1.3.0
*/

jQuery.fn.slideShow = function(_options){    
	// defaults options	    
	var _options = jQuery.extend({		
		slideEl:'div.slide',		
		linkNext:'a.next',		
		linkPrev:'a.prev',		
		linkPause:'a.pause',		
		numElement:'div.slideNav li a',		
		duration:500,		
		autoSlideShow:false,		
		switchTime:3000,
		noCicle:false,
		disableClass:'no-active',
		event:'click',		
		currentEl:'span.cur',		
		allEl:'span.all',
		hideBeforeShow: false,
		hoverStopGallery:true
	},_options);
    return this.each(function(){
	    var _THIS = jQuery(this),
			_slideEl = jQuery(_options.slideEl, _THIS),
			_linkNext = jQuery(_options.linkNext, _THIS),
			_linkPrev = jQuery(_options.linkPrev, _THIS),
			_linkPause = jQuery(_options.linkPause, _THIS),
			_numElement = jQuery(_options.numElement, _THIS),
			_currentEl = jQuery(_options.currentEl, _THIS),
			_allEl = jQuery(_options.allEl, _THIS),
			_duration = _options.duration,
			_switchTime = _options.switchTime,
			_numElActive, _timer = false, _hover = false, _current = 0, _next = 0, _pause = true;
		
		if (!_slideEl.filter('.active').length) {
			_slideEl.eq(0).addClass('active');
			_current = 0;
		} else {
			_current = _slideEl.index(_slideEl.filter('.active'));
		}
		_slideEl.not(".active").hide();
		
		if (jQuery(_numElement).length && _options.numElement) activeNumEl();
		if (_options.autoSlideShow) {
			_pause = false;
			_timer = setTimeout(function(){nextEl()},_switchTime);
			if (_linkPause.length && _options.linkPause) _linkPause.addClass('play')
			if (_options.hoverStopGallery) contentHover();
		}
		if (_options.currentEl && _currentEl.length) {
			_allEl.html(_slideEl.length);
			currentNum();
		}
		if (_linkNext.length && _options.linkNext) {
			_linkNext.click(function(){
				nextEl();
				return false;
			});
		}
		if (_options.noCicle) {
			_linkPrev.addClass('prev-'+_options.disableClass);
		}
		if (_linkPrev.length && _options.linkPrev) {	
			_linkPrev.click(function(){
				_linkNext.removeClass('next-'+_options.disableClass);
				if (!_slideEl.is(':animated') && !jQuery(this).hasClass('prev-'+_options.disableClass)) {
					if (_timer) clearTimeout(_timer);
					_next = _current-1;
					if (_next < 0) _next = _slideEl.length-1;
					if (_options.noCicle && _next-1 < 0) {
						jQuery(this).addClass('prev-'+_options.disableClass);
					}
					fadeElement();
					activeNumEl();
					pauseCode();
				}
				return false;
			});
		}
		if (_numElement.length && _options.numElement) {
			_numElement.bind(_options.event, function(){
				if (!_slideEl.is(':animated')) {
					_next = _numElement.index(jQuery(this));
					_linkNext.removeClass('next-'+_options.disableClass);
					_linkPrev.removeClass('prev-'+_options.disableClass);
					if (_options.noCicle && _next+1 >= _slideEl.length) _linkNext.addClass('next-'+_options.disableClass);
					if (_options.noCicle && _next-1 < 0) _linkPrev.addClass('prev-'+_options.disableClass);
					if (_timer) clearTimeout(_timer);
					if (!_slideEl.eq(_next).hasClass("active")){
						fadeElement();
						activeNumEl();
						pauseCode();
					}
				}
				return false;
			});
		}
		if (_linkPause.length && _options.linkPause) {
			_linkPause.click(function(){
				if (!_pause) {
					jQuery(this).removeClass('play');
					clearTimeout(_timer);
					_pause = true;
				} else {
					jQuery(this).addClass('play');
					_timer = setTimeout(function(){nextEl()},_switchTime);
					_pause = false;
				}
				return false;
			});
		}
		function fadeElement(){
			if (_current != _next) {
				_slideEl.removeClass('active');
				_slideEl.eq(_current).addClass('hide');
				
				if (!_options.hideBeforeShow) {
					_slideEl.eq(_next).fadeIn(_duration, function(){
						_slideEl.filter('.hide').hide().removeClass('hide');
					}).addClass('active');
				} else {
					_slideEl.filter('.hide').fadeOut(_duration, function(){
						_slideEl.eq(_next).fadeIn(_duration);
					}).removeClass('hide');
				}
				_current = _next;
				if (_options.currentEl && _currentEl.length) currentNum();
			}
		};
		function currentNum() {
			_currentEl.html(_current+1);
		}
		function activeNumEl() {
			_numElement.parent().removeClass("active");
			_numElement.eq(_current).parent().addClass("active");
		};
		function nextEl(){
			_linkPrev.removeClass('prev-'+_options.disableClass);
			if (!_slideEl.is(':animated') && !_linkNext.hasClass('next-'+_options.disableClass)) {
				if (_timer) clearTimeout(_timer);
				_next = _current+1;
				if (_next == _slideEl.length) _next = 0;
				if (_options.noCicle && _next+1 >= _slideEl.length) {
					_linkNext.addClass('next-'+_options.disableClass);
				}
				fadeElement();
				activeNumEl();
				pauseCode();
			}
		};
		function pauseCode(){
			if (!_pause) {
				if (_linkPause.length && _options.linkPause) {
					if (_linkPause.hasClass('play')) {
						_timer = setTimeout(function(){nextEl()},_switchTime);
					}					
				} else {
					_timer = setTimeout(function(){nextEl()},_switchTime);
				}
			}
		}
		function contentHover() {
			_hover = true;
			_slideEl.mouseenter(function() {
				if (_timer) clearTimeout(_timer);
			}).mouseleave(function(){
				pauseCode();
			});			
		}
    });
}
/*!
 * jQuery UI 1.8.9
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI
 */
;(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,
NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,
"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");
if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f,
"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,
d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}});
c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&
b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery);
;/*!
 * jQuery UI Widget 1.8.9
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
;


