﻿jQuery(function () {
	var sFontSize = Get_Cookie("_nzrelay_fontsize");
	var sLineHeight = Get_Cookie("_nzrelay_lineheight");
	var sContrast = Get_Cookie("_nzrelay_contrasts");
	if (sFontSize === null) {
		sFontSize = "10pt"
		Set_Cookie("_nzrelay_fontsize", sFontSize, 7, "/", "", "");
	}
	if (sLineHeight === null) {
		sLineHeight = "18px"
		Set_Cookie("_nzrelay_lineheight", sLineHeight, 7, "/", "", "");
	}
	if (sContrast === null) {
		sContrast = "Normal"
		Set_Cookie("_nzrelay_contrasts", sContrast, 7, "/", "", "");
	}
	AdjFont(sFontSize, sLineHeight);
	AdjContrast(sContrast);
});
function ModFont(fontsize, lineheight) {
	if (Get_Cookie('_nzrelay_fontsize')) {
		Delete_Cookie("_nzrelay_fontsize");
		Set_Cookie("_nzrelay_fontsize", fontsize, 7, "/", "", "");
	}
	if (Get_Cookie('_nzrelay_lineheight')) {
		Delete_Cookie("_nzrelay_lineheight");
		Set_Cookie("_nzrelay_lineheight", lineheight, 7, "/", "", "");
	}
	AdjFont(fontsize, lineheight);
}
function ModContrast(sContrast) {
	if (Get_Cookie('_nzrelay_contrasts')) {
		Delete_Cookie("_nzrelay_contrasts");
		Set_Cookie("_nzrelay_contrasts", sContrast, 7, "/", "", "");
	}
	AdjContrast(sContrast);
}
function AdjFont(fontsize, lineheight) {
	jQuery(".PageContent").css("font-size", fontsize).css("line-height", lineheight);
	jQuery(".PageContent span").css("font-size", fontsize).css("line-height", lineheight);
	jQuery(".PageContent div").css("font-size", fontsize).css("line-height", lineheight);
	jQuery(".PageContent ol li").css("font-size", fontsize).css("line-height", lineheight);
	jQuery(".PageContent ul li").css("font-size", fontsize).css("line-height", lineheight);

	jQuery(".Frame > .SideMenu > a").css("font-size", fontsize).css("line-height", lineheight);
	jQuery(".Frame > .Menu > div > a").css("font-size", fontsize).css("line-height", lineheight);
}
function AdjContrast(sContrast) {
	jQuery(".BodyStyle").removeClass("WhiteBlue");
	jQuery(".BodyStyle").removeClass("YellowBlack");
	if (sContrast !== 'Normal') {
		jQuery(".BodyStyle").addClass(sContrast);
		jQuery(".PageContent span").removeAttr("style");
	}
}
function Get_Cookie(check_name) {
	var a_all_cookies = document.cookie.split(';');
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; 
	var i = '';
	for (i = 0; i < a_all_cookies.length; i++) {
		a_temp_cookie = a_all_cookies[i].split('=');
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if (cookie_name == check_name) {
			b_cookie_found = true;
			if (a_temp_cookie.length > 1) {
				cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if (!b_cookie_found) {
		return null;
	}
}
function Set_Cookie(name, value, expires, path, domain, secure) {
	var today = new Date();
	today.setTime(today.getTime());
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + (expires));
	document.cookie = name + "=" + escape(value) +
		((expires) ? ";expires=" + expires_date.toGMTString() : "") + 
		((path) ? ";path=" + path : "") +
		((domain) ? ";domain=" + domain : "") +
		((secure) ? ";secure" : "");
}
function Delete_Cookie(name, path, domain) {
	if (Get_Cookie(name)) document.cookie = name + "=" +
			((path) ? ";path=" + path : "") +
			((domain) ? ";domain=" + domain : "") +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function SubmitDetails(){
	var sName=jQuery('#edtName').val();
	var sEmail=jQuery('#edtEmail').val();
	var sPhone=jQuery('#edtPhone').val();
	var sAddress1=jQuery('#edtAddress_1').val();
	var sAddress2=jQuery('#edtAddress_2').val();
	var sAddress3 = jQuery('#edtAddress_3').val();
	var sCategory = jQuery("input[@name='Category']:checked").val();   
	if(sName!=""){
		if(sEmail!=""){
			if(sPhone!=""){
				if(sAddress1!=""){
					if(sAddress2!=""){
						if(sAddress3!=""){
							jQuery.ajax({ timeout: 10000, url: '/Subscribe/?flow=savedetails&name=' + sName + '&email=' + sEmail + '&phone=' + sPhone + '&address1=' + sAddress1 + '&address2=' + sAddress2 + '&address3=' + sAddress3 + '&category=' + sCategory, success: function (data) { alert("Success! Your details has been saved."); }, error: function (msg) { alert('Error has occured: ' + msg); } });
						} else {
							alert('Please supply details for all of the fields within this form and try again.');
						}
					} else {
						alert('Please supply details for all of the fields within this form and try again.');
					}
				} else {
					alert('Please supply details for all of the fields within this form and try again.');
				}
			} else {
				alert('Please supply details for all of the fields within this form and try again.');
			}
		} else {
			alert('Please supply details for all of the fields within this form and try again.');
		}
	} else {
		alert('Please supply details for all of the fields within this form and try again.'); 
	}
}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18204976-1']);
_gaq.push(['_trackPageview']);

(function () {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
