function $() {
    var elements = [];
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
        if (typeof element == 'string') {
      element = document.getElementById(element);
    }
        if (arguments.length == 1) {
      return element;
  }
    }
  return elements;
}

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name + '='),
        len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0, name.length))) {
        return null;
    }
    if (start == -1) {
        return null;
    }
    var end = document.cookie.indexOf(';', len),
        endLength = document.cookie.length;
    if (endLength == -1) {
        return unescape(document.cookie.substring(len, end));
    }
}

function Set_Cookie(name, value, expires, path, domain, secure) {
    var cookieString = name + '=' + escape(value) + ((expires) ? ';expires=' + expires.toGMTString() : '') + ((path) ? ';path=' + path : '') + ((domain) ? ';domain=' + domain : '') + ((secure) ? ';secure' : '');
    document.cookie = cookieString;
}

function Delete_Cookie(name, path, domain) {
    if (Get_Cookie(name)) {
        document.cookie = name + '=' + ((path) ? ';path=' + path : '') + ((domain) ? ';domain=' + domain : '') + ';expires=Thu, 01-Jan-70 00:00:01 GMT';
    }
}

function not_shown_yet(cookiename) {
    if (Get_Cookie(cookiename) == 'already_shown') {
        return false;
    } else {
        Set_Cookie(cookiename, 'already_shown');
        return true;
    }
}

function MM_openBrWindow(theURL, winName, features) {
    window.open(theURL, winName, features);
}

function PopUnder(theURL, winName, features) {
    var PopUnder2 = window.open(theURL, winName, features);
    if (PopUnder2) {
        PopUnder2.blur();
    }
}

function PopUnderDual(theURL, winName, features, theURL2, winName2, features2) {
    var PopUnder = window.open(theURL, winName, features);
    if (PopUnder) {
        PopUnder.blur();
    }
    var PopUnder2 = window.open(theURL2, winName2, features2);
    if (PopUnder2) {
        PopUnder2.blur();
    }
}

function PopUnderSetCookie(cookieName, cookieDesc, theURL, winName, features) {
    if (Get_Cookie(cookieName) == cookieDesc) {
        return false;
    } else {
        Set_Cookie(cookieName, cookieDesc);
        var PopUnder = window.open(theURL, winName, features);
        if (PopUnder) {
            PopUnder.blur();
        }
        window.focus();
        return true;
    }
}

/**
 * zeigeWerbemittel()
 * show advertising media
 */

function adCorrection(adName) {
    var bwsr = navigator.userAgent.toLowerCase();
     var ad = $(adName);
    if (ad.offsetHeight > 50) {
        switch (adName) {
        case 'FlexBig':
            $('cnt').style.padding = '7.35em 0 0 0';
                             $('navLft').style.margin = '5.65em 0 0 0';
            $(adName).style.top = ((bwsr.indexOf('msie') > -1)) ? '9.25em' : '9.15em';
                             break;
        case 'FlexSky':
            if ($('newsSky') !== undefined) {
                $('newsSky').style.display = 'none';
        }
            break;
        default:
            break;
    }
    }
    else {
        ad.style.display = 'none';
        if ($('newsSky') !== undefined) {
            $('newsSky').style.display = 'block';
    }
    }
}

function zeigeWerbemittel() {
    var flexBigObj = $('FlexBig') || false,
        flexSkyObj = $('FlexSky') || false;

    if ((flexBigObj !== false) && (flexBigObj[''] !== undefined)) {
        window.setTimeout('adCorrection("FlexBig")', 100);
    }

    if (flexSkyObj[''] !== undefined) {
        window.setTimeout('adCorrection("FlexSky")', 100);
    }
}

/**
 * Layer for credit informations
 * old overlib from overlibmws.js
 * show hidden informations by clicking .infoBtn
 * add new div.creditLayerBG to create a darker and transparent background behind the informations
 */
jQuery(function() {
	        /* tooltip - tableResult Produktinfo */
	var tooltipWrapper = jQuery(".hasTooltip");

	tooltipWrapper.each(function () {
		jQuery(this).append('<div class="tooltip tooltipArrowLeft">' + jQuery('#info_' + jQuery(this).attr('title')).parent().html() + '</div>');
		});
});

/**
 * close the informations and remove the new div.createLayerBG
 * @return neueZhal int || 0
 * @param zahl int || 0 Kreditzahl bis 1010
 */

function closeOverlay() {
    jQuery('.close').click(function() {
        jQuery('.creditlayer').parent().addClass('hide');
        jQuery('body').find('div.creditLayerBG').remove();
    });
}

/**
 * CreditCalc small
 * overlayer for infoBtn
 */
jQuery(function () {
   var kreditHelpBtn = jQuery('img[name=kreditbetrag_helpBtn]'),
       vzweckHelpBtn = jQuery('img[name=vzweck_helpBtn]'),
       kreditHelp = jQuery('#kreditbetrag_help'),
       vzweckHelp = jQuery('#vzweck_help');

       kreditHelpBtn.hover(function() {
           kreditHelp.removeClass('hide');
       }, function() {
           kreditHelp.addClass('hide'); 
	});

       vzweckHelpBtn.hover(function() { 
           vzweckHelp.removeClass('hide');
       }, function() {
           vzweckHelp.addClass('hide'); 
	});
});
