$(function(){

	$('.protectedsites').click(function (e) {
		
		var docheight = $(document).height();
		var docwidth = $(document).width();
		
		
		var overlay = "<div id='trans-overlay' style='position:absolute; height:" + docheight + "px; width:" + docwidth + "px;'></div>";
		if($("#trans-overlay").length == 0){
			$('body').prepend(overlay);
		}
		else{}
		

		var popup = $('#pop-tabs');
		$(popup).center();

		popup.css({
			'z-index' : 100,                      
			'focus' : true
		});

		$(popup).show();

		return false;
	});


	$.fn.center = function () {
		this.css("position","absolute");
		this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
		this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
		return this;
	};

	/* FUNCTIONS TO CLOSE THE WINDOW, ON CLICKING THE x.png AND USING THE ESC KEY */
	$('.close-link').click(function (e) {
		var popup = $('#pop-tabs');
		var overlay = $('#trans-overlay');		
		popup.hide();
		overlay.remove();
		return false;
	});


	$(document).keyup(function(event) {

     if (event.keyCode == 27) {
		var popup = $('#pop-tabs');
		var overlay = $('#trans-overlay');		
		popup.hide();
		overlay.remove();

     }

    });
	
	/** CUSTOM TABS **/
	$(function () {
		var tabContainers = $('div.tabs > div');
		
		$('div.tabs ul.tabNavigation a').click(function () {
			tabContainers.hide().filter(this.hash).show();
			
			$('div.tabs ul.tabNavigation a').removeClass('selected');
			$('div.tabs ul.tabNavigation li').removeClass('tab-selected');

			$(this).parent().addClass('tab-selected');
			$(this).addClass('selected');
			
			return false;
		}).filter(':first').click();
	});

})