

_yt = function()
{
    this.http;
    this.browser = navigator.userAgent;
    if(this.browser.indexOf('MSIE') != -1 && this.browser.indexOf('Opera') == -1) this.browser = "Microsoft Internet Explorer";

    this.new_conn = function()
    {
        if ( this.browser == 'Microsoft Internet Explorer' ) return new ActiveXObject("Microsoft.XMLHTTP");
        else return new XMLHttpRequest();
    }


    this.load_ytinfo = function(movie_url)
    {
        http_ytinfo = this.new_conn();
        http_ytinfo.open('GET', '../../../classes/modules/youtube/ajax.yt.php?movie_url='+movie_url,true);
        //http_ytinfo.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        http_ytinfo.onreadystatechange = this._load_ytinfo_ready;
        http_ytinfo.send('');
    }

    this._load_ytinfo_ready = function()
    {
        if ( http_ytinfo.readyState == 4 )
        {
                var response     = http_ytinfo.responseText;
                if(response != '')
                {
                  getE('ytinfo').innerHTML = response;
                  getE('yt_addbutton').style.display = '';
                  getE('yt_movie_not_found').style.display = 'none';
                }
                else
                {
                   getE('yt_addbutton').style.display = 'none';
                   getE('yt_movie_not_found').style.display = '';
                }
        }
    }

    this.showhide_forms = function (id)
    {
         if(getE(id).style.display == 'none')
         {
            getE(id).style.display = '';
            if( getE('modyt_movie') )
            {
                _emb = getE('modyt_movie').getElementsByTagName('embed');
                for(var i = 0; i < _emb.length; i++)
                {
                    _emb[i].style.visibility = 'hidden';
                }
            }
         }
         else
         {
             getE(id).style.display = 'none';
             if( getE('modyt_movie') )
             {
                _emb = getE('modyt_movie').getElementsByTagName('embed');
                for(var i = 0; i < _emb.length; i++)
                {
                    _emb[i].style.visibility = 'visible';
                }
             }
         }
    }

}

_yt = new _yt();
