/**
 * class providing system related functions
 * 
 */
var synlib_CSys = Class({
  phpLocale: {
    decimal_point: ',',
    thousands_sep: '.',
    int_curr_symbol: 'EUR',
    currency_symbol: '€',
    mon_decimal_point: ',',
    mon_thousands_sep: '.',
    setlocalres: ''
  },
  initPhpLocale: function(aLocale){
    this.phpLocale.decimal_point = aLocale.decimal_point;
    this.phpLocale.thousands_sep = aLocale.thousands_sep;
    this.phpLocale.int_curr_symbol = aLocale.int_curr_symbol;
    this.phpLocale.currency_symbol = aLocale.currency_symbol;
    this.phpLocale.mon_decimal_point = aLocale.mon_decimal_point;
    this.phpLocale.mon_thousands_sep = aLocale.mon_thousands_sep;
    this.phpLocale.setlocalres = aLocale.setlocalres;
  },
  initPageTop: function(){
    var body = $(document.body);
    var pageTopBg = $('tx-synlib-pagetopbg');
    if(!$chk(pageTopBg)){
      pageTopBg = new Element('div',{
        'id': 'tx-synlib-pagetopbg'
      }); 
      pageTopBg.inject(body,'top');
    };
    var pageTop = $('tx-synlib-pagetop');      
    if(!$chk(pageTop)){      
      pageTop = new Element('div',{
        'id': 'tx-synlib-pagetop',
        'class': 'tx-synlib-pagetop'
      });
      pageTop.inject(body,'top');     
    }; 
  },
  showPageTop: function(){
    var winHeight = $(window).getHeight();
    var halfWinHeight = (winHeight/2).round();
    var body = $(document.body);
    var pageTopBg = $('tx-synlib-pagetopbg');
    var pageTop = $('tx-synlib-pagetop');
    if(!$chk(pageTop) || !$chk(pageTopBg)) self.initPageTop();  
    
    var currDisplay = pageTop.getStyle('display');
    if(currDisplay=='none'){ 
      pageTopBg.setStyle('display','block');
      pageTopBg.setStyle('height',winHeight + 'px');
      pageTop.setStyle('display','block');
      pageTop.setStyle('height',winHeight + 'px');
      pageTop.setStyle('backgroundPosition','center center');
      pageTopBg.tween('opacity',0,0.8);  
      pageTop.tween('opacity',0,1); 
    }; 
  },
  hidePageTop: function(sender){
    if($chk(sender)){
      $(sender).setStyle('display','none');
    };
    var pageTopBg = $('tx-synlib-pagetopbg');
    var pageTop = $('tx-synlib-pagetop');
    var MyTopBgTween = new Fx.Tween(pageTopBg);
    var MyTopTween = new Fx.Tween(pageTop);
    var currOpacity = pageTop.getStyle('opacity');
    if(currOpacity==1){ 
      MyTopBgTween.start('opacity',0).chain(function(){pageTop.setStyle('display','none');});
      MyTopTween.start('opacity',0);
    };
  },
  showSplashContent: function(){
    var pageTop = $('tx-synlib-pagetop');
    if(!$chk(pageTop)) synlib_Sys.initPageTop();
    
    var currDisplay = pageTop.getStyle('display');
    if(currDisplay=='none') synlib_Sys.showPageTop();

    var splashContent = $('tx-synlib-splashcontent');
    if($chk(splashContent)){
      var winHeight = $(window).getHeight();  
      var height = splashContent.getHeight(); 
      var top = ((winHeight-height)/2).round(); 
      splashContent.setStyle('marginTop',top + 'px'); 
      splashContent.tween('opacity',0,1);
      var pageTop = $('tx-synlib-pagetop');
      pageTop.setStyle('backgroundPosition','center -2000px');
    };
  },
  disableFormFields: function(form){
    $(form).getElements('input').each(function(el){
      el.setProperty('readonly','readonly');
      el.setStyle('cursor','wait');
    });
    $(form).getElements('textarea').each(function(el){
      el.setProperty('readonly','readonly');
      el.setStyle('cursor','wait');
    });
  },
  enableFormFields: function(form){
    $(form).getElements('input').each(function(el){
      el.removeProperty('readonly');
      var type = el.getProperty('type');
      if(type=='text') {
        el.setStyle('cursor','text');
      } else {
        el.setStyle('cursor','auto');
      };
    });
    $(form).getElements('textarea').each(function(el){
      el.removeProperty('readonly');
      el.setStyle('cursor','text');
    });
  }
});  

var synlib_Sys = new synlib_CSys();