/* TODO: Make this go away, some methods can be implimented in Compass style and put in a utils.js 
 * For now this code has been copied to esi_legacy.js with common.js code to reduce http requests
 */

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = ";expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+";domain=.express-scripts.com;path=/;";
}

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;
}

function PopupWindow(url, height, width) {
	var features = "status=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",left=30,top=30";
	var childWindow = open(url,'choicePopup',features);
	childWindow.focus();
}

function toggleExtraInfo(el){
	if(/Show/.test(el.innerHTML))
	{
		el.innerHTML = el.innerHTML.replace(/Show/,"Hide");
		el.nextSibling.style.display = "block";
	}
	else
	{
		el.innerHTML = el.innerHTML.replace(/Hide/,"Show");
		el.nextSibling.style.display = "none";
	}
}

