	
function grayOutOff()
	{
		grayOut(false);
                ukryj(film);
	}
	
	function grayOut(vis, options) {
		  // Pass true to gray out screen, false to ungray
		  // options are optional.  This is a JSON object with the following (optional) properties
		  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
		  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
		  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
		  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
		  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
		  // in any order.  Pass only the properties you need to set.
		  var options = options || {}; 
		  var zindex = options.zindex || 50;
		  var opacity = options.opacity || 70;
		  var opaque = (opacity / 100);
		  var bgcolor = options.bgcolor || '#000000';
		  var dark=document.getElementById('darkenScreenObject');
		  if (!dark) {
		    // The dark layer doesn't exist, it's never been created.  So we'll
		    // create it here and apply some basic styles.
		    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		    var tbody = document.getElementsByTagName("body")[0];
		    var tnode = document.createElement('div');           // Create the layer.
		        tnode.style.position='absolute';                 // Position absolutely
		        tnode.style.top='0px';                           // In the top
		        tnode.style.left='0px';                          // Left corner of the page
		        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
		        tnode.style.display='none';                      // Start out Hidden
		        tnode.id='darkenScreenObject';                   // Name it so we can find it later
		    tnode.onclick = grayOutOff;
		    tbody.appendChild(tnode);                            // Add it to the web page
		    dark=document.getElementById('darkenScreenObject');  // Get the object.
		  }
		  if (vis) {
		    // Calculate the page width and height 
		    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
		        var pageWidth = document.body.scrollWidth+'px';
		        var pageHeight = document.body.scrollHeight+'px';
		    } else if( document.body.offsetWidth ) {
		      var pageWidth = document.body.offsetWidth+'px';
		      var pageHeight = document.body.offsetHeight+'px';
		    } else {
		       var pageWidth='100%';
		       var pageHeight='100%';
		    }   
		    //set the shader to cover the entire page and make it visible.
		    dark.style.opacity=opaque;                      
		    dark.style.MozOpacity=opaque;                   
		    dark.style.filter='alpha(opacity='+opacity+')'; 
		    dark.style.zIndex=zindex;        
		    dark.style.backgroundColor=bgcolor;  
		    dark.style.width= pageWidth;
		    dark.style.height= pageHeight;
		    dark.style.display='block'; 

		  } else {
		     dark.style.display='none';
		  }
		}

var film = '';
var counterFilmow = 1;

function poka(nazwa)
{
    film = nazwa;
    var ob = document.getElementById(nazwa);
    ob.style.display = 'block';
    grayOut(true);
}

function ukryj(nazwa)
{
    var ob = document.getElementById(nazwa);
    ob.style.display = 'none';
}


function handleStateChange()
{
    alert(xmlhttp.readyState + " " + xmlhttp.status );
    if (xmlhttp.readyState == 4 && xmlhttp.state == 200)
    {
       alert(xmlhttp.responseText);    
    }
}

MyXssMagic = new function() {
  var objIds = document.getElementById('cbMovieIDs');
  if (objIds == null)
  {
    return;
  }
  var listaIDs = objIds.value;
  if (listaIDs == null)
  {
    return;
  }
  
  var methodObj = document.getElementById('cbMethod');
  var methodVal = "movie_info";
  if (methodObj == null)
  {
    methodVal = "movie_info";
  }
  else
  {
    var methodVal = methodObj.value;
  }
  
  var charset = "UTF-8";
  if (document.characterSet != undefined)
  {
      charset = document.characterSet;
  }
  else if (document.charset != undefined)
  {
      charset = document.charset;
  }
  else if (document.defaultCharset  != undefined)
  {
      charset = document.defaultCharset ;
  }
  
  var CONTENT_URL = 'http://cyber-flick.com/embed.php?id=' + listaIDs + '&action=' + methodVal + '&charset=' + charset;
  var ROOT = 'cbMovieContainer';

  function requestContent( local ) {
    var script = document.createElement('script');
    script.src = CONTENT_URL;
    document.getElementsByTagName('head')[0].appendChild(script);
  }

  this.serverResponse = function( data ) 
  {
    if (!data) return;
    var div = document.getElementById(ROOT);
    var txt = '';
    for (var i = 0; i < data.length; i = i+6) 
    {
       var id = data[i];
       var title = data[i+1];
       var code = data[i+2];
       var okladka = data[i+3];
       var hidef = data[i+4];
       var niceName = data[i+5];
      //if (txt.length > 0) { txt += ", "; }
      txt += kodFilmu(id, title, code, okladka, hidef, niceName);//data[i];
    }
    txt += '<div style="clear: both;">&nbsp;</div>';
    div.innerHTML = txt;  // assign new HTML into #ROOT
    div.style.display = 'block'; // make element visible
    //alert(div.scrollWidth);
    //div.style.height = div.scrollHeight;
  }

  //document.write("<div id='" + ROOT + "' style='display: none'></div>");    
  document.write("<div id=\"" + ROOT + "\" style='display: block; margin-bottom: 10px; z-index:100;'></div>");
  requestContent();
}

function changeImage(nrDiva, isOver)
{
    //pobranie obiektu
    var NazwaObiektu = 'playButton' + nrDiva;
    var przycisk = document.getElementById(NazwaObiektu);
    if (isOver == 1)
    {
        przycisk.src = 'http://cyber-flick.com/images/playon.gif';
    }
    else
    {
        przycisk.src = 'http://cyber-flick.com/images/play.gif';
    }
}

function kodFilmu(idFilmu, tytul, shortlandFilmu, okladka, hidef, niceName)
{
   //var idFilmu = 264;
   var nrDiva = counterFilmow ;
   counterFilmow ++;

   //var script = document.createElement('script');
    // How you'd pass the current URL into the request
    // script.src = CONTENT_URL + '&url=' + escape(local || location.href);
   //script.src = "http://cyber-flick.com/api.php?id=171,172&action=movie_info";

   //ajaxLoader("/api.php?id=171,172&action=movie_info", 'c');
 
   //var tytul = '1 - Jak rozpocząć progamować na Grono.net';   
   //var shortlandFilmu = 'tomaszs20090801163906';

   //var okladka = 'http://cyber-flick.com/new_tutors/mini/' + shortlandFilmu + '.jpg';
   
   var aFilm = 'http://cyber-flick.com/movies/' + shortlandFilmu;//  + '.flv';
   var duzaOkladka = 'http://cyber-flick.com/okladka.php?faq_id=' + idFilmu;
   var napisy = 'http://cyber-flick.com/napisy_emiter.php?faq_id=' + idFilmu;

   var width = 0;
   var height = 0;
   var fvwidth = 0;
   var fvheight = 0;
   var left = 0;
   var top = 0;
   var addtext = '';
   if (hidef == "hi")
   {
      width = 870;
      height = 660;
      fvwidth = 800;
      fvheight = 620;
      left = -345;
      top = -240;
      addtext = '<a class="d8457d" href="http://cyber-flick.com/video_tutorials.php?f=' + niceName + '">Zobacz na Cyber-Flick</a><br>';
   }
   else if (hidef == "lo")
   {
      width = 430;
      height = 330;
      fvwidth = 400;
      fvheight = 300;
      left = -130;
      top = -100;
      addtext = '<a class="d8457d" href="http://cyber-flick.com/video_tutorials.php?f=' + niceName + '">Zobacz w wysokiej jakości</a><br>';
   }

   return '<style type="text/css">' + 
        'a.d8457d {' +
        '      color:#0000EE; text-decoration:none;' +
        '  }' +
        'a.d8457d:hover {' +
        '      color:#027AC6; text-decoration:underline;' +
        '        }' +
        '</style>' +
        '<div style="z-index:100; float: left; max-width; 182px; width: 182px; height: 165px; margin-bottom: 20px; margin-right: 10px;" onmouseover="changeImage(' + nrDiva + ',1);" onmouseout="changeImage(' + nrDiva + ',0);">' +
        '    <div style="padding: 1px; background-color: #84A7C1; position: relative; width: 181px; height: 115px;">' +
        '           <a href="#" class="d8457d" onClick="poka(\'div' + nrDiva  + '\'); return false;">' +
        '                <img id="playButton' + nrDiva + '" src="http://cyber-flick.com/images/play.gif" style="position: absolute; left: 70px; top: 30px; border: 0px;">' +
        '                <div style="position: absolute; background-color: #84A7C1; color: white; padding: 2px; width: 174px; padding-left: 5px; padding-top: 2px; left: 0; top: 85px; height: 27px; font-size: 10px; line-height: normal;">' + tytul + '</div>' +
        '                <img src="' + okladka  + '" style="border: 0px;">' +
        '           </a>' +
        '     <div id="div' + nrDiva  + '" style="display: none; z-index:100; position: absolute; left: ' + left + 'px; top: ' + top + 'px;">' +
        '       <div style="background-color: #A9C4D6;"><center>' +
        '          <a href="#" onClick="grayOutOff(); return false;">Ukryj film</a>' +
        '       </center></div>' +
        '       <embed' +
        '       name="mediaplayer' + nrDiva + '"' +
        '       id="mediaplayer' + nrDiva + '"' +
        '       type="application/x-shockwave-flash"' + 
        '       src="http://cyber-flick.com/mediaplayer4290.swf"' +
        '       width="' + width + '"' +
        '       height="' + height + '"' +
        '       wmode="opaque"' +
        '       allowscriptaccess="always"' +
        '       seamlesstabbing = "true"' +
        '       allowfullscreen="true"' +
        '       flashvars="skin=http://cyber-flick.com/bekle.swf&amp;autostart=true&amp;height=' + fvheight + '&amp;width=' + fvwidth + '&amp;file=' + aFilm + '&amp;image=' + duzaOkladka + '&amp;captions=' + napisy + '&amp;backcolor=F5F5F5&amp;frontcolor=000000&amp;screencolor=F5F5F5&amp;plugins=accessibility-1&amp;accessibility.fontsize=14&amp;abouttext=Made by cyber-flick.com&amp;aboutlink=http://cyber-flick.com/"' +
        '       >' +
        '       <div style="background-color: #A9C4D6;"><center>' + addtext +
        '          <a href="#" class="d8457d" onClick="grayOutOff(); return false;">Ukryj film</a>' +
        '       </center></div>' +
        '     </div>' +
        '    </div>  ' +
        '   </div>';
}
