/*
 *  Displays a modal dialogue to the user. They are them promoted to agree/disagree to the terms and conditions
 *  Agreeing with the terms allows access to the site
 *  Disagreeing with the terms redirects the user to another page
 *  A cookie is set to remember the status of the user choice.
 *  
 *  Requires: Jquery Cookie plug-in
 *  
 */
$(document).ready(function(){
 //   var cookieExpires = 1;
    var redirectLoc = "/mgl/uk/mfg"
	
    var showModal = $.cookie("Macquarie-mfg-uk-fund-center");

	// Displays a modal dialogue when the page loads if no cookie exists
	if(showModal==null){
		$("#md_popup_notice_fund_center").modal({
			close:false,
			escClose:false
		});
		$("#md_popup_notice_fund_center").focus();
	};
	
	// User clicked Yes. Close the modal dialog
	$(".md_yes").click(function(){

		// Set the cookie value to true
		$.cookie("Macquarie-mfg-uk-fund-center", "true", {
            path: '/mgl'
   //         expires: cookieExpires
        });

		$.modal.close();

		return false;
	});

	// User clicked No. Send the user to a different page
	$(".md_no").click(function(){
		window.location = redirectLoc;
		return false;
	});
});

function showDisclaimerButtons() {
	if( document.getElementById('chk_adviser').checked ) {
		document.getElementById('div_close').style.display='none';
		document.getElementById('div_proceed').style.display='block';
	}
	else {
		document.getElementById('div_close').style.display='block';
		document.getElementById('div_proceed').style.display='none';
	}
}

function cookiedDiv() {
	/*createCookie('uk-disclaimer','true',30);
	$('#popup-wrapper-2').hide();
	document.getElementById('chk_adviser').checked = false;
	$('#page-wrapper').fadeIn('slow');*/
	
	$.cookie("Macquarie-mfg-uk-fund-center", "true", {
            path: '/mgl'
})
	$.modal.close();

		return false;
}

/*function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}*/

