﻿var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}

function hideswf() {
  if (browserType == "gecko" )
     document.poppedLayer = eval('document.getElementById(\'topswf\')');
  else if (browserType == "ie")
     document.poppedLayer = eval('document.all[\'topswf\']');
  else
     document.poppedLayer = eval('document.layers[\'`topswf\']');
  document.poppedLayer.style.visibility = "hidden";
}

function show() {
  if (browserType == "gecko" )
     document.poppedLayer = eval('document.getElementById(\'topswf\')');
  else if (browserType == "ie")
     document.poppedLayer = eval('document.all[\'topswf\']');
  else
     document.poppedLayer = eval('document.layers[\'`topswf\']');
  document.poppedLayer.style.visibility = "visible";
}



function setFlashHeight(divid, newH){
    
	if (navigator.userAgent.toLowerCase().indexOf('msie')>0) {
       document.getElementById(divid).style.height = newH;

	   }else{
    	document.getElementById(divid).style.height = newH+"px";
	}	
	//alert(newH);
}
function canResizeFlash(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}

function init()
{
    // Add our fontResize handler
    var iBase = TextResizeDetector.addEventListener(onFontResize,null);
}
		
		
function onFontResize(e,args)
{
    getScrollXY();
}

//id of element to check for and insert control
TextResizeDetector.TARGET_ELEMENT_ID = 'backgroundAnim';
//function to call once TextResizeDetector has init'd
TextResizeDetector.USER_INIT_FUNC = init;

function getScrollXY()
{
    if( document.getElementById( "flashAnim" ) == undefined )
    {
        // We're probably in Low Graphics mode so just return...
        return;
    }
    
    var height;
    if ( navigator.userAgent.toLowerCase().indexOf('msie') > -1 )
    {
        
        if( document.documentElement.clientHeight > document.body.clientHeight + 150 )
        {
            height = document.documentElement.clientHeight
        }
        else
        {
            height = document.body.clientHeight + 150;
        }
        // Set flash height for Internet Explorer
        setFlashHeight('backgroundAnim', height);

        // Ressize flash object twice to ensure it picks up the new height
        // of its parent container...	
        document.getElementById( "flashAnim" ).style.height = "99%";		
        document.getElementById( "flashAnim" ).style.height = "100%";

    }
    else
    {
        if( document.documentElement.clientHeight > document.documentElement.offsetHeight + 150 )
        {
            height = document.documentElement.clientHeight
        }
        else
        {
            height = document.documentElement.offsetHeight + 150;
        }
        // Set flash height for non IE browsers
        setFlashHeight('backgroundAnim', height);
    }
}

// This function is called on an interval to check the document height.
// IE doesnt need it, as it uses the onResize event.
function CheckFirefoxHeight()
{
    if( document.documentElement.offsetHeight != m_iCurrentHeight )
    {
    
        m_iCurrentHeight = document.documentElement.offsetHeight;

        getScrollXY();
    }
}

var m_iCurrentHeight = -1;
var m_iIntervalID;

// If its not IE, set up an interval to check the height of the
// document and adjust flash accordingly...
if (navigator.userAgent.toLowerCase().indexOf('msie')>0)
{
    // Do Nothing
}
else
{
    // NOT IE
    m_iIntervalID = window.setInterval( CheckFirefoxHeight, 200 );
}



function grassLoaded( hex )
{
    document.body.style.backgroundColor = hex;
}




function PositionWebsite()
{
    var container = document.getElementById( "container2" );
    if( container == undefined )
    {
        container = document.getElementById( "container" );
    }
    
    if( container != undefined )
    {
        var iContainerWidth = 770;//container.clientWidth;
        container.style.marginLeft = GetMargin( iContainerWidth ) + "px";
    }
}

function GetMargin( containerWidth )
{
    var iContainerWidth = containerWidth;

    var iWindowWidth = document.documentElement.clientWidth;
    
    var iNewLeftMargin = (iWindowWidth - iContainerWidth) * 0.3;
    
    return Math.ceil( iNewLeftMargin );
}


// New FSCommand used by IE to fix form data being lost when
// using the browser bakc button...
function flashAnim_DoFSCommand(command, args) {

	switch( command )
	{
		case "grassLoaded":
			grassLoaded( args );
			break;
		case "getScrollXY":
			getScrollXY();
			break;
		default:
			// Do Nothing
			break;
	}
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub flashAnim_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call flashAnim_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

 



