/* * HTML classes with popup functionality * * After the class name you can add some popup window options like window height * or width. The option list must be comma seperated. */ var popupElements = new Array ( 'EXTERNAL', 'teaser-adventskalender,width=620,height=530', 'luzie,width=500,height=340' ); /* * FOR INTERNET EXPLORER * HTML id's containing hover elements * * After the id you can indicate the HTML tag containing the elements which * visibility is switching. If there is no tag given, the li element is the * default value. */ var iehoverElements = new Array ( ); var printElements = new Array ( ); var favoritesElements = new Array ( ); window.onload = init; function init ( // no attributes ) { var Links = document.getElementsByTagName ( 'a' ); Popups = getWindowAttribute ( popupElements ); doPopups ( Popups, Links ); doPrint ( printElements, Links ); doFavorites ( favoritesElements, Links ); } /* FUNCTIONS */ /* * Entfernt alle Leerstellen aus einem Array */ function aTrimArray ( Elements ) { if ( Elements.length < 0 ) return false; var ElementsReturn = new Array (); for ( var i = 0; i < Elements.length; i++ ) { ElementsReturn[ i ] = Elements[ i ].replace ( new RegExp ( '/\s/' ), '' ); } return ElementsReturn; } function printPage ( // no attributes ) { window.print (); return false; } function hasComma ( mString ) { if ( mString.length < 1 ) return false; var Return = mString.indexOf ( ',' ); if ( Return > -1 ) return true; return false; } function getWindowAttribute ( Elements ) { if ( Elements.length < 1 ) return false; var WindowNames = new Array (); var WindowAttributes = new Array (); for ( var i = 0; i < Elements.length; i++ ) { WindowAttributes[ i ] = aTrimArray ( Elements[ i ].split ( "," ) ); WindowNames[ i ] = WindowAttributes[ i ].shift (); } var Return = new Array ( WindowNames, WindowAttributes ); return Return; } function arrayWalker ( mArray, mFunction, mAttribute ) { if ( mArray.length < 1 ) return false; if ( mFunction.charAt ( 0 ) == '.' ) { var Method = mFunction; } var Return = new Array (); for ( var i = 0; i < mArray.length; i++ ) { if ( Method ) { Return[ i ] = eval ( 'mArray[ i ]' + Method + ' ( ' + mAttribute + ' )' ); } else { Return[ i ] = eval ( mFunction + ' ( mArray[ i ] )' ); } } return Return; } function doPrint ( Prints, Links ) { if ( !document.getElementsByTagName ) return false; if ( Prints.length < 1 ) return false; for ( var i = 0; i < Links.length; i++ ) { if ( checkClasses ( Prints, Links[ i ].className ) ) { Links[ i ].onclick = function () { window.print (); return false; } } } } function doFavorites ( Favorites, Links ) { if ( !window.attachEvent ) return false; if ( !document.getElementsByTagName ) return false; if ( Favorites.length < 1 ) return false; for ( var i = 0; i < Links.length; i++ ) { if ( checkClasses ( Favorites, Links[ i ].className ) ) { Links[ i ].onclick = function () { window.external.AddFavorite ( this.href, document.title ); return false; } } } } function doPopups ( // Array containing HTML classes with popup functionality Popups, Links ) { if ( !document.getElementsByTagName ) return false; if ( Popups.length < 1 ) return false; for ( var i = 0; i < Links.length; i++ ) { if ( checkClasses ( Popups[ 0 ], Links[ i ].className ) ) { Links[ i ].onclick = function () { var PopupName = checkClasses ( Popups[ 0 ], this.className ); var PopupId = inArray ( PopupName, Popups[ 0 ] ); buildPopup ( this.href, PopupName, Popups[ 1 ][ PopupId ] ); return false; }; } } } function buildPopup ( WindowLocation, WindowName, WindowAttributes ) { WindowName = WindowName.replace ( /-/, "_" ); window.open ( WindowLocation, 'DAAD' + WindowName , WindowAttributes.join ( ',' ) ); } function checkClasses ( Needles, Haystack ) { for ( var i = 0; i < Needles.length; i++ ) { if ( Haystack.indexOf ( Needles[ i ] ) > -1 ) { return Needles[ i ]; } } return false; } function inArray ( SearchTerm, Array ) { if ( SearchTerm.length < 1 ) return false; if ( Array.length < 1 ) return false; for ( var i = 0; i < Array.length; i++ ) { if ( Array[ i ] == SearchTerm ) { return i; } } return false; } function openPopup (strSeite, intBreite, intHoehe, strName, strScrollbars) { var intScreenWidth = screen.width; var intScreenHeight = screen.height; var intPosX = (intScreenWidth / 2) - (intBreite / 2); var intPosY = (intScreenHeight / 2) - (intHoehe / 2); // In der open()-Funktion dürfen keine Leerstellen verwendet // werden, da sonst bei einigen Browsern eine korrekte // Darstellung verhindert wird. winPopup = window.open(strSeite,strName,'width='+ intBreite +',height='+ intHoehe +',left='+ intPosX +',screenX='+ intPosX +',top='+ intPosY +',screenY='+ intPosY +',menubar=no,scrollbars='+ strScrollbars +',resizable=no,location=no,status=no,directories=no,dependent'); winPopup.focus(); }