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) {
		var cookie = c.substring(nameEQ.length,c.length);
		if(cookie.charAt(0) == '{') {
		    cookie = eval("["+cookie+"]")[0];
		}
		return cookie;
	    }
	}
	return null;
}

function checkCookie(name)
{
	return ReadCookie('session_id');
}

function getUsrRole()
{
	return ReadCookie('rid');
}

/**
 * Function:validateLoginForm
 * Validates the Username & Password fields, and alerts error message if User 
 *   has left them blank.
 */
function validateLoginForm(form) {
    if(form.uname.value == '' || form.pass.value == '') {
	alert('Username or Password field cannot be left Blank.');
	return false;
    }
    return true;
}
