$(document).ready(function(){

	$("#carousel.scrollable").scrollable({circular:true, speed:1000}).navigator({navi:'#nav-carousel'}).autoscroll({ autoplay:true, interval:5000 });
	$("#scroller").scrollable({circular: true}).autoscroll({ autoplay: true });
	$("a#single_image").fancybox();

	$("#feeds").fancybox({
	'width'				: 800,
	'height'			: 500,
	'autoScale'			: false,
	'autoDimensions' 		: true, 
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
	'scrolling'			: 'yes'
	});

	$("#searchform").ajaxForm({
		success: function(responseText){
			$.fancybox({
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'content' : responseText
            		});
        	}
	});

	$("#privacyL").fancybox({
	'width'				: 402,
	'height'			: 514,
	'autoScale'			: false,
	'autoDimensions' 		: true, 
	'transitionIn'		: 'fade',
	'transitionOut'		: 'fade',
	'type'				: 'iframe',
	'scrolling'			: 'yes',
      	'hideOnOverlayClick':false,
	'hideOnContentClick':false,
	'showCloseButton'    : false,
	'enableEscapeButton'	: false
	});

	$("#privacyS").fancybox({
	'width'				: 402,
	'height'			: 443,
	'autoScale'			: false,
	'autoDimensions' 		: true, 
	'transitionIn'		: 'fade',
	'transitionOut'		: 'fade',
	'type'				: 'iframe',
	'scrolling'			: 'yes',
      	'hideOnOverlayClick':false,
	'hideOnContentClick':false,
	'showCloseButton'    : true
	});

	$("#blogg").fancybox({
	'width'				: 800,
	'height'			: 500,
	'autoScale'			: false,
	'autoDimensions' 		: true, 
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
	'scrolling'			: 'yes'
	});
	
	$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	$('.tabContainer .tabList:not(.inactiveTabList) div').click(function() {
		$(this).parent('.tabList').find('div').removeClass('panelButtonOn').addClass('panelButtonOff');
		$(this).parents('.tabContainer').find('.panelBar .panelBox').hide();
		$(this).removeClass('panelButtonOff').addClass('panelButtonOn');
		$(this).parents('.tabContainer').find('.panelBar'+this.id+'Panel.panelBox').show();
		$(this).find('a').blur();
		return false;
	});

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li.active").show(); //Activate first tab
	$(".tab_content.active").show(); //Show first tab content


	$('#map').prepend('<span id="loader">Loading ...</span>').addClass('script'); 
	$('#eu').find('li').hide();

	var mapUrl=$('#eu').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");
	var mapUrl='/lib/img/obj_map.png'; 
	var mapImg=new Image();
	  $(mapImg).load(function(){
	   $('#loader').fadeOut(); 
	   $('#map').find('li').fadeIn(); 
	   $('#eu').find('a').prepend('<span class="map" />');
	   for(var i=1;i<20;i++){ 
	    $('#eu .map').append('<span class="s'+i+'" />'); }
	    if($('#map').hasClass('tooltip')){
	     $('#eu').children('li').each(function(){ 
	     var tooltipName=$(this).children('a').text(); 
	     var tooltipLeft=$('.tt').outerWidth()/-2; 
	     var tooltipTop=$('.tt').outerHeight()/-2; 
	     $(this).append('<span class="tt">'+tooltipName+'</span>'); 
	     $('.tt').css({'display':'none','margin-left':tooltipLeft,'margin-top':tooltipTop});});
	     $('#eu li').hover(function(){
	     $(this).children(".tt:visible").hide(); 
	     $(this).children(".tt").show(); 
	     $(this).children("a").removeAttr('title');},function(){
	     $(this).children(".tt").hide();
         });
      }
   })
    .error(function(){
     $('#loader').text('No map!'); 
     $('#eu').find('span').hide(); 
     $('#map,#eu').css({'height':'auto','left':'0','margin':'0 auto'});
    }).attr('src',mapUrl);
  var loaderPos=$('#loader').outerWidth()/-2; 
  $('#loader').css('margin-left',loaderPos);
  $('#eu').children('li').click(function(){window.location.href=$(this).children('a').attr('href');
  });

   $('#region').find('a').hover(function(){
     var linkid=$(this).attr('class');
     $('#map .active').removeClass();
     $('#map').find('.tt:visible').hide();
     $('#'+linkid).children('a').addClass('active');
     $('#'+linkid).find('.tt').show();
    },function(){
      $('#map .active').removeClass();
      $('#map').find('.tt:visible').hide();
     });

	$('table tr th').mouseover(function() {
	$('#tooltip').text($(this).attr('title'));
	});
});
	$('#eu').find('li').hide();

$(window).load(function() {
	$('#slider div').nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
			slices:1,
			animSpeed:1000,
			pauseTime:5000,
			directionNav:false, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:false, //1,2,3...
			keyboardNav:false, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
		    controlNavThumbs:false, //Use thumbnails for Control Nav			
			manualAdvance:false, //Force manual transitions
			captionOpacity:1 //Universal caption opacity
		});
	$('#productslider div').nivoSlider({
			effect:'random', //Specify sets like: 'fold,fade,sliceDown'
			slices:1,
			animSpeed:1500,
			pauseTime:5000,
			directionNav:false, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:false, //1,2,3...
			keyboardNav:false, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
		    controlNavThumbs:false, //Use thumbnails for Control Nav			
			manualAdvance:false, //Force manual transitions
			captionOpacity:1 //Universal caption opacity
		});
	$('#serviceslider div').nivoSlider({
			effect:'random', //Specify sets like: 'fold,fade,sliceDown'
			slices:1,
			animSpeed:1500,
			pauseTime:5000,
			directionNav:false, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:false, //1,2,3...
			keyboardNav:false, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
		    controlNavThumbs:false, //Use thumbnails for Control Nav			
			manualAdvance:false, //Force manual transitions
			captionOpacity:1 //Universal caption opacity
		});
});

function PClose(url){
$.fancybox.close();    
window.location = url;
}

function applyDefaultValue(elem, val) {
	elem.value = val;
	elem.onfocus = function() {
		if(this.value == val) {
		this.style.color = '';
		this.value = ''; //On focus, make blank
		}
	}
	elem.onblur = function() {
		if(this.value == '') {
		this.value = val; //If it's not in focus, use declared value
		}
	}
}

