days = 3
params = new Array();

function type(){
return "darshifaq";}

function time(){
return new whenIs(now(), days);}

function setCookie(name, value, expires, domain, path, secure) {
var newCookie = name + "=" + escape(value) +
((expires)? ";expires=" + expires.toGMTString():"") +
((path)? ";path=" + path :"") +
((domain)? ";domain=" + domain :"") +
((secure)? ";secure" :"")
document.cookie = newCookie
}

function getCookie(name) {
var prefix = name + "="
var start = document.cookie.indexOf(prefix)
if (start == -1)
	return null
	var end = document.cookie.indexOf(";", start+prefix.length)
if (end == -1)
	end = document.cookie.length
	var value = document.cookie.substring(start+prefix.length, end)
	return value
}

function whenIs(anyDate, n){
msDate = (anyDate.getTime()) +
(n * (Math.round(1000*60*60*24)-0.5))
tempDate = new Date()
tempDate.setTime(msDate)
return tempDate
}

function getOptions(name) {
if (navigator.cookieEnabled != true) return getCookie(type())
}

function sendOptions(name){
if (getCookie(type()))
{
	if (getCookie(type()) == name)
		{
		setCookie(type(), name, time())
		}
		else
		{
		setCookie(type(), name, time())
		}
}
	else
		{
		setCookie(type(), name, time())		
		}
}

function now() {
return new Date()
}

function goPage() {
var d = document.location.href
var goLink = getCookie(type())
if (d.indexOf(goLink) < 0 && goLink != null) location.href = goLink
}

function getParam(){
str=getCookie(type());
if (!str) return;
len = str.length;
if (len > 0){
 var start = 0;
	if(str.indexOf('-') != -1) {
	  for (q=0; q<=len; q++){
		end = str.indexOf('-',q)
		if (end==-1) e=len 
			else e=end
		params[unescape(str.substring(q-1,e))]=1;
		if (end == - 1) return
		 else q=end+1;
		}
	}
	else {params[str]=1;}
 }
}

function updateParam(){
str='';
for (i in params) {
	if (params[i]!=0) {
	 if (str.length > 0) str+='-';
	 str+=i;
	 }
	}
setCookie(type(),str,time());
}

function setParamOn(n){
params[n]=1;
updateParam();
}
function setParamOff(n){
params[n]=0;
updateParam();
}

function openLayers(){
getParam();
for (i in params) onoff(i)
}
