//var __BASE_DIR = '/personal/jnews/';
var __BASE_DIR = '/';

function openEmailFriend(url, id, lang){
	window.open(__BASE_DIR+'sendtofriend.php?&url='+url+'&id='+id+'&lang='+lang, '', 'status=no,scrollbars=yes,resizable=yes,menubar=no,location=no,width=400,height=500');
	return false;
}

function openPrintVersion(url, id, lang){
	window.open(__BASE_DIR+'printable.php?url='+url+'&id='+id+'&lang='+lang, '', 'status=no,scrollbars=yes,toolbar=yes,resizable=yes,menubar=yes,width=600,height=445');
	return false;
}

function openContactUs(){
	if ($('#over_layer').get().length) return;
	
	
	$('<div></div>')
		.attr({ id : 'over_layer' })
		.css({
			position : 'absolute',
			left : '0',
			top : '0',
			width : $(document.body).width() + 'px',
			height : $(document.body).height() + 'px',
			backgroundColor : '#000',
			zIndex : 1000,
			opacity : 0.5
		})
		.appendTo(document.body)
		.click(function(){
			$('#contact_form').css({
				display : 'none'
			});
			$('#over_layer').remove();
		});
		
	$('#contact_form')
		.css({
			left : '50%',
			top : '50%',
			marginLeft : -(Math.floor($('#contact_form').width()/2)) + 'px',
			marginTop : -(Math.floor($('#contact_form').height()/2)) + 'px'
		})
		.slideDown('fast');
}

$(document).ready(function() {
	$(".networks_logo").hover(function(){
		var networkID = $(this).attr("id");
		
		if (!$("#"+networkID+"_tip").length) {
			var smallLogo = $(this).attr("src");
			var bigLogo = smallLogo.substr(0, smallLogo.length-10)+"_big.gif";
			
			var tipContainer = $("<div></div>")
				.attr("id", networkID+"_tip")
				.css({
					top : parseInt($("#"+networkID)[0].offsetTop)-62,
					left : parseInt($("#"+networkID)[0].offsetLeft)-46
				})
				.addClass("network_tip")
				.append($("<img />").attr("src", bigLogo))
				.appendTo("body");
		}
		else {
			$("#"+networkID+"_tip").show();
		}
	}, function(){
		var networkID = $(this).attr("id");
		if ($("#"+networkID+"_tip").length) {
			$("#"+networkID+"_tip").hide();
		}
	});
	
	$(".archive_news_link a").click(function(){
		$(".archive_news_box").toggle();
		return false;
	});
	
	$("#photopage_slideshow_box").cycle({
		timeout : 5000,
		speed : 500
	});
	$("#photopage_slideshow_box .image_box_caption").css("opacity", 0.5);
	
	$('#top_menu_container li').hover(function(){
		$(this).toggleClass('active');
	}, function(){
		$(this).toggleClass('active');
	});
});