var DetectImageState = {
    version: '1.0',
    imagesDisabled: true,
    inserted_id: 'detectimagestate-test-img',
    callback: function() { },
    ie_detectionComplete: false,
    img: null,
    ie_Timeout: 100,
    init: function(testerimg, cb) {
        this.callback = cb;
        document.body.innerHTML += '<img id="'+this.inserted_id+
		  '" style="display:none;position:absolute;left:-1000px;" src="'+testerimg+'?'+Math.random()+'" alt="" />';
        this.img = document.getElementById(this.inserted_id);

        if (window.opera || navigator.userAgent.toLowerCase().indexOf('opera') >- 1) {
            var pre = this.img.complete;
            this.img.src = 'about:blank';
            this.imagesDisabled = (!pre && this.img.complete) ? false : true;
            DetectImageState.callback(this.imagesDisabled);
            return;
        } else if (typeof this.img.readyState != 'undefined') {
            this.img.src = this.img.src+'?'+Math.random();
            this.img.onabort = function() {
                DetectImageState.ie_detectionComplete = true;
                DetectImageState.imagesDisabled = false;
                DetectImageState.callback(DetectImageState.imagesDisabled);
            };

            setTimeout('if (!DetectImageState.ie_detectionComplete) DetectImageState.callback(DetectImageState.imagesDisabled);', this.ie_Timeout);
            return;
        } else {
            this.imagesDisabled = this.img.complete;
            DetectImageState.callback(this.imagesDisabled);
            return;
        }
    }
};


function check_png_bgrnd(element)
{
	element.runtimeStyle.filter = "";
	if (!(/MSIE (7|8).+Win/.test(navigator.userAgent)))
	{
		var src;
		src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
		if (src)
		{
			if ((/MSIE (5\.5|6).+Win/.test(navigator.userAgent)))
			{
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
				element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";
			}
			else if (/MSIE (5).+Win/.test(navigator.userAgent))
			{
				src = element.currentStyle.backgroundImage.replace(/.png/i,".gif");
				element.runtimeStyle.backgroundImage = src;
			}
		}
	}
}

function mmb_light_on(E)
{
	if (E.className == "t_mmb") 
	{
		E.className="t_mmb_h";
		document.getElementById(E.id+"_l").className="t_mmb_l_h";
		document.getElementById(E.id+"_r").className="t_mmb_r_h";
	}
}

function mmb_light_off(E)
{
	if (E.className == "t_mmb_h")
	{
		E.className="t_mmb";
		document.getElementById(E.id+"_l").className="t_mmb_l";
		document.getElementById(E.id+"_r").className="t_mmb_r";
	}
}

function lm_light_on(E)
{
	E=E.parentNode;
	if (E)
	{
		if (E.className == "t_lm")	E.className="t_lm_h";
		else if (E.className == "t_lsm")	E.className="t_lsm_h";
	}
}

function lm_light_off(E)
{
	E=E.parentNode;
	if (E)
	{
		if (E.className == "t_lm_h")	E.className="t_lm";
		else if (E.className == "t_lsm_h")	E.className="t_lsm";
	}
}

function images_detected(bDisabled) 
{
    if (!bDisabled)
	{
		document.getElementById("logo_txt").className="logo_off";
		document.getElementById("logo_img").className="logo_img_on";
		if (!(/MSIE (5(?!\.5)).+Win/.test(navigator.userAgent)))
		{
			var e;
			e=document.getElementById("d_bn_2_caption_txt");
			if (e)
			{
				document.getElementById("d_bn_2_caption_img").className=e.className+"_img";				
				e.className="d_bn_2_off";
			}
		} else {
			document.getElementById("d_bn_3").className="d_bn_3_off";
		}
	}
}

function reseller_change(E)
{
	if (E.checked)
	{
		document.getElementById("bynowlink").href=E.value;
	}
}

function TrackSUD()
{
	_gaq.push(['_trackEvent', 'SyncUpEvent', 'SyncUpDownload']);
}

function TrackTPD()
{
	_gaq.push(['_trackEvent', 'TrayPlayerEvent', 'TrayPlayerDownload']);
}
