﻿/* Diamonds Software Web Access AnAlyst, Copyright 2009 */
var _AnA={
	ac:function(t,x){
		try{
			i=new Image();
			i.src=t+"?"+x;
		}catch(e){alert('ac '+e.description);}
	},
	
	cc:function(n,v,d){
		var t=new Date();
		t.setTime(t.getTime()+(d*24*60*60*1000));
		var exp="; expires="+t.toGMTString();
		document.cookie=n+"="+v+exp+"; path=/";
	},
	
	rc:function(n){
		var q=n+"=";
		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(q)==0){
				return c.substring(q.length,c.length);
			}
		}
		return null;
	},
	
	ec:function(n){
		_AnA.cc(n,"",-1);
	},
	
	gh:function(){
		var hs=window.location.hash;
		if(hs==null) hs=document.location.hash;
		if(hs.substr(0,4)=="#AnA"){
			return hs.substr(4,hs.length);
		}else{
			return null;
		}
	},
	
	h2c:function(){
		try{
			var h=_AnA.gh();
			if(h!=null){
				_AnA.ec("AnA");
				_AnA.cc("AnA",h,14);
			}
		}catch(e){alert('h2c '+e.description);}
	},
	
	c2v:function(){
		return _AnA.rc("AnA");
	},
	
	v2s:function(c,u){
		try{
			_AnA.ac(u+"Analyst.ana","c="+c+"&u="+escape(window.location));
		}catch(e){alert('v2s '+e.description);}
	},
	
	ctl:function(u){
		_AnA.h2c();
		var c=_AnA.c2v();
		if(c!=null){_AnA.v2s(c,u);}
	}
}