// Based on FlashTag.js class by Macromedia
// Thanks to FlashObject sample /tutorials (http://blog.deconcept.com/flashobject/) by Geoff Stearns for the Flash Detection method basis

function isSSL() {
    $url = location.href;
    
    if ($url.match(/^https:/)) {
        return true;
    }
    
    return false;
}


function FlashElement(src, width, height, loginSrc){
	this.src = src;
    this.loginSrc = loginSrc;
	this.width = width;
	this.height = height;
	this.version = "8,0,15,0";
	this.id = "flashMovie";
	this.className = "";
	this.style = "";
	this.bgcolor = "#ffffff";
	this.quality = "high";
	this.scaleMode = "noscale";
	this.stageAlign = "LT";
	this.allowScriptAccess = "always";
	this.flashVars = null;
	this.wmode = null;
	//this.isPlugin = this._detectPlugin();
}

var p = FlashElement.prototype;
var p2 = FlashElement.prototype;

var worldFlag = true;

p.toString = function(){
    var isMS = (navigator.appName.indexOf ("Microsoft") != -1) ? true : false;
    var str = "";

	if( document.URL.indexOf("/world/") == -1 ) {
		//ブラウザで表示されているURLが安心Worldではない('/world/'が含まれていない)
		worldFlag = false;
	}


    if (isMS)
    {
        str += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" ';
        str += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" ';
        if (!isSSL()) {
            str += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version + '" ';
        } else {
            str += 'codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version + '" ';
        }
		str += 'id="' + this.id + '" ';
		str += 'className="' + this.className + '" ';
		str += 'style="' + this.style + '" ';
		str += 'width="' + this.width + '" ';
        str += 'height="' + this.height + '">';
        str += '<param name="movie" value="' + this.src + '" />';
		str += '<param name="src" value="' + this.src + '&worldFlag=' + worldFlag + '" />';
		str += '<param name="bgcolor" value="' + this.bgcolor + '" />';
        str += '<param name="quality" value="' + this.quality + '" />';
		str += '<param name="scale" value="' + this.scaleMode + '" />';
		str += '<param name="salign" value="' + this.stageAlign + '" />';
		str += '<param name="allowScriptAccess" value="' + this.allowScriptAccess + '" />';
        if(this.flashVars != null)
        {
            str += '<param name="flashvars" value="' + this.flashVars + '" />';
        }
		if(this.wmode != null)
        {
            str += '<param name="wmode" value="' + this.wmode + '" />';
        }
        str += '</object>';
    }
    else
    {
        str += '<embed src="' + this.src + '&isIE=false&worldFlag=' + worldFlag + '" ';
        str += 'width="' + this.width + '" ';
        str += 'height="' + this.height + '" ';
		str += 'id="' + this.id + '" ';
		str += 'name="' + this.id + '" ';
		str += 'className="' + this.className + '" ';
		str += 'style="' + this.style + '" ';
		str += 'bgcolor="' + this.bgcolor + '" ';
		str += 'quality="' + this.quality + '" ';
		str += 'scale="' + this.scaleMode + '" ';
		str += 'salign="' + this.stageAlign + '" ';
//        str += 'wmode="transparent" ';
		str += 'allowScriptAccess="' + this.allowScriptAccess + '" ';
		if (this.flashVars != null){
            str += 'flashvars="' + this.flashVars + '" ';
        }
		if (this.wmode != null){
            str += 'wmode="' + this.wmode + '" ';
        }
        str += 'type="application/x-shockwave-flash" ';
        if (!isSSL()) {
            str += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        } else {
            str += 'pluginspage="https://www.macromedia.com/go/getflashplayer">';
        }
        str += '</embed>';
    }
    return str;
}

p2.toString2 = function(){
    var isMS = (navigator.appName.indexOf ("Microsoft") != -1) ? true : false;
    var str = "";
    if (isMS)
    {
        if (!isSSL()) {
            str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="205" height="103" id="FlashLogin" style="margin-left: 249px; margin-top: 12px ">';
        } else {
            str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="205" height="103" id="FlashLogin" style="margin-left: 249px; margin-top: 12px ">';
        }
        str += '<param name="allowScriptAccess" value="sameDomain" />';
        str += '<param name="movie" value="' + this.loginSrc + '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="' + this.loginSrc + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="220" height="109" name="FlashLogin" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';

        str += '</object>';
    }
    else
    {

        str += '<embed src="' + this.loginSrc + '&isIE=false" ';
        str += 'width="220" ';
        str += 'height="110" ';
        str += 'id="' + this.id + '" ';
        str += 'name="FlashLogin" ';
        str += 'className="' + this.className + '" ';
        str += 'style="margin-left: -4px; margin-top: 8px " ';
        str += 'bgcolor="' + this.bgcolor + '" ';
        str += 'quality="' + this.quality + '" ';
        str += 'scale="' + this.scaleMode + '" ';
        str += 'salign="' + this.stageAlign + '" ';
//        str += 'wmode="transparent" ';
        str += 'allowScriptAccess="' + this.allowScriptAccess + '" ';
        if (this.flashVars != null){
            str += 'flashvars="' + this.flashVars + '" ';
        }
        str += 'type="application/x-shockwave-flash" ';
        if (!isSSL()) {
            str += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        } else {
            str += 'pluginspage="https://www.macromedia.com/go/getflashplayer">';
        }
        str += '</embed>';
    }
    return str;
}

p.write = function(){
    var str = this.toString();
    document.write(str);
}

p2.write2 = function(){
    var str = this.toString2();
    document.write(str);
}

delete p;

