/*USED FOR ADDTHIS BUTTON - TEMPRARLY DISABLED...
string = document.title;
var anArray = new Array(2);
anArray[0] = new Array("Ã–", "Ã¶", "Ã„", "Ã¤", "Ãœ", "Ã¼", "ÃŸ");
anArray[1] = new Array("Oe", "oe", "Ae", "ae", "Ue", "ue", "ss");
for (var i=0; i<anArray[0].length; i++){
myRegExp = new RegExp(anArray[0][i],"g");
string = string.replace(myRegExp, anArray[1][i]);
}

document.title = string;
*/

//Window Manager start
function Applications(url) {

	windowOpen(url,'Applications');
}

function Security(url) {
	windowOpen(url,'Security');
}

function Systems (url) {
	windowOpen(url,'Systems');
}

function ITSolutions(url) {
	windowOpen(url,'ITSolutions');

}

function windowOpen(url,name) {
	var t = window.open(url,name);
	t.focus();
}

function hideElement(elem) {
	var toHide = document.getElementById(elem);
	if (toHide) {
		toHide.style.display='none';
	}
}

//Window Manager end

function resize() {
	var i=0;
	if (navigator.appName == 'Netscape')
		i=40;
	if (document.images[0])
		window.resizeTo(document.images[0].width +30, document.images[0].height+90-i);
	self.focus();
}

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);
	var lurl = "width="+width+",height="+height+","+param;

	window.open(url, "", lurl);
}

/*!!Do not delete this function!!.
 You need this function to use the validation of the formulargenerator.*/

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 addToFavoritesDE(pagename) {
	var errmsg="Ihr Browser unterstÃ¼tzt leider kein automatisches HinzufÃ¼gen von Seiten zu den Favoriten. Vermutlich handelt es sich nicht um den Internet Explorer. Bitte verwenden Sie das entsprechende MenÃ¼-Kommando ihres Browsers, um diese Seite zu Ihren Lesezeichen hinzuzufÃ¼gen. Vielen Dank!";
	return addToFavorites(pagename,errmsg);
}

function addToFavoritesEN(pagename) {
	var errmsg="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 addToFavorites(pagename,errmsg);
}

function addToFavorites(pagename,errmsg) {
	if(window.external) {
		window.external.AddFavorite(location.href,pagename)
	} else {
		// this is not an Internet Explorer
		alert(errmsg);
	}
	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;
		}
	}
}

/* 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,'/');
}

function NewWindowOPM(z) {
	window.open(z,  "", "width=400,height=200,scrollbars=no,resizable=no");
}

function loginSubmit() {
	var formobj = document.forms["DominoLogin"];
	document.cookie="sessionCookie=troet";
	(getCookie("sessionCookie"))?formobj.submit():alert ("Please enable sessionbased cookies in your browser \npreferences and reload the page!");
}

function getXMLHTTP() {
	// function to create an XmlHttp object
	var xmlHttp = null;

	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(oc) {
			xmlHttp = null;
		}
	}

	if(!xmlHttp && typeof XMLHttpRequest != "undefined") {
		xmlHttp = new XMLHttpRequest();
	}

	return xmlHttp;
}

function testpopup() {
	var t = window.open('',popup,'width=100,height=100,resizable=yes');
	t.document.write("<html><head><script language=\"JAvaScript\" type=\"text/JavaScript\">var i=0;function resize() {  if (navigator.appName == \'Netscape\') i=40;");
	t.document.write("if (document.images[0]) window.resizeTo(document.images[0].width +30, document.images[0].height+90-i); self.focus();self.reload();}");
	t.document.write("</script></head>");
	t.document.write("<body onLoad=\"resize();\"><span onClick=\"window.close();\"><img src=\""+url+"\" alt=\"\" border=\"0\" /></span></body></html>");
}

function parsequery(qstring) {
	var arg_pairs = new Object();
	arg_pairs.names = new Array();
	arg_pairs.values = new Array();
	var length = 0;
	var query = qstring;
	if(query == "") {
		return null;
	}
	var pairs = query.split("\&");
	length=pairs.length;
	for(var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if(pos == -1) {
			continue;
		}
		var arg_name = pairs[i].substring(0,pos);
		var arg_value = pairs[i].substring(pos+1);
		arg_pairs.names[i] = arg_name;
		arg_pairs.values[i] = arg_value;
	}
	return arg_pairs;
}

function popup(url,height, width) {
	var optionen = 'scrollbars=no,menubar=no,resizable=no,width='+width+',height='+height;
	var t = window.open('','popup',optionen);
	if (t) {
		t.document.open();
		t.document.write("<html><head></head>");
		t.document.write("<body style=\"margin:0px;padding:0px;position:absolute;top:0px;\" onClick=\"window.close();\"><img src=\""+url+"\" alt=\"\" border=\"0\" ");
		t.document.write(" width=\""+width+"\" height=\""+height+"\" /></body></html>");
		t.focus();
		t.document.close();
	}
	return false;

}

function popup2() {
	var href = this.href;
	var target = this.target;
	var width=500;
	var height=500;
	if (target.toLowerCase()=='popup') {
		var url_pairs = parsequery(href);

		for (i = 1; i < url_pairs.names.length;i++) {
			if (url_pairs.names[i].toLowerCase() =='b') {
				width=url_pairs.values[i];
			}
			if (url_pairs.names[i].toLowerCase() =='h') {
				height=url_pairs.values[i];
			}

		}
		popup(href,height,width);
		return false;
	}
}

function enablePopup() {
	var aTags = document.getElementsByTagName("a");
	var aTag='';
	for (i = 0; i < aTags.length; i++) {
		aTag = aTags[i];
		if (aTag.target.toLowerCase()=="popup") {
			aTag.onclick=popup2;

		}
	}

}

function getFieldValue2(field) {
	if (field) {
		switch(field.type) {
			case "text" :
			case "textarea" :
			case "password" :
			case "hidden" :
				return field.value;

			case "select-one" :
				var i = field.selectedIndex;
				if (i == -1)
					return "";
				else
					return (field.options[i].value == "") ? field.options[i].text : field.options[i].value;

			case "select-multiple" :
				var allChecked = new Array();
				for(i = 0; i < field.options.length; i++)
					if(field.options[i].selected)
						allChecked[allChecked.length] = (field.options[i].value == "") ? field.options[i].text : field.options[i].value;
				return allChecked;

			case "button" :
			case "reset" :
			case "submit" :
				return "";

			case "radio" :
			case "checkbox" :
				if (field.checked) {
					return field.value;
				} else {
					return "";
				}
			default :
				if(field[0].type == "radio") {
					for (i = 0; i < field.length; i++)
						if (field[i].checked)
							return field[i].value;

					return "";
				} else if(field[0].type == "checkbox") {
					var allChecked = new Array();
					for(i = 0; i < field.length; i++)
						if(field[i].checked)
							allChecked[allChecked.length] = field[i].value;

					return allChecked;
				} else
					var str = "";
				for (x in field) {
					str += x + "\n";
				}
				debug("I couldn't figure out what type this field is...\n\n" + field.name + ": ???\n\n\n" + str + "\n\nlength = " + field.length);
				break;
		}
	}
	return "";
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
	var rv = -1; // Return value assumes failure
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

function checkRSS() {

	if (checkVersion()==false) {
		var rssfeed = document.getElementById('RSSFEED');
		if (rssfeed) {
			rssfeed.style.display='none';
		}
	}
} //checkRSS

function checkVersion() {

	var ver = getInternetExplorerVersion();

	if ( ver > -1 ) {
		if ( ver > 6.0 )
			return true;
		else {
			return false;
		}
	}
	return true;
}

function openNews(url,target) {
	try {

		var docnumber = document.getElementById('DocNumber');
		if (docnumber) {
			url = url + docnumber.value;
		}
		if (target =='_blank') {
			window.open(url);
		} else {
			top.location.href=url;
		}
	} catch(e) {
		alert(e.description);
	}
}

function doResize() {
	var lnav = document.getElementById('LinkeNavigation');
	if (lnav) {

	}

}

function cycleCenter(currSlideElement, nextSlideElement, options, forwardFlag) {
	//alert(currSlideElement.style.width);
	//	alert(currSlideElement.style.height);
}

$(document).ready( function() {

	$('#gallery a').lightBox();
	$('.lightbox').lightBox();

	$('#tabs').tabs();

	$('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		height: 'auto',
		timeout: 2000,
		fit:1
	});

  $('#anmeldunglink').click(function() {
 		$(window).scrollTop($(document).height())
 		return false;
 	}
   )
   
   if(getParameterByName("fe1")!=""){
   	$(window).scrollTop($(document).height())
   }

	//Dialog Tell-a-Friend START
	$('#show-recommendation').click( function () {
		openDialog($(this), "Seite weiterempfehlen", 625, 550, "")	
	}
	);
	//Dialog Tell-a-Friend END
	
	//Dialog Rate START
	$('#show-rate').click( function () {
		openDialog($(this), "Seite bewerten", 625, 550, "")	
	}
	);
	//Dialog Rate END


	//Dialog Mailing List START
	$('.show-eventmailinglist').click( function () {
		openDialog($(this), "Event-Mailingliste", 625, 600, "")	
	}
	);
	//Dialog Mailing List END
	
	
	
	$(".ConLink>a[href='../id/ITSol_DE_OnlineBewerbung']").click( function () {
		openDialog($(this), "Online Bewerbung", 625, 550, "/BSAZ/web.nsf/id/ITSol_DE_OnlineBewerbung")
		return false;
	}
	);
});

function closeDialog(){
	$('#dialog').dialog('close')
}

function openDialog(oElement, sTitle, iWidth, iHeight, sUrl){
	
	var dialogOpts = {
		title: sTitle,
		modal: true,
		autoOpen: false,
		height: iHeight,
		width: iWidth,
		open: function() {
			if(sUrl==""){
				sUrl = oElement.attr("rel");
			}
			//alert(sUrl)
			var d = $('#dialog').html('<iframe style="height:' + (iHeight-14) + 'px;width:'+(iWidth-14)+'px" border="0" frameborder="0" id="ifrm"></iframe>');
	        $("#dialog>#ifrm").attr("src", sUrl);
			//$("#example").load();
			return false;
		}
	};
	$("#dialog").dialog(dialogOpts);
	$("#dialog").dialog("open");
	return false;
}

function openApplyPopUp(sUrl) {
	var iWidth=(screen.width/2)-(650/2);
	var iHeight=(screen.height/2)-(650/2);
	window.open(sUrl,'','width=650,height=650,left='+iWidth+',top='+iHeight+',statusbar=yes,resizable=yes,scrollbars=no');
	return false;
}

function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

