function tinkoffPlayer(id)
{
	this.id = id;

	this.$ = function(id)
	{
		return document.getElementById(id+'_'+this.id);
	}

    this.showLinkPane = function()
    {
    	this.hideLinkPane();
    	this.menuPane.className = 'player_title hide';
    	if (!this.linkPane)
    	{
    		this.linkPane = this.$('tvpl');
            this.linkPaneV = this.$('tvpl_v');
    		this.linkPaneV.value = window.location.href;
    	}
    	this.linkPane.className = 'player_title show';
    	this.linkPaneV.focus();
    	this.linkPaneV.select();
       return false;
    };

    this.showCodePane = function()
    {
    	this.hideLinkPane();
    	this.menuPane.className = 'player_title hide';
    	if (!this.codePane)
    	{
    		this.codePane = this.$('tvpc');
            this.codePaneV = this.$('tvpc_v');
    	}
   		this.codePaneV.value = this.$('tvp').innerHTML;
    	this.codePane.className = 'player_title show';
    	this.codePaneV.focus();
    	this.codePaneV.select();
       return false;
    };

    this.hideLinkPane = function()
    {
        if (this.linkPane) this.linkPane.className = 'player_title hide';
        if (this.codePane) this.codePane.className = 'player_title hide';
    	this.menuPane.className = 'player_title show';
    };

    this.setQuality = function(el,url)
    {
    	if (el.className.indexOf('red')>-1) return;
    	this.hideLinkPane();
//    	var v = '_'+el.innerHTML.toLowerCase();
    	this.$('tvp_sd').className = 'text_title pointer';
    	this.$('tvp_md').className = 'text_title pointer';
    	this.$('tvp_hd').className = 'text_title pointer';
    	el.className += ' red';

    	var r = this.$('tvp').innerHTML;

    	var old = r.split(';file=');
    	old = old[1].split('"');
    	old = old[0];

    	r = r.replace(old,url).replace(old,url);
    	this.$('tvp').innerHTML = r;
    };

    this.loadSrc = function(src,id)
    {
	    window.location.href=src;
    	if (this.loaded) return;
    	this.loaded = true;
    	(new CAjax()).req('/video/load/'+id);
       return false;
    }

    this.menuPane = this.$('tvpt');
}

