////////////////////////////////////////////////////////////////
//
// wScript.js 5.0.1
// erstellt durch Scholl Communications AG, 77694 Kehl, www.scholl.de
// erstellt mit Weblication Content Management Server, www.weblication.de
//
////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
//
// Anzupassende Variablen:
//
var mailPostfix = '@domain.dd';
//
////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
//
// Beschreibung: Browsererkennung
//
////////////////////////////////////////////////////////////////

var browser = new browserDetection();
function browserDetection(){
  /*
  var ns  		= (document.layers) ? 1 : 0;
	var ie  		= (document.all) ? 1 : 0;
	var dom 		= (document.getElementById) ? 1 : 0;
	var mac 		= (navigator.platform.indexOf("Mac") != -1) ? 1 : 0;
	*/
  this.useragent 			= navigator.userAgent.toLowerCase();
  
  this.browserName 		= "undetected";
  this.browserVersion = "undetected";
  
  this.isMozilla 			= false;
  this.isNetscape 		= false;
  this.isNetscape6 		= false;
  this.isNetscape7 		= false;
  this.isIE 					= false;
  this.isIE6 					= false;
  this.isIE7 					= false;
  this.isIE8 					= false;
  this.isFF 					= false;
  this.isFF2 					= false;
  this.isFF3 					= false;
  this.isFF35 				= false;
  this.isChrome 			= false;
  this.isOpera 				= false;
  this.isSafari 			= false;
  
  // Mozilla
  if(this.useragent.search(/mozilla/) != -1) {
  	this.isMozilla 			= true;
    this.browserName 		= "Mozilla";
    this.browserVersion = parseFloat(/(mozilla[^\s]*)/.exec(this.useragent)[0].split("/")[1]);
  }

  // Netscape
  if(this.useragent.search(/netscape/) != -1) {
    this.browserName 		= "Netscape";
    this.browserVersion = parseFloat(/(firefox[^\s]*)/.exec(this.useragent)[0].split("/")[1]);
    var browserVersionTest = ""+this.browserVersion;
    if(browserVersionTest.substring(0, 1) == 7) {
    	this.isNetscape7 	= true;
    } else if(browserVersionTest.substring(0, 1) == 6) {
    	this.isNetscape6 	= true;
    } else if(browserVersionTest.substring(0, 1) <= 5) {
    	this.isNetscape 	= true;
    }
  }
  
  // IE
  if(this.useragent.search(/msie/) != -1) {
    this.isIE 					= true;
    this.browserName 		= "IE";
    this.browserVersion = parseFloat(/(msie[^;]*)/.exec(this.useragent)[0].split(" ")[1]);
    var browserVersionTest = ""+this.browserVersion;
    if(browserVersionTest.substring(0, 1) == 8) {
    	this.isIE8 				= true;
    } else if(browserVersionTest.substring(0, 1) == 7) {
    	this.isIE7 				= true;
    } else if(browserVersionTest.substring(0, 1) <= 6) {
    	this.isIE6 				= true;
    }
  }

  // Firefox
  if(this.useragent.search(/firefox/) != -1) {
    this.isIE 					= true;
    this.browserName 		= "Firefox";
    this.browserVersion = parseFloat(/(firefox[^\s]*)/.exec(this.useragent)[0].split("/")[1]);
    var browserVersionTest = ""+this.browserVersion;
    if(browserVersionTest.substring(0, 3) == "3.5") {
    	this.isFF35 			= true;
    } else if(browserVersionTest.substring(0, 1) == 3) {
    	this.isFF3 				= true;
    } else if(browserVersionTest.substring(0, 1) <= 2) {
    	this.isFF2 				= true;
    }
  }

	// Chrome
  if(this.useragent.search(/chrome/) != -1) {
    this.isChrome 			= true;
    this.browserName 		= "Chrome";
    this.browserVersion = parseFloat(/(chrome[^\s]*)/.exec(this.useragent)[0].split("/")[1]);
  }

  // Opera
  if(this.useragent.search(/opera/) != -1) {
    this.isOpera 				= true;
    this.browserName 		= "Opera";
    this.browserVersion = parseFloat(/(opera[^\s]*)/.exec(this.useragent)[0].split("/")[1]);
  }
  
  // Safari
  if(this.useragent.search(/khtml/) != -1) {
    this.isSafari 			= true;
    this.browserName 		= "Safari (Win)";
    this.browserVersion = parseFloat(/(version[^\s]*)/.exec(this.useragent)[0].split("/")[1]);
  }
}



////////////////////////////////////////////////////////////////
//
// Beschreibung: Druckt das aktuelle Dokument
//
////////////////////////////////////////////////////////////////

function wPrintDocument(){  
  if(document.all && navigator.appVersion.substring(22,23)==4) {
    self.focus();
    var OLECMDID_PRINT = 6;
    var OLECMDEXECOPT_DONTPROMPTUSER = 2;
    var OLECMDEXECOPT_PROMPTUSER = 1;
    var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
    document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
    WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
    WebBrowser1.outerHTML = '';
  } else {
    window.print();  
  }
}

////////////////////////////////////////////////////////////////////////////////////////
//
// Beschreibung: Prüft, ob die Plichtfelder im Formular korrekt ausgefüllt worden sind.
//
////////////////////////////////////////////////////////////////////////////////////////

function checkForm(validatorsNameStr, validatorsTypeStr, validatorsIdentStr, validatorsMsgStr) {
  var checkEmail   = /.*\@.*\.\w+/i;

  var errorName 			= new Array();
  
  var sendFormular 		= true;
  var validatorsName 	= validatorsNameStr.split("|");
  var validatorsType 	= validatorsTypeStr.split("|");
  var validatorsIdent = validatorsIdentStr.split("|");
  var validatorsMsg  	= validatorsMsgStr.split("|");

	if(validatorsName.length > 0) {
		for(i=0; i<validatorsName.length; i++) {
			jQuery('input#'+validatorsName[i]).removeClass('inputError');
			
			var value = jQuery('input#'+validatorsName[i]).val();
			if(validatorsType[i] == 'email') {
				if(checkEmail.test(value) == false) {
					errorName.push(validatorsName[i]);          
				}
			} else if(validatorsType[i] == 'captcha' || validatorsType[i] == 'required') {
				if(value == '') {
					errorName.push(validatorsName[i]);          
				}
			} else if(validatorsType[i] == '==') {
				var valueIdent = jQuery('input#'+validatorsIdent[i]).val();
				
				if(valueIdent == '' || value != valueIdent) {
					errorName.push(validatorsName[i]);
					errorName.push(validatorsIdent[i]);
				}
			}
		}
	}
	if(errorName.length > 0) {
		for(i=0; i<errorName.length; i++) {
			errorName[i] = trim(errorName[i]);
			if(errorName[i] != "" && jQuery('input#'+errorName[i])) {
				jQuery('input#'+errorName[i]).addClass('inputError');
				jQuery('input#'+errorName[i]).focus();
			}
		}
		sendFormular = false;
	}
	return sendFormular;
}

////////////////////////////////////////////////////////////////
//
// setzt im Zusammenhang mit einem Formular festgestellte Fehler
//
////////////////////////////////////////////////////////////////

function setFormErrors(errorNameStr) {
  var errorName 	= errorNameStr.split("|");
	if(errorName.length > 0) {
		for(i=0; i<errorName.length; i++) {
			jQuery('input#'+errorName[i]).addClass('inputError');
			jQuery('input#'+errorName[i]).focus();
		}
	}
}

////////////////////////////////////////////////////////////////
//
// Zeichenkette trimmen
//
////////////////////////////////////////////////////////////////
function trim(zeichenkette) {
  // Erst führende, dann Abschließende Whitespaces entfernen
  // und das Ergebnis dieser Operationen zurückliefern
  return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
}

////////////////////////////////////////////////////////////////
//
// E-Mail auf Gültigkeit prüfen
//
////////////////////////////////////////////////////////////////
function checkEmail(email) {
  var sendBack = false;

  var a   = false;
  if(typeof(RegExp) == 'function') {
    var b = new RegExp('abc');
    if(b.test('abc') == true){
      a = true;
    }
  }

  if(a == true) {
    reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                     '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                     '(\\.)([a-zA-Z]{2,4})$');
    sendBack = (reg.test(email));
  } else {
    sendBack = (email.search('@') >= 1 && email.lastIndexOf('.') > email.search('@') && email.lastIndexOf('.') >= email.length-5);
  }
  //alert(email+"\n"+sendBack);
  return sendBack;
}

////////////////////////////////////////////////////////////////
//
// Wechselt zu einer anderen Seite
//
////////////////////////////////////////////////////////////////
function wOpenURL(url){
  if(location.pathname.indexOf('/weblication/grid5/') != 0){
    location.href = url;
  }
}

////////////////////////////////////////////////////////////////
//
// Öffnet ein Popup-Fenster
//
////////////////////////////////////////////////////////////////
function wOpenPopupURL(url, name, options){

  var regWidth = /width=(\d+)/;
  regWidth.exec(options);
  width = RegExp.$1; 
  if(width == ''){   
    width = 640; 
  }

  var regHeight = /height=(\d+)/;
  regHeight.exec(options);
  height = RegExp.$1;       
  if(height == ''){   
    height = 480; 
  }    


  if(!name && !width && !height && !options){
    return window.open(url, name);
    return;
  }
  //Zusaetzliche Optionen angeben
  if(!options){
    options = ',resizable=no,scrollbars=no,status=no';
  }
  //Position zentriert festlegen
  
  var posLeft = (screen.width / 2)  - (width  / 2);
  var posTop  = (screen.height / 2) - (height / 2);
  //alert('top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);<<<
  return window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);
}


function wOpenPopupURL2(url, width, height){

  var name = '';
  
  if(width == '' || width == ' '){
    width = 786;
  }
  if(height == '' || height == ' '){
    height = 677;
  }
  
  url = url.replace(/&amp;/g, '&');
  options = ',location=no, menubar=no,toolbar=no,resizable=no,scrollbars=no,status=no';
  width   = parseInt(width);
  height  = parseInt(height);

  var posLeft = (screen.width / 2)  - (width  / 2);
  var posTop  = (screen.height / 2) - (height / 2);
  window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);
}

////////////////////////////////////////////////////////////////
//
// Beschreibung: Generiert Spam-sichere Email
//
////////////////////////////////////////////////////////////////
function wSendMailNospam(data){
  location.href = 'mailto:' + data.replace('|', '@');
}

function wSendMailNospam2(name){
  location.href = 'mailto:' + name + mailPostfix;
}

////////////////////////////////////////////////////////////////
//
// jQuery - Bereich
//
////////////////////////////////////////////////////////////////

var $j = jQuery.noConflict();



jQuery(document).ready(function() {
  
  // disabled-Inputs Klasse zuweisen
  jQuery('input:disabled').addClass('inputDisabled');
  
  
  

  // Suchfeld - onclick Wert entfernen
  jQuery('#searchBox input').click(function(e) {
    jQuery(this).val('');
  });
  
  // Kontaktformular - Toggle
  jQuery('#kontakt_auswahl input[type="radio"]').click(function() {
    var type = jQuery(this).val();
    if(type == 'Post'){
      jQuery('#kontakt_post').fadeIn("slow");
      jQuery('#kontakt_email').fadeOut("slow");
    }
    else{
      jQuery('#kontakt_email').fadeIn("slow");
      jQuery('#kontakt_post').fadeOut("slow");
    }
  });

  
  // Länderwahl auf Startseite
  jQuery("#frankInternational").change(function(e){
    e.preventDefault();
    var link = jQuery(this).val();
    location.href = link;
    //window.open(link, '_blank');
  });
  
  
  //Fancybox
  jQuery('a[rel=fancybox]').fancybox({
    'hideOnContentClick': true,
    'overlayShow':true,
    'overlayOpacity': 0.5,
    'centerOnScroll': false
  });
  
  jQuery("a[rel*=pdflist]").fancybox({
		'titleShow' : false,
		'scrolling' : 'no',
		'hideOnContentClick' : false
 });

	jQuery(".elementPictureLupeButton").mouseover(function() {
	  jQuery(this).css('background', 'transparent url(/global/wGlobal/layout/images/icons/but_lupe_r.gif) no-repeat scroll 0 0');

  });
	jQuery(".elementPictureLupeButton").mouseout(function() {
		jQuery(this).css('background', 'transparent url(/global/wGlobal/layout/images/icons/but_lupe_n.gif) no-repeat scroll 0 0');
  });
  
  //Druckvorschau
	jQuery("#printpreviewLink").click(function(e) {
    e.preventDefault();

    var anchor  = location.hash;
    var url     = location.href.replace(anchor, '');
    
    if(url.indexOf('?') >= 0) {
      url += '&viewmode=print';
    } else {
      url += '?viewmode=print';    
    }
    
    wOpenPopupURL(url, 'wPrintpreview', 'width=730,height=520,scrollbars=yes');
  });
  
  //Seite empfehlen
  jQuery("#tellafriendLink").fancybox({
    'hideOnContentClick': false,
    'frameWidth': 320,
    'frameHeight': 300,
    'overlayShow':true,
    'overlayOpacity': 0.5,
    'centerOnScroll': false
  });
});



////////////////////////////////////////////////////////////////
//
// Beschreibung: Zeigt die Druckansicht an
//
////////////////////////////////////////////////////////////////

function wShowPrintpreview(){  

  var url = location.href;
  var anchor = location.hash;

  url = url.replace(anchor, '');
  
  if(url.indexOf('?') >= 0){
    url += '&viewmode=print';
  }
  else{
    url += '?viewmode=print';    
  }
  
  openWindow(url, 'wPrintpreview', 'width=952,height=620,scrollbars=yes,menubar=yes');
  
}




/*********************************************************************************/
//
// �ffnet ein Fenster
//
// @param string Url
//
// @param string Name des Fensters
//
// @param string Optionen
//
// @return window			
//
/*********************************************************************************/

function openWindow(url, name, options){

  var regWidth = /width=(\d+)/;
  regWidth.exec(options);
  width = RegExp.$1; 
  if(width == ''){   
    width = 640; 
  }

  var regHeight = /height=(\d+)/;
  regHeight.exec(options);
  height = RegExp.$1;       
  if(height == ''){   
    height = 480; 
  }    


  if(!name && !width && !height && !options){
    return window.open(url, name);
    return;
  }
  //Zusaetzliche Optionen angeben
  if(!options){
    options = ',resizable=no,scrollbars=no,status=no';
  }
  //Position zentriert festlegen
  
  var posLeft = (screen.width / 2)  - (width  / 2);
  var posTop  = (screen.height / 2) - (height / 2);
  //alert('top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);<<<
  return window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);
}

////////////////////////////////////////////////////////////////
//
// Beschreibung: Druckt das aktuelle Dokument
//
////////////////////////////////////////////////////////////////

function printDocument(){  

  if(document.all && navigator.appVersion.substring(22,23)==4) {
    self.focus();
    var OLECMDID_PRINT = 6;
    var OLECMDEXECOPT_DONTPROMPTUSER = 2;
    var OLECMDEXECOPT_PROMPTUSER = 1;
    var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
    document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
    WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
    WebBrowser1.outerHTML = '';
  }
  else{
    window.print();  
  }
}