// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function divplacer()
{
	var iframe = document.getElementById("mainLayer");
	var iframeDiv = document.getElementById("iframeDiv");
	var header = document.getElementById("headerLayer");
	var topMenu = document.getElementById("menuLayer");
	
	//var bottomMenu = document.getElementById("footerLayer");
	var footer = document.getElementById("footer");
	// 
	// Browser window dimensions
	var ww = document.documentElement.clientWidth;
	var wh = document.documentElement.clientHeight;
	//document.body.offsetHeight;
	//
	
	
	// header
    header.style.width = ww+"px";
    header.style.visibility = "visible";
    //
    // top menu
    topMenu.style.top = (wh-(wh-100))+"px";
    topMenu.style.left = (ww > 800) ? ((ww/2)-(800/2))+"px" : "0px";
    topMenu.style.visibility = "visible";
    //    
    // iframe
    iframe.style.height = ((wh-200)>0)?(wh-200)+"px":wh+"px";
    iframe.style.top = (wh-(wh-150))+"px";
    
    iframe.style.left = (ww > 800) ? ((ww/2)-(800/2))+"px" : "0px";
    if (navigator.appName == "Microsoft Internet Explorer") { 
        iframe.style.overflow =  "hidden"; 
    }
    // iframe.style.overflow = (ww < 750 || wh < 550)? "scroll" : "hidden";
    // bottom menu
    //bottomMenu.style.top= (wh-50)+"px";
    footer.style.top = (wh-50)+"px";
    footer.style.visibility = "visible";
    iframe.style.visibility = "visible";
    //alert(document.getElementById("headerLayer").style.height);
    
}

function moveDiv()
{
    var bg_lyr = document.getElementById("backLayer").offsetHeight;
    // alert(bg_lyr);
    var the_style = getStyleObject("headerLayer");
    var the_left = parseInt(the_style.left);
    
    //alert(the_style.offsety.clientY);
    if (bg_lyr == 625)
    {
        //	  var the_top = parseInt(the_style.top) - 10;
    }
    else if (bg_lyr == 457)
    {
        //	  var the_top = parseInt(the_style.top) - 40;
    }
    else
    {
        //	  var the_top = parseInt(the_style.top) + 4.4;
    }

}

  function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
Lpos = (screen.width) ? (screen.width-w)/2 : 0;
Tpos = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+Tpos+',left='+Lpos+',scrollbars='+scroll+',false'
win = window.open(mypage,myname,settings)
}


function ActivateFlash()
{
    var objects = document.getElementsByTagName("object");
    for (var i = 0; i < objects.length; i++)
    {
      objects[i].outerHTML = objects[i].outerHTML;
    }
}

window.onload = ActivateFlash

// Check flash availability.
var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";

if (navigator.plugins && navigator.plugins.length)
{
    x = navigator.plugins["Shockwave Flash"];
    if (x)
    {
	    flashinstalled = 2;
	    if (x.description)
	    {
		    y = x.description;
		    flashversion = y.charAt(y.indexOf('.')-1);
	    }
    } else {
        flashinstalled = 1;
    }
   
    if (navigator.plugins["Shockwave Flash 2.0"])
    {
	    flashinstalled = 2;
	    flashversion = 2;
    }
 } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
    
    x = navigator.mimeTypes['application/x-shockwave-flash'];
    
    if (x && x.enabledPlugin) {
	    flashinstalled = 2;
    } else {
        flashinstalled = 1;
    }
} else {
   MSDetect = "true";
}

function isFlashInstalled() {
    return (flashinstalled > 0 || MSDetect == "true") ? true : false;
}

function getFlashVersion() {
    return flashversion;
}
/**************************************************************
 * Default.aspx functions.
 *
 *
 */ 
var intervalID;
//
var defaultLoaded = false;
var iFrameLoaded = false;
//
function SetLoadedPage(page) {
    
    switch(page) {
        case "default":
        defaultLoaded = true;
        break;
        case "iframe":
        iFrameLoaded = true;
        break;
        
    }
}
//
function ShowPreloader()
{
   
     var obj = document.getElementById("cover");
     var loader = document.getElementById("loader");
     var hCenter = (document.documentElement.clientWidth/2)-100;
     var vCenter = (document.documentElement.clientHeight/2)-50;
     //
     
    // Check browser type.
    
    if (navigator.appName == "Microsoft Internet Explorer") {
        obj.style.filter="Alpha(Opacity=75)";
        loader.style.filter="Alpha(Opacity=100)";
    } else {
        obj.style.opacity=75/100;
        loader.style.opacity = 100;
    }
    obj.style.width = "100%";
    obj.style.height = "100%";
    loader.style.width = "200px";
    loader.style.height = "100px"; 
    loader.style.left = hCenter+"px";
    loader.style.top = vCenter+"px";
            
    intervalID = setInterval('WatchLoad()', 100);         
}


        
function HidePreloader()
{
    var obj = document.getElementById("cover");
    var loader = document.getElementById("loader");
    // Check browser type.
    if (navigator.appName == "Microsoft Internet Explorer") {
        obj.style.filter="Alpha(Opacity=0)";
        loader.style.filter="Alpha(Opacity=0)";
    } else {
        obj.style.opacity=0;
        loader.style.opacity = 0;
    }
    obj.style.width = "0px";
    obj.style.height = "0px";
    loader.style.width = "0px";
    loader.style.height = "0px";  
    loader.style.top = "0px";
    loader.style.left = "0px"; 
            
    
}

function WatchLoad() {

    if (iFrameLoaded && defaultLoaded) {
        
        HidePreloader();
        iFrameLoaded = false;
        clearInterval(intervalID);
    } else {
        
    }
   
}
             
/**
 * This function is used to set a menu button active.
 *
 * @param   String  menuID  - Name of the SWFObject set in: 
 *                              new SWFObject("swfs/menu.swf", "topmenu", "1024", "50", "8", "");
 *                            as in this case the 2nd parameter of the constructor. 
 *
 * @param   String  btnName - Button name/label to set active.
 */
function SetActiveMenuButton(menuID, btnName)
{
    var menu = (window[menuID]) ? window.document[menuID] : document[menuID];
    menu.SetVariable('ActiveButton', btnName);
    //alert(btnName);
}
        
function UpdateMenus()
{
    var topMenu = (window["topmenu"]) ? window.document["topmenu"] : document["topmenu"];
    var bottomMenu = (window["bottommenu"]) ? window.document["bottommenu"] : document["bottommenu"];
        
    //alert(menu.id+" -- "+menu.GetVariable("ASFunc"));
    //thisMovie("menuLayer").SetActiveButton();
    //alert(menu);
    topMenu.SetVariable('ClientWinWidth', document.body.offsetWidth);
    bottomMenu.SetVariable('ClientWinWidth', document.body.offsetWidth);
    trace(document.body.offsetWidth);
           
}
function FrameLoaded()
{
   SetLoadedPage('iframe');
   HidePreloader();
   //alert("This seems to fire when navigation is complete");
   //this is where you set the preloader layer to invisible
   //you set it visible before you navigate within the iframe
}
     
 
 
/************************************/
/**
 * Flash debugging section.
 *
 */
function showFlashDebugWindow() {
    var dbgWin = document.getElementById("debug");
    if (!dbgWin) {
       
        var newDiv = document.createElement('div');
        newDiv.setAttribute('id','debug');
        newDiv.setAttribute('style','visibility:visible');
        //newDiv.style.z-index = 999;
        //document.writeln('<div id="debug" style="z-index:500; visibility:hidden;"></div>');
        document.body.appendChild(newDiv);
       
      }
    dbgWin = document.getElementById("debug");
    //
    var dbg = new SWFObject("swfs/outputPanelWindow.swf", "debug", "550", "400", "8", "");			
    dbg.addParam("quality", "high");
    dbg.addParam("menu", "false");
    dbg.addParam("swLiveConnect", "true");
    dbg.addParam("allowScriptAccess", "sameDomain");
              
    dbg.write("debug");
    dbgWin.style.visibility = "visible";
    dbgWin.style.width = "550px";
    dbgWin.style.height = "400px";
}
function hideFlashDebugWindow() {
    var dbgWin = document.getElementById("debug");
    dbgWin.style.visibility = "hidden";
    dbgWin.style.width = "0px";
    dbgWin.style.height = "0px";
}

function keyDown(e) {
    if (fl_debugEnabled) { 
        switch(e) {
        case 120:
            showFlashDebugWindow()
            break;
        case 27:
            hideFlashDebugWindow()
            break;
        case 40:
            loadTopMenu();
            break;
        }
    }
    
}

function trace(str) {
    var dbg = (window["debug"]) ? window.document["debug"] : document["debug"];
    if (dbg) {
        dbg.SetVariable('opTrace', str);
    }
}