
$(document).ready(function() {
	// footer hack
	var h = $(document).height()-$('.wrapper').height()-17;
	if($.browser.msie) {
		h-=4;
	}
	if(h>40) {
		$('.footer').height(h);
	}


	// set external links
	$("a[href^=http]").each(
	    function(){
	      if(this.href.indexOf(location.hostname) == -1) {
		  	$(this).attr('target','_blank');
	      }
	    }
	);
	var C = {
		overlayOpacity : 0.8,
		titlePosition  : 'over'

	};
	
	$(".tpl a[rel='group']").fancybox(C);
	$('a[target="_fancybox"]').fancybox(C);
	$('a.media').media();
	
	
	if($('.mainMedia .slider img').length>1) {
	    $('.mainMedia .slider').cycle({
			  fx: 'fade',
			  pager:  '.mainMedia .pager'
			 });
	}
	/*
	if ($('#s3slider').attr('id')) {
		$('#s3slider').s3Slider({
			timeOut: 3000
		});
	}
	*/
	// CLEAR INPUT FIELD
	$('.clear_input').each(function() {
		if($(this).val()=='') {
			$(this).val($(this).attr('alt'));
		}
		$(this).focus(function() {
				if($(this).val()==$(this).attr('alt')) {
					$(this).val('');
				}
			})
			.blur(function() {
				if(!$(this).val()) {
					$(this).val($(this).attr('alt'));
				}
			});
	});

	var s = $('.mainMedia img:eq(0)');
	s.hide();
	$('.topBox').css('top',-50);
	var InitBig = function() {
		s.css('visibility','visible');
		
		s.fadeIn(800,function() {
			ShowTop();	
		});
	};
	var ShowTop = function() {
		
				$('.topBox').animate({
					top : '+=64'
				},500,'easeOutBounce');
	};
	if (s.height() > 100) {	InitBig();			}
	else 				  {	s.load(InitBig);	}
	if(!s.attr('src')) {
		ShowTop();	
	}
	
});
