/**********************************************************************************************************************
 * Quick Check Browser Version
 * Ext.isIE
 * Ext.isIE6
 * Ext.isIE7
 * Ext.isIE8
 */


/**********************************************************************************************************************
 * Global Dom-Ready Events
 */
	Ext.onReady(function() {
		if(Ext.isIE6||Ext.isIE7) crossbrowserClearfix();
	});
	
	
	
/**********************************************************************************************************************
 * Crossbrowser Clearfix
 * Only used for browsers, which don't support CSS Element :after (IE6 + IE7)
 * Function searches for all elements with class 'clearfix' and inserts the clean tag at the end
 */
	function crossbrowserClearfix(){
		var clearfix = Ext.query('.clearfix');
		Ext.each(clearfix,function (data, index) {
			Ext.get(data).insertHtml('beforeEnd', '<div class="clean"></div>', false);						
		});	 	
	}


// FadeFunctions of Objects ------------------------------------------------------------------------------
	function fadeOut(obj){
		var el = Ext.get(obj);
		if(Ext.isIE6)showAllSelects(true);
		el.fadeOut();
	}
	
	function fadeIn(obj){
		var el = Ext.get(obj);
		Ext.get('layer_decker').setHeight(getScreenSize('height'));
		el.fadeIn();
	}
	
	function fadeInLayer(obj){
		var el = Ext.fly(obj);
		var decker = el.child('.layer_decker');
		var content = el.child('.flex_content');
		if(content==null) content = el.child('.layer_content');
		var doc_scroll = Ext.getDoc().getScroll();
		var doc_height = Ext.getBody().getViewSize();
		var ypos = doc_scroll.top + (doc_height.height/2) - (content.getComputedHeight()/2);
		
		if(Ext.isIE6)showAllSelects(false);
		el.removeClass('x-hidden');
		content.setStyle({'marginTop':ypos+'px'});
		decker.setHeight(getScreenSize('height'));
		//decker.setWidth(getScreenSize('width'));
		//content.setStyle({'left':'50%'});
		el.fadeIn();
	}
	
	function showAllSelects(state){
		var s = Ext.query('select');
		Ext.each(s,function (data, index) {
			(!state) ? Ext.get(data).addClass('invisible') : Ext.get(data).removeClass('invisible');
		});
	}
	


	function getScreenSize(type){
		if( window.innerHeight && window.scrollMaxY!='undefined' )  {// Firefox;
			pageWidth = window.innerWidth + window.scrollMaxX;
			pageHeight = window.innerHeight + window.scrollMaxY;
			
		}
		else if(document.body.scrollHeight > document.body.offsetHeight ){	// all but Explorer Mac
			pageWidth = document.body.scrollWidth;
			pageHeight = document.body.scrollHeight;
		}
		else {// works in Explorer 6 Strict, Mozilla (not FF) and Safari
			pageWidth = document.body.offsetWidth + document.body.offsetLeft;
			pageHeight = document.body.offsetHeight + document.body.offsetTop; }
		if(type=='height') return pageHeight;
		else return pageWidth;
	}
	
	function getScrollScreenCenter(){
		var y; //y-scroll
		var h; //browser height
		
		if( window.innerHeight && window.scrollMaxY!='undefined' )  {// Firefox;
			y = window.pageYOffset;
			pageHeight = window.innerHeight + window.scrollMaxY;
			
		}
		else if(document.body.scrollHeight > document.body.offsetHeight ){	// all but Explorer Mac
			pageHeight = document.body.scrollHeight;
		}
		else {// works in Explorer 6 Strict, Mozilla (not FF) and Safari
			pageHeight = document.body.offsetHeight + document.body.offsetTop; }
		if(type=='height') return pageHeight;
		else return pageWidth;
	}
	
	
/*********************************************************************************************************************
 * Wrapper for Firebug console.log() to avoid errors in browsers without Firebug
 */
 	function consoleLog(msg){
		try{
			console.log(msg);
		} catch(e){
			//alert(msg);
		}
	}
	
	
	
/**
 * @deprecated
*/
	
    function screenHeight(){
        if( window.innerHeight && window.scrollMaxY!='undefined' )  {// Firefox;
                pageWidth = window.innerWidth + window.scrollMaxX;
                pageHeight = window.innerHeight + window.scrollMaxY;

        }
        else if(document.body.scrollHeight > document.body.offsetHeight ){      // all but Explorer Mac
                pageWidth = document.body.scrollWidth;
                pageHeight = document.body.scrollHeight;
        }
        else {// works in Explorer 6 Strict, Mozilla (not FF) and Safari
                pageWidth = document.body.offsetWidth + document.body.offsetLeft; pageHeight = document.body.offsetHeight + document.body.offsetTop; }
        return pageHeight;
    }
	


