$(document).ready(function(){
	$('.mainMenuHolder li:last').addClass('removeBg');
	//drop menu selector
	$('.dropmenu').find('a:last').each(function(){
		$(this).addClass('borderNone');
	})
});


/*___________________________________________Homepage Slider____________________________________________*/
var photo_width = 1680;
var active_index = -1;

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;
	$('.photosliding').removeClass('btnslideractive');
	$(sliderbtnid).addClass('btnslideractive');
	$("#photos_holder .photosliding").stop(true, true).animate({ opacity: 0 }, 500).css('z-index',0);
	$("#photos_holder .btnslideractive").stop(true, true).animate({ opacity: 1 }, 500).css('z-index',1)
	$('.btnslider').removeClass('activelink');
	$(clickedLink).addClass('activelink');
	active_index = index;
	if(typeof auto_timeout != "undefined") clearTimeout(auto_timeout);
	auto_timeout = setTimeout(goNext, 5000);
}

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);
}

/*______________________________________End Home Page Slider_______________________________________*/

$(window).resize(centerActivePhoto);
$(document).ready(function () {
	centerActivePhoto();
	$('#btnsliderid1').addClass('btnslideractive');
	auto_timeout = setTimeout(goNext, 5000);
})

/**************Accordion****************/
$(document).ready(function() {
		$('.accTab').hide();
		$('.accNav').click(function(){
			$('.accTab').slideUp();
			$('.accNav').removeClass('activeNav');
			$(this).addClass('activeNav');
			
			if($(this).next('.accTab').css('display') == 'block'){
				$(this).next('.accTab').slideUp();
				$(this).removeClass('activeNav');
				}else{
				$(this).next('.accTab').slideDown();
				$(this).addClass('activeNav');	
				}/**/
				return false;
		})
	})
/****************************Drop Menu***************************/

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}



/***************Tool Tip******************************/
$(document).ready(function(){
	 $(".tooltipHolder").hide();
	 $(".item").click(function(){
	 stringref = $(this).attr("href").split('#')[1];
	 $('.tooltipHolder:not(#'+stringref+')').hide();
	 $('.tooltipHolder#' + stringref).fadeIn();
	 return false;
	 });
	 $(".tooltipClose a").click(function(){
		$(".tooltipHolder").fadeOut();
	})
});

$(document).ready(function () {
    $(".newsNode").hide();
    var getHashValue = window.location.hash
    if (!getHashValue) {
        $('.newsNode:first').show();
        $('.newsBtn:first').addClass("active");
    } else {
        $(getHashValue).show();
        $('.newsBtn' + getHashValue + '1').addClass("active");
    }
    $(".newsBtn").click(function () {
        $(".newsBtn").removeClass("active");
        $(this).addClass("active");
        $(".newsNode").slideUp();
        var content_show = $(this).attr("title");
        $("#" + content_show).slideDown();
    });
});
