// JavaScript Document
$(document).ready(function(){
	$('.breadcrumbs a:last').addClass('last');
	$('#footerbtn').click(function(){
		$('.hiddenfooter').slideToggle();
	})
})





/*---------------------------------------DropDownMenu-------------------------------------------*/
$(function(){
    $("ul.dropdown li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    });
});

function rmvloader(a) {
    a.style.visibility = 'visible';
    $(this).parent().removeClass('loading');
}



$(document).ready(function(){
	//$('a[rel=colorboxitem]').colorbox();
	$('.repRightLinks li:last').addClass('noborder');
	$('.firstLevelLi:last').addClass('lastlist');
	$('ul.sub_menu').each(function(){
		$(this).find('li:last').addClass('nobg');
	});
	//$('li.firstLevelLi:last').addClass('nobg');
	$('.hpHighlighted').hover(
		function(){
			$(this).addClass('switchBg');
		},
		function(){
			$(this).removeClass('switchBg');
	});
	$('.ui-tabs-nav-item').hover(
		function(){
			$(this).addClass('switchBg');
		},
		function(){
			$(this).removeClass('switchBg');
	});
});


/*___________________________________________Homepage Slider____________________________________________*/
        var photo_width = 1680;
        var active_index = 0;

        function showPhoto(clickedLink, index, sliderbtnid) {
            var win_width = $(window).width();
            var win_diff = (photo_width - win_width) / 2;
            var pos = -(index * photo_width) - win_diff;
            $("#photos_holder .photosliding").stop(true, true).animate({ opacity: 0 }, 1000);
            $("#photos_holder .btnslideractive").stop(true, true).animate({ opacity: 1 }, 1000);
			$('.btnslider').removeClass('activelink');
			$(clickedLink).addClass('activelink');
            $('.photosliding').removeClass('btnslideractive');
            $(sliderbtnid).addClass('btnslideractive');
            active_index = index;
			if(typeof auto_timeout != "undefined") clearTimeout(auto_timeout);
			auto_timeout = setTimeout(goNext, 8000);
        }

        function centerActivePhoto(index) {
            //if (typeof active_index != "number") return;
            var win_width = $(window).width();
            var win_diff = (photo_width - win_width) / 2;
            //var pos = -(active_index * photo_width) - win_diff;
            $("#photos_holder").stop(true, true).css({ left: -((photo_width - win_width)/2) });
        }
		
		
		
			
		var auto_timeout;
		function goNext(){
			var last_image = $('.absolutesliderbtns a:last').index();
			var first_image = $('.absolutesliderbtns a:first').index();
			var active_item = $('div.btnslideractive').index();
			var next_item = active_item + 1;
			if(next_item != last_image + 1){
				$('.absolutesliderbtns a:eq('+next_item+')').click();
			}else{
				$('.absolutesliderbtns a:eq(0)').click();
			}
		}
		function goPrev(){
			var last_image = $('.absolutesliderbtns a:last').index();
			var first_image = $('.absolutesliderbtns a:first').index();
			var active_item = $('div.btnslideractive').index();
			var prev_item = active_item - 1;
			
			if(prev_item != first_image - 1){
				$('.absolutesliderbtns a:eq('+prev_item+')').click();
			}else{
				$('.absolutesliderbtns a:eq('+last_image+')').click();
			}		
			//showPhoto(next_item,'#btnsliderid'&&next_item);
			//$("#photos_holder").stop(true, true).animate({ left: pos }, 1000);
		}


        $(window).resize(centerActivePhoto);
        $(document).ready(function () {
            centerActivePhoto();
            $('#btnsliderid1').addClass('btnslideractive');
        })
		
		
		
/*___________________________________homepage fade images____________________________________*/


