function ___getPageSize() {
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = window.innerWidth + window.scrollMaxX;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
if(document.documentElement.clientWidth){
windowWidth = document.documentElement.clientWidth;
} else {
windowWidth = self.innerWidth;
}
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = xScroll;
} else {
pageWidth = windowWidth;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
return arrayPageSize;
};

$(document).ready(function() { 
	$("ul.line li:last").addClass("last");
	
	$(".news_str a:first").show();
	
	$(".newsline .next").click(function(){
		var nextimg = $(".news_str a:visible").next();
		if ($(nextimg).is("a")) {
			$(".news_str a").hide();
			$(nextimg).show();	
		} else {
			$(".news_str a").hide();
			$(".news_str a:first").show();	
		}
		return false;
	});
	
	$(".newsline .prev").click(function(){
		var previmg = $(".news_str a:visible").prev();
		if ($(previmg).is("a")) {
			$(".news_str a").hide();
			$(previmg).show();	
		} else {
			$(".news_str a").hide();
			$(".news_str a:last").show();	
		}
		return false;
	});
	
	$(".news_column h2 a").hover(function(){
		$(this).parent().children("a").addClass("jshover");
	}, function(){
		$(this).parent().children("a").removeClass("jshover");
	});

	$(".main_news_desc h1 a").hover(function(){
		$(this).parent().children("a").addClass("jshovermain");
	}, function(){
		$(this).parent().children("a").removeClass("jshovermain");
	});
	
	$(".main_about_img img.about_pic:first").show();
	
	$(".main_about_img .listing a#about_next").click(function(){
		var nextimg = $(".main_about_img img.about_pic:visible").next();
		if ($(nextimg).is("img")) {
			$(".main_about_img img.about_pic").hide();
			$(nextimg).show();
			var numtxt = $("#about_num").html();
			var num = parseInt(numtxt) + 1;
			$("#about_num").html(num);
		} else {
			$(".main_about_img img.about_pic").hide();
			$(".main_about_img img.about_pic:first").show();
			$("#about_num").html("1");	
		}
		return false;
	});
	
	$(".main_about_img .listing a#about_prev").click(function(){
		var previmg = $(".main_about_img img.about_pic:visible").prev();
		if ($(previmg).is("img")) {
			$(".main_about_img img.about_pic").hide();
			$(previmg).show();
			var numtxt = $("#about_num").html();
			var num = parseInt(numtxt) - 1;
			$("#about_num").html(num);
		} else {
			$(".main_about_img img.about_pic").hide();
			$(".main_about_img img.about_pic:last").show();
			var numtxt = $("#all_num").html();
			$("#about_num").html(numtxt);	
		}
		return false;
	});
	
	$(".ajax_menu_link").click(function(){
		$(".ajax_menu_link").removeClass("current");
		var url = $(this).attr("href");
		$('.menu_ajax').slideUp(500);
                $('.menu_ajax').empty();
		$.post(url, function(data) {
		  $('.menu_ajax').html(data);
                  $('.menu_ajax').slideDown(500);
		});
		$(this).addClass("current");
		return false;
	});
	
	function positioningShade() {
		var arrPageSizes = ___getPageSize();
		var body_height = arrPageSizes[1];
		var screen_height = arrPageSizes[3];
		var topoffset = $(window).scrollTop();
		$('.shade').height(body_height);

		var marginleft = (arrPageSizes[0]-$('.photo_detail').width())/2 + 'px';
		if($.browser.msie && $.browser.version.substr(0,3)!="8.0" && $.browser.version.substr(0,3)!="9.0"){
			$('.photo_detail').css('left', marginleft);
		} else {
			$('.photo_detail').css('margin-left', marginleft);
		}
		var margintopnopx = ((screen_height-$('.photo_detail').height())/2) + topoffset;
		if (margintopnopx < 0) {
		  margintopnopx = 100;
		  var all_height = $('.photo_detail').height() + 120;
		  //$('.shade').height(all_height);
			
		}
		var margintop = margintopnopx + 'px';				
		$('.photo_detail').css('margin-top', margintop);
	}
	
	$(".detail_photo_link").click(function(){
		var totalstr = $('#count_p').attr("value");
		var currentstr = $(this).attr("rel");
		var total = parseInt(totalstr);
		var current = parseInt(currentstr);
		var img = $(this).attr("href");
		$('#photo_num').html(currentstr);
		$('#photo_total').html(total);
		$('#bigimage').attr("src", img);
        $("#fotoscounter").show();
		$('#bigimage').load(function(){
			$('.shade').show();
			positioningShade();
		});
		return false;
	});

	$(".top_nav a:last, #sheme").click(function(){
		var img = "/plan-jagger-final.png";
		$('#bigimage').attr("src", img);
        $("#fotoscounter").hide();
		$('#bigimage').load(function(){
			$('.shade').show();
			positioningShade();
		});
		return false;
	});
	
	$("#close_photo").click(function(){
		$('.shade').hide();
		$('#bigimage').attr("src", "");
		return false;
	});
	
	$(".show_nav #prev").click(function(){
		var totalstr = $('#photo_total').html();
		var currentstr = $('#photo_num').html();
		var total = parseInt(totalstr);
		var prev = parseInt(currentstr)-1;
		var previmg = $(".detail_photo_link[rel='"+prev+"']");
		if ($(previmg).is("a")) {
			var img = $(previmg).attr("href");
			$('#bigimage').attr("src", img);
			$('#bigimage').load(function(){
				positioningShade();
			});
			$('#photo_num').html(prev);
		} else {
			previmg = $(".detail_photo_link[rel='"+total+"']");
			var img = $(previmg).attr("href");
			$('#bigimage').attr("src", img);
			$('#bigimage').load(function(){
				positioningShade();
			});
			var num = total;
			$('#photo_num').html(num);	
		}
		return false;	
	});
	
	$(".show_nav #next").click(function(){
		var totalstr = $('#photo_total').html();
		var currentstr = $('#photo_num').html();
		var total = parseInt(totalstr);
		var next = parseInt(currentstr)+1;
		var nextimg = $(".detail_photo_link[rel='"+next+"']");
		if ($(nextimg).is("a")) {
			var img = $(nextimg).attr("href");
			$('#bigimage').attr("src", img);
			$('#bigimage').load(function(){
				positioningShade();
			});
			$('#photo_num').html(next);
		} else {
			nextimg = $(".detail_photo_link[rel='1']");
			var img = $(nextimg).attr("href");
			$('#bigimage').attr("src", img);
			$('#bigimage').load(function(){
				positioningShade();
			});
			var num = 1;
			$('#photo_num').html(num);	
		}
		return false;	
	});

        $("#bigimage").click(function(){
		var totalstr = $('#photo_total').html();
		var currentstr = $('#photo_num').html();
		var total = parseInt(totalstr);
		var next = parseInt(currentstr)+1;
		var nextimg = $(".detail_photo_link[rel='"+next+"']");
		if ($(nextimg).is("a")) {
			var img = $(nextimg).attr("href");
			$('#bigimage').attr("src", img);
			$('#bigimage').load(function(){
				positioningShade();
			});
			$('#photo_num').html(next);
		} else {
			nextimg = $(".detail_photo_link[rel='1']");
			var img = $(nextimg).attr("href");
			$('#bigimage').attr("src", img);
			$('#bigimage').load(function(){
				positioningShade();
			});
			var num = 1;
			$('#photo_num').html(num);	
		}
		return false;	
	});
	
	$('.eventblock').mouseover(function() {
	  $('.eventblock .detail').hide();
	  $(this).children(".detail").show();
	});
	$('.detail').mouseleave(function() {
	  $(this).hide();
	});
	
	$(".organize_list p:first a").addClass("current");
	$(".organize_block:first").show();
	
	$(".organize_list p a").click(function(){
		$(".organize_list p a").removeClass("current");
		$(this).addClass("current");
		var showid = $(this).attr("href");
		$(".organize_block:visible").hide();
		$(showid).show();
		return false;
	});
	
	var cap1 = Math.floor(Math.random()*50);
	var cap2 = Math.floor(Math.random()*50);
	var capsum = cap1+cap2;
	$(".ticket_order_form #capcha_label").html("Ρσμμΰ: "+cap1+"+"+cap2+"=");
	$(".ticket_order_form #capch_prov").attr("value", capsum);

});
