function setCookie(name,value) {
	setCookieDays(name,value,180); // Default to 30 days
}

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

function getCookie(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 delCookie(name) {
	setCookie(name,"",-1);
}

function inArray(arr, val) {
	for (var i = 0; i < arr.length; i++) {
		if (arr[i] == val) {
			return i;
		}
	}
	return -1;
}

function mS(sec_id) {
	var sections = (getCookie('section_list') == null) ? new Array() : getCookie('section_list').split(',');
	var exists = 0;
	sections = sections.without('');
	// dojo.query('#section-cart-add-link-' + sec_id).style('display','none');

	if (inArray(sections, sec_id) < 0) {
		sections.push(sec_id);
		dojo.byId('section-cart-add-link-' + sec_id).innerHTML = '<img src="/courselect/images/i/del.png" alt="Remove this from my list" style="vertical-align:bottom;" />';
	} else {
		sections = sections.without(sec_id);
		dojo.byId('section-cart-add-link-' + sec_id).innerHTML = '<img src="/courselect/images/i/add.png" alt="Add this to my list" style="vertical-align:bottom;" />';
	}
	sections = sections.without('');
	setCookie('section_list',sections.join(','));
}