if (getCookie('mhLoggedInUserUsername') == '' || getCookie('mhLoggedInUserUsername') == null)
{
	if (!(getCookie('mhRecognitionUsername') == '' || getCookie('mhRecognitionUsername') == null))
	{
		setCookie('mhLoggedInUserUsername', getCookie('mhRecognitionUsername'));
	}
}
if (getCookie('mhLoggedInUserFlagHasProfile') == '' || getCookie('mhLoggedInUserFlagHasProfile') == null)
{
	if (!(getCookie('mhRecognitionFlagHasProfile') == '' || getCookie('mhRecognitionFlagHasProfile') == null))
	{
		setCookie('mhLoggedInUserFlagHasProfile', getCookie('mhRecognitionFlagHasProfile'));
	}
}

function deleteCookie (name)
{
	var myDate = new Date ();
	myDate.setTime ( myDate.getTime()-1);
	document.cookie = name + "=; expires=" + myDate.toGMTString();
}

function setCookie(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" : "" );
}

function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	var result;
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
	{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	result = unescape(dc.substring(begin + prefix.length, end));
	if (result.indexOf("deleted")>=0)
	{
		return null;
	}
	else
	{
		return result;
	}
}

function bookmarkPage(url, title)
{
	if (title == '')
		title = document.title;
	if (url == '')
		url   = document.URL;

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, "");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	} else if(window.opera && window.print) { // Opera Hotlist
		return true;
	}
}

function get_auction_endtime(actionendtime, nominutes)
{
 if(myhammertime < actionendtime)
 {
  var leavingtime = actionendtime - myhammertime;
  var seconds = leavingtime;
  var days = Math.floor(((leavingtime / 60) / 60) / 24);
  var hours = Math.floor(((leavingtime - (days * 86400)) / 60) / 60);
  var minutes = Math.floor((leavingtime - ((days * 86400) + (hours * 3600))) / 60);
  var seconds = (leavingtime - ((days * 86400) + (hours * 3600) + (minutes * 60)));

  if(days > 0)
   days = days + 'T ';
  else
   days = '';

  if(hours > 0) {
   if(hours < 10) hours = '0' + hours;
   hours = hours + 'Std ';
  } else {
   if(days)
    hours = '00Std ';
   else
    hours = '';
  }

  if(minutes > 0) {
   if(minutes < 10) minutes = '0' + minutes;
   minutes = minutes + 'Min ';
  } else {
   if(hours)
    minutes = '00Min ';
   else
    minutes = '';
  }

  if(seconds > 0) {
   if(seconds < 10) seconds = '0' + seconds;
   seconds = seconds + 'Sek';
  } else {
   if(minutes)
    seconds = '00Sek';
   else
    seconds = '';
  }

  if(hours) {
   if (nominutes)
   {
    var timestring = days + hours;
   }
   else
   {
   	var timestring = days + hours + minutes;
   }

  } else {
   var timestring = minutes + seconds;
  }
  document.write(timestring);
 }
 else
 {
  document.write('beendet');
 }
}

function get_auction_endtime_short(actionendtime, nominutes)
{
	if(myhammertime < actionendtime)
	{
		var leavingtime = actionendtime - myhammertime;
		var seconds = leavingtime;
		var days = Math.floor(((leavingtime / 60) / 60) / 24);
		var hours = Math.floor(((leavingtime - (days * 86400)) / 60) / 60);
		var minutes = Math.floor((leavingtime - ((days * 86400) + (hours * 3600))) / 60);

  		if (days == 0 && hours == 0 && minutes > 0 && minutes < 60) document.write('<span class="auctionEndingAlert" style="white-space: nowrap;"> &lt; 1 Std </span>');
		else
		{
			if(days > 0) days = days + 'T ';
			else days = '';

			if(hours > 0) {
				if(hours < 10 && days > 0) hours = '0' + hours;
				hours = hours + 'Std ';
			} else {
				if(days) hours = '00Std ';
				else hours = '';
			}

			if(minutes > 0) {
				if(minutes < 10) minutes = '0' + minutes;
				minutes = minutes + 'Min ';
			} else {
				if(hours) minutes = '00Min ';
				else minutes = '';
			}

			if (minutes) var timestring = minutes;
			if (hours) var timestring = hours + minutes;
			if (days) var timestring = days + hours;

		document.write('<span style="white-space: nowrap;">' + timestring + '</span>');
		}
	}
	else
	{
		document.write('beendet');
	}
}

function static_main()
{
	var loginArea;
	loginArea = document.getElementById('lfled');

	if (document.cookie.indexOf('mhLoggedInUserUsername') != -1)
	{
		loginArea.innerHTML = loggedin;
	}
	else
	{
		loginArea.innerHTML = loggedout;
	}
}

var ns6=document.getElementById&&!document.all;
function restrictinput(maxlength,e,placeholder)
{
	if (window.event&&event.srcElement.value.length>=maxlength)
	return false;
	else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength)
	{
		var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
		if (pressedkey.test(String.fromCharCode(e.which)))
		e.stopPropagation();
	}
}

function countlimit(maxlength,e,placeholder)
{
	var theform=eval(placeholder)
	var lengthleft=maxlength-theform.value.length
	var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
	if (window.event||e.target&&e.target==eval(placeholder))
	{
		if (lengthleft<0)
		theform.value=theform.value.substring(0,maxlength)
		placeholderobj.innerHTML=lengthleft
	}
}

function displaylimit(theform,thelimit)
{
	var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b>{t}CHARACTERS_REMAINING{/t}';
	if (document.all||ns6)
	document.write(limit_text)
	if (document.all)
	{
		eval(theform).onkeypress=function()
		{
			return restrictinput(thelimit,event,theform);
		}
		eval(theform).onkeyup=function()
		{
			countlimit(thelimit,event,theform);
		}
	}
	else if (ns6)
	{
		document.body.addEventListener('keypress', function(event)
		{
			restrictinput(thelimit,event,theform);
		}, true);
		document.body.addEventListener('keyup', function(event)
		{
			countlimit(thelimit,event,theform);
		}, true);
	}
}

function payinvoice(link)
{
    alert('Funktion nicht implementiert');
}

function Help( daLink )
{
    var comwin = window.open(daLink,'Help',
	'width=560,height=450,scrollbars=yes,resize=no') ;
    comwin.focus();
}

function CheckAll()
{
    for (var i=0;i<document.gt_massdelete.elements.length;i++)
	{
		var e = document.gt_massdelete.elements[i];
	    e.checked = 1;
	}
}

function ClearAll()
{
	for (var i=0;i<document.gt_massdelete.elements.length;i++)
	{
    	var e = document.gt_massdelete.elements[i];
    	e.checked = 0;
    }
}

function popUP(mypage, myname, w, h, scroll, titlebar)
{
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4)
	{
        win.window.focus();
    }
}

function addKeyword(keyword)
{
	document.search_form.keyword_text.value=keyword;
}

function createWindow(u,n,w,h,r)
{
	args = 'width='+w+',height='+h+',resizable=no,scrollbars=yes,status=0';
    remote = window.open(u,n,args);
    if( remote != null )
	{
    	if (remote.opener == null)
		{
        	remote.opener =  self ;
        }
    }
    if( r == 1 )
	{
		return remote;
	}
}

var attw =null;
var drww =null;
function Attach( url )
{
	if( !attw || attw.closed )
	{
    	attw = createWindow( url,  'attachwin', 420, 360, 1);
    }
    attw.focus();
}

var popUpWindow=1;
function AttachFocus()
{
	T_DOCUMENT_BLUR;
    if( popUpWindow==1 )
	{
    	var msg = 'Click "Upload" to add/remove files';
    	window.alert(msg);
    	popUpWindow=0;
	}
    T_DOCUMENT_FOCUS;
    return false;
}

var eventdate = new Date("24 Dec 1997 23:00:00 GMT");
function toSt(n)
{
	s=""
	if(n<10) s+="0"
	return s+n.toString();
}

function countdown()
{
	cl=document.clock;
	d=new Date();
	count=Math.floor((eventdate.getTime()-d.getTime())/1000);
	if(count<=0)
	{
		cl.days.value ="0";
		cl.hours.value="0";
		cl.mins.value="0";
		cl.secs.value="0";
		alert("{t}Inaktive{/t}");
		return;
	}
	cl.secs.value=toSt(count%60);
	count=Math.floor(count/60);
	cl.mins.value=toSt(count%60);
	count=Math.floor(count/60);
	cl.hours.value=toSt(count%24);
	count=Math.floor(count/24);
	cl.days.value=count;
	setTimeout("countdown()",500);
}

var checkflag = "false";
function check(field)
{
	if (checkflag == "false")
	{
		for (i = 0; i < field.length; i++)
		{
  			field[i].checked = true;
		}
  		checkflag = "true";
		return "UnSelect";
	}
	else
	{
  		for (i = 0; i < field.length; i++)
		{
  			field[i].checked = false;
		}
		checkflag = "false";
  		return "Select";
	}
}

function getRadioValue(radioObject)
{
	var value = false
	if (radioObject.checked == true)
	{
		return true
	}
	for (var i=0; i<radioObject.length; i++)
	{
	    if (radioObject[i].checked)
	    {
			value = radioObject[i].value
			break;
		}
	}
	return value;
}

function newWindow(file,window)
{
	msgWindow=open(file,window,'resizable=no,width=430,height=380');
    if (msgWindow.opener == null)
	{
		msgWindow.opener = self;
	}
}

function newWindow2(file,window)
{
	msgWindow=open(file,window,'resizable=no,width=530,height=290');
    if (msgWindow.opener == null)
	{
		msgWindow.opener = self;
	}
}

var there=1;
function openFilePopup(file)
{
	var filePopup = window.open('/download.php?name=' + file, 'Vorschau', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=790,height=580');
	filePopup.focus();
}



wmtt = null;
document.onmousemove = updateWMTT;
function updateWMTT(e)
{
	if (document.all && !document.body) return;
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (wmtt != null)
	{
		wmtt.style.left = (x + 20) + "px";
		wmtt.style.top 	= (y + 20) + "px";
	}
}
function showWMTT(id)
{
	wmtt = document.getElementById(id);
	wmtt.style.display = "block"
}
function hideWMTT()
{
	wmtt.style.display = "none";
}

function include_dom(script_filename)
{
    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', script_filename);
    html_doc.appendChild(js);
    return false;
}

var included_files = new Array();

function include_once(script_filename)
{
	if (!in_array(script_filename, included_files))
	{
    	included_files[included_files.length] = script_filename;
        include_dom(script_filename);
    }
}

function in_array(needle, haystack)
{
	for (var i = 0; i < haystack.length; i++)
	{
    	if (haystack[i] == needle)
    	{
        	return true;
        }
	}
    return false;
}



function homepageSearchSetText()
{
	if (getCookie('mhLoggedInUserFlagHasProfile') != 1)
	{
		if (homepageSearchInputfield.value == '')
		{
			homepageSearchInputfield.value = searchTextDefault;
			homepageSearchInputfield.className = 'homepageSearchInputfieldBlur';
		}
	}
}

function homepageSearchUnsetText()
{
	if (getCookie('mhLoggedInUserFlagHasProfile') != 1)
	{
		if (homepageSearchInputfield.value == searchTextDefault)
		{
			homepageSearchInputfield.value = '';
			homepageSearchInputfield.className = 'homepageSearchInputfieldNormal';
		}
	}
}

function homepageSearchClearDefaultText()
{
	if (homepageSearchInputfield.value == searchTextDefault)
	{
		homepageSearchInputfield.value = '';
		homepageSearchInputfield.className = 'homepageSearchInputfieldNormal';
	}

	return true;
}

function categoryZipSetText()
{
	if (getCookie('mhLoggedInUserFlagHasProfile') != 1)
	{
		if ($('#filterZipcode').val() == '')
		{
			$('#filterZipcode').val(categoryZipTextDefault);
		}
	}
}

function categoryZipUnsetText()
{
	if (getCookie('mhLoggedInUserFlagHasProfile') != 1)
	{
		if ($('#filterZipcode').val() == categoryZipTextDefault)
		{
			$('#filterZipcode').val('');
		}
	}
}

function categoryZipClearDefaultText()
{
	if ($('#filterZipcode').val() == categoryZipTextDefault)
	{
		$('#filterZipcode').val('');
	}

	return true;
}

// static_welcomeMessage()
// Zeigt die welcomeArea bei angemeldeten Benutzern an ('Willkommen 123! (ausloggen)').
function static_welcomeMessage()
{
	if (getCookie('mhLoggedInUserUsername') != null)
	{
		var welcomeMessageArea;

		welcomeMessageArea = document.getElementById('welcomeMessageArea');
		welcomeMessageArea.className = 'mhWelcomeArea meta-signin-signup'; //Klasse mit Background setzen
		welcomeMessageArea.innerHTML = welcomeMessage;
	}
}




//Sorgt daf?r das die My-Hammer Zeit angezeigt wird
function updateTime()
{
	setTimeout ("updateTime()",1000);
	if (++mysec>59)
	{
		mysec=0;
		if (++mymin>59)
		{
			mymin=0;
			if (++myhrs>23)
				myhrs=0;
		}

	}
	Stunden = myhrs;
	Minuten = mymin;
	Sekunden = mysec;
	ZeitString = Stunden;
	ZeitString += ((Minuten < 10) ? ":0" : ":") + Minuten;
	ZeitString += ((Sekunden < 10) ? ":0" : ":") + Sekunden;

	var myuhr = document.getElementById("uhrzeit");
	myuhr.innerHTML = ZeitString;
}

//?ndert die Navigationslinks Einloggen und Ausloggen
function userstate()
{
	if (document.cookie.indexOf('mhLoggedInUserUsername') != -1)
	{
		var mhLoginLogoutLink;
		var navigationActiveRegister;
		var navigationActiveRegisterPipe;

		mhLoginLogoutLink = document.getElementById('mhLoginLogoutLink');
		mhLoginLogoutLink.innerHTML = '<a href="/logout.php">Ausloggen</a>';

		navigationActiveRegister = document.getElementById('navigationActiveRegister').style;
		navigationActiveRegisterPipe = document.getElementById('navigationActiveRegisterPipe').style;
		navigationActiveRegister.display = 'none';
		navigationActiveRegisterPipe.display = 'none';
	}
	else
	{
		var mhLoginLogoutLink;
		mhLoginLogoutLink = document.getElementById('mhLoginLogoutLink');
		mhLoginLogoutLink.innerHTML = '<a href="/login.php?clickedInNavigationBar=1">Einloggen</a>';
	}
}

var mhtrackingutype;
if ( (getCookie('mhStatPstate') == null && getCookie('mhStatID') == null && getCookie('mhStatCtype') == null && getCookie('mhStatSstate') == null) || getCookie('mhStatSstate') == 'n')
{
	mhtrackingutype = 'out.firstTime';
}
else if (getCookie('mhStatPstate') == 's' && getCookie('mhStatSstate') == null)
{
	mhtrackingutype = 'out.alreadySeen';
}
else if (getCookie('mhStatPstate') == 'c' && getCookie('mhStatSstate') == null)
{
	mhtrackingutype = 'out.regUser';
}
else
{
	mhtrackingutype = '';
}

	var lp_identification  = 'empty';
	
	function setBubbleOffsetTop(bubbleId, inputId)
	{
		var bubbleObject = document.getElementById(bubbleId);
		var inputObject = document.getElementById(inputId);

		if (!bubbleObject || !inputObject) return;
	
		var offsetTop = inputObject.offsetTop + ($.browser.msie ? 14 : -18);
		if($.browser.msie && lp_identification == 'registrieren')
		{
			offsetTop += 305;
		}
		
		$("#" + bubbleId).css("top", offsetTop + "px");
	}
	
	
	$(document).ready(function()
	{
		$(".text-error,.text-info:not(.text-error)").focus(function()
		{
			var type = $(this).hasClass("text-error") ? "error" : "info";

			if ($("#" + type + "-" + this.id).hasClass("bubble"))
			{
				var position = ($("#" + type + "-" + this.id).hasClass("bubble-info-left") || $("#" + type + "-" + this.id).hasClass("bubble-error-left")) ? "left" : "right";
				var classes = $("#" + type + "-" + this.id).attr("class");

				var tmpArr = classes.match(/bubble-offset-top([-0-9]+)/);
				var offsetTop = (tmpArr) ? parseInt(tmpArr[1]) : 0;
				
				tmpArr = classes.match(/bubble-offset-left([-0-9]+)/);
				var offsetLeft = (tmpArr) ? parseInt(tmpArr[1]) : 0;
				
				showBubble(this.id, type + "-" + this.id, position, offsetTop, offsetLeft);
			}
			else
			{
				setBubbleOffsetTop(type + "-" + this.id, this.id);
				$("#" + type + "-" + this.id).show();
				
				if ($("#" + type + "-" + this.id).length > 0 && $("#" + type + "-" + this.id).get(0).offsetHeight < 50)
				{
					$("#" + type + "-" + this.id).css("height", "50px");
					$("#" + type + "-" + this.id).children(".error-bottom,.info-bottom").css("position", "absolute");
					$("#" + type + "-" + this.id).children(".error-bottom,.info-bottom").css("bottom", "0");
				}
			}
		});
		
		$(".text-error,.text-info").blur(function()
		{
			var type = $(this).hasClass("text-error") ? "error" : "info";
			$("#" + type + "-" + this.id).hide();
		});
	});
	
	function showBubble(textId, bubbleId, position, offsetTop, offsetLeft)
	{
		var top  = $("#" + textId).offset().top - 16;
		var left = $("#" + textId).offset().left;

		if (offsetTop) top += offsetTop;
		if (offsetLeft) left += offsetLeft;
		
		if (position == "left") left -= $("#" + bubbleId).width() + 7;
		else left += $("#" + textId).width() + 10;
		
		$("#" + bubbleId).css("top", top + "px");
		$("#" + bubbleId).css("left", left + "px");
		$("#" + bubbleId).appendTo(document.body);
		$("#" + bubbleId).show();
		
		if ($("#" + bubbleId).height() < 55)
		{
			$("#" + bubbleId).css("height", "55px");
			$("#" + bubbleId).children("span.error-bottom, span.info-bottom, span.bottom").css("position", "absolute");
			$("#" + bubbleId).children("span.error-bottom, span.info-bottom, span.bottom").css("bottom", "0");
		}
	}
	
	/* OPTIONS */
	
	$(document).ready(function()
	{
		$(".optionsMore").click(function()
		{
			$(this).parent(".options").find(".optionsBox ul").css("position", "absolute");
			$(this).parent(".options").find(".optionsBox ul").css("min-width", $(this).parent(".options").get(0).offsetWidth + "px");
			$(this).parent(".options").find(".optionsBox").show();
		});
		
		$(".optionsBox").hover(
			function() { $(this).addClass("optionsHover"); },
			function() { $(this).removeClass("optionsHover"); }
		);
	
	});
	
	$(document).mouseup(function()
	{
		$(".optionsBox:not(.optionsHover)").hide();
	});
	
	$(document).ready(function()
	{
		$(".optionsMore2").click(function()
		{
			$(this).parent(".options2").find(".optionsBox2 ul").css("position", "absolute");
			$(this).parent(".options2").find(".optionsBox2 ul").css("min-width", $(this).parent(".options2").get(0).offsetWidth + "px");
			$(this).parent(".options2").find(".optionsBox2").show();
		});
		
		$(".optionsBox2").hover(
			function() { $(this).addClass("optionsHover"); },
			function() { $(this).removeClass("optionsHover"); }
		);
	
	});
	
	$(document).mouseup(function()
	{
		$(".optionsBox2:not(.optionsHover)").hide();
	});




	$().ready(function() {
		$(".userDecorationPartnerIcon").tooltip({ 
			track: true, 
			delay: 0,
			showURL: false,
			bodyHandler: function() { 
				return $(this).next(".tooltipContent").html();
			}, 
			extraClass: "tooltipAbo"
		});

		$(".userDecorationCertMemberIcon").tooltip({ 
			track: true, 
			delay: 0,
			showURL: false,
			bodyHandler: function() { 
				return $(this).next(".tooltipContent").html();
			}, 
			extraClass: "tooltipCertifiedMember"
		});
	});

	
	
