var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
var isiPad = ua.indexOf("ipad") > -1;
var isiPod = ua.indexOf("ipod") > -1;
var isiPhone = ua.indexOf("iphone") > -1;

function write_player(p_player, p_div, p_url, p_bufferlength, p_width, p_height, p_autostart, p_repeat, p_showstop, p_fullscreen, p_backcolor, p_frontcolor, p_lightcolor, p_image, p_link, p_target) {
    // --------- web devices only ---------//
    if (!isAndroid && !isiPad && !isiPod && !isiPhone) {
        // --------- Set Parameters ---------//
    
        // Media location or playlist
        var media_location = p_url;
    
        // Number of seconds an Video should be buffered
        var video_buffer_length = p_bufferlength;
    
        // Adjust the size of the video
        var video_width = p_width;
        var video_height = p_height;
    
        // Playlist position from the top
        var playlist_position = 0;
    
        // Playlist height
        var playlist_height = 100;
    
        // Playlist in live-effect: 0 = no, 1 = live
        var playlist_live = 1;
    
        // Video autostart: 0 = no, 1 = auto start
        var video_autostart = p_autostart;
    
        // Video repetition: 0 = no, 1 = auto repeate
        var video_repeat = p_repeat;
    
        // Video shuffle: 0 = no, 1 = shuffle
        var video_shuffle = 0;
    
        // Show stop control: 0 = no, 1 = show
        var video_showstop = p_showstop;
    
        // Show controls: 0 = no, 1 = show
        var showcontrols = 1;
    
        // Show Player controls: 0 = show within video, 1 = show below video
        var video_showctls = 1;
    
        // Size of controls: 0 = show normal controls, 1 = show large controls
        var video_ctls_size = 0;
    
        // Fullscreen option: 0 = show no fullscreen option, 1 = show fullscreen
        // option
        var video_fullscreen = p_fullscreen;
    
        // Defines the background color of the player controls
        var back_color = p_backcolor;
    
        // Defines the icon color of the player controls
        var front_color = p_frontcolor;
    
        // Defines the mouse over color of the player controls icons
        var light_color = p_lightcolor;
    
        // Defines the background color of the unselected playlist
        var pl_back_color = "#DADEE6";
    
        // Defines the text color of the unselected playlist
        var pl_text_color = "#4A4F58";
    
        // Defines the background color of the now-playing title of the playlist
        var pl_sel_back_color = "#4A4F58";
    
        // Defines the text color of the now-playing title of the playlist
        var pl_sel_text_color = "#DADEE6";
    
        // Defines the mouse over color of the playlist selection
        var pl_light_color = p_lightcolor;
    
        // Defines the mouse over text color of the playlist selection
        var pl_light_text_color = "#FFFFFF";
    
        // Defines the transparency of the playlist
        var pl_transparency_value = 80;
    
        // -------- End of Parameters -------//
    
        var video_display_height = video_height;
    
        media_location = media_location.toLowerCase();
    
        media_location = media_location.replace("?", "%3F");
        media_location = media_location.replace("=", "%3D");
        media_location = media_location.replace("&", "%26");
    
        if (media_location.substr(media_location.length - 4) != ".xml"
                || playlist_live == 0)
            playlist_live = "false";
        else
            playlist_live = "true";
    
        if (video_autostart == 0)
            video_autostart = "false";
        else
            video_autostart = "true";
    
        if (video_repeat == 0)
            video_repeat = "list";
        else
            video_repeat = "true";
    
        if (video_shuffle == 0)
            video_shuffle = "false";
        else
            video_shuffle = "true";
    
        if (video_showstop == 0)
            video_showstop = "false";
        else
            video_showstop = "true";
    
        if (showcontrols == 0) {
            video_showctls = 0;
            showcontrols = "false";
        } else
            showcontrols = "true";
    
        if (video_ctls_size == 0) {
            if (video_showctls == 0)
                video_display_height += 20;
            else {
                video_height += 20;
                video_display_height = video_height - 20;
            }
    
            video_ctls_size = "false";
        } else {
            if (video_showctls == 0)
                video_display_height += 40;
            else {
                video_height += 40;
                video_display_height = video_height - 40;
            }
    
            video_ctls_size = "true";
        }
    
        if (video_fullscreen == 0)
            video_fullscreen = "false";
        else
            video_fullscreen = "true";
    
        back_color = back_color.replace("#", "");
        front_color = front_color.replace("#", "");
        light_color = light_color.replace("#", "");
    
        back_color = "0x" + back_color;
        front_color = "0x" + front_color;
        light_color = "0x" + light_color;
    
        pl_back_color = pl_back_color.replace("#", "");
        pl_text_color = pl_text_color.replace("#", "");
        pl_sel_back_color = pl_sel_back_color.replace("#", "");
        pl_sel_text_color = pl_sel_text_color.replace("#", "");
        pl_light_color = pl_light_color.replace("#", "");
        pl_light_text_color = pl_light_text_color.replace("#", "");
    
        pl_back_color = "0x" + pl_back_color;
        pl_text_color = "0x" + pl_text_color;
        pl_sel_back_color = "0x" + pl_sel_back_color;
        pl_sel_text_color = "0x" + pl_sel_text_color;
        pl_light_color = "0x" + pl_light_color;
        pl_light_text_color = "0x" + pl_light_text_color
    
        var s1 = new SWFObject(p_player, "IMSFP", video_width, video_height, "8");
        s1.addParam("allowfullscreen", video_fullscreen);
        s1.addVariable("file", media_location);
        s1.addVariable("bufferlength", video_buffer_length);
        // s1.addVariable("width",video_width);
        // s1.addVariable("height",video_height);
        // s1.addVariable("displayheight",video_display_height);
        s1.addVariable("resize_video", "automatic");
        // s1.addVariable("overstretch","fit");
        s1.addVariable("playlistposition", playlist_position);
        s1.addVariable("playlistheight", playlist_height);
        s1.addVariable("playlistlive", playlist_live);
        var date = new Date();
        var hour = date.getHours();
        var min = date.getMinutes();
        var sec = date.getSeconds();
        var time = (hour < 10 ? "0" + hour : hour) + ":"
                + (min < 10 ? "0" + min : min) + ":" + (sec < 10 ? "0" + sec : sec);
        s1.addVariable("playlistlivetime", time);
        s1.addVariable("autostart", video_autostart);
        s1.addVariable("repeat", video_repeat);
        s1.addVariable("shuffle", video_shuffle);
        s1.addVariable("showstop", video_showstop);
        s1.addVariable("largecontrols", video_ctls_size);
        s1.addVariable("usefullscreen", video_fullscreen);
        s1.addVariable("volume", "80");
        s1.addVariable("showcontrols", showcontrols);
        s1.addVariable("nocontrols", "false");
        s1.addVariable("showdigits", "false");
        if (media_location.substr(media_location.length - 4) == ".xml")
            s1.addVariable("showdownload", "false");
        s1.addVariable("backcolor", back_color);
        s1.addVariable("frontcolor", front_color);
        s1.addVariable("lightcolor", light_color);
        s1.addVariable("pl_backcolor", pl_back_color);
        s1.addVariable("pl_textcolor", pl_text_color);
        s1.addVariable("pl_sel_backcolor", pl_sel_back_color);
        s1.addVariable("pl_sel_textcolor", pl_sel_text_color);
        s1.addVariable("pl_lightcolor", pl_light_color);
        s1.addVariable("pl_lighttextcolor", pl_light_text_color);
        s1.addVariable("pl_transparency", pl_transparency_value);
        if (p_image != "")
            s1.addVariable("image", p_image);
        if (p_link != "")
            s1.addVariable("link", p_link);
        if (p_target != "")
            s1.addVariable("target", p_target);
        s1.addVariable("tunneling", "yes");
        //document.write("To view this video download <a href=\"http://www.macromedia.com/go/getflashplayer\">Flash Player</a>");
        s1.write(p_div);
    }
}
