   function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
    }

    
    function generateGuidInternal()
        {
            var result, i, j;
            result = '';
            for(j=0; j<32; j++)
            {
                if( j == 8 || j == 12|| j == 16|| j == 20)
                    result = result + '-';
                i = Math.floor(Math.random()*16).toString(16).toUpperCase();
                result = result + i;
            }
            return result
        }
    
    function QoofWriteWidget(){
   
        if(typeof(Qoof_episodeid)=="undefined") Qoof_episodeid = null;
        if(typeof(Qoof_playlistid)=="undefined") Qoof_playlistid = null;
        if(typeof(Qoof_uniqueId)=="undefined") Qoof_uniqueId = generateGuidInternal();
        if(typeof(Qoof_widgetWidth)=="undefined") Qoof_widgetWidth = '200';
        if(typeof(Qoof_widgetHeight)=="undefined") Qoof_widgetHeight = '275';
        if(typeof(Qoof_affiliateID)=="undefined") Qoof_affiliateID = '';
        if(typeof(Qoof_menu)=="undefined") Qoof_menu = true;
        if(typeof(Qoof_priceComp)=="undefined") Qoof_priceComp = false;
        if(typeof(Qoof_autoplay)=="undefined") Qoof_autoplay = false;
        if(typeof(Qoof_buttonText)=="undefined") Qoof_buttonText = '';
	if(typeof(Qoof_LPID)=="undefined") Qoof_LPID = '';

	Qoof_affiliateID = trim(Qoof_affiliateID);

        var Qoof_params;
        if(Qoof_playlistid == null){
            Qoof_params= "episodeid=" + Qoof_episodeid;
        }else{
            if(Qoof_episodeid == null){
                Qoof_params= "playlistid=" + Qoof_playlistid;
            }else{
                Qoof_params= "playlistid=" + Qoof_playlistid + 
                        "&episodeid=" + Qoof_episodeid;
            }
        }
        
        var Qoof_HTTPReferrer = document.location.href;        

        var Qoof_ObjectTag      =     "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'\n";
            Qoof_ObjectTag      +=    "			id='Qoof_Widget' WIDTH='" + Qoof_widgetWidth + "' HEIGHT='" + Qoof_widgetHeight + "'\n";
            Qoof_ObjectTag      +=    "			codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'>\n";
            Qoof_ObjectTag      +=    "			<param name='movie' value='http://ws.qoof.com/widget/Qoof_V2_15.swf' />\n";
            Qoof_ObjectTag      +=    "			<param name='quality' value='high' />\n";
            Qoof_ObjectTag      +=    "			<param name='bgcolor' value='#869ca7' />\n";
            Qoof_ObjectTag      +=    "			<param name='allowScriptAccess' value='always' />\n";
            Qoof_ObjectTag      +=    "			<param name='allowFullScreen' value='true' />\n";
            Qoof_ObjectTag      +=    "			<param name='flashvars' value='" + Qoof_params + "&uid=" + Qoof_uniqueId + "&affiliateID=" + Qoof_affiliateID + "&rotateInterval=2&widgetWidth=" + Qoof_widgetWidth + "&Menu=" + Qoof_menu + "&ComparePrice=" + Qoof_priceComp + "&AutoPlay=" + Qoof_autoplay + "&HTTPReferrer=" + Qoof_HTTPReferrer + "&buttonText=" + Qoof_buttonText + "' />\n"
            Qoof_ObjectTag      +=	  " <EMBED src='http://ws.qoof.com/widget/Qoof_V2_15.swf' FlashVars='" + Qoof_params + "&uid=" + Qoof_uniqueId + "&affiliateID=" + Qoof_affiliateID + "&rotateInterval=2&widgetWidth=" + Qoof_widgetWidth + "&Menu=" + Qoof_menu + "&ComparePrice=" + Qoof_priceComp + "&AutoPlay=" + Qoof_autoplay + "&HTTPReferrer=" + Qoof_HTTPReferrer + "&buttonText=" + Qoof_buttonText + "' allowScriptAccess='always' quality=high bgcolor=#FFFFFF WIDTH='" + Qoof_widgetWidth + "' HEIGHT='" + Qoof_widgetHeight + "' ALIGN='' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'wmode='transparent'>\n";
            Qoof_ObjectTag      +=	  " </EMBED>\n";
            Qoof_ObjectTag      +=	  " </object>\n";

        document.write(Qoof_ObjectTag);
        
    }
   
  
