var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;	
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "block";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "none";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function fotoCon(id, width, winheight, description){
	fotowin = window.open("", "foto", "width =" +width +",height =" + winheight +",location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=no");
	fotowin.document.write("<html><head><title>foto</title></head><body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\"><img src=\"/mma_bin.php?src=mid&amp;id=" + id + "&amp;table=users_bin\"/><br clear=\"all\"><div style=\"color: #333333; font-size:60%; margin-left :10px; margin-right :10px; margin-top :5px; font-family: Arial;  align=\"justify\">"+ description +"</div></boby></html>");
	fotowin.document.close();
	document.body.onfocus = closeFotoWin;
}

function foto(id, width, winheight, description){
	fotowin = window.open("", "foto", "width =" +width +",height =" + winheight +",location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=no");
	fotowin.document.write("<html><head><title>foto</title></head><body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\"><img src=\"/util/bin.php?src=mid&amp;id=" + id + "&amp;table=users_bin\"/><br clear=\"all\"><div style=\"color: #333333; font-size:60%; margin-left :10px; margin-right :10px; margin-top :5px; font-family: Arial;  align=\"justify\">"+ description +"</div></boby></html>");
	fotowin.document.close();
	document.body.onfocus = closeFotoWin;
}

function fotoCat(idShow, idFoto, width, height, table){
	if(height < 514){
		var height = parseInt(height)+50;	
	}else{
		var height = 514;
	}

	window.open("/gallery.php?idshow="+idShow+"&idfoto="+idFoto+"&width="+width+"&table="+table, "foto", "width =" +width +",height =" + height +",location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=yes");
	//fotowin.document.write("<html><head><title>foto</title></head><body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\"><img src=\"/util/bin.php?id=" + id + "&amp;table="+table+"\"/><br clear=\"all\"><div style=\"color: #333333; font-size:60%; margin-left :10px; margin-right :10px; margin-top :5px; font-family: Arial;  align=\"justify\"></div></boby></html>");
	//fotowin.document.close();
	//document.body.onfocus = closeFotoWin;
}

function closeFotoWin() {
	if(fotowin != null && !(fotowin.closed)) {
		fotowin.close();
	}
}

//mail decode
function mDec(ensl, enlsShow, addToHref, firstPartHrefOnly) {
	if ((enlsShow == undefined || enlsShow == "") && (firstPartHrefOnly == undefined || firstPartHrefOnly == "")) {
		enlsShow = ensl;
	}
	
	if (addToHref == undefined) {
		addToHref = "";
	}

	s="";
	for(i=0; i<enlsShow.length; i++) {
		n=enlsShow.charCodeAt(i);
		if (n >= 35 && n <= 126) {
			s+=String.fromCharCode((n-3));
		} else {
			s+=enlsShow.charAt(i);
		}
	}
	nslvShow = s;
	
	a="pdlowr="+ensl; 
	nslv = "";
	for(i=0; i<a.length; i++) {
		n=a.charCodeAt(i)-3;
		nslv+=String.fromCharCode(n);
	}
	if (firstPartHrefOnly == true) {
		document.write("<a class=\"email\" href=\"" + nslv + addToHref + "\">");		
	} else {
		document.write("<a class=\"email\" href=\"" + nslv + addToHref + "\">"+nslvShow+"</a>");		
	}
}

function printWindow() {
	window.open("?vie=print", "print", "width=620,height=550,location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes, resizable=no,status=no");
}

function switchOver(num) {
	document['image'+num].src = eval("image" + num + "over.src");
}
function switchOff(num) {
	document['image'+num].src = eval("image" + num + "off.src");
}
