Element.implement({
        getFormValues: function ()
        {
            return this.toQueryString().parseQueryString();
        }
});

function decryptCharcode(n,start,end,offset){n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);}
return String.fromCharCode(n);}
function decryptString(enc,offset){var dec="";var len=enc.length;for(var i=0;i<len;i++){var n=enc.charCodeAt(i);if(n>=0x2B&&n<=0x3A){dec+=decryptCharcode(n,0x2B,0x3A,offset);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}}
return dec;}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-1);}



window.addEvent('domready', function(){
var bgimg = $(document.body).getStyle('background-image')
.replace("url(\"",'')
.replace("\")",'')
.replace("url(",'')
.replace(")",'')
.replace("http://partylite.le5.consulting1x1.info/",'');

//if(console && console.log) console.log(bgimg);

var image = new Element('img',{src:bgimg,'id':'layout_background'}).inject(document.body);
$(document.body).setStyle('background','#FFF');
//  if($('layout_background'))
  {  
//    $('layout_background').setStyle('display', 'none');
    
//    var imagelist = $('layout_background').getChildren();
$$('.pl_accordion').each(function(item,index)
{
  new Fx.Accordion(item.getElements('.pl_accordion_title'), item.getElements('.pl_accordion_content'), {alwaysHide: true});
});
    
    var minWidth = 140;
    var minHeight = 80;
  
    var styles = {};
    var toggled = 0;
    var currentab = 0;
   

    function scaleResize (image, center) {
      var docheight = window.getSize().y;
//      var docwidth = $('layout_outer').getSize().x;
var docwidth = window.getSize().x;
      var sw = (docheight/117)*160;

      var mscreenmode = 'h';   
      if(docwidth >= sw)
      {
        sw = docwidth;
        mscreenmode = 'w';
      }/*
      if(sw/160*117 < docheight)
{
sw = (docheight/117)*160;
}*/

      image.setStyle('width',sw);
      image.setStyle('height',sw/160*117);


      var wsize = window.getSize();
      var isize = image.getSize();
      
      if(mscreenmode == 'h')      
      {
        styles.width  = null;
        styles.height = docheight;
      }
      else
      {
        styles.width  = docwidth;
        styles.height  = null;
      }

    
      if (styles.width  !== null && minWidth  > styles.width)  styles.width  = minWidth;
      if (styles.height !== null && minHeight > styles.height) styles.height = minHeight;

      // *** Calculate second dimension size
      if (styles.width  === null) styles.width  = Math.round(styles.height * isize.x / isize.y);
      if (styles.height === null) styles.height = Math.round(styles.width  * isize.y / isize.x);

      // *** Position in the center of the screen
      if (center){
        // *** Horizontal
        if (styles.width > wsize.x)      styles.left = 0 - Math.round((styles.width - wsize.x) / 2);
        else if (styles.width < wsize.x) styles.left = Math.round((wsize.x - styles.width) / 2);
        else styles.left = 0;
/*
        // *** Vertical
        if (styles.height > wsize.y)      styles.top = 0 - Math.round((styles.height - wsize.y) / 2);
        else if (styles.height < wsize.y) styles.top = Math.round((wsize.y - styles.height) / 2);
        else styles.top = 0;*/
      }
styles.top = 0;
      styles.position = 'absolute';
      image.setStyles(styles);
    }
    
    function scaleImage () {
      scaleResize(image, true);
    }

    window.addEvents({
      'domready': scaleImage,
      'resize': scaleImage
    });
  }
    
});


