/*
* 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'
);
var Links = document.getElementsByTagName ( 'a' );
window.onload = init;
function init
(
// no attributes
)
{
Popups = getWindowAttribute ( popupElements );
doPopups ( Popups, Links );
}
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 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 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;
}