// Copyright 2006-2007 Morose Media

var pnghack = false;
var minTotalHeight = -1;
var totalHeight = -1;
var clientHeight = -1;

function setLayout() {
	if (window.innerHeight){
    clientHeight = window.innerHeight;
  } else {
    clientHeight = document.documentElement.clientHeight;
  }
	totalHeight = document.getElementById('main').offsetHeight;
	
	if (minTotalHeight == -1) 
	{
	  minTotalHeight = totalHeight;
	} else {
		totalHeight = minTotalHeight;
	}
	
	if (clientHeight > totalHeight) {
	  document.getElementById('mainbackground').style.height = clientHeight + 'px';
	  document.getElementById('main').style.height = clientHeight + 'px'; 
	} else {
	  document.getElementById('mainbackground').style.height = totalHeight + 'px';
	  document.getElementById('main').style.height = totalHeight + 'px'; 		
	}
}

var imageprefetcharray = new Array();
var imageprefetchtodoarray = new Array();

function imageprefetch(url) {
	imageprefetchtodoarray.push(url);
}

function imageprefetchgo() {
	if (imageprefetchtodoarray.length > 0) {
		for (var i = 0; i < imageprefetchtodoarray.length; i++) {
			var img = new Image; 
			img.src = imageprefetchtodoarray[i];
			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;
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function doFlash(id, data) {
	document.getElementById(id).innerHTML = data;
}

function flashitemsSize(count, pcd) {
	return (20 + (pcd * count));
}

function flashitems(divid, flashid, countx, county, pcd) {
	if (!pcd) { pcd = 140; }
	
  doFlash(divid, ' \
	  <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="' + flashitemsSize(countx, pcd) + '" height="' + flashitemsSize(county, pcd) + '" id="imageitemlist' + flashid + '" align="top"> \
	  <param name="allowScriptAccess" value="sameDomain" /> \
	  <param name="movie" value="' + basepath + 'flash/flashitems.v' + versions.items + '.swf" /> \
	  <param name="quality" value="high" /> \
	  <param name="bgcolor" value="#ffffff" /> \
    <param name="wmode" value="transparent" /> \
    <param name="scale" value="noScale" /> \
    <param name="salign" value="lt" /> \
    <param name="flashvars" value="flashID=' + flashid + '&pcWT=' + countx + '&pcHT=' + county + '&pcD=' + pcd + '" /> \
	  <embed src="' + basepath + 'flash/flashitems.v' + versions.items + '.swf" quality="high" bgcolor="#ffffff" width="' + flashitemsSize(countx, pcd) + '" height="' + flashitemsSize(county, pcd) + '" \
	   name="imageitemlist' + flashid + '" align="top" allowScriptAccess="sameDomain" wmode="transparent" scale="noScale" salign="lt" \
	   flashvars="flashID=' + flashid + '&pcWT=' + countx + '&pcHT=' + county + '&pcD=' + pcd + '" \
	   type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> \
	  </object> \
  ');
}

doFlash('flashmenu', ' \
  <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="960" height="360" id="menu" align="middle"> \
  <param name="allowScriptAccess" value="sameDomain" /> \
  <param name="movie" value="' + basepath + 'flash/menu.v' + versions.menu + '.swf" /> \
  <param name="quality" value="high" /> \
  <param name="wmode" value="transparent" /> \
  <param name="bgcolor" value="#ffffff" /> \
  <param name="flashvars" value="subtitle=' + escape(menuData.subtitle) + '&current=' + escape(menuData.current) + '&basepath=' + escape(menuData.basepath) + '" /> \
  <embed src="' + basepath + 'flash/menu.v' + versions.menu + '.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="960" \
   height="360" name="menu" align="middle" allowScriptAccess="sameDomain" \
   flashvars="subtitle=' + escape(menuData.subtitle) + '&current=' + escape(menuData.current) + '&basepath=' + escape(menuData.basepath) + '" \
   type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object> \
');

doFlash('mainlogo', ' \
  <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="1048" height="1183" id="menu" align="middle"> \
  <param name="allowScriptAccess" value="sameDomain" /> \
  <param name="movie" value="' + basepath + 'flash/logo.v' + versions.logo + '.swf" /> \
  <param name="quality" value="high" /> \
  <param name="wmode" value="transparent" /> \
  <param name="bgcolor" value="#ffffff" /> \
  <embed src="' + basepath + 'flash/logo.v' + versions.logo + '.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="1048" \
   height="1183" name="menu" align="middle" allowScriptAccess="sameDomain" \
   type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object> \
');

mmLinksPrefetch();