﻿// Global vars
var framework;

function startUpApp() {
	framework = new Framework();
	return "running";
}

window.onresize = function(){
	if(framework != null){
		setTimeout("framework.onWindowResized();", 50);
	}
}

window.onscroll = function(){
	if(framework != null){
		setTimeout("framework.onUserScroll();", 50);
	}
}


function Framework(){

}

Framework.prototype.getWindowHeight = function(){
	if (self.innerHeight){
		return self.innerHeight;
	}
	if (document.body.clientHeight){
		return document.body.clientHeight;
	}
	return 0;
}

Framework.prototype.getWindowWidth = function(){
	if (self.innerWidth){
		return self.innerWidth;
	}
	if (document.body.clientWidth){
		return document.body.clientWidth;
	}
	return 0;
}

Framework.prototype.onWindowResized = function() {
	var flash = null;
	if(navigator.appName.indexOf("Microsoft") != -1)
        flash = window["application"];
    else
        flash = document.embeds["application"];
	flash.onBrowserResized( this.getWindowWidth(), this.getWindowHeight() );
}

function getBrowserHeight() {
	return framework.getWindowHeight();	
}

function getBrowserWidth() {
	return framework.getWindowWidth();	
}

function maxWindow() {
	
	window.moveTo(0,0);
	
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	} else if (document.layers || document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth) {
		    top.window.outerHeight = screen.availHeight;
		    top.window.outerWidth = screen.availWidth;
	  	}
	}
	
}

Framework.prototype.onUserScroll = function(update){
	var flash = null;
	if(navigator.appName.indexOf("Microsoft") != -1)
        flash = window["application"];
    else
        flash = document.embeds["application"];
	flash.onBrowserScroll(getBrowserScrollOffset());
}

function getBrowserScrollOffset() {
	var pageYOffset = 0
    if( typeof( window.pageYOffset ) == 'number' ) {
        //Non-IE
        pageYOffset = window.pageYOffset;
    }
    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE 6+ in 'standards compliant mode'
        pageYOffset = document.documentElement.scrollTop;
    }
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //IE 4 compatible
        pageYOffset = document.body.scrollTop;
    }
    return pageYOffset;
}






