﻿function Vector2ToString(obj){return "{"+obj.X+", "+obj.Y+"}";}

function GetAbsolute(obj){
	var re={X:obj.offsetLeft, Y:obj.offsetTop};
	
	if(obj.offsetParent){
		var re2=GetAbsolute(obj.offsetParent);
		re.X+=re2.X;
		re.Y+=re2.Y;
	}
	
	return re;
}

function IncludesClass(obj, className){
	if(obj==null){return false;}
	var temp=" "+obj.className+" ";
	return temp.indexOf(" "+className+" ")>-1;
}

var CookieManager=function(Name, Expiry){
	this.Name="";
	this.Expiry=365;
	this.FoundCookie=false;
	
	this.FullCookie=document.cookie;
	
	var cookie="; "+document.cookie+"; ";
	if(cookie.indexOf(Name)>-1){this.FoundCookie=true;}
	
	this.Set=function(key, value){
		var eDate=new Date();
		eDate.setDate(eDate.getDate()+this.Expiry);
        document.cookie=this.Name+key+"="+value+"; expires="+eDate.toGMTString()+"; path/";
        this.FullCookie=document.cookie;
	}
	this.Get=function(key){
        var cookie="; "+document.cookie+"; ";
        var startString="; "+this.Name+key+"=";
        var start=cookie.indexOf(startString);
        if(start<0){return null;}
        start+=startString.length;
        var end=cookie.indexOf(";", start);
        if(end<0){return null;}

		var re=cookie.substring(start,end);
        return re=="" ? null : re;
	}

	this.Clear=function(){
		var docCookie="; "+document.cookie+"; ";
		var eDate=new Date();
		eDate.setDate(eDate.getDate()-1);
		var cookies=docCookie.split("; ");
		for(var c=0; c<cookies.length; c++){
			var cookie=cookies[c];
			if(cookie==""){continue;}
			if(cookie.indexOf(this.Name)==0){
				var variable=cookie.split("=");
				document.cookie=variable[0]+"=;expiry="+eDate.toGMTString()+";";
			}
		}
	}

	if(Name!=null){this.Name=Name;}
	if(Expiry!=null){this.Expiry=Expiry;}
}






