// JavaScript Document

document.movieName		=		"ZAP1_Site";
document.movieVersion	=		"005";
document.debugMode		=		"nodebug";

function newWin(theURL,winName,features) { 	
	var stdFeatures	=	'location=no,menubar=no,toolbar=no,width=300,height=300';

	//Create the window//
	var outWindow	=	window.open(theURL,winName,features + stdFeatures);
		
 	return outWindow;
};
//-----------------------------------------------//


function traceDebug(inValue){
	if(document.debugMode	!= "debug") return;
	if(!document.debugWindow) showDebugWindow();
	document.debugWindow.traceDebug(inValue);
};

function showDebugWindow(){
	if(document.debugMode	!= "debug") return;
	document.debugWindow		=		newWin("debug.html","Debug","");
	
	if(!document.debugWindow) return;
};

function getWindowWidth(){
		var windowWidth		=		window.innerWidth || document.body.clientWidth;
		return windowWidth;	
};

function getWindowHeight(){
		var windowHeight		=		window.innerHeight || document.body.clientHeight;
		return windowHeight;	
};

function getMovieWidth(){
	var theMovie;
	var outWidth;
	theMovie					=		document.getElementById(document.movieName);
	if(!theMovie) return 0;
	outWidth					=		theMovie.offsetWidth;
	return outWidth;
};

function getMovieHeight(){
	var theMovie;
	var outHeight;
	theMovie					=		document.getElementById(document.movieName);
	if(!theMovie) return 0;
	outHeight					=		theMovie.offsetHeight;
	return outHeight;
};


function getApplicationHeight(){
	var theMovie;
	var appHeight;
	
	theMovie	=	document.getElementById(document.movieName);
	if(!theMovie) return;
	
	
	appHeight	=	theMovie.getAppHeight();
	
	
	return appHeight;
};

function adjustMovieScaling(){
		//Get the required Height from the application..

		//var appHeight			=		getApplicationHeight();
		//traceDebug(appHeight);
		
		
		var minWidth			=		1100;
		var minHeight			=		1100;
		var windowWidth			=		window.innerWidth || document.body.clientWidth;
		var windowHeight		=		window.innerHeight || document.body.clientHeight;

		var theMovie	=	document.getElementById(document.movieName);
		
		//traceDebug(theMovie);
		
		var theNewWidth,theNewHeight;		
		
		
		theNewWidth		=		(windowWidth < minWidth)? String(minWidth) + "px":"100%";
		theNewHeight	=		(windowHeight < minHeight)? String(minHeight) + "px":"100%";
				
		theMovie.style.width		=		theNewWidth;
		theMovie.style.height		=		theNewHeight;
		
		theMovie.width		=		(windowWidth < minWidth)?String(minWidth):"100%";
		theMovie.height		=		(windowHeight < minHeight)?String(minHeight):"100%";
		
		try{
		
			document.styleSheets[0].cssRules[0].style.width		=		(windowWidth < minWidth)?String(minWidth) + "px":"100%";
			document.styleSheets[0].cssRules[0].style.height	=		(windowHeight < minHeight)?String(minHeight) + "px":"100%";
		}catch(e){}
		
};



function createApplication(inTarget){
		var initRID		=		"100001";
				
        var so = new SWFObject('client/flash/' + document.movieName + '_' + document.movieVersion + '.swf?initRID=' + initRID, document.movieName, '100%', '100%', '8', '#FFFFFF');
        so.useExpressInstall('swfobject/expressinstall.swf');
        so.addParam('menu', 'false');
        so.write('THEMOVIE');
		
		try{

			adjustMovieScaling();
		}catch(e){}
		
		if(document.debugMode == "debug") showDebugWindow();
};

window.onresize = function(){

	adjustMovieScaling();
};	

