/*
	Set new dimensions to Flash object holder (OBJECT & EMBED).
	Initial call to this method show contain root object which contains flash play in it.
	Method will recursively go as deep as possible to seek for Object element.
	So, if you don't want to see client's PC to suffer try not to pass <html> object as reference :))
	You must call this method on window.onload event. And you ask yourself why - because of IE...of course :)
	
	WARNING!!!
	When flash blocker is turned on, OBJECT tag is ignored and redim cannot work
*/
function redimFlashObject(obj,newWidth){

	//looking for child nodes...
	for(var i=0; i< obj.childNodes.length; i++) { 
		elem = obj.childNodes[i];
		
		if (elem.nodeType != 1) //if it is not element
			continue;
			
		//check if node name is OBJECT
		if (elem.nodeName.toLowerCase() == "object" || elem.nodeName.toLowerCase() == "embed" ){
			iwdt = elem.getAttribute("width");
			
			//if current width is less then or equal to requested max, then we'll skip further processing
			if (iwdt <= newWidth)
				return;
				
			ihg = elem.getAttribute("height");
			
			ratio = iwdt/ihg;
			iwdt = newWidth;			
			ihg = Math.floor(iwdt/ratio);

			elem.width=iwdt;
			elem.height=ihg;			
			
			if (elem.hasChildNodes()){
				for(var j=0; j< elem.childNodes.length; j++){
					ielem=elem.childNodes[j];
					
					if (ielem.nodeType != 1) //if it is not element
						continue;										

					if (ielem.nodeName.toUpperCase() == "EMBED"){
						ielem.width=iwdt;
						ielem.height=ihg;									
						break;
					}
				}
			}
			return true;
		}
		else if (elem.hasChildNodes()){
			if (redimFlashObject(elem,newWidth)) {
				return true;
			}
		}
	}
}

