// JavaScript Document
var min=12;
var max=24;
function changeFontSize(_chngValue) {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
	  var s =p[i].style.fontSize?parseInt(p[i].style.fontSize.replace("px","")):min;
	  if(_chngValue=="higher"){
		if(s!=max)s += 1;
	  }
	  else if(_chngValue=="lower"){
		if(s!=min)s -= 1;
	  }
	  p[i].style.fontSize = s+"px";
   }
}	
$(function() {
	$(".l-news").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: 1,
		auto:5000,
		speed:500,
		btnNext: ".next",
        btnPrev: ".prev"
	});
});

this.vtip = function() {    
    this.xOffset = -10; // x distance from mouse
    this.yOffset = 10; // y distance from mouse       
    $(".vtip").unbind().hover(    
        function(e) {
            this.t = this.title;
            this.title = ''; 
            this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);
            $('body').append( '<p id="vtip" style="width:250px">' + this.t + '</p>' );
            $('p#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
        },
        function() {
            this.title = this.t;
            $("p#vtip").fadeOut("slow").remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
        }
    );            
};

var currentID = 1;
var newsLoop = true;
function changeNews(targetID){
	currentID = targetID;
	$( '.homeFirstNewsItem' ).fadeOut();
	$( "#homeFirst-"+targetID ).fadeIn();
	
	$( ".firstNewsCircleIcons" ).css("background-color","#EFEFEF");
	$( ".firstNewsCircleIcons" ).css("width","5px");
	$( ".firstNewsCircleIcons" ).css("height","5px");
	$( ".firstNewsCircleIcons" ).css("margin-top","3px");
	
	$( "#homeFirstIcon-"+targetID ).css("background-color","#CCC");
	$( "#homeFirstIcon-"+targetID ).css("width","10px");
	$( "#homeFirstIcon-"+targetID ).css("height","10px");
	$( "#homeFirstIcon-"+targetID ).css("margin-top","0");
}
setInterval(function() {
	if (currentID < 5){
		newID = currentID + 1;
	} else {
		newID = 1
	}
	if ( newsLoop ){
		changeNews(newID);
	}
}, 6000)


jQuery(document).ready(function($){	

	changeNews(1);								
  	$( '.firstNewsCircleIcons' ).click( function() {
		targetID = $(this).attr( 'rel' );
		changeNews(targetID);
		newsLoop = false;
	} );
	$(".links-items").hover('out', function(){
		$(".links-items").slideUp("fast");
													
	});	
	$(".share-b").hover('out', function(){
		$(".links-items").slideUp("fast");
													
	});
  	$('.share-b' ).click( function() {
		if ($(".links-items").is(":hidden")) {
		$(".links-items").slideDown("fast");
		} else {
		$(".links-items").slideUp("fast");
		}
	} );
  	$('.email-b' ).click( function() {
		if ($(".emailThis").is(":hidden")) {
		$(".emailThis").fadeIn("fast");
		} else {
		$(".emailThis").fadeOut("fast");
		}
	} );	
	$("div.print-b").mouseover(function (){
	  $(this).addClass("imgHover-print");
	});
	$("div.print-b").mouseout(function (){
	  $(this).removeClass("imgHover-print");
	});
	$("div.email-b").mouseover(function (){
	  $(this).addClass("imgHover-email");
	});
	$("div.email-b").mouseout(function (){
	  $(this).removeClass("imgHover-email");
	});	
	$("div.share-b").mouseover(function (){
	  $(this).addClass("imgHover-share");
	});
	$("div.share-b").mouseout(function (){
	  $(this).removeClass("imgHover-share");
	});		
	vtip();
})





		$(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').show();
			
			$('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('div.tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();
		});
