/* 
	Clubsoft's SWF Game Scaler
 
  Use: Call the following function:
  
  	new csScaleGame("<GameID - The Name/ID of the Embed/Element", <Scale - As a fraction, i.e. 1 = 100%, 2 = 200%, 0.5 = 50%>)
  	
 		Example: new csScaleGame("zeb", 2);
 		
 		
 	We're using "new" to create it as an object to allow the function to act as a constructor, and allow us to have multiple scales per page if we so desire.
 	
 	The function will wait until the flash object is completely loaded before scaling - I've found issues if trying to do this prematurely.
 	
*/

		
function csScaleGame(gameid,zoom) {
	var callback = this /* Set local callback */
	this.flashObj = gameid /* Aquire game object */
	this.inter = 0 /* Placeholder for Interval ID */
	this.zScale = zoom /* Zoom Scale as fraction, 1 = 100%, 2 = 200%, 0.5 = 50% etc.. */
	this.waitLoad = function () { /* Main function */
		if (window.document[this.flashObj]) {
			if (window.document[this.flashObj].PercentLoaded() == 100) { /* Wait for game to load first */
				window.document[this.flashObj].Zoom(0) /* Reset zooming parameters to allow fit-to-window */
				window.document[this.flashObj].width = window.document[this.flashObj].width * this.zScale /* Resize object/embed to rescaled width and height */
				window.document[this.flashObj].height = window.document[this.flashObj].height * this.zScale
				clearInterval(this.inter); /* Stop checking if loaded */
			}
		}
	}
	callback.inter = setInterval(function () { callback.waitLoad() }, 100); /* Check game load progress every 100ms */
}
