//  ITK-Services.net - GLOBAL JS Data   -------------------------------------------- 
//  (C) 2009 ITK-Services.net ------------------------------------------------------ 



//  I M A G E  H O O V E R   -------------------------------------------------------

function on(id) { 
document.getElementById(id).style.display='block';
} 
function off(id) { 
document.getElementById(id).style.display='none';
}


// B R E A K  F R A M E S E T   -----------------------------------------------------

if (top.frames.length > 0)
  {
  top.location.href = self.location.href;
  }


// F O R M  C H E C K -------------------------------------------------------------

function formcheck () {
	if (document.forms[0].Name.value == '') {
	document.forms[0].Name.style.border='1px solid red';
	alert('Bitte geben Sie Ihren Namen ein!');
	document.forms[0].Name.focus();
	return false;
}
	if (document.forms[0].Mail.value == '') {
	document.forms[0].Mail.style.border='1px solid red';
	alert('Bitte tragen Sie Ihre E-Mail-Adresse ein!');
	document.forms[0].Mail.focus();
	return false;
}
	var str = document.forms[0].Mail.value;
	if (document.forms[0].Mail.value.indexOf ('@', 0) == -1 || str.length < 6 || document.forms[0].Mail.value.indexOf ('.',0) == -1){
	document.forms[0].Mail.style.border='1px solid red';
	alert('Bitte geben Sie eine gültige E-Mail-Adresse ein!');
	document.forms[0].Mail.focus();
	return false;
}
	if (document.forms[0].Mitteilung.value == '') {
	document.forms[0].Mitteilung.style.border='1px solid red';
	alert('Bitte tragen Sie Ihre Nachricht ein!');
	document.forms[0].Mitteilung.focus();
	return false;
}
	return true;
}


// F O R M  H O O V E R  I E ----------------------------------------------------

function inf(obj){
	obj.style.backgroundColor='#EAECED';
}
function outf(obj){
	obj.style.backgroundColor='#fff';
}

function in_button(obj){
	obj.style.backgroundColor='#6A7B8F';
}
function out_button(obj){
	obj.style.backgroundColor='#EFAF05';
}


// L I N K  E X T E R N --------------------------------------------------------
// by J. E. Hellbusch, J. Hofer & S. Heller - www.barrierefreies-webdesign.de

function newwindow() {
  neuesFenster = window . open(this . href);
  neuesFenster . focus();
  return false;
}

function searchnewwindows() {
  var externerLinkText = "Externer Link";
  var textNeuesFenster = " - öffnet in einem neuen Fenster";
  if (!document . getElementsByTagName) { return } ;
  var links = document . getElementsByTagName("a");
  for (i = 0; i < links . length; i++) {
        textAlt = links[i] . getAttribute("title");
        if (textAlt && (textAlt . indexOf(externerLinkText) != -1)) {
            textZusatz = textAlt . substring((textAlt . indexOf(externerLinkText)) + externerLinkText . length, textAlt . length);
            links[i] . setAttribute("title", externerLinkText + " " + textNeuesFenster + textZusatz);
      links[i] . onclick = links[i] . onkeypress = newwindow;
      links[i] . style . borderBottom = "0";
    }
  }
}


// B L U R  L I N K S  I E ---------------------------------------------------

function BlurLinks(){
lnks=document.getElementsByTagName('a');
for(i=0;i<lnks.length;i++){
lnks[i].onclick=new Function("this.blur()");
}
}


// G O O G L E  M A P ----------------------------------------------------------

function load() { 
	if (GBrowserIsCompatible()) { 
	var map = new GMap2(document.getElementById("map")); 
	var control = new GLargeMapControl(); 
	map.addControl(control); 
	control = new GMapTypeControl(); 
	map.addControl(control); 
	map.setCenter(new GLatLng(51.70742,7.14251), 13); 
	map.openInfoWindow(map.getCenter(),"<img src='../../images/design/main/map_logo.gif' alt='ITK-Services.net Logo' /><br /><strong>ITK-Services.net</strong><br />Herner Weg 45<br />45772 Marl");
	} 
}


// S W I T C H E R -------------------------------------------------------------

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365 );
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


// A D D  E V E N T S -----------------------------------------------------

function addEvents(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}
addEvents(window, 'load', searchnewwindows);
// addEvents(window, 'load', BlurLinks);

window.addEvent('domready',function() { new SmoothScroll({ duration:700 }, window); });