﻿if (typeof UseSSL == "undefined")
{
	if(location.protocol == "https:") 
	{
		UseSSL = true;
	}
	
	else
	{
		UseSSL = false;
	}
}

function InjectVSPScript(new_script)
{
    var scripts = document.getElementsByTagName('script');   
    
    if(scripts)
	{
		for(var i=0; i < scripts.length; i++)   
		{   
			if(scripts[i].src.indexOf('vsp.js') != -1)   
			{   
				break;   
			}
		}
    
		if(scripts[i])
		{
			scripts[i].parentNode.insertBefore(new_script, scripts[i]);  
		}
		
		else
		{
			var vsp_head = document.getElementsByTagName ("head")[0] || document.documentElement;
			vsp_head.insertBefore(new_script, vsp_head.firstChild);
		}
	}
}

function IncludeVSPJavaScript(jsFile,use_defer)
{
    var new_script = document.createElement('script');
    new_script.setAttribute("type","text/javascript");

    if(use_defer)
    {
        new_script.setAttribute("defer","defer");
    }
  
    new_script.src = jsFile;
    InjectVSPScript(new_script);
}

function LoadVSP()
{
    IncludeVSPJavaScript(((UseSSL) ? "https" : "http") + "://virtual-person.com/exterior/vsp_loading.js", false);
}


if(window.onload == null)
{
    window.onload = LoadVSP;
    
    if (document.addEventListener)
    {
        document.addEventListener("Load", LoadVSP, false);
    }
}

else
{
    if(typeof vsp_old_onload == "undefined")
    {
        vsp_old_onload = window.onload;
        
        window.onload = function() { vsp_old_onload(); LoadVSP(); }

        if (document.addEventListener)
        {
            document.addEventListener("Load", function() { vsp_old_onload(); LoadVSP(); }, false);
        }
    }

}


