//var APP_VERSION = 103;

function previewRace(raceID, playerVersion)
{
    var myObject = document.createElement('object');
    myObject.width = "400";
    myObject.height = "400";
    myObject.classid = "clsid:563C679D-D9F8-4765-8743-9AB2EAB6867E"; 
    if(myObject.object)
    {
	if(checkVersion(APP_VERSION)) return;
        if(!myObject.previewRace(raceID))
        {
            if(confirm("Can't find HorseRacing application (no app).\nYou should download and install it first."))
                //window.open("http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe");
                window.location = "http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe";
        }
    }
    else
    {
        if(confirm("Can't find HorseRacing application (no helper).\nYou should download and install it first."))
            //window.open("http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe");
            window.location = "http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe";
    }
}

function previewRaceLive(raceID, playerVersion)
{
    var myObject = document.createElement('object');
    myObject.width = "400";
    myObject.height = "400";
    myObject.classid = "clsid:563C679D-D9F8-4765-8743-9AB2EAB6867E"; 
    if(myObject.object)
    {
		//checkVersion(playerVersion);
		if(checkVersion(APP_VERSION)) return;
        if(!myObject.previewRaceEx(raceID, true))
        {
            if(confirm("Can't find HorseRacing application (no app).\nYou should download and install it first."))
                //window.open("http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe");
                window.location = "http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe";
        }
    }
    else
    {
        if(confirm("Can't find HorseRacing application (no helper).\nYou should download and install it first."))
            //window.open("http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe");
            window.location = "http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe";
    }
}

function checkVersion(availablePlayerVersion)
{
	var newVersion = availablePlayerVersion;
	var needToUpdate = false;

    var myObject = document.createElement('object');
    myObject.width = "400";
    myObject.height = "400";
    myObject.classid = "clsid:563C679D-D9F8-4765-8743-9AB2EAB6867E"; 
	if(typeof(myObject.needToUpdate)!="undefined") needToUpdate = myObject.needToUpdate(newVersion);
	else needToUpdate = true;
	
	//alert(needToUpdate);
	if(needToUpdate)
		if(confirm("New version of player is available.\nDo you want to download new version?"))
		{
			window.location = "http://digitaldowns.us/newrace/horseracing/horseracinginstall.exe";
			return true;
		}

}