
var RULI = (GetCookie('regname') != null);

function GetCookie(sName) {
	
	 
	
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++) {
		
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
			return unescape(aCrumb[1]);
	}
	
	
	return null;
  
}

function SetCookie(sName, sValue) {
	document.cookie = sName + "=" + escape(sValue) + ";";
}

function NoSSL(atag) {

	var url = atag.href;
	
	if (url.substr(0,8).toLowerCase() == 'https://')
		atag.href = 'http://www.nzmp.com' + url.substr(url.indexOf('/',8)); 
		
}

function GoRegURL(url) {

	if (url.charAt(0) == '/') 
		url = 'https://www.nzmp.com' + url; 
		
	if (RULI) {
		location.href = url;
	} else {
		OpenRegPopup('https://www.nzmp.com/cda/registration/popup/1,6714,,00.html?fUrl=https%3A%2F%2Fwww%2Enzmp%2Ecom%2Fcda%2Fregistration%2Frestricted%5Farea%2F1%2C6710%2C%2C00%2Ehtml&fTitle=NZMP+Restricted+Area&fResize=380%2C395&fUrlParameters='+escape('url='+url), 380, 395);
	}

}

function OpenRegPopup(url, width, height, scrollbars) {

	isIE = window.navigator.userAgent.indexOf("MSIE ") != -1;
	
	numargs = arguments.length;

	if (numargs < 4) scrollbars = 'no';
	
	if (isIE) {
		if (numargs < 3) height = 400;
		if (numargs < 2) width = 400;
		resizable = 'yes';
	} else {
		height = 400;
		width = 400;
		resizable = 'no';	
	}
	
	params = 'toolbar=0,location=0,directories=0,status=0,menubar=0';
	params += ',top=20,left=20';
	params += ',resizable=' + resizable;
	params += ',height=' + height;
	params += ',width=' + width;
	params += ',scrollbars=' + scrollbars;
	
	win = window.open(url, 'registrationpopup', params, true);
	win.focus();
	
	return win;

}

function DoLogin() {

	if (RULI) {
		OpenRegPopup('https://www.nzmp.com/cda/registration/popup/1,6714,,00.html?fUrl=https%3A%2F%2Fwww%2Enzmp%2Ecom%2Fcda%2Fregistered%2Fregistration%2Flogon%5Fsuccess%2F1%2C6712%2C%2C00%2Ehtml&fTitle=Already+Logged+In&fResize=380%2C190', 380,190);
	} else {
		top.window.location.href = 'https://www.nzmp.com/cda/registered/registration/logon/1,6708,,00.html';
	}
}

function DoRegistration() {

	OpenRegPopup('https://www.nzmp.com/cda/registration/popup/1,6714,,00.html?fUrl=https%3A%2F%2Fwww%2Enzmp%2Ecom%2Fcda%2Fregistration%2Foptions%2F1%2C6703%2C%2C00%2Ehtml&fTitle=Registration+Options&fResize=380%2C330', 380, 330);

}


