$(document).ready(function() {

	// SEARCHBOX
	 $(function() {
		if(!$.support.placeholder) { 
			var active = document.activeElement;
			$(':text').focus(function () {
				if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
					$(this).val('').removeClass('hasPlaceholder');
				}
			}).blur(function () {
				if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
					$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
				}
			});
			$(':text').blur();
			$(active).focus();
			$('form').submit(function () {
				$(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
			});
		}
	});

	// HOME SLIDER
	if ($('#slideShowImageContainer').length > 0 && $('#slideShowNavigation').length > 0) {
		function slideSwitch() {
			activeItem = $('#slideShowImageContainer .item.active');
			activeNavPoint = $('#slideShowNavigation ul li.active');

			if ( activeItem.length == 0 ) activeItem = $('#slideShowImageContainer .item:last');
			if ( activeNavPoint.length == 0 ) activeNavPoint = $('#slideShowNavigation ul li.active');

			nextItem =  activeItem.next().length ? activeItem.next() : $('#slideShowImageContainer div:first');
			nextNavPoint = activeNavPoint.next().length ? activeNavPoint.next() : $('#slideShowNavigation ul li:first');

			activeItem.addClass('last-active');
			activeNavPoint.addClass('last-active');
			
			if(jQuery.support.opacity) {
				nextItem.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000, function() {
					activeItem.removeClass('active last-active');
				});
			} else {
				nextItem.addClass('active');
				activeItem.removeClass('active last-active');
			}
			nextNavPoint.addClass('active')
			activeNavPoint.removeClass('active last-active');
		}
		$(function() {
			setInterval(function() {
				slideSwitch(); 
			}, 6000 );
		});
	}

	// PAGE BACKGROUND
	fromtop = $(document).height() - 819;
	$('#bgStripeBottom').css('top', fromtop + 'px');
	$('#bgStripeBottom').show();

});
