// Tooltip
var qTipTag="a,span,img,div,input",qTipX=-7,qTipY=17;tooltip={name:"qTip",offsetX:qTipX,offsetY:qTipY,tip:null};
tooltip.init=function(){var a="http://www.w3.org/1999/xhtml";if(!c)var c="qTip";var b=document.getElementById(c);if(!b){b=document.createElementNS?document.createElementNS(a,"div"):document.createElement("div");b.setAttribute("id",c);document.getElementsByTagName("body").item(0).appendChild(b)}if(document.getElementById){if(this.tip=document.getElementById(this.name))document.onmousemove=function(g){tooltip.move(g)};for(var f=qTipTag.split(","),d=0;d<f.length;d++)if(b=document.getElementsByTagName(f[d]))for(var e=
0;e<b.length;e++){a=b[e];if(c=a.getAttribute("title")){a.setAttribute("tiptitle",c);a.removeAttribute("title");a.removeAttribute("alt");a.onmouseover=function(){tooltip.show(this.getAttribute("tiptitle"))};a.onmouseout=function(){tooltip.hide()}}}}};
tooltip.move=function(a){var c=0,b=0;if(document.all){c=document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft;b=document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;c+=window.event.clientX;b+=window.event.clientY}else{c=a.pageX;b=a.pageY}this.tip.style.left=c+this.offsetX+"px";this.tip.style.top=b+this.offsetY+"px"};
tooltip.show=function(a){if(this.tip){this.tip.innerHTML=a;this.tip.style.display="block"}};tooltip.hide=function(){if(this.tip){this.tip.innerHTML="";this.tip.style.display="none"}};

// Chat
var chat_latenz = 3500;
var ajax_request = new XMLHttpRequest();
var ajax_result = "";
function ajax_get(url) { ajax_request.open('GET', url, true); ajax_request.onreadystatechange = ajax_do; ajax_request.send(null); }
function ajax_do() { if(ajax_request.readyState == 4) { if(chat_latenz < 15000) { chat_latenz = chat_latenz+75; } ajax_result = ajax_request.responseText.split("/-/"); document.getElementById("chatlog").innerHTML += ajax_result[0]; document.getElementById("chatlog").scrollTop = document.getElementById("chatlog").scrollHeight; eval(ajax_result[1]); window.setTimeout("ajax_get('chat_read.php');", chat_latenz); return false; } }
function chat_send() { $action_check = document.chat_form.chat_msg.value.split(" "); if ($action_check[0] == "/w") { $syntax = ""+$action_check[0]+" "+$action_check[1]+" "; } else if ($action_check[0] == "/k") { $syntax = ""+$action_check[0]+" "; } else { $syntax = ""; } window.setTimeout("chat_clear();", 150); return false; }
function chat_clear() { chat_latenz = 3500; document.chat_form.chat_msg.value = $syntax; document.chat_form.chat_msg.focus(); return false; }
function chat_whisper(name) { document.chat_form.chat_msg.focus(); document.chat_form.chat_msg.value = '/w '+name+' '; return false; }

// Page
function show_agb() { window.open('agb.php', 'AGB', 'width=400,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes'); }
function br2nl(a){a=a.replace(/<br\s*\/?>/mg,"\r\n");return a=a.replace(/<BR\s*\/?>/mg,"\r\n")}
function checkScroll(obj) { if(obj.clientHeight < obj.scrollHeight) { obj.style.height = (parseInt(obj.scrollHeight))+'px'; return false; } } 
function openlayer(titel, page){document.getElementById("layer").innerHTML='<div id="layerbg" class="page_overlay"><div class="layer_border"><div class="layer_window"><div class="layer_wrap"><div class="layertitel_left">'+titel+'</div><div class="layertitel_right"><a href="#" onclick="closelayer(); return false;">Fenster schließen</a></div><div id="layercnt" class="layercnt_border"><iframe src="'+page+'"  width="715" height="407" frameborder="0" scrolling="no"></iframe></div></div></div></div></div>'; return false;}function closelayer(){document.getElementById("layer").innerHTML="";}function openwindow(page){window.open(''+page+'', 'window', 'width=715,height=407,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');return false;}
function openabfrage(text,link){document.getElementById("abfrage").innerHTML='<div id="abfragebg" class="page_overlay"><div class="abfrage_border"><div class="abfrage_window"><div class="abfrage_wrap"><div class="abfragetitel_left">Sicherheitsabfrage</div><div class="abfragetitel_right"><a href="#" onclick="closeabfrage(); return false;">Fenster schließen</a></div><div class="abfragecnt_border"><div class="abfragecnt_border_wrap"><div class="abfrage_cnt_left"><img src="http://cdn.automatendealer.de/img/info.png" border="0" alt="" width="48" height="48" style="margin-top:2px;"></div><div class="abfrage_cnt_right"><div>'+text+'</div><div style="margin-top:14px; height:21px; overflow:hidden;"><a href="'+link+'" class="abfrage_button">Ja, fortsetzen!</a><a href="#" class="abfrage_button" style="margin-left:15px;" onclick="closeabfrage(); return false;">Nein, abbruch!</a></div></div></div></div></div></div></div></div>'; return false;}function closeabfrage(){document.getElementById("abfrage").innerHTML="";return false;}function closewerbung(){document.getElementById("werbungbg").style.display="none"; return false;}function openflash(swf){document.getElementById("flash").innerHTML='<div id="flashbg" class="page_overlay"><div class="flash_erfolg"><object type="application/x-shockwave-flash" width="900" height="300" data="flash/'+swf+'.swf"><param name="movie" value="flash/'+swf+'.swf"><param name="wmode" value="transparent"></object><span id="flash_cd"></span></div></div>'; return false;}
function closeflash(){document.getElementById("flash").innerHTML='';return false;}
function openflash_a(swf){document.getElementById("a_overlay").innerHTML='<object type="application/x-shockwave-flash" width="100" height="100" data="flash/'+swf+'.swf"><param name="movie" value="flash/'+swf+'.swf"><param name="wmode" value="transparent"></object>';return false;}
function insert_object(a,b){var c=document.comf.msg;c.focus();if(typeof document.selection!="undefined"){c=document.selection.createRange();var d=c.text;c.text=a+d+b;c=document.selection.createRange();d.length==0?c.move("character",-b.length):c.moveStart("character",a.length+d.length+b.length);c.select()}else if(typeof c.selectionStart!="undefined"){var e=c.selectionStart,f=c.selectionEnd;d=c.value.substring(e,f);c.value=c.value.substr(0,e)+a+d+b+c.value.substr(f);e=d.length==0?e+a.length:e+a.length+
d.length+b.length;c.selectionStart=e;c.selectionEnd=e}else{for(d=/^[0-9]{0,3}$/;!d.test(e);)e=prompt("Einf\u00fcgen an Position (0.."+c.value.length+"):","0");if(e>c.value.length)e=c.value.length;d=prompt("Bitte geben Sie den zu formatierenden Text ein:");c.value=c.value.substr(0,e)+a+d+b+c.value.substr(e)}}function key_is_numeric(a){iKeyCode=window.navigator.appName=="Netscape"?a.which:event.keyCode;return iKeyCode<32||String.fromCharCode(iKeyCode).match(/[,0-9]/)?true:false}
function show_object(a) { document.getElementById(a).style.display = "block"; }
function quote(a) { var text = document.getElementById(a).innerHTML; text = text.replace(/<b>/gi, "[b]"); text = text.replace(/<\/b>/gi, "[/b]"); text = text.replace(/<u>/gi, "[u]"); text = text.replace(/<\/u>/gi, "[/u]"); text = text.replace(/<i>/gi, "[i]"); text = text.replace(/<\/i>/gi, "[/i]"); text = text.replace(/<br>/gi, "\r"); text = text.replace(/<br \/>/gi, "\r");  text = text.replace(/<span[\s\S]*?class=([\s\S]*?)\"[\s\S]*?>/gi, "[quote]$1"); text = text.replace(/<\/span>/gi, "[/quote]");  if(document.getElementById("ftp_form")) { document.getElementById("ftp_form").style.display = "block"; document.comf.action.value = "new_post"; } else if(document.getElementById("igm_form")) { document.getElementById("igm_form").style.display = "block"; } document.comf.msg.value = "[quote]"+text+"[/quote]\r\n\r\n"; checkScroll(document.comf.msg); jump_to_end(document.comf.msg); }
function jump_to_end(ta) { len = ta.value.length; if(ta.setSelectionRange) { ta.setSelectionRange(len,len); ta.focus(); } else if(ta.createTextRange){ var rn = ta.createTextRange(); rn.moveStart('character',len); rn.select(); } }
function hide_object(a){document.getElementById(""+a+"").style.display="none";}
function hide_infoleiste(a){document.getElementById(a).style.display="none";$info_sum_inactive="0";for($i=0;$i<$p_infos;$i++)document.getElementById("infoleiste_"+$i).style.display=="none"&&$info_sum_inactive++;if($info_sum_inactive==$p_infos)document.getElementById("infoleiste_spacer").style.display="none";}
function hide_infoleisten(){for($i=0;$i<$p_infos;$i++){document.getElementById("infoleiste_"+$i).style.display="none";}document.getElementById("infoleiste_spacer").style.display="none";}
var cd_times=Array();
function cd_addtime(a,b,c,d){if(document.getElementById(b)&&a>0){var e=cd_times.length;cd_times[e]={};cd_times[e].time=a;cd_times[e].id=b;cd_times[e].typ=c;cd_times[e].special=d}}
function cd_update(){if(cd_times.length>0){for(var a=0;a<cd_times.length;++a){var b=cd_times[a].time,c=cd_times[a].typ,d=cd_times[a].special;if(b<0&&c==1){b=0;if(document.getElementById("layer").innerHTML == ""){location.href=$p_global}}else if(b<0&&c==2){b=0;document.getElementById(d).innerHTML="Ausverkauft"}else if(b<0&&c==3){b=0;closeflash();}c=Math.floor(b%60);if(c<10)c="0"+c;d=Math.floor(b/60%60);if(d<10)d="0"+d;b=Math.floor(b/60/60%24);if(b<10)b="0"+b;b=b+":"+d+":"+c;if(document.getElementById(cd_times[a].id))document.getElementById(cd_times[a].id).innerHTML=b;cd_times[a].time--}setTimeout("cd_update()",1000)}}function cd_start(){$p_global=$p_global.replace("action","blocked_action");cd_update()}
function start_game(name,game) { openlayer(''+name+'', 'minigames/'+game+'/search.php'); }

// IE9 - Pinned
function ie9_flash(){try{if(window.external.msIsSiteMode()){window.external.msSiteModeActivate();}}catch (ex){}}

if(document.chat_form) {
document.chat_form.onsubmit = function() { chat_send(); }
document.chat_form.chat_msg.onfocus = function() { if(this.value == 'Nachricht eingeben...') { this.value = ''; } }
document.chat_form.chat_msg.onblur = function() { if(this.value == '') { this.value = 'Nachricht eingeben...'; } }
}
