var expDays = 8;

var page = "client/popup.html";
var windowprops = "width=680, height=500, location=no, toolbar=no, menubar=no, scrollbars=no, resizable=yes";

function GetCookie (name) { 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
		return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break; 
	} 
	return null;
}

function SetCookie (name, value) { 
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) + 
	((domain == null) ? "" : ("; domain=" + domain)) + 
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) { 
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 1); 
	var cval = GetCookie (name); 
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var exp = new Date(); 
//var targetDate = new Date("08/31/2008");

exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
//alert(exp);

function amt(){
	var count = GetCookie('new_20090323_1')
	if(count == null) {
		SetCookie('new_20080121_1','1')
		return 1
	}else {
		var newcount = parseInt(count) + 1;
		DeleteCookie('new_20090323_1')
		SetCookie('new_20090323_1',newcount,exp)
		return count
	}
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1){
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
	
	var count = GetCookie('new_20090323_1');
	var today = new Date();
//	var targetDate = new Date("08/31/2008");
//	alert(targetDate + exp);
//	var timeBeforeTarget = (Math.floor(( targetDate.getTime() - today.getTime()) / 86400000)) + 1;
	if (count == null) {
		count=1;
		SetCookie('new_20090323_1', count, exp);
	}else {
		count++;
		SetCookie('new_20090323_1', count, exp);
	}
	if (count<4){
//		alert(count);
//	if (count<4 && timeBeforeTarget>0){
		document.getElementById('new_popup_id').style.display='block';
//		popitup("client/popup.html");
	}
	
}




function popitup(url){
	var newwindow = '';
	//alert(document.getElementById('new_popup_id').style.display);
	//document.getElementById('new_popup_id').style.display='block';
	
/*
	if (!newwindow.closed && newwindow.location){
		newwindow.location.href = url;
	}else{
		newwindow=window.open(url,'name','width=680, height=500, location=no, toolbar=no, menubar=no, scrollbars=no, resizable=yes');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {
		newwindow.focus();
	}*/
	return false;
}












