﻿/*Kodlama:Ahmet AKÇAY*/

var tfkbFO = {
    flashVersion: 0,
    myFlashVersion: 7,
    latestFlashVersion: 25,
    myId: "",
    mywidth: 0,
    myheight: 0,
    mysrc: "",
    altImage: "",
    altHref: "",
    altTarget: "",
    parameters: Array(),
    alternateRun: null,
    suggestFlash: true,
    usemap: "",
    mapAttr: "",

    getFlashVersion: function () {
        flashVersion_DONTKNOW = 0;
        var agent = navigator.userAgent.toLowerCase();
        if (this.isNoFlashDevice(agent)) {
            return flashVersion_DONTKNOW;
        }
        else {
            if (navigator.plugins != null && navigator.plugins.length > 0) {
                var flashPlugin = navigator.plugins['Shockwave Flash'];
                if (typeof flashPlugin == 'object') {
                    for (var i = this.latestFlashVersion; i >= 3; i--) {
                        if (flashPlugin.description.indexOf(i + '.') != -1) { flashVersion = i; break; }
                    }
                }
                else {
                    flashVersion = flashVersion_DONTKNOW;
                }
            }
            else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win") != -1 && agent.indexOf("16bit") == -1) {
                var doc = '' +
				'<scr' + 'ipt language="VBScript"\> \n' +
				'On Error Resume Next \n' +
				'Dim obFlash \n' +
				'flashVersion = 0 \n' +
				'For i = ' + this.latestFlashVersion + ' To 3 Step -1 \n' +
				'	Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n' +
				'	If IsObject(obFlash) Then \n' +
				'		flashVersion = i \n' +
				'		Exit For \n' +
				'	End If \n' +
				'Next \n' +
				'</scr' + 'ipt\> \n';
                document.write(doc);
            } else { flashVersion = flashVersion_DONTKNOW; }
            return flashVersion;
        }
    },

    defaultSetup: function () {
        this.parameters["movie"] = this.parameters["src"];
        this.parameters["name"] = this.parameters["Id"];
        if (this.parameters["quality"] == undefined) this.parameters["quality"] = "high";
        if (this.parameters["pluginspage"] == undefined) this.parameters["pluginspage"] = "http://www.macromedia.com/go/getflashplayer";
        if (this.parameters["align"] == undefined) this.parameters["align"] = "middle";
        if (this.parameters["play"] == undefined) this.parameters["play"] = "true";
        if (this.parameters["loop"] == undefined) this.parameters["loop"] = "true";
        if (this.parameters["scale"] == undefined) this.parameters["scale"] = "noscale";
        if (this.parameters["wmode"] == undefined) this.parameters["wmode"] = "window";
        if (this.parameters["devicefont"] == undefined) this.parameters["devicefont"] = "false";
        if (this.parameters["bgcolor"] == undefined) this.parameters["bgcolor"] = "#ffffff";
        if (this.parameters["menu"] == undefined) this.parameters["menu"] = "true";
        if (this.parameters["allowFullScreen"] == undefined) this.parameters["allowFullScreen"] = "false";
        if (this.parameters["allowScriptAccess"] == undefined) this.parameters["allowScriptAccess"] = "sameDomain";
        if (this.parameters["salign"] == undefined) this.parameters["salign"] = "";
        this.myId = this.parameters["Id"];
        if (this.parameters["FlashVersion"] != undefined) this.myFlashVersion = this.parameters["FlashVersion"];
        this.mywidth = this.parameters["width"];
        this.myheight = this.parameters["height"];
        this.mysrc = this.parameters["movie"];
    },

    init: function () {
        this.flashVersion = this.getFlashVersion();
        this.defaultSetup();
        if (this.flashVersion >= this.myFlashVersion) {
            this.generateObj();
        }
        else {
            this.generateAltImage();
        }

    },

    generateAltImage: function () {
        if (this.alternateRun == null) {
            dummyImage = '';
            if (this.altImage != "") {
                dummyImage += '<div style="display:inline;">';
                if (this.suggestFlash == true) {
                    dummyImage += '<div style="width:158px;position:absolute;z-index:9999;margin-left:' + (parseInt(this.parameters["width"]) - 158) + 'px;"><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BUIGP" target="_blank"><img src="_i/FlashPlayer.gif" border="0" alt="" /></a>'
                    dummyImage += '</div>';
                }
                if (this.altHref != "") {
                    dummyImage += '<a href="' + this.altHref + '"';
                    if (this.altTarget != "") dummyImage += ' target="' + this.altTarget + '"'
                    dummyImage += '>';
                }
                dummyImage += '<img style="z-index:9998;" src="' + this.altImage + '"';
                if (this.usemap.length > 0) {
                    dummyImage += ' usemap="#' + this.usemap + '"';
                }
                dummyImage += '  border="0" alt="" />';
                if (this.altHref != "") { dummyImage += '</a>'; }
                if (this.mapAttr.length > 0) { dummyImage += this.mapAttr; }
                dummyImage += '</div>'
                document.write(dummyImage)
            }
            else {
                alert("Adobe Flash Player bulunamadı ya da Adobe Flash Player " + this.flashVersion + " bu uygulama için eski bir versiyon.")
            }
        }
        else {
            this.alternateRun();
        }
    },

    generateObj: function () {
        dummyObj = '';
        dummyObj += '<object id="' + this.myId + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
        dummyObj += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.myFlashVersion + ',0,0,0" '
        dummyObj += 'width=' + this.mywidth + ' height=' + this.myheight + '>'

        for (var i in this.parameters) {
            if (i != "width" && i != "height" && i != "FlashVersion" && i != "Id" && i != "src" && typeof (this.parameters[i]) != "function" && typeof (this.parameters[i]) != "object") dummyObj += '<param name="' + i + '" value="' + this.parameters[i] + '" />'
        }

        dummyObj += '<embed src="' + this.parameters["src"] + '" width="' + this.parameters["width"] + '" height="' + this.parameters["height"] + '" wmode="' + this.parameters["wmode"] + '" quality="' + this.parameters["quality"] + '" align="' + this.parameters["align"] + '" scale="' + this.parameters["scale"] + '" salign="' + this.parameters["salign"] + '" menu="' + this.parameters["menu"] + '" bgcolor="' + this.parameters["bgcolor"] + '" name="' + this.parameters["name"] + '" allowScriptAccess="' + this.parameters["allowScriptAccess"] + '" type="application/x-shockwave-flash" pluginspage="' + this.parameters["pluginspage"] + '" />'
        dummyObj += '</object>'
        document.write(dummyObj)
    },

    isNoFlashDevice: function (_agent) {
        var blockedText = ["iphone", "wp7", "iemobile", "hd7"]
        for (var i = 0; i < blockedText.length; i++) {
            if (_agent.indexOf(blockedText[i]) > -1) {
                return true;
            }
        }
        return false;
    }
}

Array.prototype.add = function (_name, _val) {
    this[_name] = _val;
}

