var isFirefox = 0;
var isIE = 0;
var isRTL = 0;
var isAttach = 0;
var isListen = 0;

function identify()
{
    if (window.attachEvent)
        isAttach = 1;
    if (window.addEventListener)
        isListen = 1;
    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
        isFirefox = new Number(RegExp.$1);
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
        isIE = new Number(RegExp.$1);
        // if (isIE == 8)
        //    isRTL = 1;
    }
}

function get_url_param(p)
{
    p = p.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]" + p + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if( results == null )
        return "";
    else
        return results[1];
}

embed_youtube = function()
{
    var d = document.getElementById("embed_youtube");
    if (d == null)
        return;
    var video = get_url_param("video");
    var width = get_url_param("w");
    var height = get_url_param("h");
    document.title = unescape(get_url_param("title"));
    var str = '<object width="' + width + '" height="{@height}">';
    str = str + '<param name="movie" value="http://www.youtube.com/v/' + video + '&hl=en&amp;fs=1"></param>';
    str = str + '<param name="allowFullScreen" value="true"></param>';
    str = str + '<param name="allowscriptaccess" value="always"></param>';
    str = str + '<embed src="http://www.youtube.com/v/' + video + '&hl=en&amp;fs=1"';
    str = str + 'type="application/x-shockwave-flash"';
    str = str + 'allowscriptaccess="always"';
    str = str + 'allowfullscreen="true"';
    str = str + 'width="' + width + '"';
    str = str + 'height="' + height + '">';
    str = str + '</embed></object>';
    d.innerHTML = str;
}

identify();
if (isAttach) {
    window.attachEvent("onload", embed_youtube); 
} else if (isListen) {
    window.addEventListener("DOMContentLoaded", embed_youtube, false);
}


