//jQuery.noConflict();

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


$(function(){

	$('a[rel=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel

	//$('a.lightbox').lightBox(); // Select all links with lightbox class


	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();
		alert(id);
		$(this).addClass('active');
		return false;
	});*/


	/*var elevator = $('.elevator');
	if (elevator.length)
	{
		var firstel = elevator.find('.item:eq(0)');
		$('.content').animate({ height: firstel.height() + 'px' }, 'normal');
		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();
					content.animate({ height: self.find('#'+id).height() + 'px' }, 'normal');

				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: 820 + '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);
			});
	}

	$(document).ready(function() {
		$('#sub-slider-full').coinslider({width: 645, height: 318, navigation: false, delay: 5000, spw: 1, sph: 1, effect: 'straight', links: false, hoverPause: false, opacity: 1, titleSpeed: 0});
		$('#sub-slider').coinslider({width: 392, height: 318, navigation: false, delay: 5000, spw: 1, sph: 1, effect: 'straight', links: false, hoverPause: false, opacity: 1, titleSpeed: 0});
		$('#slider').coinslider({width: 644, height: 316, navigation: true, delay: 5000, spw: 1, sph: 1, effect: 'straight', links: false, hoverPause: true, opacity: 1, titleSpeed: 0});
	});
	
});

$.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);


