var tartomany = "gmail.com";
var protokoll = "mailto";

function open_image(src, w, h) {
	imageview = window.open("", "imageview", "width=" + w + ",height=" + h);
	imageview.moveTo(Math.round((screen.width-w)/2), Math.round((screen.height-h)/2));
	imageview.document.open();
	imageview.document.write('<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">');
	imageview.document.write('<html><head><title>Kép megtekintése</title><link rel="stylesheet" type="text/css" href="/style.css" /><meta http-equiv="Content-type" content="text/html; charset=iso-8859-2" /><meta http-equiv="author" name="author" content="Mile Informatika - http://www.mile.hu/" /></head>');
	imageview.document.write('<body bgcolor="#000000" text="silver" link="orange" alink="yellow" vlink="orange" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >');
	imageview.document.write('<a href="#" onClick="window.close();" ><img src="' + src + '" width="' + w + '" height="' + h + '" border="0" /></a></body></html>');
	imageview.document.close();
	// imageview.document.oncontextmenu = RightClicker;
	
}

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;
}

function RightClicker() {
   return false;
}

function fmenu_preselect(menuid) {
	if (menuid) {
		eval("kepoff" + menuid + ".src = \"images/fmenu" + menuid + ".2.gif\";");
		document.getElementById("kep" + menuid).src = "images/fmenu" + menuid + ".2.gif";
	}
}


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_gallery(itemid) {
	var arrPageSizes = getPageSize();
	dy = arrPageSizes[1] - arrPageSizes[3];
	w = 800;
	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));
	posy = arrPageSizes[5] + 30;
	out = '<div id="overlaycontainer" style="left: ' + posx + 'px; top: ' + posy + 'px; width: ' + w + 'px; ">'; // height: ' + (h+20) + 'px;
	out += '<div align="center"><br /><br /><br /><br /><img src="/images/loading.gif" width="36" height="36" border="0" alt="" /><br /><br /><br /><br /></div></div>';
	$('body').append('<div id="blackoverlay" style="display: none; position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 500px;"></div>');
	$('body').append(out);
	
	$('#blackoverlay').css({
		backgroundColor:	'#000000',
		opacity:			0.8,
		width:				arrPageSizes[0],
		height:				arrPageSizes[1]
	}).fadeIn("slow", function() {
		$('#overlaycontainer').fadeIn("slow", function() {
			document.getElementById('ajaxframe').src = '/galeria_loader.php?id=' + itemid;
		});
		
	
	});
	
	$('#blackoverlay').click(function() {
		$('#overlaycontainer').remove();
		$('#blackoverlay').remove();
	});
	
	/*
	$('#overlaycontainer').click(function() {
		$('#overlaycontainer').remove();
		$('#blackoverlay').remove();
	});
	*/
}



// document.oncontextmenu = RightClicker;