/**
 * Version 0.10
 * based on jQuery
 * setAdition Position
 * @version $Rev: 11719 $
 * @author $Autho$
 * @id $Id: adition.js 11719 2011-09-15 08:57:00Z m.zander $
 */

/**
 * overwrite document.write for adition
 */



var adition = {
    
    config : {elements : ['FlexTop', 'FlexSky']},
    
    elementCount : 0,
    
    init : function (params) {
        if (params) {
            this.config = jQuery.extend(this.config, params);
        }
        
        if (typeof this.config.load != 'undefined' && this.config.load == 'domready') {
            jQuery(document).ready(function(){
                document.write = function(content) {
                    if (arguments.callee.wElement && arguments.callee.wElement != 'body') {
                        jQuery('#' + arguments.callee.wElement).append(content);
                    } else {
                        jQuery('body').append(content);
                    }
                }
                adition.loadScripts();
                adition.show();
            })
            return;
        }
        adition.show();
    },
    
    loadScripts : function () {
        if (typeof this.config.includes != 'undefined' ) {
            jQuery.each(this.config.includes, function(elementId, file){
                try {
                    
                    if (elementId != 'body') {
                        document.write.wElement = elementId;
                        jQuery('#' + elementId).empty();
                        jQuery('#' + elementId).append('<script type="text/javascript" src="' + file + '"></script>');
                    
                    } else {
                        jQuery(elementId).append('<script type="text/javascript" src="' + file + '"></script>');
                    }
                } catch(e) {
                    alert(e.message);
                }
            });
        }
        return true;
    },
    
    show : function() {
        jQuery.each(this.config.elements, function(index, elementId){
            if (jQuery('#'+elementId).length) {
                try {
                    adition[elementId](elementId);
                } catch(e) {
                    
                }
            }
        });
    },
    
    FlexTop : function(adName) {
        /* 
         * BUG [78581] https://bugzilla.unister-gmbh.de/show_bug.cgi?id=78581
         * 
         * Die Berechnung wird nicht mehr benötigt darum raus.
         * 
    	if (jQuery.browser.msie && jQuery('#FlexTop').children().length > 2 && jQuery('#' + adName).height() != 0) {
        	// IE Browser
            jQuery('#wrapper').css('margin-top', parseInt(jQuery('#' + adName).height()) - 40 + 'px');
            jQuery('#FlexTop').css('margin-left', ((805 - parseInt(jQuery('#' + adName).width())) / 2) + 'px');
        }
        else {
        	//alle nicht IE Browser
            jQuery('#wrapper').css('margin-top', parseInt(jQuery('#' + adName).css('height')) + 10 + 'px');
            jQuery('#FlexTop').css('margin-left', ((805 - parseInt(jQuery('#' + adName).css('width'))) / 2) + 'px');
        }
        */
    	jQuery('#FlexTop').css('visibility', 'visible')
        
    },
    
    FlexSky : function() {
        if (jQuery('#googleAdsenseNew_sky').length > 0 && jQuery('#FlexSky').children().length > 2) {
            jQuery('#googleAdsenseNew_sky').css('margin-top', '20px');
        }
        if (jQuery('#FlexTop').children().length > 2) {
        }
        jQuery('#FlexSky').css('visibility', 'visible');
    }
};

