$(function(){
	myCheckers = new Array();
	myCheckCookie = new Array();
	myCheckCookie = myGetCookie("autoChecker");
	
	if(myCheckCookie){
		
		myCheckers = myCheckCookie.split('+');
		
		for(i=0; i<myCheckers.length; i++){
			if(document.getElementById){
				if(document.getElementById("check"+myCheckers[i])){
					document.getElementById("check"+myCheckers[i]).checked = "true";
				}
			} else if(document.all){
				document.all("check"+myCheckers[i]).checked = "true";
			}
		}
	}
});

function checkObject(id){
	if(document.all){
		if(document.all("check"+id).checked){
			addCheckCookie(id);
		} else {
			dieCheckCookie(id);
		}
	}else if(document.getElementById){
		if(document.getElementById("check"+id).checked){
			addCheckCookie(id);
		} else {
			dieCheckCookie(id);
		}
	}
}

function addCheckCookie(id){
	var myNewCookie = null;
	var isAlready = false;
	myCheckers = new Array();
	myCheckCookie = new Array();
	myCheckCookie = myGetCookie("autoChecker");
	
	if(!myCheckCookie == ""){
		myCheckers = myCheckCookie.split('+');
		
		for(i=0; i<myCheckers.length; i++){
			if(myCheckers[i] == id) isAlready = true ;
			
			myNewCookie =  (i == 0) ? myCheckers[i] : myNewCookie + '+' + myCheckers[i];
		}
		
		if(isAlready == false) myNewCookie += '+' + id;
		mySetCookie("autoChecker", myNewCookie);
	} else {
		mySetCookie("autoChecker", id);
	}
}

function dieCheckCookie(id){
	var myNewCookie ="";
	myCheckers = new Array();
	myCheckCookie = new Array();
	myCheckCookie = myGetCookie("autoChecker");
	
	if(myCheckCookie != null){
		myCheckers = myCheckCookie.split('+');
		var n = 0;
		
		for(i=0; i<myCheckers.length; i++){
			if(myCheckers[i] === id) continue;
			myNewCookie =  (n == 0) ? myCheckers[i] : myNewCookie + '+' + myCheckers[i];
			n += 1;
		}
		
		mySetCookie("autoChecker", myNewCookie);
	}
}

function mySetCookie(myCookie,myValue,myDay){
   myExp = new Date();
   myExp.setTime(myExp.getTime()+(myDay*24*60*60*1000));
   myItem = "_" + myCookie + "=" + escape(myValue) + ";";
   myExpires = "expires="+myExp.toGMTString();
   document.cookie =  myItem + "expires=";
   /* document.cookie =  myItem + myExpires; */
}

function myGetCookie(myCookie){
   myCookie = "_" + myCookie + "=";
   myValue = null;
   myStr = document.cookie + ";" ;
   myOfst = myStr.indexOf(myCookie);
   if (myOfst != -1){
      myStart = myOfst + myCookie.length;
      myEnd   = myStr.indexOf(";" , myStart);
      myValue = unescape(myStr.substring(myStart,myEnd));
   }
   return myValue;
}