function createCookie2(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 readCookie2(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 eraseCookie2(name) {
	createCookie2(name,"",-1);
}

function checkCookie2()
{
	if (readCookie2('country')) {
		var country=readCookie2('country');

		if (country==null || country=="") {createCookie2('country','',10);}
		
		return "Y"
	} else {
		return "N"
	}
}


function langcookieset() {
	var href = window.location.pathname;
	// don't continue without support for appendChild
	if (document.body.appendChild) {
		if (href.indexOf("francais")!=-1){		
			createCookie2('language','French',10);
		}else{
			createCookie2('language','English',10);
		}
	}
}

function cookieset(href) {
	var href = window.location.pathname;
	// don't continue without support for appendChild
	if (document.body.appendChild) {
		if((href == "/canada.html")||(href == "/francais/canada.html")){		
			createCookie2('country','Canada',10);
		}
		if((href == "/united-states.html")||(href == "/francais/united-states.html")){		
			createCookie2('country','US',10);
		}
		if((href == "/international.html")||(href == "/francais/international.html")){		
			createCookie2('country','International',10);
		}
		if((href == "/about-rbc.html")||(href == "/francais/about-rbc.html")){		
			createCookie2('country','AboutRBC',10);
		}		
	}
}

