function setStyle( obj, property, value ) {
	var element = getRef( obj );
	if( element ) {
		if( element.style ) element.style[property] = value;
		else element[property] = value;
	}
}

function getStyle( obj, property ) {
	var element = getRef( obj );
	if( element.style ) return element.style[property];
	else return element[property];
}

function is_function(obj) {
	if( !obj ) return false;
    return (obj.constructor.toString().indexOf("Function")!= -1);
}

function getCompStyle( obj, cAttribute ){
	var element = getRef( obj );

	//if IE
	if ( element.currentStyle ) {
		var curVal = eval( 'element.currentStyle.' + cAttribute );
	}
	else {
		//if Mozilla/FF
		var curVal = eval( 'document.defaultView.getComputedStyle( element, null ).' + cAttribute );
	}

	return curVal;
}

function setClass( obj, classname ) {
	getRef(obj).className = classname;
}

function getRef(obj){
	return (typeof obj == "string") ?
	document.getElementById(obj) : obj;
}

function objectExists( obj ) {
	return (document.getElementById(obj) != null);;
}

function pageHeight() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	return myHeight;
}

function pageWidth() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	return myWidth;
}

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}

function fixSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName] = new Object();
	} else {
		return document[movieName] = new Object();
	}
}

// Gets a reference to the specified SWF file by checking which browser is
// being used and using the appropriate JavaScript.
// Unfortunately, newer approaches such as using getElementByID() don't
// work well with Flash Player/ExternalInterface.
function getSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function resize() {
	var myWidth = pageWidth();
	var myHeight = pageHeight();
        	
	if( ( myWidth / myHeight ) > 1.84 ) {
        <!-- resize maintaining height -->
		var flashHeight = Math.round( myHeight * 2.55 );
    	var flashWidth = Math.round( flashHeight * 1.25 );
    }
    else {
        <!-- resize maintaining width -->
        var flashWidth = Math.round( myWidth * 1.70 );
		var flashHeight = Math.round( flashWidth / 1.25 );
    }
	
	
	if( getSWF('Main') ) {
		try {
			var obj = getSWF("Main");
			var obj2 = getRef("Main");
			
			obj.width = flashWidth;
			obj.height = flashHeight;
			
			obj2.width = flashWidth;
			obj2.height = flashHeight;			
		}
		catch(err) {
		}
	}
}

addEvent( window, "resize", resize, false );

