var popupStatus = 0;

function loadPopup(){
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7",
			"height": document.documentElement.clientHeight
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#googleCompliance").fadeIn("fast");
		popupStatus = 1;
	}
}

function closePopup(){
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#googleCompliance").fadeOut("fast");
		popupStatus = 0;
	}
}

$(document).ready(function(){
	if( typeof activateC2A != 'function' ){
		document.write ('error: the function "activateC2A" has not been defined');
		return;
	}

	$("#googleClose,#googleNee").click(function(){
		closePopup();
	});

	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1)	closePopup();
	});

	$("#googleJa").click(function(){

		$('#agree').after('<input type="checkbox" id="agree" checked=checked /><input type="hidden" name="agree" value="1" />').remove();

		closePopup();
		activateC2A();
	});
});