
  function set_fullscreen(elem){
    var b = document.body;   
    elem.style.position = 'absolute';  
    var left = b.offsetLeft, 
        top = b.offsetTop,
        width = b.offsetWidth,
        height = b.offsetHeight,
        l = b._loading;
    elem.style.left = left+'px';
    elem.style.top = top+'px';
    elem.style.width = width+'px';
    elem.style.height = height+'px';
  }

  function set_element_top_middle(elem){
    height = document.body.offsetHeight;  
    sY = 0;
    if( typeof( scrollY ) == 'number' ) sY = scrollY;
    if( typeof( document.documentElement.scrollTop ) == 'number' ) sY = document.documentElement.scrollTop;     
 
    sX = 0;
    if( typeof( scrollX ) == 'number' ) sX = scrollX;
    if( typeof( document.documentElement.scrollLeft ) == 'number' ) sX = document.documentElement.scrollLeft;  
    
    
      var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    }  
    //alert(sX);
    elem.style.position = 'absolute';
    elem.style.display = 'inline';     
    elem.style.top = (sY+Math.round(myHeight/2)-Math.round(elem.offsetHeight/2))+'px';
    elem.style.left = (sX+Math.round(myWidth/2)-Math.round(elem.offsetWidth/2))+'px';
    
  }  
  

  function view(path, type){
    
    set_fullscreen($('all_waiting'));
    $('all_waiting').style.display='inline';
    insert_flash(path, type);
    $('player_cont').innerHTML = '<div class="close_button" onclick="hide_flash(); return false;">X</div>' + $('player_cont').innerHTML;
    $('player_cont').style.display='inline';
    set_element_top_middle($('player_cont'));
    
  }
  
  
  function hide_flash(){
    $('player_cont').style.display = 'none';
    $('player_cont').innerHTML = '';
    $('all_waiting').style.display = 'none';
 
  }
  
  function insert_flash(path, type){
    //if ($('player_cont').innerHTML!='') $('player_cont').innerHTML='asdasd';

    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length){
        if (type=='flv'){
          var s1 = new SWFObject("/flash/flvplayer.swf","single","500","500","7");
          s1.addParam("allowfullscreen","true");
          s1.addVariable("image","/img/preview.jpg");
          s1.addVariable("width","500");
          s1.addVariable("height","500");
        }else if (type=='mp3'){
          var s1 = new SWFObject("/flash/mp3player.swf", "line", "240", "20", "7")      
          s1.addVariable("repeat","true");
          s1.addVariable("showdigits","true");
          s1.addVariable("showdownload","false");
          s1.addVariable("width","240");
          s1.addVariable("height","20");    
        }
        s1.addVariable("file",path);
        s1.write("player_cont");
    } else {
    
        if (type=='flv'){
          var s1 = new SWFObject("/flash/flvplayer.swf?"+"file="+path+"&image=/img/preview.jpg&width=500&height=500","single","500","500","7");
          s1.write("player_cont");
        }else if (type=='mp3'){
          $('player_cont').innerHTML = '<embed id="line" width="240" height="20" flashvars="repeat=true&showdigits=true&showdownload=false&width=240&height=20&file='+path+'" quality="high" name="line" style="" src="/flash/mp3player.swf" type="application/x-shockwave-flash"/>'
          
          //var s1 = new SWFObject("/flash/mp3player.swf?"+"file="+path+"repeat=true&showdigits=true&showdownload=false&width=240&height=20","line","240","20","7");
        }
        
    }
  }
  