System =
{

	getUrl: function(url)
	{
		var tags = document.getElementsByTagName('base');
		if (!/^http:\/\//.test(url) && tags.length > 0)
		{
			var base = tags.item(0);
			url = base.getAttribute('href') + url;
		}
		return url;
	},

	openUrl: function(url, target)
	{
		window.open(System.getUrl(url), target!=null ? target : '_self');
	},

	openPopup: function(url, name, options, params)
	{
		if (options == null) options = {};
		if (options.width == null) options.width = 500;
		if (options.height == null) options.height = 500;
		if (options.scrollbars == null) options.scrollbars = 1;
		if (options.top == null)
			options.top = Math.floor((screen.height - options.height - 50) / 2);
		if (options.left == null)
			options.left = Math.floor((screen.width - options.width) / 2);
		if (params != null)
		{
			for (key in params)
			{
				url += url.indexOf('?') > -1 ? '&' : '?';
				url += key+'='+encodeURI(params[key]);
			}
		}
		popup = window.open(System.getUrl(url), name,
			'width='+options.width+
			',height='+options.height+
			',left='+options.left+
			',top='+options.top+
			',scrollbars='+options.scrollbars
		);
		popup.focus();
		if (options.close != null)
			window.onfocus = function(){try {popup.close();} catch(e) {}};
		return popup;
	},

	insertApplet: function(id, attrs, params)
	{
		var html = '<applet';
		for (var key in attrs)
			html += ' '+key+'="'+attrs[key]+'"';
		html += '>\n';
		if (params != null)
		{
			for (var key in params)
				html += '<param name="'+key+'" value="'+params[key]+'" />\n';
		}
		html += '</applet>\n';
		document.getElementById(id).innerHTML = html;
	},

	insertVideo: function(id, url, width, height, autoStart)
	{
		var html = '<object' + 
    	' height="' + height + '"' + 
    	' width="' + width + '"' +
    	' type="application/x-oleobject"' +
    	' standby="Videó töltése..."' +
    	' codebase="http://www.microsoft.com/ntserver/netshow/download/en/nsmp2inf.cab#Version=5,1,51,415"' +
    	' classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"' + 
    	' codebase="http://www.microsoft.com/ntserver/netshow/download/en/nsmp2inf.cab#Version=5,1,51,415"' + 
    	' type="application/x-oleobject"' + 
    	' standby="Videó töltése...">' + 
        '<param name="url" value="' + url + '">' +
		'<param name="autoStart" value="' + (1 == autoStart ? "true" : "false") + '">' +
		'<param name="uiMode" value="mini">' +
		'<param name="PlayCount" value="1">' +
		'<param name="showControls" value="1">' +
		'<param name="showStatusBar" value="1">' +
		'<param name="autosize" value="false">' +
		'<param name="enableContextMenu" value="1">' +
		'<param name="stretchToFit" value="0">' +
		'<param name="Volume" value="100">' +
		'<embed' + 
    	' height="' + height + '"' + 
    	' width="' + width + '"' +
    	' type="video/x-ms-asf-plugin"' + 
    	' pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp"' + 
    	' src="' + url + '"' + 
    	' showcontrols="1"' + 
    	' enablecontextmenu="1"' + 
    	' playcount="1"' + 
    	' showstatusbar="1"' + 
    	' loop="false"' + 
    	' autostart="' + autoStart + '"' + 
    	' uimode="full">' + 
		'</object>';
		
		document.getElementById(id).innerHTML = html;
		
	}

}

function getSilverlightVersion() {
    var version = 'NoSilverlight';
    var container = null;
    try {
        var control = null;
        if (window.ActiveXObject) {
            control = new ActiveXObject('AgControl.AgControl');
        }
        else {
            if (navigator.plugins['Silverlight Plug-In']) {
                container = document.createElement('div');
                document.body.appendChild(container);
                container.innerHTML = '<embed type="application/x-silverlight" src="data:," />';
                control = container.childNodes[0];
            }
        }
        if (control) {
            if (control.isVersionSupported('2.0')) { version = 'Silverlight/2.0'; }
            else if (control.isVersionSupported('1.0')) { version = 'Silverlight/1.0'; }
        }
    }
    catch (e) { }
    if (container) {
        document.body.removeChild(container);
    }
    return version;
}
