function CookieUsr(cookieName, domainName) {
	this.cookieName = cookieName;
	this.domainName = domainName;
	this.url = "/tools/cookie.php";

	this.getExpDate = function(days, hours, minutes, expired) {
		if (expired == "" || expired == null || expired == false) {
			var expDate = new Date( );
			if (typeof days == "number" && typeof hours == "number" &&
				typeof hours == "number") {
				expDate.setDate(expDate.getDate( ) + parseInt(days));
				expDate.setHours(expDate.getHours( ) + parseInt(hours));
				expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));
				return expDate.toGMTString( );
			}
		} else {
			return "Thu, 01-Jan-1970 00:00:01 GMT";
		}
	}

	this.yearExpireDate = this.getExpDate(366, 0 ,0);
	
	this.getToday = function(timeType) {
		var currentTime = new Date();
		var year = currentTime.getFullYear();
		var month = currentTime.getMonth() + 1;	
		var day = currentTime.getDate();	
		var hours = currentTime.getHours();
		var minutes = currentTime.getMinutes();
		var today;
		
		switch(timeType) {
			case "monthly":
				today = year + "" + month;
				break
			case "daily":
				today = year + "" + month + "" + day;
				break
			case "hourly":
				today = year + "" + month + "" + day + "" + hours;
				break
			case "minute":
				today = year + "" + month + "" + day + "" + hours + "" + minutes;
				break
			default:
				today = year + "" + month + "" + day;
		}
		
		return today;
	}

	this.todayVal = this.getToday();
	
	this.getCookie = function(Name) {
		var re = new RegExp(Name+"=[^;]+", "i");
		if (document.cookie.match(re)) 
			return unescape(document.cookie.match(re)[0].split("=")[1]);
		return "";
	}
	
	this.setCookie = function(name, value, expireDate ) {
		this.q = name + "=" + value + "; expires=" + expireDate + "; domain=" + this.domainName + "; ";		
		document.cookie = this.q;

		var CV = this.getCookie(name);
		if (CV != "" && CV != null)
			return true;
		else
			return false;		
	}
	
	function CooProcessChange(responseText) {
		if ( responseText == "completed" ) {
		} else {
			this.setCookie(this.cookieName, this.todayVal, this.getExpDate(0, 0, 0, "expired"));
		}
	}
	
	this.uniqueuser = function() {
		this.cookieVal = this.getCookie(this.cookieName);
		
		if ( (this.cookieVal == "" || this.cookieVal == null) || this.cookieVal != this.todayVal ) {
			if ( this.setCookie(this.cookieName, this.todayVal, this.yearExpireDate) ) {
				var agt = navigator.userAgent.toLowerCase();
				var urlForSend = this.url +
					   	  		 "?userAgent=" + agt;
				MBGAjax(urlForSend, CooProcessChange, "GET");
			}
		}
	}
}
var UU = new CookieUsr("sabah-uu", ".sabah.com.tr");
UU.uniqueuser();

var UUM = new CookieUsr("sabah-uum", ".sabah.com.tr");
UUM.todayVal = UUM.getToday("monthly");
UUM.url = "/tools/cookie_monthly.php";
UUM.uniqueuser();