/*
* 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'
);
window.onload = init;
function init
(
// no attributes
)
{
Links = document.getElementsByTagName ( 'a' );
Popups = getWindowAttribute ( popupElements );
detectMarktfinderForm();
doPopups ( Popups, Links );
// TEMP Start
var CountrySelect = document.getElementById ( 'select-country' );
if
(
CountrySelect
)
{
CountrySelect.onchange = function ()
{
document.getElementById ( 'country-selection' ).submit ();
}
}
var MarktFinderStandard = 'PLZ oder Ort';
var KleinanzeigenSucheStandard = '- Suchbegriff -';
var MarktfinderBoxStandard = '- PLZ oder Ort -';
inputFieldFocus ( 'input-marktfinder', '', MarktFinderStandard )
inputFieldFocus ( 'classifieds-search-terms', '', KleinanzeigenSucheStandard )
inputFieldFocus ( 'marktfinder-box-search-term', '', MarktfinderBoxStandard )
// TEMP Ende
}
/* 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 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, 'Fressnapf' + 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 inputFieldFocus ( InputField, FocusValue, StandardValue )
{
InputField = document.getElementById ( InputField );
if
(
InputField
)
{
InputField.onfocus = function ()
{
if
(
InputField.value == StandardValue
)
{
InputField.value = FocusValue;
}
else
{
InputField.select ();
}
}
InputField.onblur = function ()
{
if
(
InputField.value == FocusValue
)
{
InputField.value = StandardValue;
}
}
}
}
function detectMarktfinderForm
(
// no attributes
)
{
if(document.getElementById ( 'marktfinder-form' ))
{
inputFieldFocus ( 'input-marktfinder', '', 'PLZ oder Ort' );
}
}
function KatzenstreuPopup () {
var Katzenstreu = window.open("http://www.bioplan-tiernahrung.de/popup_katzenstreu/", "Katzenstreu", "width=660,height=450,left=100,top=200");
Katzenstreu.focus();
}