function getAbsoluteTop(o) {
	oTop = o.offsetTop;
	while(o.offsetParent != null) {
		oParent = o.offsetParent;
		oTop += oParent.offsetTop;
		o = oParent;
	}
	return oTop;
}

var layoutmatch = new Array();
var donesifr = false;

function addLayoutMatch(idmain, idmatch, idmatchcontent) {
	var tmp = new Array(4);
	tmp[0] = idmain;
	tmp[1] = idmatch;
	tmp[2] = idmatchcontent;
	
	layoutmatch.push(tmp);
}

function setLayout() {
	var clientWidth = document.body.clientWidth;
	var clientHeight = document.body.clientHeight;
	
	var mainWidth = 900;
	var mainLeft = Math.round((clientWidth - mainWidth) / 2);
	var mainRight = mainLeft + mainWidth;
	
	var rightWidth = clientWidth - mainRight;
	
	document.getElementById('mainright').style.width = Math.max(0, rightWidth) + 'px';

	var maxy = 0;
	elms = document.getElementsByTagName('div');
	if (elms.length > 0) {
		for (var i = 0; i < elms.length; i++) {
			if ((elms[i].id != 'container') && (elms[i].id != 'main') && (elms[i].id != 'mainleft') && (elms[i].id != 'mainright')) {
				maxy = Math.max(maxy, getAbsoluteTop(elms[i]) + elms[i].offsetHeight);
			}
		}
	}
	
	if (window.innerHeight) {
		maxy = Math.max(maxy, window.innerHeight);
	}
	if (document.body.clientHeight) {
		maxy = Math.max(maxy, document.body.clientHeight);
	}
	if (document.documentElement) {
		if (document.documentElement.clientHeight) {
			maxy = Math.max(maxy, document.documentElement.clientHeight);
		}
	}
	
	if (maxy > 1600) { maxy = 1600; }
	
	if (maxy > 0) {
		document.getElementById('container').style.height = maxy + 'px';
		document.getElementById('main').style.height = maxy + 'px';
		document.getElementById('mainleft').style.height = maxy + 'px';
		document.getElementById('mainright').style.height = maxy + 'px';
	}
		
	if (layoutmatch.length > 0) {
		for (var i = 0; i < layoutmatch.length; i++) {
			var mainelm = document.getElementById(layoutmatch[i][0]);
			var matchelm = document.getElementById(layoutmatch[i][1]);
			var matchcontentelm = document.getElementById(layoutmatch[i][2]);

			var mainbottom = getAbsoluteTop(mainelm) + mainelm.offsetHeight;
			var matchbottom = getAbsoluteTop(matchelm) + matchelm.offsetHeight;
			
			if (mainbottom != matchbottom) {
				matchcontentelm.style.height = (matchcontentelm.offsetHeight + (mainbottom - matchbottom)) + 'px';
				matchcontentelm.style.minHeight = (matchcontentelm.offsetHeight + (mainbottom - matchbottom)) + 'px';
				
				matchbottom = getAbsoluteTop(matchelm) + matchelm.offsetHeight;
				if (mainbottom != matchbottom) {
					var diff = mainbottom - matchbottom;
					
					matchcontentelm.style.height = (matchcontentelm.offsetHeight + (mainbottom - matchbottom) + diff) + 'px';
					matchcontentelm.style.minHeight = (matchcontentelm.offsetHeight + (mainbottom - matchbottom) + diff) + 'px';
				}
			}
		}
	}	
}

function intsIFR() {
	if(typeof sIFR == "function") {
 		sIFR.replaceElement(".flashtitle", named({sFlashSrc: sitebase + "images/layout/titles.swf", sColor: "#000000", sWmode: "transparent"}));
	}
}

function gosIFR() {
	if (!donesifr) {
		if(typeof sIFR == "function") {
	    sIFR.bAutoInit = false;
    	sIFR.setup();
    	intsIFR();
		}
		donesifr = true;
	}
}

function doneLoading() {
	gosIFR();
	setLayout();
}

setLayout();
window.onresize = setLayout;
window.onload = doneLoading;
document.onload = doneLoading;

var imageprefetcharray = new Array();
function imageprefetch(url) {
	var img = new Image; 
	img.src = url;
	imageprefetcharray.push(img);	
}

function xmlconn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }
      };
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

document.getElementById('flashmovie').innerHTML =
	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="189" height="189" id="flashmovie" align="left"> \
		 <param name="allowScriptAccess" value="sameDomain" /> \
		 <param name="movie" value="' + sitebase + 'images/layout/flashmovie.swf" /> \
	 	 <param name="quality" value="high" /> \
		 <param name="scale" value="noscale" /> \
		 <param name="salign" value="l" /> \
		 <param name="wmode" value="transparent" /> \
		 <param name="bgcolor" value="#ffffff" /> \
		 <embed src="' + sitebase + 'images/layout/flashmovie.swf" quality="high" scale="noscale" salign="l" wmode="transparent" bgcolor="#ffffff" width="189" height="189" name="flashmovie" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> \
	 </object>';

