try{console}
catch(e){
           console = { log:function( obj){ alert(obj); }}
        }
function getCenterScreen()
{
    var middleScreen = {'x': screen.width/2, 'y': screen.height/2};
/*
    if(  '\v' == 'v' )
    {
        middleScreen.x = window.top;
        middleScreen.y = window.width;
    }
    else
    {
        middleScreen.x = window.screenX;
        middleScreen.y = window.screenY;
     }
*/
    return middleScreen;
}


/*---------------------------------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------Create form for Image---------------------------------------------*/

function showSlideImage( imagePath ){
   var image = getById('imageLoad');
   getCenterScreen();
   if( image )
   {
      image.src    = imagePath;
      image.onload = function(){ var myFx = new Fx.Tween('divImageLoad',{duration:1000});
                                     myFx.start('opacity','1');
                                 var myFx = new Fx.Tween('imageClose',{duration:1000});
                                     myFx.start('opacity','1');
                               }
   }
   else
   {
        var div         = document.createElement( 'div'  );
        var img         = document.createElement( 'img' );
        var imgClose    = document.createElement( 'img'  );
        
        imgClose.src = '/www/assets/images/default/imageContent/close.png';
        imgClose.setAttribute( 'id', 'imageClose' );
        div.setAttribute( 'id', 'divImageLoad' );
        img.setAttribute( 'id', 'imageLoad' );
        img.onload = function(){
                                    
                                    
                                    new Fx.Tween('divImageLoad', {duration:1000}).start('opacity','1');
                                    
                                    var position   = getElementPosition(div);
                                    position.left += div.offsetWidth;
                                    
                                    imgClose.style.position = 'absolute';
                                    imgClose.style.top    = (position.top  - 18) + 'px';
                                    imgClose.style.left   = (position.left - 18) + 'px';
                                    imgClose.style.cursor = 'pointer';
                                    imgClose.title        = 'Close';
                                    document.body.appendChild(imgClose);
                               }
        
       img.src    = imagePath;
       with( div.style )
       {
           position           = 'absolute';
           border             = '1px solid #8DBDE3';
           backgroundColor   = '#FFFFFF';
           padding            = '10px';
       }
       
       div.appendChild(img);
       document.body.appendChild(div);
       
       centerScreen   = getCenterScreen();
       div.style.top  = '400px'; /*div.style.top  = centerScreen.x + 'px';*/
       
       
       div.style.left = (centerScreen.y) + 'px';
       div.onclick    = function(){
                                    new Fx.Tween('divImageLoad',{duration:1000}).start('opacity','0'); 
                                    new Fx.Tween('imageClose',{duration:1000}).start('opacity','0');
                                  };
       imgClose.onclick = function(){   
                                        new Fx.Tween('divImageLoad',{duration:1000}).start('opacity','0');
                                        new Fx.Tween('imageClose',{duration:1000}).start('opacity','0');
                                    };
       div.title = 'click to close';
       
       
       
       //new Fx.Tween('divImageLoad',{duration:1}).start('opacity','0');
       //new Fx.Tween('divImageLoad',{duration:1500}).set('opacity','0');
       
       
       

       
       /*imgClose.onclick = function(){ new Fx.Tween('divImageLoad',{duration:1000}).start('opacity','0');
                                      new Fx.Tween(imgClose,{duration:1000}).start('opacity','0');
                                    };*/
       
/*
var position   = getElementPosition($('divImageLoad'));
position.left += $('imageLoad').offsetWidth;

var img = document.createElement('img');
img.src = 'http://speedygames.server.int/www/assets/images/default/imageContent/close.png';
img.style.position = 'absolute';
img.style.top = (position.top - 5) + 'px';
img.style.left = (position.left - 5) + 'px';
*/
       
   }
}
/*---------------------------------------------END Create form for Image---------------------------------------------*/


function centerElement(elementId){
        if ( window.ActiveXObject )
        {
          var scrollTop  = document.body.scrollTop;
          var scrollLeft = document.body.scrollLeft;
          if ( scrollTop !== 0 || undefined == scrollTop )
          {
            scrollTop = document.body.scrollTop;
            scrollLeft = document.body.scrollLeft;
            if (!scrollTop)
            {
              scrollTop  = 0;
              scrollLeft = 0;
            }
          }
          $(elementId).style.top  = parseInt(200 + scrollTop) + 'px';
    //      div.style.width = parseInt( div.style.width ) + scrollLeft;
        }
        else
        {
          $(elementId).style.top  = 200 + parseInt(window.pageYOffset) + 'px';//parseInt(screen.height / 2) + 'px';
    //      $(elementId).style.width = parseInt( $(elementId).style.width ) + parseInt(window.pageXOffset) + 'px';
        }
//        $(elementId).style.left = parseInt(screen.width / 2 - $(elementId).offsetWidth / 2 ) + 'px';
        $(elementId).style.left = parseInt( screen.width / 2 - $(elementId).offsetWidth ) + 'px';
    }
/*---------------------------------------------End Create Form for Image---------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------*/
/*Требуется ОБЪЕКТ*/
function getElementPosition( $obj )
{
  var elemTop = parseInt($obj.offsetTop);
  var elemLeft = parseInt($obj.offsetLeft);
  var element = $obj;

  while (element.offsetParent !== null ){

    element = element.offsetParent;
    elemTop += parseInt(element.offsetTop);
    elemLeft += parseInt(element.offsetLeft);
  }

  var result = {'top': elemTop, 'left': elemLeft};
  return result;
}

function getById( elementId )
{
    return document.getElementById( elementId );
}

function __get( elementId )
{
    return getById( elementId );
}

function getObjectInfo( $obj )
{
    if( typeof( $obj ) === 'string' )
    {
        $obj = getById( $obj );
    }

    var width  = $obj.offsetWidth;
    var height = $obj.offsetHeight;
    var tag   = $obj.tagName;


    return { 'width': width, 'height': height, 'tag': tag };
}

function openPopup(theURL, widt, heig, resizable)
{ //v3.0
  var $left = screen.width / 2 - 200;
  var $top = screen.height / 2 - 250;

  if ( widt )
  {
    $left = parseInt( screen.width / 2 - widt / 2 );
  }

  if ( heig )
  {
    $top = parseInt( screen.height / 2 - heig / 2 );
  }

  features = '';

  if ( widt )
  {
    features += ', width='+widt;
  }
  if ( heig )
  {
    features += ', height='+heig;
  }
  /*
  if ( scrollbars )
  {
    features += ', scrollbars=1';
  }
  */
  if ( resizable )
  {
    features += ', resizable=1';
  }
  if ( features.indexOf(',') == 0 )
  {
    features = features.substr(1);
  }

  window.open(theURL, '', features + ", left=" + $left + ", top=" + $top + ', scrollbars=yes, toolbar=1, status=1' );//+ ', scrollbars=1'     +', location=1, toolbar=1, menubar=1');
  //status=1, toolbar=1,
}

var loading = {
  show: function( action )
  {

    if ( !getById('screen') )
    {
      var div              = document.createElement('DIV');
      div.style.filter     = 'alpha(opacity=50)';
      div.style.opacity    = '0.5';
      div.style.top        = '0px';
      div.style.left       = '0px';
      div.style.background = '#efefef';
      div.style.position   = 'absolute';

      div.id = 'screen';
      div.align = 'left';
      div.innerHTML = "<a href='javascript: void(0)' onClick='loading.hide()'>close</a>&nbsp;&nbsp;&nbsp;";
      document.body.appendChild(div);
      //$('loadData').style.left = parseInt(document.body.clientWidth / 2 ) + 'px';
    }

    div.style.width  = document.body.offsetWidth + 'px';
    div.style.height = document.body.offsetHeight + 'px';

    if ( window.ActiveXObject )
    {
      var $scrollTop = document.documentElement.scrollTop;
      var $scrollLeft = document.documentElement.scrollLeft;
      if ( $scrollTop !== 0 || undefined == $scrollTop )
      {
        $scrollTop = document.body.scrollTop;
        $scrollLeft = document.body.scrollLeft;
        if (!$scrollTop)
        {
          $scrollTop = 0;
          $scrollLeft = 0;
        }
      }

      //$('loadData').style.top = 200 + $scrollTop + 'px';
      div.style.width = parseInt( div.style.width ) + $scrollLeft;
    }
    else
    {
      //$('loadData').style.top = 200 + parseInt(window.pageYOffset) + 'px';//parseInt(screen.height / 2) + 'px';
      div.style.width = parseInt( div.style.width ) + parseInt(window.pageXOffset) + 'px';
    }


/*
    if ( action !== false )
    {
      $('loadData').show();
    }
*/
  },

  hide: function()
  {
    if ( getById('screen') )
    {
      getById('screen').style.display = 'none';
    }
    //$('loadData').hide();
  }
}