function loadScript(url, callback)
{
    // adding the script tag to the head as suggested before
   var head = document.getElementsByTagName('head')[0];
   var script = document.createElement('script');
   script.type = 'text/javascript';
   script.src = url;

   // then bind the event to the callback function 
   // there are several events for cross browser compatibility
   script.onreadystatechange = callback;
   script.onload = callback;

   // fire the loading
   head.appendChild(script);
}


function program(width,height) {
    var rightNow = new Date();                                                                                                                
    var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);                                                                           
    var temp = date1.toGMTString();                                                                                                           
    var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ") -1));                                                                        
    var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);                                                                                
    var domain = window.location.hostname;                                                                                                    
    document.write("<iframe src=\"http://api.fingramtv.ru/program_list.php?tz="+hoursDiffStdTime+"&domain="+domain+"\" width=\""+width+"px\" height=\""+height+"\" style=\"font:14px Arial;\" frameborder=\"1\"></iframe>");
    return 0;
}

var dymmu = function() {
var domain = window.location.hostname;
document.write("<h3 id='fingramtv'>Pleas enable javascript</h3>\n\
<script type='text/javascript'>\n\
  jwplayer('fingramtv').setup({\n\
    'flashplayer': 'http://api.fingramtv.ru/jwplayer/player.swf',\n\
    'playlistfile': 'http://fingramtv.ru/playlist4.php?domain="+domain+"',\n\
    'domain': 'fingramtv.ru',\n\
    'backcolor': '000000',\n\
    'frontcolor': 'c8871f',\n\
    'lightcolor': 'f7dcb1',\n\
    'screencolor': '222222',\n\
    'playlistsize': '86',\n\
    'volume': '50',\n\
    'controlbar': 'over',\n\
    'autostart': 'true',\n\
    'repeat': 'list',\n\
    'width': '560',\n\
    'height': '420'\n\
  });\n\
</script>\n\
");
};

function player() {
var domain = window.location.hostname;
//loadScript("http://api.fingramtv.ru/jwplayer/jwplayer.js", dymmu)
document.write("<object type=\"application/x-shockwave-flash\" data=\"http://api.fingramtv.ru/jwplayer/player.swf\" quality=\"high\" width=\"560\" height=\"420\">\n\
<param name=\"movie\" value=\"http://api.fingramtv.ru/jwplayer/player.swf\" />\n\
<param name=\"allowFullScreen\" value=\"true\" />\n\
<param name=\"FlashVars\" value=\"config=http://api.fingramtv.ru/jwplayer/config.xml&file=http://api.fingramtv.ru/playlist.php?domain="+domain+"\">\n\
<param name=\"wmode\" value=\"transparent\" />\n\
<param name=\"allowScriptAccess\" value=\"always\" />\n\
</object>");

return 0;
}


function game() {
var domain = window.location.hostname;
//loadScript("http://api.fingramtv.ru/jwplayer/jwplayer.js", dymmu)


document.write("<object type=\"application/x-shockwave-flash\" data=\"http://api.fingramtv.ru/jwplayer/player.swf\" quality=\"high\" width=\"560\" height=\"420\">\n\
<param name=\"movie\" value=\"http://api.fingramtv.ru/jwplayer/player.swf\" />\n\
<param name=\"allowFullScreen\" value=\"true\" />\n\
<param name=\"FlashVars\" value=\"config=http://api.fingramtv.ru/jwplayer/config.xml&file=http://api.fingramtv.ru/playlist.php?domain="+domain+"\">\n\
<param name=\"wmode\" value=\"transparent\" />\n\
<param name=\"allowScriptAccess\" value=\"always\" />\n\
</object>");

return 0;
}
