if (!pathPrefix) { var pathPrefix = ""; }

function idm_createPoll(url) {
	idm_showPopUpWindow('',url, 444, 590, 'id_createPoll');
}
function idm_openPollReminder(url) {
	idm_showPopUpWindow('',url, 440, 200, 'id_openPollReminder');
}
function idm_openMailToModerator(url) {
	idm_showPopUpWindow('',url, 440, 200, 'id_openMailToModerator');
}
function idm_showIdCard(url,nickname) {
	idm_showPopUpWindow('',url+'?nickname='+nickname, 440, 360, 'id_showIdCard');
}
function idm_showSkypeId(url) {
	idm_showPopUpWindow('',url, 330, 200, 'id_showSkypeId');
}
function idm_openSubscribeClub(clubId) {
	idm_showPopUpWindow('','/membersubscribe.htm?clubId='+clubId, 440, 360, 'id_openSubscribeClub');
}
function idm_openClubDisclaimer() {
	idm_showPopUpWindow('','/configmyclubfoundingdisclaimer.htm', 440, 360, 'id_openClubDisclaimer');
}
function idm_openNetikette() {
	idm_showPopUpWindow('','/netikette.htm', 460, 355, 'id_openNetikette');
}
function idm_openNetiketteForum(url) {
	netiketteUrl = url+'/netikette.htm';
	idm_showPopUpWindow('',netiketteUrl, 460, 355, 'id_openNetiketteForum');
}
function idm_openClubRules(rules) {
	idm_showPopUpWindow('','/clubrules.htm?clubId='+rules, 440, 360, 'id_openClubRules');
}
function idm_openVotingSuccess() {
	idm_showPopUpWindow('','/forum/ebay/voting_success.jsp', 440, 360, 'id_openVotingSuccess');
}
function idm_openPinboardMessage(url) {
	idm_showPopUpWindow('',url, 455, 220, 'id_openPinboardMessage');
}
function idm_openAddAcknowledgementWindow(url) {
	idm_showPopUpWindow('',url, 440, 360, 'id_openAddAcknowledgementWindow');
}
function idm_openConfigMemberMails(clubId) {
	idm_showPopUpWindow('','/configmembermails.htm?clubId='+clubId, 440, 360, 'id_openConfigMemberMails');
}
function idm_openConfigMemberApply(clubId) {
	idm_showPopUpWindow('','/configmemberapply.htm?clubId='+clubId, 440, 360, 'id_openConfigMemberApply');
}

function idm_openConfigMemberMail2Moderator(clubId) {
	idm_showPopUpWindow('','/configmembermail2moderator.htm?clubId='+clubId, 440, 360, 'id_openConfigMemberMail2Moderator');
}
function idm_openConfigMemberInvite(clubId) {
	idm_showPopUpWindow('','/configmemberinvite.htm?clubId='+clubId, 440, 360, 'id_openConfigMemberInvite');
}
function idm_openCreateExpertArea(nickname) {
	idm_showPopUpWindow('','/createexpertarea.htm?nickname='+nickname, 505, 385, 'id_openCreateExpertArea');
}
function idm_openAddExpertArea(categoryName, categoryId) {
	idm_showPopUpWindow('','/createexpertarea.htm?categoryId=' + categoryId + '&categorySelected='+categoryName+'&create=true', 505, 385, 'id_openAddExpertArea');
}
function idm_openEditExpertAreaTags(categoryName, categoryId) {
	idm_showPopUpWindow('','/addexpertareatags.htm?name='+categoryName+'&id='+categoryId, 505, 385, 'id_openEditExpertAreaTags');
}
function idm_openCancelClubMembership(clubId) {
	idm_showPopUpWindow('','/cancelmembership.htm?clubId='+clubId, 505, 385, 'id_openCancelClubMembership');
}
function idm_openReportAbuseClub(clubId,clubGalleryId,currentImageId){
	abuseUrl = "/reportabuseclubs.htm?clubId="+clubId+"&clubGalleryId="+clubGalleryId+"&currentImageId="+currentImageId;
	idm_showPopUpWindow('',abuseUrl, 460, 350, 'id_openReportAbuseClub');
}
function idm_openReportAbuseCalendar(clubId,currentEventId){
	abuseUrl = "/reportabuseclubs.htm?clubId="+clubId+"&currentEventId="+currentEventId;
	idm_showPopUpWindow('',abuseUrl, 460, 350, 'id_openReportAbuseCalendar');
}
function idm_openReportAbuseProfile(profileOwnerId, nickname){
	abuseUrl = "/reportabuse_profile.htm?profileOwnerId="+profileOwnerId+"&nickname="+nickname;
	idm_showPopUpWindow('',abuseUrl, 460, 350, 'id_openReportAbuseProfile');
}
function idm_openReportAbusePoll(url){
	idm_showPopUpWindow('',url, 460, 350, 'id_openReportAbuseClub');
}

function idm_openCommunityPollProposal(){
	idm_showPopUpWindow('','/commpoll/sendproposal.htm', 500, 425, 'id_openCommunityPollProposal');
}

function idm_openConfigMemberMail2Ebay(clubId) {
	idm_showPopUpWindow('','/configmembermail2ebay.htm?clubId='+clubId, 440, 360, 'id_openConfigMemberMail2Ebay');
}
function idm_openUserComplaintProfil(nickname) {
	idm_showPopUpWindow('','/usercomplaintprofile.htm?nickname='+nickname, 440, 360, 'id_openUserComplaintProfil');
}
function idm_openConfigFounderEdit(clubId){
	idm_showPopUpWindow('','/configfounderedit.htm?clubId='+clubId, 440, 360, 'id_openConfigFounderEdit');
}
function idm_openInfotour() {
	var infotour = window.open('/tour/info-tour-popup.jsp','Infotour','width=720,height=515');
}
function idm_openGameRequirements(){
	idm_showPopUpWindow('','/gamerequirements.htm', 500, 605, 'id_openGameRequirements');
}
function idm_openSearchtipps(){
	idm_showPopUpWindow('','/search/searchtipps.htm', 480, 350, 'id_openSearchtipps');
}
function idm_openForumSearchtipps(){
	idm_showPopUpWindow('',pathPrefix+'/searchtipps.htm', 480, 350, 'id_openForumSearchtipps');
}
function idm_openForumAbuse(messageID,threadID){
	abuseUrl = "/forum/ebay/abuse!default.jspa?messageID="+messageID+"&threadID="+threadID;
	idm_showPopUpWindow('',abuseUrl, 460, 350, 'id_openForumAbuse');
}
function idm_fotoFolderCreate(title,url) {
	idm_showPopUpWindow(title,url, 440, 510, 'id_fotofoldercreate');
}
// EVENT CALENDAR
function idm_openCalendarCreate(clubId, referer) {
	idm_showPopUpWindow('','/clubsCalendarEvent.htm?clubId=' + clubId + '&referer=' + escape(referer), 520, 500, 'id_calendarCreateEntry');
}
function idm_openCalendarEventEdit(eventId, referer) {
	idm_showPopUpWindow('','/editClubsCalendarEvent.htm?eventId='+ eventId +'&editing=true&referer=' + escape(referer), 520, 480, 'id_calendarEditEntry');
}
function idm_openCalendarApproveEvent(eventId, referer) {
	idm_showPopUpWindow('','/approveEvent.htm?eventId='+ eventId + '&referer=' + escape(referer), 520, 440, 'id_calendarApproveEntry');
}
function idm_openCalendarDeleteEvent(eventId, referer) {
	idm_showPopUpWindow('','/deleteEvent.htm?eventId='+ eventId + '&referer=' + escape(referer), 520, 440, 'id_calendarDeleteEntry');
}
// Community Hub
function idm_openInfoMovie() {
	idm_showPopUpWindow('','/tour/info-tour-popup.jsp', 725, 520, 'id_infoTour');
}
function idm_openMovie(movieID) {
	idm_showPopUpWindow('','/communityMovie.htm?id='+movieID, 565, 490, 'id_infoMovie');
}
/* collected pop-openers
---------------------------------------------------------------------*/
function idm_showPopUpWindow(title,pageUrl, width, height, windowId){
		// showcase should not run if lightbox is open
		if (typeof marginaltimeout != 'undefined') {
			window.clearTimeout(marginaltimeout);
		}
		w = new openPopUpWindow();
		w.display(title,pageUrl, width, height, windowId);
		myObserver = {
			onDestroy: function(eventName, win) {
				if (win == w.getWindow()) {
					w.removeWindow();
					Windows.removeObserver(this);
				}
			}
		}

		Windows.addObserver(myObserver);
}
 /*
 * ---------------------------------------------------------------
 * Blocktrigger for forums
 * ---------------------------------------------------------------
 */
	function IDM_switchBlocks(idm_block)
	{
		var idm_blocktrigger = idm_block + '-trigger';
		var idm_blockother = idm_block + '-other';

		if (Element.hasClassName(idm_blocktrigger, 'idm-opened')) {

			Element.toggle(idm_block,'slide');


			if ($(idm_blockother) != undefined) Element.toggle(idm_blockother,'slide');

			Set_Cookie( idm_blocktrigger, 'idm-closed', '', '/', '', '' );
			Element.removeClassName(idm_blocktrigger, 'idm-opened');
			Element.addClassName(idm_blocktrigger, 'idm-closed');
		} else {
			if ($(idm_blockother) != undefined) Element.toggle(idm_blockother,'slide');
			Element.toggle(idm_block,'slide');
			Set_Cookie( idm_blocktrigger, 'idm-opened', '', '/', '', '' );
			Element.removeClassName(idm_blocktrigger, 'idm-closed');
			Element.addClassName(idm_blocktrigger, 'idm-opened');
		}
	}

/**
 * ---------------------------------------------------------------
 * Generic getter for markup elements called by its css class name
 * ---------------------------------------------------------------
 *
 * Usage examples of how to call the function:
 *
 * To get all a elements in the document with a "info" class:
 * idm_getElementsByClassName(document, "a", "info");
 *
 * To get all div elements within the element named "container", with a "col" and a "left" class:
 * idm_getElementsByClassName(document.getElementById("container"), "div", ["col", "left"]);
 *
 * @author Andrej.Becker
 *
*/

function idm_getElementsByClassName (oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if (typeof oClassNames == "object") {
		for (var i=0; i<oClassNames.length; i++) {
			arrRegExpClassNames.push( new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)") );
		}
	} else {
		arrRegExpClassNames.push( new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)") );
	}
	var oElement;
	var bMatchesAll;
	for (var j=0; j<arrElements.length; j++) {
		oElement = arrElements[j];
		bMatchesAll = true;
		for (var k=0; k<arrRegExpClassNames.length; k++){
			if ( !arrRegExpClassNames[k].test(oElement.className) ) {
				bMatchesAll = false;
				break;
			}
		}
		if (bMatchesAll) {
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
};	//end idm_getElementsByClassName()



/**
 * ---------------------------------------------------------------
 * Place a close-box-button within a layout module
 * ---------------------------------------------------------------
 *
 * @author Andrej.Becker
 *
*/
//
// storage array for closed-up boxes
document._arrayHiddenElements = new Array();

function findBlindUpBox(obj,type) {
	if (type == null) {
		type = "standard";
	}
	if (document.getElementById && document.getElementsByTagName && obj != null) {
		//
		// store closed Elements in order to re-open them later
		var _hiddenElement = obj +"_hidden";
		var _storage = document._arrayHiddenElements;
		var _trigger = false;
		for (j=0; j<_storage.length; j++) {
			if (_storage[j] == _hiddenElement) {
				_trigger = true;
			}
		}
		// find target box that we want to close
		var _mainbox     = document.getElementById(obj);
		var _containers  = _mainbox.getElementsByTagName("DIV");

		if (type == "standard") {
			var _targetbox   = _containers[3];
			var _buttonbox   = _containers[0].parentNode.parentNode;
		} else if (type == "pinboard") {
			var _targetbox   = _containers[4];
			var _buttonbox   = _containers[0];
		}

		var _buttonimage = _buttonbox.getElementsByTagName("IMG");

		//
		if (_trigger == false) {
			// now store box in array
			var _pusher = _storage.push(_hiddenElement);
			// swap close button image
			if (_buttonimage[0].src.indexOf("cpriv") != -1) {
				_buttonimage[0].src = pathPrefix+"/static/gfx/button/boxtrigger_cpriv_open.gif";
			} else {
				_buttonimage[0].src = pathPrefix+"/static/gfx/button/boxtrigger_open.gif";
			}
			// prevent IE from showing hidden content until box is closed ...
			_mainbox.style.overflow = "hidden";
			if (type == "standard") {
				for (m=0; m<_containers.length; m++) {
					//_containers[m].style.overflow = "hidden";
				}
			}
			// apply closing box effect
			new Effect.BlindUp(_targetbox);
		} else {
			// now check storage array and delete item
			for (k=0; k<_storage.length; k++) {
				if (_storage[k] == _hiddenElement) {
					_storage[k] = "";
				}
			}
			// swap close button image
			if (_buttonimage[0].src.indexOf("cpriv") != -1) {
				_buttonimage[0].src = pathPrefix+"/static/gfx/button/boxtrigger_cpriv_close.gif";
			} else {
				_buttonimage[0].src = pathPrefix+"/static/gfx/button/boxtrigger_close.gif";
			}
			// reset IE values
			_mainbox.style.overflow = "visible";
			if (type == "standard") {
				for (n=0; n<_containers.length; n++) {
					//_containers[n].style.overflow = "visible";
				}
			}
			// apply opening box effect
			new Effect.BlindDown(_targetbox);
		}
		return _targetbox;
	}
};	// end findBlindUpBox()


//TODO: maybe useful functions for later...
/*
 * explorer fix to disable background image reloading
 */
/*
 *
 try {
document.execCommand("BackgroundImageCache", false, true);
} catch(error) {}
*/


/**
 * ---------------------------------------------------------------
 * Cookie handling
 * ---------------------------------------------------------------
**/
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

// this function gets the cookie, if it exists
// don't use this, it's weak and does not handle some cases
// correctly, this is just to maintain legacy information
function Get_Cookie( name ) {

var start = document.cookie.indexOf( name + "=" );
var 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 );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
//checking searchstring length
	function checkForm(fieldId,errorId,missingId) {
	$(errorId).style.display = "none";
	$(missingId).style.display = "none";
		if ($(fieldId).value.length<3) {
		$(errorId).style.display = "block";
		return(false);
		}
		if ($(fieldId).value == "Suchbegriff eingeben" || $(fieldId).value == "Stichwort eingeben") {
		$(missingId).style.display = "block";
		return(false);
		}
	}

function modalWindowHideDisturbingElements(){
	var moveTags = ['object', 'select', 'input', 'iframe'];
	moveTags.each (function(sTag) {
					cElements = document.getElementsByTagName(sTag);
					$A(cElements).each( function(singleElement){
					Element.addClassName(singleElement,'idm-minimized');
					});
				});
	// -- The Obeserver moves flash and input fields out of sight
	myObserver = {
		onDestroy: function(eventName, win) {
			moveTags.each (function(sTag) {
					cElements = document.getElementsByTagName(sTag);
					$A(cElements).each( function(singleElement){
					Element.removeClassName(singleElement,'idm-minimized');
					});
			Windows.removeObserver(this);
			})
		}
	}
	Windows.addObserver(myObserver);
}

//the client's browser version in [#]#.# format
function getUserAgentName(){
	var retVal = "unknown";
	var myUserAgent = navigator.userAgent.toLowerCase();
	if(myUserAgent.indexOf("opera") != -1)
		retVal = "opera";
	else if(myUserAgent.indexOf("safari") != -1)
		retVal = "safari";
	else if(myUserAgent.indexOf("firefox") != -1)
		retVal = "firefox";
	else if(myUserAgent.indexOf("msie") != -1)
		retVal = "msie";
	else if(myUserAgent.indexOf("gecko") != -1)
		retVal = "mozilla";
	else
		retVal = "unknown";

	return retVal;
}
function getUserAgentVersion() {
	var retVal = "0.0";
	var vSearch = /./;
	var myUserAgent = navigator.userAgent.toLowerCase();
	switch(getUserAgentName()){
		case "opera":
			vSearch = /opera\s(\d\.\d)\d*|opera\/(\d\.\d)\d*/i;
			version = vSearch.exec(myUserAgent);
			if(version != null)
				retVal = (version[1]) ? version[1] : version[2];
		break;
		case "safari":
			vSearch = /Safari\/(\d{3})\.\d+/i;
			version = vSearch.exec(myUserAgent);
			if(version != null)
				retVal = (version[1] >= 125) ? 1.0 : 0;
		break;
		case "firefox":
			vSearch = /Firefox\/(\d\.\d)/i;
			version = vSearch.exec(myUserAgent);
			if(version != null)
				retVal = version[1];
		break;
		case "msie":
			vSearch = /MSIE\s(\d\.\d)/i;
			version = vSearch.exec(myUserAgent);
			if(version != null)
				retVal = version[1];
		break;
		case "mozilla":
			vSearch = /rv:(\d\.\d)/i;
			version = vSearch.exec(myUserAgent);
			if(version != null)
				retVal = version[1];
		break;
		default:
			retVal = "0.0";
		break;
	}
	return retVal;
}

var TextCounter = Class.create();
TextCounter.prototype = {
	initialize: function(textareaid, maxLengthEl, maxLength) {
		this.maxLength = maxLength;
		this.textarea = $(textareaid);
		this.maxLengthEl = $(maxLengthEl);
		this.maxLengthEl.innerHTML = maxLength;
		Event.observe(this.textarea, 'keyup', this.checkChars.bindAsEventListener(this));
		Event.observe(this.textarea, 'keydown', this.checkChars.bindAsEventListener(this));
		this.checkChars();
	},
	checkChars: function(e) {
		var includeBreaksInCount = false;
		var charCount = this.textarea.value.length;
		var breaks = 0;
		if (!includeBreaksInCount) {
			var lines = this.textarea.value.split('\n');
			breaks = lines.length;
			for (var i=0; i<lines.length; i++) {
				var line = lines[ i ];
				if (line.charCodeAt(line.length-1) == 13)
					breaks++;
			}
		}
		if ((charCount-breaks) > this.maxLength) {
			this.textarea.value = this.textarea.value.substring(0, (this.maxLength + breaks) );
		}
		if (this.maxLengthEl) {
			if ((charCount-breaks) > this.maxLength) {
				this.maxLengthEl.innerHTML = 0;
			} else {
				this.maxLengthEl.innerHTML = (this.maxLength + breaks) - charCount;
			}
		}
	}
}



/**
 * Static Helper Class for Session
 *
 * @author fhoffmann
 */
SessionHelper = {

	/**
	 * Get the login status for client by an ajax request.
	 * Note, that the header contains the return value of true|false
	 *
	 * @return boolean
	 */
	isEbayUserLoggedIn: function() {

		var ebayUserLoggedIn = "false";

		new Ajax.Request("/loginstate.htm", {
			method: "head",
			asynchronous: false,
			onSuccess: function(transport) {
				try {
					ebayUserLoggedIn = transport.getResponseHeader("ebayLoggedIn");
				} catch(e) {}
			}
		});

		return ebayUserLoggedIn.indexOf("true") == 0;
	}
}