// JavaScript Document
/*---------------------------------------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');
    });
});




$(document).ready(function(){
	$('.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');
	})
});


/**********************Accordion********************/
function initMenu() {
	$('.accordion li a.acchead:first').addClass('acc-head-open');
	$('.accordion li.on ul.sublevelmenu:first').show();
	$('.accordion li a.acchead').click(
		function() {
			var checkElement = $(this).parent().find('ul.sublevelmenu');
			//alert(checkElement);
			//var DivHeight = checkElement.height();
			//checkElement.css('height', DivHeight);
			if((checkElement.is('ul.sublevelmenu')) && (checkElement.is(':visible'))) {
				checkElement.slideUp(500);
				$(this).removeClass('on');
				$(this).parent().removeClass('on');
			//return false;
			}
			if((checkElement.is('ul.sublevelmenu')) && (!checkElement.is(':visible'))) {
			$('.accordion li ul.sublevelmenu:visible').slideUp(500);
			//alert(DivHeight)
			checkElement.slideDown(500).addClass('acc-body-visible');
			$('.accordion li a.on').removeClass('on');
			$('.accordion li.on').removeClass('on');
			$(this).addClass('on');
			$(this).parent().addClass('on');
			return false;
		}
	});
}
$(document).ready(function() {
	initMenu();
});


/********************************** Slide Show ******************************************/
function slideSwitch(id) {
    var $active = $('#' +id+' IMG.active');
    if ( $active.length == 0 ) $active = $('#' +id+' IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#' +id+' IMG:first');
    // uncomment the 3 lines below to pull the images in random order
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
$(function() {
    setInterval( "slideSwitch('slideshow1')", 3000 );
});

/*******************Addthis********************/
function sharethis(href, encoding) {
	var link;
	if (encoding == null)
		link = href.replace('URL', encodeURIComponent(document.location.toString()));
	else
	link = href.replace('URL', document.location.toString());
	link = link.replace('TITEL', document.title);
	window.open(link, 'share');
}

$(document).ready(function () {
    $(".sharelayer").hide();
    $(".followlayer").hide();

    jQuery(".sharing").hover(
    function () {
        $(".sharelayer,.followlayer").fadeIn(100);

    },
    function () {
        $(".sharelayer,.followlayer").fadeOut(100);
    }
    );

});
