

function login_xp() {
	firmenWin = window.open ("", "xp", "width=800,height=600,resizable=yes,toolbar=yes, scrollbars=yes");
	document.forms.frmAnmeldung.submit();
	document.forms.frmAnmeldung.TextBoxKennung.value='';
	document.forms.frmAnmeldung.TextBoxPSW.value='';
	firmenWin.focus();
	return false;
}


function openInfoWindow() {
	var windowWidth = 480;
	var windowHeight = 320;
	var windowName = "Test";
	var windowUri = "/en/online/info.html";

	var centerWidth = (window.screen.width - windowWidth) / 2;
	var centerHeight = (window.screen.height - windowHeight) / 2;

	newWindow = window.open(windowUri, windowName, 'resizable=0,width=' + windowWidth +
	',height=' + windowHeight +
	',left=' + centerWidth +
	',top=' + centerHeight);

	newWindow.focus();
	return newWindow.name;
}


function submitLoginForm() {
	if (document.frmAnmeldung.TextBoxKennung.value.match(/^.*@.*$/)) {
		//document.frmAnmeldung.action = "/sites/dkv-globality.com/en/online/checkCredentials.html";
		document.frmAnmeldung.action = "https://services.dkv-globality.com/sso/Auth";
	} else {
		document.frmAnmeldung.action = "http://www.globality.dkv.com/eng/cgibin/adm/22205.php";
		document.frmAnmeldung.target = "_blank";
	}
	if (document.frmAnmeldung.TextBoxKennung.value.length > 0) {
		document.frmAnmeldung.submit()
	}
}


function setCookie(c_name, value, expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value)+
	((expiredays == null) ? "" : ";expires="+exdate.toGMTString());
}


function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start = c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return "";
}


function getTime() {
	var t = new Date();
	var h = ( (t.getHours() < 10) ? "0"+t.getHours() : t.getHours() );
	var m = ( (t.getMinutes() < 10) ? "0"+t.getMinutes() : t.getMinutes() );
	var s = ( (t.getSeconds() < 10) ? "0"+t.getSeconds() : t.getSeconds() );
	return h+":"+m+":"+s;
}


function getSitaDate() {
	var t = new Date();
	//alert(t.getDate()+"."+(t.getMonth()+1)+"."+t.getFullYear());
	var d = ( (t.getDate() < 10) ? "0"+t.getDate() : t.getDate() );
	var m = ( ((t.getMonth()+1) < 10) ? "0"+(t.getMonth()+1) : (t.getMonth()+1) );
	var y = t.getFullYear();
	//alert(d+"."+m+"."+y);
	return d+"."+m+"."+y;
}


function getBirthDateForAge(age) {
	var t = new Date();
	var d = ( (t.getDate() < 10) ? "0"+t.getDate() : t.getDate() );
	var m = ( ((t.getMonth()+1) < 10) ? "0"+(t.getMonth()+1) : (t.getMonth()+1) );
	var y = t.getFullYear() - age;
	return d+"."+m+"."+y;
}

// /en/


















function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

function isDigit (c) {
	return ((c >= "0") && (c <= "9"))
}

function isInteger (s) {
	var i;
	if (isEmpty(s))
	if (isInteger.arguments.length == 1) return 0;
	else return (isInteger.arguments[1] == true);

	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}

function isSignedInteger (s) {
	if (isEmpty(s))
	if (isSignedInteger.arguments.length == 1) return false;
	else return (isSignedInteger.arguments[1] == true);

	else {
		var startPos = 0;
		var secondArg = false;

		if (isSignedInteger.arguments.length > 1)
		secondArg = isSignedInteger.arguments[1];

		// skip leading + or -
		if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
		startPos = 1;
		return (isInteger(s.substring(startPos, s.length), secondArg))
	}
}

function isPositiveInteger (s) {
	var secondArg = false;

	if (isPositiveInteger.arguments.length > 1)
		secondArg = isPositiveInteger.arguments[1];

	// The next line is a bit byzantine.  What it means is:
	// a) s must be a signed integer, AND
	// b) one of the following must be true:
	//    i)  s is empty and we are supposed to return true for
	//        empty strings
	//    ii) this is a positive, not negative, number

	return (isSignedInteger(s, secondArg) && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}


function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;

	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";

	if(typeof(arr) == 'object') { //Array/Hashes/Objects
		for(var item in arr) {
			var value = arr[item];

			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}















$(document).ready(function() {

	$('img#applyOnlineImage').hover(
	function() {
		this.src = '/en/apply/images/Online_Application_red.jpg';
	},
	function() {
		this.src = '/en/apply/images/Online_Application_black.jpg';
	});

});
