// JavaScript Document

var is_msie = document.all ? 1 : 0;

function change_public_lang(newlang) {
	var p = "" + self.location;
	p = p.replace(/[\&\?]+plc\=[a-z]{2}/gi, "");
	p = p.replace(/[\&\?]+logout\=true/gi, "");
	p = p.replace(/#$/gi, "");
	if(p.search(/[\&\?]+lang\=/gi)!=-1) {
		p = p.replace(/([\&\?]+lang\=)[a-z]{2}$/, "$1" + newlang);
		p = p.replace(/([\&\?]+lang\=)[a-z]{2}\&/, "$1" + newlang + "&");
	}
	else if(p.search(/\?/gi)!=-1) {
		p += "&plc=" + newlang;
	}
	else {
		p += "?plc=" + newlang;
	}
	p = p.replace(/\?\&/g, "?");
	p = p.replace(/[\&]{2,}/g, "&");
	self.location = p;
	return false;
}

function openwindow(url_address,window_width,window_height,framename,additional,is_picture,title) {
  sx = (screen.availWidth - window_width) / 2;
  sy = (screen.availHeight - window_height) / 2;
  params = "width="+window_width+",height="+window_height+",Left="+sx+",Top="+sy+",screenX="+sx+",screenY="+sy;
  if(additional>"") params += "," + additional;
  nw = window.open(url_address, framename, params);
  if(is_picture) {
  	var metatitle = title ? title : "Photo";
    nw.document.open();
    nw.document.write("<html><head><title>" + metatitle + "</title></head>\n");
    nw.document.write("<body marginwidth='0' marginheight='0' topmargin='0' leftmargin='0'>\n");
    nw.document.write("<table border=0 cellpadding=0 cellspacing=0 style='border:thin outset;height:"+window_height+"px;width:"+window_width+"px'><tr><td align='center' style='background-color:#D4D0C8'><img src='"+url_address+"' alt='photo' align='middle'></td></tr></table>\n");
    nw.document.write("</body>\n");
    nw.document.write("</html>\n");
    nw.document.close();
  }
  nw.focus();
  return false;
}

function openmodal(obj,url_address,window_width,window_height,scroll,debug) {
  if(debug) {
    sx = (screen.availWidth-12 - window_width) / 2;
		sy = (screen.availHeight-50 - window_height) / 2;
    params = "width="+window_width+",height="+window_height+",Left="+sx+",Top="+sy+",screenX="+sx+",screenY="+sy;
    if(scroll=="no") nw = window.open(url_address, "_blank", params);
    else nw = window.open(url_address, "_blank", params+",scrollbars=yes");
    FromModalWindow = "";
  }
  else {
    if(scroll=="no") FromModalWindow = obj.showModalDialog(url_address, null, "help:no;scroll:no;status:no;center:yes;statusbar:no;minimize:no;maximize:no;border:thin;statusbar:no;dialogWidth:"+window_width+"px;dialogHeight:"+window_height+"px");
    else FromModalWindow = obj.showModalDialog(url_address, null, "help:no;status:no;center:yes;statusbar:no;minimize:no;maximize:no;border:thin;statusbar:no;dialogWidth:"+window_width+"px;dialogHeight:"+window_height+"px");
  }
  return FromModalWindow;
}

function setBudapestCardContainer() {
	var oHeader = document.getElementById("divBudapestCardHeader");
	var oFooter = document.getElementById("divBudapestCardFooter");
	var oContainer = document.getElementById("divBudapestCardContainer");
	if(!oHeader || !oFooter || !oContainer) return false;
	var H = 1*document.body.clientHeight - 1*oHeader.offsetHeight - 1*oFooter.offsetHeight;
	if(H>1*oContainer.offsetHeight) {
		if(is_msie) oContainer.style.height = H + "px";
		else oContainer.style.height = (H - 40) + "px";
	}
	return true;
}

