//Functions for checking if a s3 cookie is present -> this indicate if the user is logged in

//Read the content of a cookie
function readCookie(name) {
	var nameEQ = name + "=";
	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,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//Split a string with the : delimeter and return
//n-th field from the string
function readCookieField(input, fieldNo) {
	if(!input){
        return null;
    }
    var fieldArray = input.split(':');
	if(fieldArray[fieldNo]){
        return fieldArray[fieldNo];
    }else{
        return null;
    }
}



