/** This is a custom version by Mike Challis http://www.642weather.com/weather/scripts.php Modified to resize a WDL swf http://www.642weather.com/weather/live.php modified to rezize wdl based on width of "flashcontent" div rather than screen width This version is customm tailored for the Weather Display/PHP/AJAX Website Template set wdl page or mml page this allows function settings to pad the bottom of the page and make room for any content below the swf this assumes that the swf 'flashcontent' div is inside a 'main-copy' div that is inside a 'page' div as standard for the Weather Display/PHP/AJAX Website Template set wdl page or mml page or it will not work! * SWFForceSize v1.0: Flash container size limiter for SWFObject - http://blog.pixelbreaker.com/ * * SWFForceSize is (c) 2006 Gabriel Bucknall and is released under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * Dependencies: * SWFObject v1.5 - (c) 2006 Geoff Stearns. * http://blog.deconcept.com/swfobject/ */ function VideoForceSize( swfObject, MinWidth, MaxWidth, Ratio, BelowDivPadding, PageHeightPadding) { this.div = swfObject.getAttribute('id'); this.MinWidth = MinWidth; this.MaxWidth = MaxWidth; this.Ratio = Ratio; this.BelowDivPadding = BelowDivPadding; this.PageHeightPadding = PageHeightPadding; var o = this; this.addWindowEvent( 'onload', this, this.onLoadDiv ); this.addWindowEvent( 'onresize', this, this.onResizeDiv ); } VideoForceSize.prototype = { addWindowEvent: function( eventName, scope, func ) { var oldEvent = window[ eventName ]; if (typeof window[ eventName ] != 'function') window[ eventName ] = function(){ func.call( scope ); }; else { window[ eventName ] = function() { if( oldEvent ) oldEvent(); func.call( scope ); } } }, getWinSize: function() { var winH, winW; if (parseInt(navigator.appVersion)>3) { if ( document.body.offsetWidth ){ // Gecko / WebKit winW = document.body.offsetWidth; winH = document.body.offsetHeight; } else if ( document.body.offsetWidth ){ // MS winW = document.body.offsetWidth; winH = document.body.offsetHeight; } } return { height: winH, width: winW }; }, onLoadDiv: function() { document.getElementById( this.div ).style.width = "100%"; document.getElementById( this.div ).style.height = "100%"; this.onResizeDiv(); }, onResizeDiv: function() { // # begin mchallis modifications // # modified to rezize based on width of "flashcontent" div rather than screen width // http://www.ozzu.com/programming-forum/javascript-getting-div-current-width-t39999.html // mchallis comment out original code //var winSize = this.getWinSize(); //var w = winSize.width < this.minW? this.minW+"px" : "100%"; //var h = winSize.height < this.minH? this.minH+"px" : "100%"; var mydivW = document.getElementsByTagName("div")["flashcontent1"].offsetWidth; var mydivH = document.getElementsByTagName("div")["flashcontent1"].offsetHeight; var w, h; if (mydivW > this.MaxWidth) { w = this.MaxWidth - 10; h = (this.MaxWidth * this.Ratio) - 10; } else { w = mydivW - 10; h = (mydivW * this.Ratio) - 10; } // # end mchallis modifications /* for IE on PC, turn off the disabled scrollbar on the right when there's no content to scroll */ if( document.all ) document.body.scroll = ( w!="100%" || h!="100%" )? "auto" : "no"; document.getElementById( this.div ).style.width = w+"px"; document.getElementById( this.div ).style.height = h+"px"; // # begin mchallis modifications // this allows function settings to pad the bottom of the page and make room for any content below the swf // this assumes that the swf 'flashcontent' div is inside a 'main-copy' div that is inside a 'page' div // as standard for the Weather Display/PHP/AJAX Website Template set wdl page or mml page // or it will not work! document.getElementById( 'page' ).style.height = (w * this.Ratio) + this.PageHeightPadding +"px"; document.getElementById( 'main-copy' ).style.height = (w * this.Ratio) + this.BelowDivPadding +"px"; // # end mchallis modifications } }