var FLASH_OBJ = "myFlash";
var FLASH_EMB = "myFlashEmb";
	function generateFlashObject(params) {
		var flashVars = "";
		for (var item in params){
			flashVars += item + "="+params[item]+"&";
		}
		object = "<object id='"+FLASH_OBJ+"' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='325' height='550' align='middle'>"
				+ "<param name='allowScriptAccess' value='sameDomain' />"
				+ "<param name='movie' value='/r29373/flash/flv-player_en_US.swf' />"
				+ "<param name='quality' value='high' />"
				+ "<param name='bgcolor' value='#C6DDE8' />"
				+ "<param name='FlashVars' value='"+flashVars+"'/>"
				+ "<embed src='/r29373/flash/flv-player_en_US.swf' id='"+FLASH_EMB+"' flashvars='"+flashVars+"' "
				+ "quality='high' bgcolor='#C6DDE8' width='325' height='550' name='load' align='middle' "
				+ "allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
				+ "</object>";

		return object;
	}

    function getFlashObject() {
        var flashObj;
        if(document.getElementById(FLASH_EMB) != null){
            flashObj = document.getElementById(FLASH_EMB);
        }else if(document.getElementById(FLASH_OBJ) != null){    
            flashObj = document.getElementById(FLASH_OBJ);
        }
        return flashObj;
    }

	function showFlashObject(videoId, personPid, autoPlay, streamUrl)  {
		document.getElementById("flashObject").innerHTML = generateFlashObject({indexPath : "/get/index/"+videoId, pid : personPid, flvPath : streamUrl, streamId : videoId, autoplay : autoPlay});
	}
	
	function navigateToPid(pid) {
		getFlashObject().navigateToPid(pid);
	}
	
	function seekTo(sec) {
		var vdFlash = getFlashObject();
		vdFlash.seekVideo(sec);
	}
	
	function trimString(sInString) {
		sInString = sInString.replace( /^\s+/g, "" );// strip leading
		return sInString.replace( /\s+$/g, "" );// strip trailing
	}
	
	function handleResponse(componentName) {
		if(componentName == "story") {
			showStoryOnPage(window.frames[componentName].getComponentContent());
		}
	}
	
	
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";

function getHeight() {
    var result = 0;
    if (document.body.scrollHeight && navigator.appVersion.indexOf("Win") != -1) {
    // body.scrollHeight gets the correct value on WIN IE6, but non on MAC
        result = document.body.scrollHeight;
    }else if (document.documentElement.scrollHeight) {
        result = document.documentElement.scrollHeight;
    }else if (document.documentElement.offsetHeight) {
        result = document.documentElement.offsetHeight;
    }
    return result;
 }
    
function JSFX_FloatDiv(id, sx, sy) {
    var el= d.getElementById ? d.getElementById(id) : d.all ? d.all[id] : d.layers[id];
    window[id + "_obj"] = el;

    if(d.layers){ 
        el.style=el; 
    }

    el.cx = el.sx = sx;
    el.cy = el.sy = sy;
    el.sP = function(x, y) {
        this.style.left = x + px;
        this.style.top = y + px;
    };
    el.sPP = function(x, y) {
        this.style.left = x + px;
        this.style.top = y + px;
        this.style.visibility = "visible";
        //alert("x:"+x+", y:"+y);
    };

    var pX, pY;
    pX = (el.sx >= 0) ? 0 : ns ? innerWidth : 
    document.documentElement && document.documentElement.clientWidth ? 
    document.documentElement.clientWidth : document.body.clientWidth;

    pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
    document.documentElement.scrollTop : document.body.scrollTop;
    if(el.sy < 0) {
        pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ?
        document.documentElement.clientHeight : document.body.clientHeight;
    }

    el.cx = pX + el.sx;
    el.cy = pY + el.sy;
    el.sPP(pX + el.sx, pY + el.sy);

    el.flt = function() {
        var pX, pY;
        try{
            pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
            document.documentElement && document.documentElement.clientWidth ? 
            document.documentElement.clientWidth : document.body.clientWidth;
    
            pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
            document.documentElement.scrollTop : document.body.scrollTop;
    
            if(this.sy < 0) {
                pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ?
                document.documentElement.clientHeight : document.body.clientHeight;
            }
            this.cx += (pX + this.sx - this.cx)/4;
            this.cy += (pY + this.sy - this.cy)/4;
            var offset = 20;
            this.cx = Math.floor(this.cx*100)/100;
            this.cy = Math.floor(this.cy*100)/100;
            if( (getHeight() - (parseInt(this.style.height.replace("px","")) + this.cy + 100 - this.sy - offset)) < 0){
            } else if(this.cy - this.sy < this.sy - offset) {
            } else {
                this.sP(this.cx, this.cy - this.sy + offset);
            }
            setTimeout(this.id + "_obj.flt()", 50);
        }catch(e){
        
        }
    }
    return el;
}