// javascript policy.js
window.onload = function(){
	window.setTimeout("userAccept.showDiv()", 100)
}
var userAccept = {
	showDiv   : function(){
		this.showEle("stu-agreement");
		this.clearTick();
	},
	showButton : function(){
		if(!userAccept.but || userAccept.but===0){
			this.showEle("stu-button");
			userAccept.but = 1;
		}else if(userAccept.but){
			this.hideEle("stu-button");
			userAccept.but =0;
		}
	},
	showEle	: function(ele){
		var ele = document.getElementById(ele);
		ele.style.display = "block";
	},
	hideEle	: function(ele){
		var ele = document.getElementById(ele);
		ele.style.display = "none";
	},
	clearTick : function(){
		document.getElementById("stu-checkbox").checked = false;	
	},
	postToServer : function(){
		var Ajax = this.getAjaxObject();
		Ajax.onreadystatechange = function() {
			if(Ajax.readyState==4 && Ajax.status==200) {
				window.location.reload();
	}
}
		Ajax.open("POST", "/php/auth/policy.php", true);
		Ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		Ajax.send("accept=true");
	},
	getAjaxObject : function(){
		if (window.XMLHttpRequest)  {
		  return new XMLHttpRequest();
  		}else{// code for IE6, IE5
		  return new ActiveXObject("Microsoft.XMLHTTP");
  		}
		return	false;
	}
}

