/*
    feindura - Flat File Content Management System
    Copyright (C) 2009 Fabian Vogelsteller [frozeman.de]

    This program is free software;
    you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with this program;
    if not,see <http://www.gnu.org/licenses/>.
*/
// java/windowBox.js version 0.37 (requires mootools-core and mootools-more)

/* ---------------------------------------------------------------------------------- */
// dimms the background and calls: requestSite(site,siteTitle);
// NOT IN USE
function openWindowBox(site,siteTitle,fixed) {

    $('dimmContainer').setStyle('opacity','0');
    $('dimmContainer').setStyle('display','block');
    
    var fadeBg = new Fx.Tween($('dimmContainer'), {duration: 300, transition: Fx.Transitions.Sine.easeOut});
    fadeBg.start('opacity', '0.5');
    
   // open the window box
   fadeBg.onComplete = function(e){
      if(site) {
        
        // if fixed is true, than the window positon is relative,
        // means its fixed in the document, and NOT scrolling with the user
        if(fixed || navigator.appVersion.match(/MSIE ([0-6]\.\d)/)) {
          $('windowBox').setStyle('position','relative');
        } else {
          $('windowBox').setStyle('position','fixed');
        }
        
        // set the fade
        $('windowBox').set('opacity','0');  			
        $('windowBox').tween('opacity','1');
  		  

        // IE HACK, wont bring the bottom div to the top
  			if(navigator.appVersion.match(/MSIE ([0-6]\.\d)/)) {
  			   $$('#windowBox .boxBottom')[0].setStyle('top','68px');
  			}
        
  			// send HTML request
  			//$('windowBox').removeEvents();
  			//$('windowRequestBox').removeEvents();
        requestSite(site,siteTitle);
  		}
  	}
    
}
// NOT IN USE - END

// FADE IF WINDOW IS OPEN
window.addEvent('domready',function() {

  
  if($('blendContainer') != null) {

    $('blendContainer').set('fade', {duration: '400', transition: Fx.Transitions.Pow.easeOut});
    
    $('blendContainer').setStyle('opacity','0');
    $('blendContainer').tween('opacity','1');    
    
    // hides the windowBox
    if($('windowBox') != null) {
      //$('windowBox').setStyle('opacity','0');
      //$('windowBox').setStyle('top','100%');
      //$('windowBox').tween('top','15%');
    }
  
    // fades the dimmContainer // last effect     
    $('blendContainer').get('tween').addEvent('complete', function(e) {
 			    
 			    if($('windowBox') != null) {
            
            //$('windowBox').tween('opacity','1');
            //$('windowBox').tween('top','15%');
          }
 			    
 			      
  			  this.removeEvents();
  			   
  			  //if(redirectAfter)
  			    //document.location.href = redirectAfter;
    });
  }
  
  

});


/* ---------------------------------------------------------------------------------- */
// fades all windows out and set windowBoxContainer to display:none;
// and remove alle Events from dimmContainer, windowBox, windowRequestBox
function closeWindowBox() {
      
			// resize the box by a slide
			$('windowBox').set('tween', {duration: '400', transition: Fx.Transitions.Pow.easeOut});			
			if($('blendContainer') != null)
			 $('blendContainer').set('fade', {duration: '400', transition: Fx.Transitions.Pow.easeOut});
			
			// slides the windowBox out
			$('windowBox').tween('opacity','0');
      
      // fades the windowBox
      $('windowBox').get('tween').addEvent('complete', function(e) {

          this.removeEvents();
      });
      
      if($('blendContainer') != null)
        $('blendContainer').tween('opacity','0');
        //$('blendContainer').fade('out');
      
      // fades the dimmContainer // last effect
      if($('blendContainer') != null) {
        $('blendContainer').get('tween').addEvent('complete', function(e) {
     			   
      			   this.removeEvents();
      			   
      			    document.location.href = 'index.php';
        });
      }
        
      return false;
}