
$(document).ready(function(){

	$('.roBox').click(function(){
		window.location.href = $(this).children('.roBoxConHover a:first').attr('href')
	}).mouseover(function(){
		$(this).attr('class','roBoxHover')
		$(this).children('div:first').hide()
		$(this).children('div:last').show()
	}).mouseout(function(){
		$(this).attr('class','roBox')
		$(this).children('div:last').hide()
		$(this).children('div:first').show()
	})
	
	$('#eventBoxList').jcarousel({
        vertical: true,
		animation: 3000,
		auto: 5,
		visible: 2,
		scroll: 2,
		wrap: 'circular'
    });
	
	$('#eventTeaserList').jcarousel({
        vertical: true,
		animation: 3000,
		auto: 5,
		visible: 1,
		scroll: 1,
		wrap: 'circular'
    });
	
	$('.xmasGame').fancybox({
		'width': 950,
		'height': 600,
		'hideOnOverlayClick': false
	});
	
	
	//Lightboxes
	$('.lightboxImage').fancybox({
		'hideOnOverlayClick': false
	});
	
	$('.lightboxGallery').fancybox({
		'width': 950,
		'height': 600,
		'hideOnOverlayClick': false
	});
	
	$('.lightboxVideo').fancybox({
		'width': 1000,
		'height': 585,
		'hideOnOverlayClick': false,
		'type': 'iframe'
	});
	
});

function openGame() {
var x=window.open ('/kunden/cpmo/www.nsf/files/js/$file/pluginCheck.html','Spiel','resizable=no,width=550,height=350,left=0,top=0')
}

function openPicture(link) {
var x=window.open (link,'magnify','resizable=no,width=640,height=480,left=10,top=10')
x.focus();
}

function movepic(img_id,img_src) {
	document[img_id].src=img_src;
	return true;
}

function sucheblur(r)
{
	if(r.value==""){
		r.value="";
	} 
}

function StartSuche(r,s)
{
	window.location.href = s+"?Open&q1="+r.q1.value;
}

function openNewWindow(url,width,height,iDefaultPosTop,iDefaultPosLeft,Userparam){
var iPosLeft;
var iPosTop;
if (screen.width){
	iPosLeft=(screen.width/2)-width/2;
	iPosTop=(screen.height/2)-height/2;
}
else{
	iPosLeft=iDefaultPosLeft;
	iPosTop=iDefaultPosTop;
}
param=Userparam+",top="+String(iPosTop)+",left="+String(iPosLeft);
window.open(url, "", "width="+width+",height="+height+","+param);
}

function getFieldValue ( theField, vType){
	//this function will return the field value (or value list) based on the element type
	theValue=""; 
	sep=";"; 
	hits=0;
	vType=vType.toLowerCase();
	//text is the user-entered value as a string
	if(vType=="text" ) return(theField.value); 
	//textarea is the user-entered value as a string array of one element
	if(vType=="textarea" ) return(theField.value);
	//select is an array of selection pointers to an array of strings representing the choices
	if(vType=="select"){
		for ( i=0; i<theField.options.length; i++){
			if(theField.options[i].selected){
				hits++;
				if(theField.options[i].value==""){
					e=theField.options[i].text;
				}else{ 
					e=theField.options[i].value;
				}
				if(hits==1){
					theValue=e;
				}else{
					theValue+= sep+e;
				}
			}
		}
		return(theValue);
	}
	if(vType=="dropdown"){
		if(theField.options[0].selected){
			return("");
		}
		return("True");
	}
	// check Emailaddress
	if(vType=="mail"){
		var mail=theField.value;
		if(mail==""){
			return ("");
		}else{
			var erg =mail.search(/.+@..+\...+/);
			if(erg==-1){
				return ("");
			}
			var erg=mail.search(/\s/);
			if(erg!=-1){
				return ("");
			}
		}
		return (mail);
	}
	//checkboxes & radio buttons
	if(vType=="checkbox"||vType=="radiobutton"){
		if(theField.value==null){
			//if we're here, we are validating a radio button or a nn multi-element checkbox
			for ( i=0; i<theField.length; i++){
				if(theField[i].checked){
					hits++;
					if(hits==1){
						theValue=theField[i].value;
					}else{
						theValue+= sep+theField[i].value;
					}
				} 
			}
		} 
		return(theValue);
	}else{
		return(theField.value);
	}
}

/* Use this function to open a link. Use any htmltag with parameter "value (URL [|"_self"])"  to open the url. */

function openElementLink(objField,sType){
var sFieldValue=getFieldValue(objField,sType);

if (sFieldValue!=""){
	var aValue=sFieldValue.split("|");
	if(aValue[1]=="_self"){
		 location.href=aValue[0];
	}
	else{
		window.open(aValue[0]);
	}
}
}

/*Bottomline*/

function printPage(){
	purl=location.href;
	anchor="";
	p=purl.indexOf("#");
	if(p>0){
		anchor=purl.substring(p)
		purl=purl.substring(0,p)
	}
	if(purl.indexOf("?")!= -1 || purl.indexOf("!") != -1) {
		purl = purl + "&setprintmode"+anchor;
	} else if(purl.indexOf("!")== -1) {
		purl = purl + "?open&setprintmode"+anchor;
	}
	printWindow(purl);
}

function printWindow(adr){
	 var param='width=640,height=500,scrollbars=yes,resizable=yes,locationbar=no,menubar=yes,screenX=50,screenY=50';
	 var title="PrintWindow";
	 adr=adr.replace(/#/,"%23");		 
	 window.open(adr,title,param);
}

function addToFavorites(pagename){
	if(window.external){
		window.external.AddFavorite(location.href,pagename)
	}else{
		// this is not an Internet Explorer
		alert("Your browser does not support automated adding to favourites, probably you are not using Internet Explorer. However, please yuse your browsers menu command for bookmarking instead. Thank you!");
	}
	return false;
}

function switchCSS(element,classname){
	if(is.ie){
	 	obj=document.all[element];
	 	if(obj){
			obj.className=classname;
		}
	}
	if(is.moz||is.opera||is.opera6||is.ns6||is.ns7){
		obj=document.getElementById(element);
	 	if(obj){
			obj.className=classname;
		}
	}
}

function loginSubmit() {
		 if (document.layers) {
		 		 formobj = document.layers['LoginLayerAnonymous'].document._DominoForm;
		 } else {
		 		 formobj = document._DominoForm;
		 }
document.cookie="sessionCookie=troet";
		 (GetCookie("sessionCookie"))?formobj.submit():alert ("Please enable sessionbased cookies in your browser \npreferences and reload the page!");
}

/* 2 functions
function GetCookie(sName)
{
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  // a cookie with the requested name does not exist
  return null;
}

*/
function enter(){
	var hotkey=13;
	if (document.layers)
	document.captureEvents(Event.KEYDOWN)
	if (document.layers){		 		 		 
		if(e.which==hotkey)loginSubmit();
	}else if (document.all){
		 if(event.keyCode==hotkey)loginSubmit();
	}
}

var UNdefValue="Name";
var UNtmpStyle=null;
function UNonFocus(o){
	if(o){
		if(o.value){
			if(o.value==UNdefValue){
				o.value=''
			}
		}
		if(o.style.getAttribute){
			UNtmpStyle=o.style.getAttribute("bordercolor","false");
			o.style.setAttribute("bordercolor","#d00021","false");
		}
	}
}

function UNonBlur(o){
	if(o){
		if(o.value==''){
			o.value=UNdefValue;
		}
		if(o.style.setAttribute){
			o.style.setAttribute("bordercolor",UNtmpStyle,"false");
		}
	}
}

var PWtmpStyle=null;
function PWonFocus(o){
	if(o){
		if(o.style.getAttribute){
			PWtmpStyle=o.style.getAttribute("bordercolor","false");
			o.style.setAttribute("bordercolor","#d00021","false");
		}
		o.select();
	}
}

function PWonBlur(o){
	if(o){
		if(o.style.setAttribute){
			o.style.setAttribute("bordercolor",PWtmpStyle,"false");
		}
	}
}

function setCookie(name,value,expires,path,domain,secure){
	var curCookie=name+"="+escape(value)+
	((expires)?"; expires="+expires.toGMTString():"")+
	((path)?"; path="+path:"")+
	((domain)?"; domain="+domain:"")+
	((secure)?"; secure":"");
	document.cookie=curCookie;
}

function getCookie(name){
	var dc=document.cookie;
	var prefix=name+"=";
	var begin=dc.indexOf("; "+prefix);
	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;
	return unescape(dc.substring(begin+prefix.length, end));
}

function fixDate(date) {
        var base = new Date(0)
        var skew = base.getTime()
        if (skew > 0)
                date.setTime(date.getTime() - skew)
}
function startLogin() {
  formobj = document.formlogin;
  if(formobj.NickName.value == "")
  {
     alert("Please enter your Nickname");
     return false;
  }		
  var now = new Date();
  fixDate(now);
  now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
  setCookie("SametimeNickname",formobj.NickName.value, now,'/');
}
