﻿
function createRatingCookie(value,days) {
	
	
	var cc=readCookie('CTFRatingCookie');

		if(cc==null)
		{
			
			cc=value;
			
		}
		else
		{
			if(cc.indexOf(value) == -1)
				if(cc!=null)
					cc=cc+'|'+value;
				else
					cc=value;
		}
	
	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 = "CTFRatingCookie="+cc+expires+"; path=/";
	
	createSavedRatingId(value);
	
}

function createSavedRatingId(value)
{
	var cc=readCookie('CTFLastSavedId');

	cc=value;
		
	
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	
	
	document.cookie = "CTFLastSavedId="+cc+expires+"; 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;
}

