﻿
var cs_c9630edf33604f97804c8faa04fa047f_Utils = new Object();
cs_c9630edf33604f97804c8faa04fa047f_Utils.CreateSafeFunction = function(instance, func)
{
    return function() {
        return func.apply(instance, arguments);
    }
}
var loader_c9630edf33604f97804c8faa04fa047f = new cs_c9630edf33604f97804c8faa04fa047f_Loader();
loader_c9630edf33604f97804c8faa04fa047f.ReplaceScriptTag('http://www.mvm.com/cs/members/LovelyShan/embedFullAvator.aspx','<img src=\"http://shopping.mvm.com/compositor?v=4&amp;789CAD94DB6EE3201086DFC697068C0FF8C217DD5669575BADAA6EEF4798E043131B649CB5FAF63BB69B264A9D4AC95606E91F041FCCEF8122CB6BB5C3EEB9ECD5965E95094ABD21E391F0ACCDC8300CA4F9DB102BD54696DA116BEC6E2BFBDAB4CEB3E5C28452768D6E7B475C65ACADDB12064D03AF3E9ADA9957AD4E6630E2EA5E93AA5F1BE548DD4CAC2DE42550E6F7A5F46ADCCCF749D5CC0D0AE8F49672A914D0F4B06B14253C0CA618660D0C30A7089878B87B8431C4E4C621DF62DACBD860011B44FC038B1A39294BD3F01BB8C91137998ECBD8392CFE931561CCA73E23C5D698CE55726D86BD630586B0C28FBE03D85780DCACDFF62B473DAD9CD7FDFE15C39F5BB4EDC7F333AC5E38DC3C3178FC49C333C456AB0D19A9740F1C4726E084B9B90FE8045D66E4935B98CF26C77E1066D71775DF8F45323B18021507FB18A5019B63983582C33816E7B2BFA088C45111896B8AE862ECF5AEB0535728E51FAEA0BEC695CBEFC0FF70BFB8039FB00BAFCECEE96E2515AA280DD74405052741A4240979CC858A9548631EE709D3B1C4ABC1902E12DFB6E577BD2B2787FC07DE43A67D\r\n\">');

function cs_c9630edf33604f97804c8faa04fa047f_Loader()
{
    this._scriptsToLoad = new Array();
    this._currentScript = 0;

    this.AddScriptToLoad = function(scriptToLoad)
    {
        this._scriptsToLoad[this._scriptsToLoad.length] = scriptToLoad;
    }

    this.ReplaceScriptTag = function(scriptUrl, html)
    {
        scriptUrl = scriptUrl.toLowerCase();

        var scripts = document.getElementsByTagName('script');
        var script = null;
        for (var i = 0; i < scripts.length; i++)
        {
            if (scripts[i].src && scripts[i].src.toLowerCase() == scriptUrl)
	        {
		        script = scripts[i];
		        break;
	        }
        }

        if (script)
        {
	        var d = document.createElement('div');
	        d.innerHTML = html;
	        script.parentNode.insertBefore(d, script);
            script.parentNode.removeChild(script);
        }
    }

    this.AddCssText = function(cssText, media)
    {
        var s = document.createElement('style');
        s.type = 'text/css';

        if (media)
            s.media = media;

        if (s.styleSheet)
            s.styleSheet.cssText = cssText;
        else
            s.appendChild(document.createTextNode(cssText));

        document.getElementsByTagName('HEAD')[0].appendChild(s);            
    }

    this.LoadAll = function()
    {
        if (this._scriptsToLoad.length > 0 && this._currentScript < this._scriptsToLoad.length)
            this._scriptsToLoad[this._currentScript].Load(cs_c9630edf33604f97804c8faa04fa047f_Utils.CreateSafeFunction(this, this._loadSuccessful), cs_c9630edf33604f97804c8faa04fa047f_Utils.CreateSafeFunction(this, this._loadFailed));
    }

    this._loadSuccessful = function()
    {
        this._currentScript++;
        this.LoadAll();
    }

    this._loadFailed = function(e)
    {
        if (e)
            alert(e.message);
        else if (window.error)
            alert(window.error.message);
        else
            alert('An unknown error occured while loading scripts associated to the latest callback');
    }
}

function cs_c9630edf33604f97804c8faa04fa047f_ScriptToLoad(isInclude, content)
{
    this._isInclude = isInclude;
    this._content = content;
    this._element = null;
    this._completeCallback = null;
    this._errorCallback = null;
    this._errorTimeout = null;

    this._isSafari = function()
    {
        return navigator.userAgent.indexOf('Safari') != -1;
    }

    this._isIE = function()
    {
        return navigator && navigator.userAgent && navigator.userAgent.indexOf('MSIE') != -1
    }

    this.Load = function (completeCallback, errorCallback)
    {
        if (this._isInclude)
        {
            if (this._isScriptIncludeRegistered(this._content))
            {
                if (completeCallback)
                    completeCallback();
            }
            
            this._element = document.createElement('script');
            this._element.src = this._content;

            this._completeCallback = completeCallback;
            this._errorCallback = errorCallback;
            
            if (this._isSafari())
            {
                try
                {
                    document.getElementsByTagName('HEAD')[0].appendChild(this._element);
                }
                catch (e)
                {
                   if (errorCallback)
                       errorCallback(e);
                }

                setTimeout(cs_c9630edf33604f97804c8faa04fa047f_Utils.CreateSafeFunction(this, this._completeCallback), 999);
            }
            else
            {
                if (this._isIE())
                {
                    this._element.onreadystatechange = cs_c9630edf33604f97804c8faa04fa047f_Utils.CreateSafeFunction(this, this._readyStateChanged);
                }
                else
                {
                    this._element.readyState = 'loaded';
                    this._element.onload = cs_c9630edf33604f97804c8faa04fa047f_Utils.CreateSafeFunction(this, this._readyStateChanged);
                }
                
                document.getElementsByTagName('HEAD')[0].appendChild(this._element);
                
                this._errorTimeout = setTimeout(cs_c9630edf33604f97804c8faa04fa047f_Utils.CreateSafeFunction(this, this._errorOccured), 29999);
            }
        }
        else
        {
            var element = document.createElement('script');
            element.type = 'text/javascript';
            
            if (this._isSafari())
                element.innerHTML = this._content.replace(/(?:^\W*\/\/[^$]*?$|\/\*.*?\*\/)/gm, '');
            else
                element.text = this._content;
             
            try
            {
                document.getElementsByTagName('HEAD')[0].appendChild(element);
                
                if (!this._isSafari())
                    document.getElementsByTagName('HEAD')[0].removeChild(element);
            }
            catch (e)
            {
               if (errorCallback)
                   errorCallback(e);
            }

            if (completeCallback)
                completeCallback();
        }
    }

    this._isScriptIncludeRegistered = function(scriptUrl)
    {
        var scripts = document.getElementsByTagName('SCRIPT');
        
        for (var i = 0; i < scripts.length; i++)
        {

            if (scripts[i].src == scriptUrl)
                return true;
        }
        
        return false;
    }
    
    this._readyStateChanged = function()
    {
        if (this._element && (this._element.readyState == 'loaded' || this._element.readyState == 'complete'))
        {
            clearTimeout(this._errorTimeout);
            
            this._element.onreadystatechange = null;
            this._element.onload = null;
            this._element.onerror = null;
             
            if (this._completeCallback)
                this._completeCallback(); 
        }
    }
    
    this._errorOccured = function()
    {
        if (this._element)
        {
            this._element.onreadystatechange = null;
            this._element.onload = null;
            this._element.onerror = null;
        }
        
        if (this._errorCallback)
            this._errorCallback({'message': 'A script was not able to be loaded within the allowed time.  The callback has failed'});
    }
};
