/*//////////////////////////////////////////////////////////////////////////////////////////////////////////
		CUSTOM JAVASCRIPT EFFECTS  
//////////////////////////////////////////////////////////////////////////////////////////////////////////*/



/****************************************************************************
	BANNER - Customising the home page banner 
****************************************************************************/

jQuery(function($) {
	
	var timer;
	var container = '#BANNER '; /* ID name of the DIV */
	var slides = 7; /* Number of slides */
	
	var i=1;
	var next;
	
	function button(id)
	{
		$(container+'ul.slides li').hide();
		$(container+'ul.slides li.slide'+id).fadeIn(500);
		$(container+'ul.buttons li').removeClass('active');
		$(container+'ul.buttons li.button'+id).addClass('active');
		
		if(id == slides){
  			next = 1;
  		}else{
  			next = parseInt(id)+1;
  		}
		
		clearTimeout(timer);
		timer = setTimeout(function(){
			$(container+'ul.slides li').fadeOut(1000);
			setTimeout(function(){
				button(next);
			}, 1000);
		}, 7000);
		
		
		return false;
	}
	
	function onLoad()
	{
		$(container+'ul.slides li').hide();
		$(container+'ul.slides li.slide1').fadeIn(500);
		$(container+'ul.buttons li.button1').addClass('active');
		
		clearTimeout(timer);
		timer = setTimeout(function(){
			$(container+'ul.slides li').fadeOut(1000);
			setTimeout(function(){
				button(2);
			}, 1000);
		}, 7000);
	}
	
	/* slide indicator buttons */
	while(i <= slides)
	{
		$(container+'.button'+i+' a').click(function(){
			var value = $(this).parent().attr("class").substr(6);
			button(value);
			return false;
		});
  		
		i++;
	}
  	
	onLoad();

});

























/****************************************************************************
	SCROLL TO TOP
****************************************************************************/

$(function ()
{
    $.fn.scrollToTop = function (options)
    {
        if (options)
        {
            var speed = options.speed;
            var ease = options.ease;
        }
        else
        {
            var speed = "slow";
            var ease = "jswing";
        }
        var scrollDiv = $(this);
        $(this).hide().removeAttr("href");
        if ($(window).scrollTop() != "0")
        {
            $(this).fadeIn("slow");
        }
        $(window).scroll(function ()
        {
            if ($(window).scrollTop() == "0")
            {
                $(scrollDiv).fadeOut("slow");
            }
            else
            {
                $(scrollDiv).fadeIn("slow");
            }
        });
        $(this).click(function (event)
        {
            $("html, body").animate(
            {
               scrollTop: "0px"
            }, speed, ease);
        });
    }
}); 


/* --- ADDITIONAL CODE FOR 'SCROLL TO TOP' EFFECT --- */

$(function() {
	$(".toTop").scrollToTop({speed:1200,ease:"easeInOutCubic"});
});












/****************************************************************************
	TOGGLE DIV
****************************************************************************/

/* --- SIMPLE TOGGLE JAVASCRIPT --- */

jQuery(document).ready(function(){
	jQuery(".openpanel").click(function(){
	  jQuery(".toggle").slideToggle(300);
		jQuery(this).toggleClass("active"); return false;
	});
});



jQuery(document).ready(function(){
	jQuery(".quickjump").click(function(){
	  jQuery(".quickjump-menu").slideToggle(200);
		jQuery(this).toggleClass("active"); return false;
	});
});



/* --- ADVANCED TOGGLE JAVASCRIPT  --- */

$(document).ready(function() { 
	$(".desc").hide();  
	$("h3.open-close").click(function(){  
	
	if ($(this).is(".current"))
		{
			$(this).removeClass("current");
			$(this).next(".desc").slideUp(400);
		}
	
	else
		{
			$(".desc").slideUp(400);
			$("h3.open-close").removeClass("current");
	  
			$(this).addClass("current");
			$(this).next(".desc").slideDown(400);
		}
	});
});










/***************************************************
		TABS JAVASCRIPT
***************************************************/

jQuery(document).ready(function($){
	//Default Action
	$(".tab-content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab-content:first").show(); //Show first tab content
		
			
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab-content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	
	
	
	
	// Content switcher tabs
	$(".switch-content").hide(); //Hide all content
	$("ul.tab-switcher li:first").addClass("active").show(); //Activate first tab
	$(".switch-content:first").show(); //Show first tab content
	
	
	//On Click Event for Content Switcher
	$("ul.tab-switcher li").click(function() {
		$("ul.tab-switcher li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".switch-content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	
	//On Click Event for Content Switcher
	$(".next-slide").click(function() {
		$(".switch-content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

})








/***************************************************
		STICKY DIV JAVASCRIPT
***************************************************/
$(function() {
	var offset = $("#stickydiv").offset();
	var topPadding = 20;
	$(window).scroll(function() {
		if ($(window).scrollTop() > offset.top) {
			$("#stickydiv").stop().animate({
				marginTop: $(window).scrollTop() - offset.top + topPadding
			});
		} else {
			$("#stickydiv").stop().animate({
				marginTop: 0
			});
		};
	});
});













/***************************************************
		WINDOW SLIDES - Homepage
***************************************************/

 $(document).ready(function () {
   //find div
	var div = $('#slide-scroll-window');
	//find ul width
	var liNum = $(div).find('#windowslides').children('div.slide-content-block').length;
	var speed = 500;
	var containerWidth = 960;
	var itemWidth = 470;
	
	$('#scroll-prev-btn').click(function(e){	
			//alert($(div).scrollLeft()+containerWidth);
			//alert(liNum*itemWidth);
		  if(($(div).scrollLeft()+containerWidth)<(liNum*itemWidth)){
			 $(div).animate({
				scrollLeft: '+='+containerWidth
			  }, speed);
		  }
	});	
	
	$('#scroll-next-btn').click(function(e){	
		if(($(div).scrollLeft()+containerWidth)>containerWidth){
				$(div).animate({
				scrollLeft: '-='+containerWidth
			  }, speed);
		}
	});
	
});




/***************************************************
		LIGHT BOX CUSTOM
***************************************************/

$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook',slideshow:5000, autoplay_slideshow:false});
});


























