var tartomany = "axe.hu";
var protokoll = "mailto";

function show_hide_layer(layerid) {
	if (layerid != "") {
		v = document.getElementById(layerid).style.visibility;
		if (v != "visible") v = "visible";
			else v = "hidden";
		document.getElementById(layerid).style.visibility = v;
	}
}

function hide_layer(layerid) {
	if (layerid != "") {
		cucc = eval("$(" + layerid + ");");
		cucc.fadeOut("fast");
	} // document.getElementById(layerid).style.visibility = "hidden";
}

function show_layer(layerid) {
	if (layerid != "") {
		cucc = eval("$(" + layerid + ")");
		cucc.fadeIn("fast");
	} // document.getElementById(layerid).style.visibility = "visible";
}


function open_close_layer(layerid) {
	if (layerid != "") {
		d = document.getElementById(layerid).style.display;
		if (d != "block") d = "block";
			else d = "none";
		document.getElementById(layerid).style.display = d;
	}
}

function close_layer(layerid) {
	document.getElementById(layerid).style.display = "none";
}

function open_layer(layerid) {
	document.getElementById(layerid).style.display = "block";
}


function level_kuldes(hova) {
	window.location = protokoll + ":" + hova + "@" + tartomany + "?subject=Informacio kerese";
}

function RightClicker() {
   return false;
}

var opendropdown = "";
var dropintervalid = 0;
function dropdown_open(menuid) {
	if (dropintervalid) clearTimeout(dropintervalid);
	if (opendropdown != "" && opendropdown != menuid) {
		dropdown_hide(opendropdown);
	}
	if (opendropdown != menuid) show_layer(menuid);
	opendropdown = menuid;
}

function dropdown_hide() {
	if (dropintervalid) clearTimeout(dropintervalid);
	hide_layer(opendropdown);
	opendropdown = "";
}

function dropdown_timer() {
	if (dropintervalid) clearTimeout(dropintervalid);
	dropintervalid = setTimeout(dropdown_hide, 1000);
}

function dropdown_timer_stop() {
	if (dropintervalid) clearTimeout(dropintervalid);
}


function getPageSize() {
	var xScroll, yScroll;
	var xScrollPos = document.body.scrollLeft;
	var yScrollPos = document.body.scrollTop;
	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, xScrollPos, yScrollPos);
	return arrayPageSize;
};



function open_image(src, w, h) {
	var arrPageSizes = getPageSize();
	posx = Math.abs(Math.round((arrPageSizes[2]-w)/2));
	// posy = Math.abs(dy + Math.round((arrPageSizes[3]-h)/2));
	posy = arrPageSizes[5] + Math.abs(Math.round(arrPageSizes[3]/2 - h/2));
	out = '<div id="overlaycontainer" style="left: ' + posx + 'px; top: ' + posy + 'px; width: ' + (w+2) + 'px; text-align: center; ">'; // height: ' + (h+20) + 'px;
	out += '<img src="' + src + '" width="' + w + '" height="' + h + '" border="1" alt="" /></div>';
	$('body').append('<div id="blackoverlay" style="display: none; position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 100%;"></div>');
	$('body').append(out);
	
	$('#blackoverlay').css({
		backgroundColor:	'#000000',
		opacity:			0.8,
		width:				arrPageSizes[0],
		height:				arrPageSizes[1]
	}).fadeIn("slow", function() {
		$('#overlaycontainer').fadeIn("fast");
		
	});
	
	$('#blackoverlay').click(function() {
		$('#overlaycontainer').remove();
		$('#blackoverlay').remove();
	});
	
	$('#overlaycontainer').click(function() {
		$('#overlaycontainer').remove();
		$('#blackoverlay').remove();
	});
	
		// $('body').bind('keydown', function(event) {
		$(document).keydown(function(event) {
			if (event.keyCode == 27) {
				$('#slidecontainer').remove();
				$('#blackoverlay').remove();
				$(document).unbind('keydown');
			} 
		});
	
}




function content_float_in() {
	if (document.getElementById("maincontent_left_floater")) $(maincontent_left_floater).animate({left: '0px'}, 500, 'swing');
	if (document.getElementById("maincontent_right_floater")) $(maincontent_right_floater).animate({left: '0px'}, 500, 'swing');
	if (document.getElementById("maincontent_label_bottom_center")) $(maincontent_label_bottom_center).fadeIn(500);
	if (document.getElementById("maincontent_center_floater")) $(maincontent_center_floater).fadeIn(500);
	if (document.getElementById("maincontent_label_top")) $(maincontent_label_top).fadeIn(500);
	if (document.getElementById("maincontent_label_bottom_left")) $(maincontent_label_bottom_left).fadeIn(500);
	if (document.getElementById("maincontent_label_bottom_right")) $(maincontent_label_bottom_right).fadeIn(500);
}

function content_float_out(linkto) {
	if (document.getElementById("maincontent_left_floater"))  {
		dw = $(maincontent_left_floater).width();
		$(maincontent_left_floater).animate({left: '-' + dw + 'px'}, 500, 'swing');
		if (document.getElementById("maincontent_right_floater"))  {
			dw = $(maincontent_right_floater).width();
			$(maincontent_right_floater).animate({left: '' + dw + 'px'}, 500, 'swing');
		}
		if (document.getElementById("maincontent_label_bottom_center")) $(maincontent_label_bottom_center).fadeOut(500);
		if (document.getElementById("maincontent_center_floater")) $(maincontent_center_floater).fadeOut(500);
		if (document.getElementById("maincontent_label_top")) $(maincontent_label_top).fadeOut(500);
		if (document.getElementById("maincontent_label_bottom_left")) $(maincontent_label_bottom_left).fadeOut(500);
		if (document.getElementById("maincontent_label_bottom_right")) $(maincontent_label_bottom_right).fadeOut(500, function(){
			window.location = linkto;
		});
	} else {
		window.location = linkto;
	}
}


function content_loader(url) {
	content_float_out();
	document.getElementById('ajaxframe').src = url;
	content_float_in();
}



