// Copyright by HJCMS http://www.hjcms.de, All Rights Reserved
function debug() { if (window.console && window.console.log) window.console.log ('[HJCMS]: ' + debug.caller + '\n:' + Array.prototype.join.call(arguments,' ')); }
function rtTracker (cat, obj) { try { var tracker = _gaq._getTracker('UA-11624538-1'); var ret = tracker._trackEvent(cat,obj.href,cat,1); if (!ret) { tracker._trackPageview(obj.href); } } catch (e) { debug(e) }; }
function swapDisplay (i) { var obj = document.getElementById(i); try { if (obj.style.display == 'none') { obj.style.display = ''; } else { obj.style.display = 'none'; } } catch(e) { debug(e) }; }
function setInputValues (o, v) { if (v.length < 1) { return; } var pcre = new RegExp(/(\&\w+;)+/i); var obj = document.getElementById(o); if (obj.value.length < 1) { obj.value = v.replace(pcre,''); } else { obj.value = obj.value + ', ' + v.replace(pcre,''); } }
function checkTextInput (na, info) {
   var s = document.getElementById(na);
   if (s.value.length < 2) { alert("Fehlende Eingabe bei " + info + "!"); s.style.background = '#FFFFC0'; s.focus(); return false; }
   s.style.background = '#C0FFC0';
   return true;
}
function checkEMail (na) {
   var m = document.getElementById(na);
   if (m.value.length < 2) { alert("Keine E-Mail angegeben!"); m.style.background = '#FFFFC0'; m.focus(); return false; }
   var r = new RegExp(/([\w\d\-\._]{3,})(@)([\w\d\-\._]{3,})(\.)(\w){2,5}/i);
   if (r.test(m.value) == false) { alert("Das scheint keine Reguläre E-Mail Adresse zu sein!"); m.style.background = '#FFFFC0'; m.focus(); return false; }
   var p = new RegExp(/.+(@jensrichter\-trainings\.de)$/i);
   if (p.test(m.value) == true) { alert("Sie können keine Domain des Seitenbetreibers,\nbei einer Antwort E-Mail Adresse verwenden!"); m.style.background = '#FFFFC0'; m.focus(); return false; }
   m.style.background = '#C0FFC0';
   return true;
}
function checkKontaktFormContent (obj) {
   var fields= new Object();
   fields["inp_name"] = "Name";
   fields["inp_subject"] = "Betreff";
   for (var inp in fields) { if (! checkTextInput(inp, fields[inp])) { return false; } }
   if (! checkEMail('inp_mail')) { return false; }
   return true;
}
function setLinkExtern (n, t) {
   var reg = new RegExp('\.(com|org)\b');
   var hier = new RegExp('hier');
   var dom = (reg.test(n)) ? n : n+'.de';
   if(hier.test(n.toLowerCase()) == true) { document.write ('<a href="http://www.'+dom+'/?referrer=Richter-Trainings" class="iContentColored" target="_blank">'+t+'<\/a>'); } else { document.write ('<a href="http://www.'+dom+'/?referrer=Richter-Trainings" class="iContent" target="_blank">'+t+'<\/a>'); }
}
function whatis (o) {
   var arr = new Array();
   arr["EPW-Coaching"] = "Erfolgs-Potential-Wachstums-Coaching";
   arr["EPW-OutdoorCoaching"] = "Erfolgs-Potential-Wachstums–OutdoorCoaching";
   arr["EPW"] = "Erfolgs-Potential-Wachstum";
   arr["ROC"] = "Reflektives OutdoorCoaching";
   arr["DGMC"] = "Deutsche Gesellschaft für Mediationscoaching";
   arr["BTP"] = "Business-Turbo-Power Coaching";
   arr["SUM"] = "Systemisches-Unternehmens-Mediations Coaching";
   arr["HPG"] = "Heil-Praktiker-Gesetz";
   arr["NLP"] = "Neuro-Linguistic-Programming";
   arr["AZUBI"] = "Auszubildender";
   arr["DGMC"] = "Deutsche Gesellschaft für Mediationscoaching";
   try { var txt = arr[o.firstChild.nodeValue]; if (txt.length > 1) { Tip(txt); } } catch(e) { debug(e) };
}
function modifyTableCells() {
   var w = (window.innerWidth) ? window.innerWidth : document.body.clientWidth;
   if (w < 1100) {
      var tbs = document.getElementsByTagName('td');
      for (var i in tbs) { try { if (tbs[i].getAttribute('class',0) == 'label') { tbs[i].setAttribute('style','width:145px;'); } } catch(e) {}; }
      for (var i = 1; i <= 4; ++i) { try { document.getElementById('cTitle'+i).style.fontSize = '12px'; } catch(e) {}; }
      try { document.getElementById('dynamic_slogan').style.fontSize = '20px'; } catch(e) {};
   }
}
/** TODO https://developer.mozilla.org/en/DOM/window.mozRequestAnimationFrame
* Zur zeit ist requestAnimationFrame nicht relevant weil die performace nicht gut ist :-/ */
function startSlider(div) {
   var interval = null;
   var disabled = 0;
   var dir = 1; // 0=DOWN,1=UP
   var max = 1149; // -1
   if (!div) { return; }
   div.style.top = '0px';
   position = function() { return parseInt(div.style.top); };
   goUp = function() { if (position() >= (max - div.offsetHeight) && position() <= 0 && dir != 0) { div.style.top = (parseInt(div.style.top)-1)+'px'; dir = 1; } else { dir = 0; Stop(); } };
   goDown = function() { if (position() >= 0 && dir != 1) { dir = 1; Stop(); } else if (position() <= 0 && dir != 1) { div.style.top = (parseInt(div.style.top)+1)+'px'; dir = 0; } else { dir = 1; Stop(); } };
   Start = function() { if (!div || (disabled==1)) { return; } if (dir == 1) { interval = window.setInterval (function() { goUp() },45); } else { interval = window.setInterval (function() { goDown() },45); } };
   Stop = function() { window.clearInterval (interval); interval = null; };
   Toggle = function() { ((disabled) ? disabled=0 : disabled=1); if (window.sessionStorage) { window.sessionStorage.setItem('disable.animation',disabled); } };
   div.onmouseover = function() { Stop() };
   div.onmouseout = function() { Start() };
   div.ondblclick = function() { Toggle() };
   if (window.sessionStorage) { disabled = parseInt(window.sessionStorage.getItem('disable.animation')); }
   window.setTimeout(function() { Start() },3000);
}
function pageOnLoadReady() {
   try { dynamicstyle(); } catch (e) {};
   var div = document.getElementById ? document.getElementById('bildcontainer') : document.all.bildcontainer;
   if (div) {startSlider(div);}
   modifyTableCells();
}
/** EOF */

