//Start
jQuery(function($) {
	
//Homepage feature slider and tabs
  $(function() {
  $(".slidetabs").tabs(".images > div", {effect: 'fade',fadeInSpeed: "slow",rotate: true}).slideshow({autoplay: true, interval: 6000});
  $("#chained").scrollable({circular: true, mousewheel: true}).navigator().autoscroll({interval: 6000});
  $("ul.tabs").tabs("div.panes > div",{event:'mouseover',current: 'active',effect: "fade" }); 
});

//Overlay	
$(".triggers a[rel]").overlay({effect: 'apple'});					   
  $('.openclose .content').hide();
  $('.openclose h3').click(function() {
    $(this).parent().find('.content').slideToggle("normal");
  }); 
  
//Vertical Sliding
$('.boxgrid.caption').hover(function(){
$(".cover", this).stop().animate({top:'170px'},{queue:false,duration:140});
}, function() {
$(".cover", this).stop().animate({top:'225px'},{queue:false,duration:140});
});	

$('.boxgrid.caption2').hover(function(){
$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:140});
}, function() {
$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:140});
});	

//Gallery 1 - Load First Gallery Image
if($('#gallery .images').length == 1) {
var query = $("#gallery .images a:first").attr("href").split("?")[1];
var alt = $("#gallery .images a:first img").attr("alt");
var url = "/?"+query+" #mainimage";
if($('#gallery .hijax').length == 0) {
$("#mainimage").wrap('<div class="hijax" />');
}
$("#mainimage").empty().html('<img src="/images/preloader.gif" class="preloader" />');
$("#gallery .hijax").load(url,{},function(){ $("#mainimage img").attr("alt", alt)});
$(this).addClass("current");
};

//Ajax Gallery 1
	$("#gallery .images a").click(function(){									  									  
		$("#gallery .images a").removeClass("current");										  
		$(this).addClass("current");	
		if($('#gallery .hijax').length == 0) {
        $("#mainimage").wrap('<div class="hijax" />');
      	}	
		var alt = $(this).find("img").attr("alt");									
		var query = $(this).attr("href").split("?")[1];
		var url = "/?"+query+" #mainimage";
		$("#mainimage").empty().html('<img src="/images/preloader.gif" class="preloader" />');
		$("#gallery .hijax").load(url,{},function(){ $("#mainimage img").attr("alt", alt)});
		return false;
	});

//End
});


