﻿//------------------------------------------------------------------------------------------------//
// MAIN FUNCTIONS SECTION                                                                         //
//------------------------------------------------------------------------------------------------//
function GetMainFormName() {
    var i;
    for (i = 0; i < document.forms.length; i++) {
        // Framework v1.0.3705
        if (document.forms[i].name.indexOf("_ServerForm") != -1)
            return document.forms[i].name;
        // Framework v1.1.4322
        if (document.forms[i].name.indexOf("__aspnetForm") != -1)
            return document.forms[i].name;
        // Framework v2.0.50727
        if (document.forms[i].name.indexOf("aspnetForm") != -1)
            return document.forms[i].name;
    }
    return null;
}

function SaveElement(ElementObject, ElementValue) {
    var mf = GetMainFormName();
    if (mf == null) return;
    var element = GetElement(ElementObject, mf);
    if (element != null) {
        element.value = ElementValue;
    }
}

function GetElementName(n, mf) {
    if (n == null || n == "") return null;
    n = n.toLowerCase();
    var i, s, j;
    for (i = 0; i < document.forms[mf].elements.length; i++) {
        if (document.forms[mf].elements[i].name.toLowerCase().lastIndexOf(n) != -1) {
            var strform = document.forms[mf].elements[i].name.toLowerCase();
            var strformname = strform.substr(strform.lastIndexOf(n));
            if (strformname == n)
                return document.forms[mf].elements[i].name;
        }
    }
    return null;
}

function GetElementID(n, mf) {
    if (n == null || n == "") return null;
    n = n.toLowerCase();
    var i, s, j;
    for (i = 0; i < document.forms[mf].elements.length; i++) {
        if (document.forms[mf].elements[i].id.toLowerCase().lastIndexOf(n) != -1) {
            var strform = document.forms[mf].elements[i].id.toLowerCase();
            var strformname = strform.substr(strform.lastIndexOf(n));
            if (strformname == n)
                return document.forms[mf].elements[i].id;
        }
    }
    return null;
}

function GetElement(ElementName, formName) {
    return document.forms[formName].elements[GetElementID(ElementName, formName)];
}


//------------------------------------------------//
// Forum functions								  //
//------------------------------------------------//
function afficheEtoiles(nb) {
    for (i = 0; i < nb && nb <= 5; i++)
        document.write("<img src=\"/img/img_ref/common/forum/pict_etoile.gif\" border=\"0\">");
}

var OpenedDiv = "";

function DisplayPost(divname) {
    if (OpenedDiv != "")
        document.getElementById(OpenedDiv).style.display = "none";

    if (OpenedDiv != divname) {
        document.getElementById(divname).style.display = "block";
        OpenedDiv = divname;
    }
    else
        OpenedDiv = "";
}

function forumsearch() {
    var mf = GetMainFormName();
    if (mf == null) return;
    var sfield = document.forms[mf].searchfield.value;
    var criteria = document.forms[mf].selectsearch.selectedIndex;
    if (criteria == "0") {
        alert("no critaria");
        return;
    }
    if (sfield == "") {
        alert("no field");
        return;
    }
    else window.location = "search.aspx?searchid=" + criteria + "&search=" + sfield
}

var newWindow;
function openPopup(url, popupWidth, popupHeight) {
    if (newWindow && !newWindow.closed) {
        newWindow.close();
    }

    var winl = (screen.width - popupWidth) / 2;
    var wint = (screen.height - popupHeight) / 2;

    newWindow = open(url, 'popup', ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + popupWidth + ",height=" + popupHeight + "\""));
    newWindow.focus();
}

function openPopup2(url, popupWidth, popupHeight) {
    if (newWindow && !newWindow.closed) {
        newWindow.close();
    }

    var winl = (screen.width - popupWidth) / 6;
    var wint = (screen.height - popupHeight) / 6;

    newWindow = open(url, 'popup', ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + popupWidth + ",height=" + popupHeight + "\""));
    newWindow.focus();
}

function openPopup3(url, popupWidth, popupHeight) {
    if (newWindow && !newWindow.closed) {
        newWindow.close();
    }

    var winl = 0;
    var wint = 0;
    var w = screen.width;
    var h = screen.height;
    if (popupWidth > 0) { w = popupWidth; }
    if (popupHeight > 0) { h = popupHeight; }
    newWindow = open(url, 'popup', ("toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + w + ",height=" + h + "\""));
    newWindow.focus();
}
function openPopup4(url, popupWidth, popupHeight) {
    if (newWindow && !newWindow.closed) {
        newWindow.close();
    }

    var winl = (screen.width - popupWidth) / 8;
    var wint = (screen.height - popupHeight) / 8;

    newWindow = open(url, 'popup', ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + popupWidth + ",height=" + popupHeight + "\""));
    newWindow.focus();
}
function openOpener1(url) {

    try {
        window.opener.focus()
        window.close();

    }
    catch (e) {//error is raised of opener is closed, then open a new window

        var newWindow1;
        newWindow1 = open(url, '', ("toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,top=" + 0 + ",left=" + 0 + ",width=" + screen.width + ",height=" + screen.height + "\""));
        newWindow1.focus();
        window.close();
    }


}

function openPressPopup(url, popupWidth, popupHeight) {
    if (newWindow && !newWindow.closed) {
        newWindow.close();
    }

    var winl = (screen.width - popupWidth) / 6;
    var wint = (screen.height - popupHeight) / 6;

    newWindow = open(url, 'popup', ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + popupWidth + ",height=" + popupHeight + "\""));
    newWindow.focus();
}



function NavigateTo(_url) {
    if (_url != "") document.location.href = _url;
}

//---------------------------------------------------------//
// Validate zipcode: Zip should have 5 numeric characters  //
//---------------------------------------------------------//
function ValidateZip(zipTextbox) {
    //Check if zip code length is 5
    if (zipTextbox.value.length != 5) {
        return false;
    }
    else {
        //If zipcode length is 5, only allow 0-9 to be entered as the characters
        var checkOK = "0123456789";
        var allValid = true;
        for (var i = 0; i < zipTextbox.value.length; i++) {
            ch = zipTextbox.value.charAt(i);

            for (var j = 0; j < checkOK.length; j++) {
                if (ch == checkOK.charAt(j))
                    break;
            }

            if (j == checkOK.length) {
                allValid = false;
                break;
            }
        }
        if (!allValid) {
            return false;
        }
        else {
            return true;
        }
    }
}

/***************************************************************************************************************/


/*
* Never Use $get( anyid ) function in this file, as this file is shared by homepage and AJAX is not loaded on Home Page for optimization purposes
* Instead use document.getElementById() function. 
*/
function CreateTransparentControl(DivID, CLSID, ObjectID, WIDTH, HEIGHT, URL, FLASHVARS, AUTOSTART) {
    var d = document.getElementById(DivID);
    var objectTag = '<object classid=' + CLSID + ' id=' + ObjectID + ' width=' + WIDTH + ' height=' + HEIGHT + ' codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
    objectTag = objectTag + '<param name="allowScriptAccess" value="sameDomain">';
    objectTag = objectTag + '<param name="movie" value=' + URL + '>'
    objectTag = objectTag + '<param name="FlashVars" value=' + FLASHVARS + '>';
    objectTag = objectTag + '<param name="quality" value="high">'
    objectTag = objectTag + '<param name="autoStart" value=' + AUTOSTART + '/>';

    objectTag = objectTag + '<param name="wmode" value="transparent" />'

    objectTag = objectTag + '<embed wmode="transparent" src="' + URL + '" flashVars="' + FLASHVARS + '" quality="high" bgcolor="#000000" width="' + WIDTH + '" height="' + HEIGHT + '" name="main" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
    objectTag = objectTag + "</object>";
    d.innerHTML = objectTag;
}
function SetLogin(loginname) {
    var mf = GetMainFormName();
    if (mf == null) return;
    var login = GetElementName("hidden_login", mf)
    if (login != null)
        document.forms[mf].elements[login].value = loginname;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function MM_showHideLayers() { //v9.0
    var i, p, v, obj, args = MM_showHideLayers.arguments;
    for (i = 0; i < (args.length - 2); i += 3)
        with (document) if (getElementById && ((obj = getElementById(args[i])) != null)) {
        v = args[i + 2];
        if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v; }        
        obj.visibility = v;
    }

}

function isEnter(e,inputObj) {
    if (e.keyCode == 13) {
        gosearch(inputObj.id);
    }
    return true;
}

function gosearch(inputObj) {
    var mf = GetMainFormName();
    if (mf == null) return;

    var searchWord = document.getElementById(inputObj).value;
    searchWord = searchWord.toLowerCase();
    if (searchWord != 'search') {
        document.forms[mf].action = "/_us/_en/search/index.aspx?SearchKeywords=" + searchWord;
        document.forms[mf].submit();
    }
}

function DoAlternate(imgObj, objToShowHideStr, status) {
    var objToShowHide = document.getElementById(objToShowHideStr);
    if (typeof (status) != 'undefined') {
        if (status == 'show') {
            imgObj.src = '/img/ICN_Mns.gif';
            objToShowHide.style.display = 'block';
        } else if (status == 'hide') {
            imgObj.src = '/img/ICN_Pls.gif';
            objToShowHide.style.display = 'none';
        }
    }
    else {
        if (imgObj.src.indexOf('/img/ICN_Pls.gif') != -1)
            imgObj.src = '/img/ICN_Mns.gif';
        else
            imgObj.src = '/img/ICN_Pls.gif';

        if (objToShowHide.style.display == 'block')
            objToShowHide.style.display = 'none';
        else
            objToShowHide.style.display = 'block';
    }
}

function AdjustHeights() {
    var leftCont = document.getElementById('LeftNavContainer');
    var rightCont = document.getElementById('RightContainer');
    var maxHeight = 0;
    if (leftCont != null && rightCont != null) {
        if (leftCont.offsetHeight) {
            maxHeight = Math.max(leftCont.offsetHeight, rightCont.offsetHeight);
        } else if (leftCont.style.pixelHeight) {
            maxHeight = Math.max(leftCont.style.pixelHeight, rightCont.style.pixelHeight);
        }
        leftCont.style.height = maxHeight + "px";
        rightCont.style.height = maxHeight + "px";
    }
}
function ResetHeights() {
    var leftCont = document.getElementById('LeftNavContainer');
    var rightCont = document.getElementById('RightContainer');
    var maxHeight = 0;
    if (leftCont != null && rightCont != null) {
        leftCont.style.height = '';
        rightCont.style.height = '';
    }
}
/*
* This Update was provided by magic zoom team as a fix to the flickering problem of the Top Menu in IE
* Please do no change any thing below this code, it is very important JS update/hack 
**/

if (window.attachEvent /* only for IE */) {
    window['MM_showHideMenuLayers'] = function() {
        args = MM_showHideMenuLayers.arguments;        
        for (i = 0; i < (args.length - 2); i += 3) {
            with (document) {
                if (getElementById && getElementById(args[i])) {
                    MM_showHideMenuLayers_callback(args[i], args[i + 1], args[i + 2]);
                }
            }
        }
    }

    function MM_showHideMenuLayers_callback(id, unknow_argument, mode, second) {
        second = second || false;
        el = document.getElementById(id);
        over = mode == 'show' ? true : false;        
        if (!second && !over) {
            setTimeout(function() { MM_showHideMenuLayers_callback(id, unknow_argument, 'hide', true); }, 100);
            el.setAttribute('sameAttribute', 1);
            return;
        } else if (!over && el.getAttribute('sameAttribute') == 0) {
            return;
        }
        el.setAttribute('sameAttribute', 0);
        if (el.style) {            
            el.style.visibility = (mode == 'show') ? 'visible' : (mode == 'hide') ? 'hidden' : mode;
            if (AJAX_IsIE6()) {
                // the logic is oposite for hiding the dropdown for IE6
                var val = (mode == 'show') ? 'hidden' : 'visible';
                ToggleDropDowns(val);
                //alert(val);              
            }
        }

    }

    window['MM_swapImage'] = function() {
        args = MM_swapImage.arguments;
        var j = 0;
        document.MM_sr = new Array;
        for (var i = 0; i < (args.length - 2); i += 3) {
            if (MM_findObj(args[i])) {
                MM_swapImage_callback(args[i], args[i + 1], args[i + 2]);
                document.MM_sr.push(MM_findObj(args[i]));
            }
        }
    }

    function MM_swapImage_callback(id, unknow_argument, img/*,second*/) {
        el = MM_findObj(id);
        el.setAttribute('sameAttributeSwap', 0);
        if (!el.oSrc) {
            // alert('First Time :: oSrc : ' + el.oSrc);alert('Src : '+ el.oSrc);
            el.oSrc = el.src;
            el.src = img;
        }
        else {
            // TM : Added the else statement to solve the image swap issue
            // el.oSrc=el.src;
            el.src = img;
        }
    }

    window['MM_swapImgRestore'] = function() {
        var i, x, a = document.MM_sr;
        for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) {
            MM_swapImgRestore_callback(x);
        }
    }

    function MM_swapImgRestore_callback(el, second) {
        second = second || false;
        if (!second) {
            setTimeout(function() { MM_swapImgRestore_callback(el, true); }, 100);
            el.setAttribute('sameAttributeSwap', 1);
            return;
        } else if (el.getAttribute('sameAttributeSwap') == 0) {
            return;
        }
        el.setAttribute('sameAttributeSwap', 0);
        el.src = el.oSrc;
    }
}

function AJAX_IsIE6() {
    if (navigator.appName == 'Microsoft Internet Explorer') {

        if (navigator.appVersion.indexOf('MSIE 6.0') != -1) {
            return true;
        }
    }
    return false;

}
function ToggleDropDowns(state) {
    //alert(state);
    var mf = GetMainFormName();
    var variantDD = document.getElementById('varlist')
    if (variantDD != null)
        variantDD.style.visibility = state;

    var quantityDDID = GetElementID("QtyList", mf);
    var objquantityDD = document.getElementById(quantityDDID);
    if (objquantityDD != null) {
        objquantityDD.style.visibility = state;
    }

}

// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

 
     
function DisplayNewLetterMessageBubble(divObj){
    clearTimeout(footer_timer);
    _CoreModalPopUp._PopupControlID = divObj;
    _CoreModalPopUp.ShowModal();
}

function ShowLoginBubble()
{
     var _obj=document.getElementById("AjaxLoginBubble");
         if (_obj!=null) {
            _obj.style.visibility='visible';
            _obj.style.display="";
            
         }
          //_CoreModalPopUp._PopupControlID='dummy1';
         _CoreModalPopUp._PopupControlID = "AjaxLoginBubble";
          _CoreModalPopUp.ShowModal();
          //_CoreModalPopUp._PopupControlID="AjaxLoginBubble";
         
//    _CoreModalPopUp._PopupControlID = "AjaxLoginBubble";
//    _CoreModalPopUp.ShowModal();
}
function HideLoginBubble(){
    var _obj=document.getElementById("AjaxLoginBubble");
         if (_obj!=null) {
            _obj.style.visibility='hidden';
            _obj.style.display="none";
            
         }
    _CoreModalPopUp.HideModal();     
}

function ShowForgotPasswordBubble()
{
    HideLoginBubble();           
    _CoreModalPopUp._PopupControlID = "ForgotPassword_Bubble";
    _CoreModalPopUp.ShowModal();
}

function ShowContactUsBubble(index)
{
    if (typeof (index) != 'undefined') {
        var contactUSIframe = document.getElementById("ContactUS_Bubble_iframe");
        // window.frames["ContactUS_Bubble_iframe"].SelectMailSubject(index);
        document.getElementById('ContactUS_Bubble_iframe').contentWindow.SelectMailSubject(index);

        //contactUSIframe.SelectMailSubject(index);

    }
    _CoreModalPopUp._PopupControlID = "AjaxContactUsBubble";
    _CoreModalPopUp.ShowModal();
    
}

function HideContactUsBubble()
{              
    _CoreModalPopUp.HideModal();
    // reset the src of the contactus iframe to show the contact form
    document.getElementById('ContactUS_Bubble_iframe').src = '/_us/_en/iframe/contactus.aspx';
    _CoreModalPopUp._PopupControlID = "AjaxContactUsThankyouBubble";
    _CoreModalPopUp.ShowModal();
}

function HideMakeupBubble() {

    _CoreModalPopUp.HideModal();    
}

function ShowOrderHistoryDetailAddToBagErrorBubble(errorMsg) {
    $get("OrderHistoryError_Message").innerHTML = errorMsg.replace("<li>", "");
    _CoreModalPopUp._PopupControlID = "AjaxOrderHistoryDetailAddtoBagErrorBubble";
    _CoreModalPopUp.ShowModal();
}

var div_checkout_newmember_id = "DIV_CHECKOUT_NEW_MEMBER";
var div_checkout_newmember_reg_id = "DIV_CHECKOUT_NEW_MEMBER_REGISTER";

function ShowNewMemberRegistration() {

    var _objNewMember = document.getElementById(div_checkout_newmember_id);
    var _objNewMemberReg = document.getElementById(div_checkout_newmember_reg_id);

    if (_objNewMember != null) {    
        _objNewMember.style.visibility = "hidden";
        _objNewMember.style.display = "none";
    }

    if (_objNewMemberReg != null) {        
        _objNewMemberReg.style.visibility = "visible";
        _objNewMemberReg.style.display = "";

    }

}

function SelectVariantFromDropdown(optionValue, optionText) {
    var array = optionValue.split('#');
    
    //Set the Variant Price and Name in text    
    $get('ProductVariantPrice').innerHTML = array[1];
    $get('ProductVariantName').innerHTML = optionText;

    //Reset all swatch names
    var strArr = "";
    var sku = "";
    var swatchDiv = "";
    var varlistDropdown = $get("varlistDropdown");
    
    for (var i = 0; i < varlistDropdown.options.length; i++) {
        strArr = varlistDropdown.options[i].value.split('#');
        sku = strArr[0];        
        swatchDiv = 'varlistSwatchName_' + sku;
        $get(swatchDiv).style.fontWeight = "normal";
    }
    
    //Set the selected swatch name
    swatchDiv = 'varlistSwatchName_' + array[0];
    $get(swatchDiv).style.fontWeight = "bold";
    
    //Set the stock web button
    if (array[2] <= OOS_THRESHOLD) {
        if (array[4] == 1) {
            $get("AddToBag").style.display = "none";
            $get("OutOfStock").style.display = "none";
            $get("Preorder").style.display = "";
            $get("Backorder").style.display = "none";
        }
        else if (array[4] == 2) {
            $get("AddToBag").style.display = "none";
            $get("OutOfStock").style.display = "none";
            $get("Preorder").style.display = "none";
            $get("Backorder").style.display = "";
        }
        else {
            $get("AddToBag").style.display = "none";
            $get("OutOfStock").style.display = "";
            $get("Preorder").style.display = "none";
            $get("Backorder").style.display = "none";
        }
    }
    else {
        $get("AddToBag").style.display = "";
        $get("OutOfStock").style.display = "none";
        $get("Preorder").style.display = "none";
        $get("Backorder").style.display = "none";
    }
}   

var LastCrossSell = null;
function ShowCorssSell(currentVariant) {
    if (LastCrossSell == null) {
        $('#CrossSell_' + currentVariant).show();
        LastCrossSell = $('div.tabbed ul.tabs li:first').attr("sku");
        if (currentVariant != LastCrossSell)
            $('#CrossSell_' + LastCrossSell).hide();        
    } else {
    $('#CrossSell_' + currentVariant).show();
    $('#CrossSell_' + LastCrossSell).hide();
    }
    LastCrossSell = currentVariant;
}

function CreateLimelightPlayer(DivID, WIDTH, HEIGHT, FileName,AUTOSTART) {
    var d = document.getElementById(DivID);

    if (!DetectFlashVer("10", "0", "10.0")) {
        d.style.height = "326";
        d.innerHTML = 'This video requires Adobe Flash Player 10. Please click <a style="color:#FF0000" target="_blank" href="http://get.adobe.com/flashplayer/"><u>here</u></a> to download it';
    } else {
        var objectTag = '<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 id=OBJ_' + DivID + ' width=' + WIDTH + ' height=' + HEIGHT + ' codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
        objectTag = objectTag + '<param name="allowScriptAccess" value="sameDomain">';
        objectTag = objectTag + '<param name="movie" value="/images/flash/video_player.swf" >'
        objectTag = objectTag + '<param name="quality" value="high">'
        objectTag = objectTag + '<param name="autoStart" value=' + AUTOSTART + '/>';
        objectTag = objectTag + '<param name="allowFullScreen" value="true" />';
        objectTag = objectTag + '<param name="wmode" value="transparent" />';
        var FLASHVARS = "mediaURL=rtmp://loreal.fcod.llnwd.net/a1685/o15/SoftSheen_Carson_USA/" + FileName + "&buffer=0&streamType=Streaming&" +
                "autoPlay=" + AUTOSTART + "&playerWidth=" + WIDTH + "&playerHeight=" + HEIGHT +
                "&autoHideControls=false&autoHideTime=5&initialVolume=50";
        objectTag = objectTag + '<param name="FlashVars" value=' + FLASHVARS + '>';
        objectTag = objectTag + '<embed wmode="transparent" src="/images/flash/video_player.swf" flashVars="' + FLASHVARS + '" quality="high" bgcolor="#000000" width="' + WIDTH + '" height="' + HEIGHT + '" name="main" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer">';
        objectTag = objectTag + "</object>";
        d.innerHTML = objectTag;
    }
}

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2008 Adobe Systems Incorporated.  All rights reserved.
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion() {
    var version;
    var axo;
    var e;
    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }
    if (!version) {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful. 

            // default to the first public version
            version = "WIN 6,0,21,0";
            // throws if AllowScripAccess does not exist (introduced in 6.0r47)		
            axo.AllowScriptAccess = "always";
            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }
    if (!version) {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }
    if (!version) {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }
    if (!version) {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }

    return version;
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer() {
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;

    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // older WebTV supports Flash 2
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if (isIE && isWin && !isOpera) {
        flashVer = ControlVersion();
    }
    return flashVer;
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
    versionStr = GetSwfVer();
    if (versionStr == -1) {
        return false;
    } else if (versionStr != 0) {
        if (isIE && isWin && !isOpera) {
            // Given "WIN 2,0,0,11"
            tempArray = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
            tempString = tempArray[1]; 		// "2,0,0,11"
            versionArray = tempString.split(","); // ['2', '0', '0', '11']
        } else {
            versionArray = versionStr.split(".");
        }
        var versionMajor = versionArray[0];
        var versionMinor = versionArray[1];
        var versionRevision = versionArray[2];
        // is the major.revision >= requested major.revision AND the minor version >= requested minor
        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
}
