// Scrambles passwords using simple cipher algorithm
function getScrambledPassword(pwd) {
		var cipher = ['k', 's', 'z', 'h', 'x', 'b', 'p', 'j', 'v', 'c', 'g', 'f', 'q', 'n', 't', 'm'];
		var result="";
		if (pwd == null)
				pwd = "";
		pwd = encodeURIComponent(pwd);
		//alert("encoded password: " + pwd);
		for(var i=0;i<pwd.length;i++) {
						var cc = pwd.charCodeAt(i);
				result += cipher[Math.floor(cc/16)] + cipher[cc%16];
		}
		//alert("scrambled password: " + result);
		return result;
}

$(document).ready(function(){$("#suche").focus(function(){if($(this).attr("value")=="Suchbegriff eingeben"){$(this).attr("value","")}});$("#suche").blur(function(){if($(this).attr("value")==""){$(this).attr("value","Suchbegriff eingeben")}}); $("#benutzername").focus(function(){if($(this).attr("value")=="Benutzername"){$(this).attr("value","")}});$("#benutzername").blur(function(){if($(this).attr("value")==""){$(this).attr("value","Benutzername")}});$("#password").focus(function(){if($(this).attr("value")=="Passwort"){$(this).attr("value","")}});$("#password").blur(function(){if($(this).attr("value")==""){$(this).attr("value","Passwort")}});

	$("form[action='http://helpdesk.iskv.de/arsys/forms/XREMPROD7/ISK_SCCTP_ControlPanel/ISKControlWeb']").submit(function(){
	
		var f = $(this);
	
		if(f.find("#benutzername").val() == ""){
			alert("You must enter a user name.");
			return false;
		}
		
		// get time zone from the system
		f.find("input[name='timezone']").val(getTimezone());
		
		// scramble the password before submitting
		f.find("#password").val(getScrambledPassword(f.find("#password").val()));
		
		return true;
	});

});
