function highlight(row) {
	row.id = "highlightIntakeRow";
}

function unhighlight(row) {
	row.id = "";
}

function highlightResult(row) {
	for (var i = 0; i < row.cells.length; i++) {
		row.cells[i].id="highlightResult";
	}
}

function unhighlightResult(row) {
	for (var i = 0; i < row.cells.length; i++) {
		row.cells[i].id="";
	}
}

function checkboxTextSelect(checkbox) {
	if (checkbox.checked == true) {
		checkbox.checked = false;
	}	
	else {
		checkbox.checked = true;
	}
	highlightSelectedAnswer(checkbox);	
}

/**Used on intake.html to highlight selected answers**/
function highlightSelectedAnswer(clickObj) {
	if (clickObj.checked == true) {
		clickObj.parentNode.className = "highlightSelectedAnswer";
	}
	else {
		clickObj.parentNode.className = "";
	}
}


// COOKIES
/*
	Cookie functions
	@param name		the name of the cookie
	@param value 		the value of the cookie
	@param value 		time expries
	@param path 		accessing within the domain (example: /home/  /directory/ etc)
	@param domain		the domain name (www.yourname.com)
	@param secure 	"", "yes", "no"
 */
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/*
	Gets the cookie from the web browser (client's side)
	Splits the string by ";" and get information.
	In this case, we want to know the tab id.
	@param name			the name of the cookie
*/
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/*
	Deletes a cookie
	Gets a cookie and set its expiration date's to any date in the past.
	@param name				the name of the cookie
	@param path				the website's path
	@param domain			the website's domain
*/
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function numbericOnly(e)
{
	var keynum;
	var keychar;
	var numcheck;
	
	if(window.event) // IE
	  {
	  keynum = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  keynum = e.which;
	  }
	  
	// Backspace | Returns true;
	if (keynum == 8) { return true; }
	
	keychar = String.fromCharCode(keynum);
	numcheck = /\d/;
	return numcheck.test(keychar);
}

function floatOnly(e)
{
	var keynum;
	var keychar;
	var numcheck;
	
	if(window.event) // IE
	  {
	  keynum = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  keynum = e.which;
	  }
	  
	// Backspace | Returns true;
	if (keynum == 8) { return true; }
	
	keychar = String.fromCharCode(keynum);
	if (keychar == ".") { return true; }	
	numcheck = /\d/;
	return numcheck.test(keychar);
}



