function video_help_download(a) {
    window.open(a.href,'', 'toolbars=no,status=yes,location=no,resizable=yes,scrollbars=yes');
    return false;
}

function video_buy_dvd(url) {
	window.open(url,'','');
	return false;
}


function show_video(config) {

// config = http://www.flexis.ru/dev/intuit-dev/Intuit2/lection1.xml

var hasProductInstall = DetectFlashVer(6, 0, 65);
var hasRequestedVersion = DetectFlashVer(9, 0, 0);

if ( hasProductInstall && !hasRequestedVersion ) {
    var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
    var MMredirectURL = window.location;
    document.title = document.title.slice(0, 47) + " - Flash Player Installation";
    var MMdoctitle = document.title;

    AC_FL_RunContent(
        "src", "/ssi/playerProductInstall",
        "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
        "width", "802",
        "height", "400",
        "align", "middle",
        "id", "IntuitMaxi",
        "quality", "high",
        "bgcolor", "#000000",
        "name", "IntuitMaxi",
        "allowScriptAccess","sameDomain",
        "type", "application/x-shockwave-flash",
        "pluginspage", "http://www.adobe.com/go/getflashplayer"
    );
} else if (hasRequestedVersion) {
    AC_FL_RunContent(
            "src", "/ssi/IntuitMaxi",
            "width", "802",
            "height", "400",
            "id", "IntuitMaxi",
            "allowFullScreen", "true",
            "FlashVars", "config=" + config
    );
  } else {
    var alternateContent =  'Для демонстрации лекций необходим Flash Player. '
       + '<a href=http://www.adobe.com/go/getflash/>Установить Flash</a>';
    document.write(alternateContent);
  }
}


function  _set_counter(id,cnt) {
	var o = document.getElementById(id);
	if(!o) return;
	var avalue=getElementsByClass('value',o,'div');
	if(!avalue.length) return;
	var value=avalue[0];
	value.innerHTML = cnt;
}

function  set_video_counter() {
	_set_counter('video_counter',counter_video);
	_set_counter('download_counter',counter_downlod);
	set_download();
}

function  __set_video_counter() {
	var o = document.getElementById('video_counter');
	if(!o) return;
	var avalue=getElementsByClass('value',o,'div');
	if(!avalue.length) return;
	var value=avalue[0];
	value.innerHTML = counter_video;
}

function get_cookie(cc) {
	var c = document.cookie;
	var cr = cc + '=';
	var p = c.indexOf(cr);
	if(p<0) return '';
	var l = cr.length;
	p = p+l;
	var pp = c.indexOf(';',p);
	if(pp<0) return c.substring(p);
	if(pp==p) return '';
	return c.substring(p,pp);
}

function  set_download() {
	var eduuid = get_cookie('eduuid');
	if(eduuid.length != 0) return;
	var o = document.getElementById('lecture_body');
	if(!o) return;
	var avalue=getElementsByClass('download',o,'div');
	if(!avalue.length) return;
	var d = avalue[0];
	var els = d.getElementsByTagName('a');

	var elsLen = els.length;
	var patt=new RegExp("\.(avi|mp3|mp4)$");
	for (var i = 0; i < elsLen; i++) {
		var a = els[i];
		var href=a.href;
		if(patt.test(href)) {
			a.href = '/help/popup/vneedsauth.html';
			a.target="_blank";
//			a.style = "text-decoration: line-through; color: #990000;";
			a.style.textDecoration='line-through';
			a.onclick = function(){
			    window.open('/help/popup/vneedsauth.html','', 'toolbars=no,status=yes,location=no,resizable=yes,scrollbars=yes');
			    return false;
			};
			a.title = "Для скачивания необходима авторизация  \n"+a.title;
		}
	}
	
}