function FlashPlayer( config, newBid, newQueryParams, newAffiliateId, newVideoUrl, newPreviewBid, newSampleId )
{
    this.width = "100%";
    this.height = "100%";
    this.target = null;
    this.rootFile = "skinVideoroot.swf";
    this.autoPlay = null;
    this.limitedPlay = null;
    this.activeStatus = null;
    this.mute = false;

    this.queryParams = escape( newQueryParams );
    this.bid = newBid;
    this.affiliateId = newAffiliateId;
    this.videoUrl = newVideoUrl;
    this.previewBid = newPreviewBid;
    this.sampleId = newSampleId;

    this.domainUrl = null;
    this.rootUrl = null;

    /**
     * covers the params:
     * => width
     * => height
     * => target
     * => rootFile
     */
    if ( this.isValueSet( config ) ) {
        var args = config.split( ',' );
        for ( var i = 0; i < args.length; i++ ) {
            var param = args[ i ].split( '=' );
            eval( "this." + param[ 0 ] + " = '" + param[ 1 ] + "'" );
        }
    }

    this.setWidth = function( newWidth ) {
        this.width = newWidth;
    }

    this.setHeight = function( newHeight ) {
        this.height = newHeight;
    }

    this.setTarget = function( newTarget ) {
        this.target = newTarget;
    }

    this.getFlashPlayerEmbed = function( isEmbeddedPlayer ) {
        var output = '<embed src="' + this.getRootUrl( isEmbeddedPlayer ) + '" '
            + 'quality="best" '
            + 'bgcolor="#FFFFFF" '
            + 'menu="true" '
            + 'width="' + this.width + '" '
            + 'height="' + this.height + '" '
            + 'name="root" '
            + 'id="root" '
            + 'align="middle" '
            + 'scaleMode="noScale" '
            + 'allowScriptAccess="sameDomain" '
            + 'allowFullScreen="true" '
            + 'type="application/x-shockwave-flash" '
            + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
            + '</embed>';

        return output;
    }

    this.writeBlogFlashPlayer = function() {
        var output = this.getFlashPlayerEmbed( true );
	    var div_block = document.getElementById( this.target );
        
	    div_block.value = output;
    }

    this.writeFlashPlayer = function() {
        var output = this.getFlashPlayerEmbed( false );
	    var div_block = document.getElementById( this.target );

	    div_block.innerHTML = output;
    }

    this.getRootUrl = function( isEmbeddedPlayer )
    {
        if ( !this.isValueSet( this.rootUrl ) )
        {
            this.rootUrl = this.getDomain();

            if ( this.isValueSet( this.affiliateId ) )
            {
                this.rootUrl += '/a/' + this.affiliateId + '/a';
            }

            this.rootUrl += '/f/' + this.rootFile + '?';
        
            if ( this.isValueSet( this.affiliateId ) )
            {
                this.rootUrl += 'aid=' + this.affiliateId + '&';
            }

            if ( this.isValueSet( this.queryParams ) )
            {
                this.rootUrl += 'query_params=' + this.queryParams;
            }
            else if ( this.isValueSet( this.bid ) )
            {
                this.rootUrl += 'bid=' + this.bid;
            }
            else if ( this.isValueSet( this.videoUrl ) )
            {
                this.rootUrl += 'video_url=' + this.videoUrl;
            }

            if ( this.isValueSet( this.previewBid ) )
            {
                this.rootUrl += '&preview_bid=' + this.previewBid;
            }

            if ( this.isValueSet( this.autoPlay ) )
            {
                this.rootUrl += '&autoPlay=' + this.autoPlay;
                this.rootUrl += '&isEmbeddedPlayer=false';
            }
            else {
                this.rootUrl += '&isEmbeddedPlayer=' + isEmbeddedPlayer;
            }

            if (this.isValueSet( this.limitedPlay ) )
            {
              this.rootUrl += '&maxPlayTime=' + this.limitedPlay;
            }

            if (this.isValueSet( this.activeStatus ) )
            {
              this.rootUrl += '&activeStatus=' + this.activeStatus;
            }

            if ( this.isValueSet( this.mute ) )
            {
                this.rootUrl += '&mute=' + this.mute;
            }

            if ( this.isValueSet( this.sampleId ) ) {
                this.rootUrl += '&sample=' + this.sampleId;
            }
        }
        return this.rootUrl;
    }

    this.getDomain = function() {
        return "http://www.skinvideo.com";
    }

}

FlashPlayer.prototype.isValueSet = function( value ) {
    if ( value == null
      || value == 'null'
      || typeof( value ) == 'undefined'
      || value == '' )
    {
        return false;
    }
    return true;
}

function obw(i) { 
  if (exit) { 
    if (document.cookie.length > 0 && i == 0) {
      offset = document.cookie.indexOf('pu=');
      if (offset != -1) { return; }
      document.cookie='pu=1; path=/'; 
    }
    urchinTracker("/special/popunder" + i);
    var pu = window.open('http://www.skinvideo.com/redirect/pu?x=' + i,"tgt",'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=950,height=900'); 
    pu.blur();
    window.focus();
  }
}

