function showTNC(){
	var div = document.createElement('div'); // container for the tnc content
	var p = document.createElement('p'); // paragraph containing the tnc content
	
	// create checkbox for user to agree on the terms and conditions
	var inp = document.getElementById('AgreeTNC_checkbox');
	if (!inp){						
		inp = document.createElement('input');
		inp.id = 'AgreeTNC_checkbox';
		inp.type = 'checkbox';
		inp.setAttribute('onclick','setTNC(this)');
		if ($('#AgreeTNC').val() == 1){inp.style.display = 'none';}
	}
	if ($('#AgreeTNC').val() == 1){inp.setAttribute('checked','checked');} // tick the checkbox, depending on the hidden field value
	
	var label =  document.createElement('label'); // label for the the checkbox
	label.setAttribute('for','AgreeTNC_checkbox'); // assign the label to the checkbox
	if ($('#AgreeTNC').val() == 1){label.style.display = 'none';}
	
	var txtLabel = document.createTextNode(' Don\'t show this message again.'); // text for the label
	
	p.innerHTML = $('#TNCContent').html(); // assign text to the paragraph
	label.appendChild(txtLabel); // assign text to the label
	
	// assign all elements to the div
	div.appendChild(p);
	div.appendChild(inp);
	div.appendChild(label);

	$.prompt(div.innerHTML,{ buttons: { Close: true }, prefix:'jqirebcal', top:'5%'});
	
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

$(document).ready(function() { 
	var popup = getCookie("popup");
	if (!popup){	
		showTNC();
	}
});

function setTNC(obj){
	$('#AgreeTNC').val((obj.checked)? 1 : 0 );
	var tnc = $('#AgreeTNC').val();
	if(tnc == 1){
		document.cookie="popup"+"="+"true";	
	}else{
		document.cookie="popup"+"="+"";
	}
}	

function showEStatement(){
	var div = document.createElement('div'); // container for the tnc content
	var p = document.createElement('p'); // paragraph containing the tnc content
	
	// create checkbox for user to agree on the terms and conditions
	var inp = document.getElementById('AgreeTNC_checkbox');
	if (!inp){						
		inp = document.createElement('none');
	}
	
	var label =  document.createElement('label'); // label for the the checkbox		
	p.innerHTML = $('#eStatementContent').html(); // assign text to the paragraph
	
	// assign all elements to the div
	div.appendChild(p);
	div.appendChild(inp);
	div.appendChild(label);

	$.prompt(div.innerHTML,{ buttons: { Close: true }, prefix:'jqiEST', top:'10%'});
	
}			
