function Get_Cookie(name) {
	var start = document.cookie.indexOf(name + '=');
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(';',len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
	expires=new Date("1/1/2010");
	path="/";
	domain=self.location.hostname;
	document.cookie =
		name + '=' + escape(value) +
		( (expires) ? ';expires=' + expires.toGMTString() : '') +
		( (path) ? ';path=' + path : '') + 
		( (domain) ? ';domain=' + domain : '') +
		( (secure) ? ';secure' : '');
}

if(self.location.href.indexOf("?")!=-1) {
	var qs=self.location.href.substring(self.location.href.indexOf("?")+1,self.location.href.length);
	while(qs.indexOf("?")!=-1) {
		qs=qs.replace("?","&");
	}
	while(qs.indexOf(",")!=-1) {
		qs=qs.replace(",","&");
	}
	while(qs.indexOf(" ")!=-1) {
		qs=qs.replace(" ","");
	}
	var qs_array=qs.split("&");
	for(i=0;i<qs_array.length;i++) {
		if(qs_array[i].substr(0,7)=="source=") {
			if(qs_array[i].length>7) {
				Set_Cookie("leadsource",qs_array[i].substr(7,qs_array[i].length-7));
				//alert(qs_array[i].substr(7,qs_array[i].length-7));
			}
		}
	}
}

function oclpopup() {
	var URL="http://www.oncourselearning.com/popup/oncourselearning_form.cfm?";
	var leadsource=Get_Cookie("leadsource");
	if(leadsource!=null){
		if(leadsource!="") {
			URL=URL + "source=" + leadsource + "&";
		} else {
			URL=URL + "nosource=true&";
		}
	} else {
		URL=URL + "nosource=true&";
	}
	URL=URL + "filename="+self.location.href;
	MM_openBrWindow(URL,"InstantAccess","scrollbars=yes,resizable=yes,width=270,height=400");
}
