				// Functions for the PW Change page				
				// Check the user actions for the old PW field
				var myInputOldPW = document.getElementById("changepassword:oldPassword");
				if(myInputOldPW != null){
					myInputOldPW.onfocus = function() {
						if(!myInputOldPW.value){
							document.getElementById("messageCurrentPW").style.display = "block";
						}
						else{
							document.getElementById("messageCurrentPW").style.display = "none";
						}
					}
					myInputOldPW.onkeyup = function() {
						checkPWChangeButton();
						if(!myInputOldPW.value){
							document.getElementById("messageCurrentPW").style.display = "block";
						}
						else{
							document.getElementById("messageCurrentPW").style.display = "none";
						}
					}	
				}
				
				
				// Check the user actions for the confirm PW field
				var myInputConfirmPW = document.getElementById("changepassword:confirmPassword");
				if(myInputConfirmPW != null){
					myInputConfirmPW.onfocus = function() {
						if(!myInputConfirmPW.value){
							document.getElementById("enterInfo").style.display = "block";
						}
						else{
							document.getElementById("enterInfo").style.display = "none";
						}
					}
					myInputConfirmPW.onkeyup = function() {
						checkPWChangeButton();
						if(!myInputConfirmPW.value){
							document.getElementById("enterInfo").style.display = "block";
							document.getElementById("messagePWCheck").style.display = "none";
						}						
						if(myInputConfirmPW.value != myInput.value){
							if(!myInputConfirmPW.value){
								document.getElementById("enterInfo").style.display = "block";
								document.getElementById("messagePWCheck").style.display = "none";
							}
							else{
							document.getElementById("messagePWCheck").style.display = "block";
							document.getElementById("enterInfo").style.display = "none";
							}						
						}						
						if((myInputConfirmPW.value == myInput.value) && (myInputConfirmPW.value)){
							document.getElementById("messagePWCheck").style.display = "none";
							document.getElementById("enterInfo").style.display = "none";
						}
					}	
				}
												
								
				// Check the user actions for the new PW field
				var myInput = document.getElementById("changepassword:newPassword");
				var length = document.getElementById("length");
				var specialcharacter = document.getElementById("specialcharacter");
				var letter = document.getElementById("letter");				
				var number = document.getElementById("number");				

				// When the user clicks on the password field, show the message box
				if(myInput != null) {
				myInput.onfocus = function() {
 				 document.getElementById("message").style.display = "block";
					}
				}

				// When the user clicks outside of the password field, hide the message box
				if(myInput != null) {
				myInput.onblur = function() {
				  document.getElementById("message").style.display = "block";
					}
				}

				//When the user starts to type something inside the password field
				if(myInput != null) {
				myInput.onkeyup = function() {
 				 // Validate letters
  				var letters = /[A-Za-z]/g;
  				if(myInput.value.match(letters)) {  
    				letter.classList.remove("invalid");
    				letter.classList.add("valid");
  				} else {
    				letter.classList.remove("valid");
    				letter.classList.add("invalid");
  				}
  
 				 // Validate special characters
  				var specialcharacters = /[-./',;&@#*)(_+:"~]/g;
  				if(myInput.value.match(specialcharacters)) {  
    				specialcharacter.classList.remove("invalid");
   					specialcharacter.classList.add("valid");
  				} else {
    				specialcharacter.classList.remove("valid");
    				specialcharacter.classList.add("invalid");
  				}

  				// Validate numbers
  				var numbers = /[0-9]/g;
  				if(myInput.value.match(numbers)) {  
    				number.classList.remove("invalid");
    				number.classList.add("valid");
  				} else {
    				number.classList.remove("valid");
    				number.classList.add("invalid");
  				}
  
  				// Validate length
  				if((myInput.value.length >= 8) && (myInput.value.length <= 40)) {
    				length.classList.remove("invalid");
    				length.classList.add("valid");
  				} else {
    				length.classList.remove("valid");
    				length.classList.add("invalid");
  				}
									
				// Collect all unallowed symbols and check if there is any in the input filed, display error message if there is
				var allUnallowedCharacters = /[^A-Za-z0-9-./',;&@#*)(_+:"~]/g;
				var specialChar = document.getElementById("specialcharacterError");	
				if(myInput.value.match(allUnallowedCharacters))
				{
					specialChar.style.display = "block";
					specialChar.classList.add("invalid");
				}
				else{
					specialChar.style.display = "none";
					specialChar.classList.add("valid");
				}
				checkPWChangeButton();																		 
				}
				}	

				// Checks if all rules are validated and disables/enables the Change PW button
				function checkPWChangeButton(){
				// Enable/Disable the PW change button
  				if(($("#length").hasClass("valid")) && ($("#specialcharacter").hasClass("valid")) && ($("#letter").hasClass("valid")) && ($("#number").hasClass("valid")) && ($("#specialcharacterError").hasClass("valid")) && (myInputConfirmPW.value === myInput.value) && (myInputOldPW.value))
				{
					changePWButton.enable();
				}
  				else{
					changePWButton.disable();
  					}
				}
				
				
				// Set the labels for the PW rules
				if((document.getElementById("header_pwrules")) && (document.getElementById("length")) && (document.getElementById("specialcharacter")) && (document.getElementById("letter")) && (document.getElementById("number")) && (document.getElementById("specialcharacterError")))
				{
					if(getGcdmLanguage()== "de")
					{
						document.getElementById("header_pwrules").innerHTML = "Das Passwort muss Folgendes enthalten:"
						document.getElementById("length").innerHTML = "Eine Länge zwischen 8 und 40 Zeichen.";	
						document.getElementById("specialcharacter").innerHTML = "Mindestens eines der folgenden Sonderzeichen: <b>   - . / &apos; , ; &amp; @ # * ) ( _ + : &quot; ~</b>";
						document.getElementById("letter").innerHTML = "Mindestens einen Buchstaben (a-z; A-Z).";
						document.getElementById("number").innerHTML = "Mindestens eine Zahl (0-9)."
						document.getElementById("specialcharacterError").innerHTML = "Mindestens ein Zeichen ist nicht erlaubt."	 		
					}
					else{
						document.getElementById("header_pwrules").innerHTML = "Password must contain the following:"
						document.getElementById("length").innerHTML = "Length between <b>8 and 40 characters.";
						document.getElementById("specialcharacter").innerHTML = "Minimum of one of the following special characters: <b>    - . / &apos; , ; &amp; @ # * ) ( _ + : &quot; ~</b>";
						document.getElementById("letter").innerHTML = "Minimum of one Letter (a-z; A-Z).";
						document.getElementById("number").innerHTML = "Minimum of one Number (0-9)."
						document.getElementById("specialcharacterError").innerHTML = "At least one character is not allowed."				
					}
				}
				
				
				// Functions for the LoginID Change page
				// Check if the user has typed email address matching the regex validation
				var myInputNewMail = document.getElementById("changeloginid:newLoginID");
				if(myInputNewMail != null){
					myInputNewMail.onfocus = function() {
						if(!myInputNewMail.value){
							document.getElementById("enterPWInfo").style.display = "block";
							document.getElementById("errorMailNotValid").style.display = "none";
						}
						else{
							document.getElementById("enterPWInfo").style.display = "none";
						}
					}
					myInputNewMail.onkeyup = function() {
						var mailformat  = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
						if(!myInputNewMail.value){
							document.getElementById("enterPWInfo").style.display = "block";
							document.getElementById("errorMailNotValid").style.display = "none";
						}
						if(myInputNewMail.value.match(mailformat))
						{
							document.getElementById("enterPWInfo").style.display = "none";
							document.getElementById("errorMailNotValid").style.display = "none";
							changeMailButton.enable();
						}
						if(!myInputNewMail.value.match(mailformat) && (myInputNewMail.value))
						{
							document.getElementById("errorMailNotValid").style.display = "block";
							document.getElementById("enterPWInfo").style.display = "none";
							changeMailButton.disable();
						}
					}	
				}
				
				
function basysLogout(){
	sessionStorage.clear();
}


function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
    }
    return "";
}

function reAttachSelectionListener(){
	$("tr").on("click",function(event){ 
		if($(event.target).hasClass("ui-chkbox-box") 
				|| $(event.target).hasClass("ui-chkbox-icon") 
				||  event.target.tagName == "A"){
			return true;
		}
		return false;})
}
