jQuery.noConflict();

(function($, window, document, undefined){


$(function(){

	
	if ($.fn.dynamicLabel)
	{
		$('input.text, input.dynamic, input[type="text"]').dynamicLabel();
	}


	if ($.fn.colorbox)
	{
		$('a.modal').colorbox({
			speed: 400,
			opacity: 0.8,
			scalePhotos: false,
			rel: 'group1'
		});
	}


	$('.tabArea .tabs a').click(function(){
		var id = this.hash.substr(1);
		$(this).
			parents('.tabs').find('a').removeClass('active').end().
			parents('.tabArea').find('.tab').hide();
		$('#' + id).show();
		$(this).addClass('active');
		return false;
	});


	var elevator = $('.elevator');
	if (elevator.length)
	{
		elevator.each(function(){
			var self = $(this),
				content = self.find('.content'), 
				slider = content.find('.slider');

			self.find('.buttons a').click(function(){
				if (content.hasClass('expanded'))
					return false;

				var id = this.hash.substr(1).replace(/^go-/, ''),
					item = $('#' + id),
					pos = item.position();

				slider.animate({ top: '-' + Math.ceil(pos['top']) + 'px' }, 'normal');
				return false;
			});
			self.find('.toggle a').click(function(){
				var self = $(this);
				if (self.hasClass('expand'))
				{
					slider.animate({ top: '0px' }, 'fast');
					content.animate({ height: slider.height() + 'px' }, 'normal').addClass('expanded');
					self.removeClass('expand').addClass('contract');
					this.innerHTML = 'Contract this area and hide most information';
				}
				else
				{
					content.animate({ height: 470 + 'px' }, 'normal').removeClass('expanded');
					self.removeClass('contract').addClass('expand');
					this.innerHTML = 'Expand this area and show all information';
				}
				return false;
			});
		});

		if (document.location.hash.match(/#go-/))
		{
			$('a[href="' + document.location.hash + '"]').click();
		}
	}


	var map = $('#map'), timerPopup;
	if (map.length)
	{
		function hideLoc(loc)
		{
			if (!loc)
				loc = map.find('.location').not('.location-main');

			loc.removeClass('location-active');
			loc.find('.popup1').
				css('left', '').addClass('popupHide');
		}

		map.find('.location').not('.location-main').

			find('> a').hover(function(){
				if (timerPopup)
				{
					clearTimeout(timerPopup);
					timerPopup = null;
				}
				hideLoc();

				var loc = $(this.parentNode), 
					pos = loc.position(), 
					p = loc.find('.popup1');
				loc.addClass('location-active');
				p.removeClass('popupHide');
			}, function(){
				var loc = $(this.parentNode);
				timerPopup = setTimeout(function(){
					hideLoc(loc);
				}, 150);
			}).end().

			find('.popup1').hover(function(){
				if (timerPopup)
				{
					clearTimeout(timerPopup);
					timerPopup = null;
				}
			}, function(){
				var loc = $(this.parentNode);
				timerPopup = setTimeout(function(){
					hideLoc(loc);
				}, 150);
			});
	}


	var slideshow = $('#slideshow');
	if (slideshow.length)
	{
		setInterval(function(){
			var a = slideshow.find('.active'), n = a.next();
			if (!n.length)
				n = slideshow.find('li:eq(0)');
			n.addClass('next');
			a.fadeOut(600, function(){
				a.removeClass('active').show();
				n.removeClass('next').addClass('active');
			});
		}, 5600);
	}


	if ($.browser.msie)
	{
		if ($.browser.version <= 6)
		{
			try {document.execCommand("BackgroundImageCache", false, true);} catch(e){};
			if (window['DD_belatedPNG'] !== undefined)
			{
				DD_belatedPNG.fix('img, #menuSide a, input.submit, .popup1, .popupIn, .marker1, .marker2');
				DD_belatedPNG.fix('.button1 a, .button1 span, .button2 a, .button2 span, .button5 a, .button5 span');
			}
		}
	}

});


$.fn.dynamicLabel = function(){
	$(this).each(function(){
		this._default = this.value;
		$(this).bind('focus', function(){
			if (this.value == this._default)
				this.value = '';
		}).bind('blur', function(){
			if (this.value == '')
				this.value = this._default;
		});
	});
	return this;
};


})(jQuery, window, document);



// @REMOVE START@
window.log = function(){
	log.history = log.history || [];
	log.history.push(arguments);
	if (this.console) {
		console.log(Array.prototype.slice.call(arguments));
	}
};
// @REMOVE END@

