/**
 * Brings up the "Accept Community Standards" Box.
 *
 */
function acceptTerms() {
	var acceptBox = document.createElement("div");
	acceptBox.id = "acceptBox";
	YAHOO.util.Dom.setStyle(acceptBox, "margin", "-75px 0 0 -150px");
	YAHOO.util.Dom.setStyle(acceptBox, "position", "absolute");
	YAHOO.util.Dom.setStyle(acceptBox, "top", "50%");
	YAHOO.util.Dom.setStyle(acceptBox, "left", "50%");
	YAHOO.util.Dom.setStyle(acceptBox, "width", "300px");
	YAHOO.util.Dom.setStyle(acceptBox, "height", "150px");
	YAHOO.util.Dom.setStyle(acceptBox, "z-index", "1003");
	YAHOO.util.Dom.setStyle(acceptBox, "background-color", "white");
	YAHOO.util.Dom.setStyle(acceptBox, "opacity", "90");
	document.body.appendChild(acceptBox);

	acceptBox.innerHTML = '<center><br/>You must accept the <a href="http://community.nascar.com/go/info/community_standards" target="_blank"><b>Community Standards</b></a> in order to participate in the NASCAR.COM Community. By clicking the "Agree" button below, you acknowledge acceptance. <br/><br/><br/><span id="acceptLoading" style="display: none;"><img src="https://images.onesite.com/resources/images/admin/ajax-loader1.gif"></span><button id="acceptButton" type="button oneGlobalButton" onClick="acceptedTerms();"><span>Agree</span></button></center>';

	var dark = document.createElement("div");
	dark.id = "darkBG";
	YAHOO.util.Dom.setStyle(dark, "background-color", "black");
	YAHOO.util.Dom.setStyle(dark, "position", "absolute");
	YAHOO.util.Dom.setStyle(dark, "top", "0px");
	YAHOO.util.Dom.setStyle(dark, "left", "0px");
	YAHOO.util.Dom.setStyle(dark, "width", "100%");
	YAHOO.util.Dom.setStyle(dark, "height", "100%");
	YAHOO.util.Dom.setStyle(dark, "opacity", "0");
	YAHOO.util.Dom.setStyle(dark, "z-index", "1002");
	document.body.appendChild(dark);
	var newAttributes = {
	   opacity: { from:0, to: 0.8 }
	};
	
	var newAnim = new YAHOO.util.Anim(dark, newAttributes);
	newAnim.duration = .25;
	newAnim.animate();
}

/**
 * Fades the "Accept Community Standards" Box.
 *
 */
function fadeStandards() {

	dark = document.getElementById("darkBG");
	
	document.getElementById("acceptBox").style.display = 'none';
	
	var fadeoutattribs = {
		opacity: {to:0}
	};
	var fadeoutanim = new YAHOO.util.Anim(dark, fadeoutattribs);
	fadeoutanim.onComplete.subscribe(function() {
		dark.parentNode.removeChild(dark);
	});
	fadeoutanim.duration = .5;
	fadeoutanim.animate();
}

/**
 * Ajax to Accept the Community Standards.
 *
 */
function acceptedTerms() {
	document.getElementById("acceptButton").style.display = "none";
	document.getElementById("acceptLoading").style.display = "inline";
	
	var params = new Array();
	
	params['responseFunction'] = fadeStandards;
	params['templateName'] = "ajax/acceptTOS"
	params['responseType'] = 'JSON';
	params['action'] = 'loadTemplate';
	params['handlerName'] = 'one_ajax_templateLoader';
	params['requestType'] = 'class';
	OneAjax.request(params);
}