// OLGLO NMM Main Javascript

function setFontSize(size) {
	if (size) {
		var cssHref = $("#cssFontSize").attr("href");
		var path = cssHref.substring(0,(cssHref.indexOf("nmm_")+4))+size+".css";
			//$("#cssFontSize").attr("href",cssHref.substring(0,(cssHref.indexOf("nmm_")+4))+size+".css");
		$("#cssFontSize").attr("href",path);
		createCookie("style",size,365);
	}
}

function getFontSize() {
	var cssHref = $("#cssFontSize").attr("href");
	return cssHref.substring((cssHref.indexOf("nmm_")+4),(cssHref.length - 4));
}

// from OLG
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 expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function open_popup(src, name, width, height,location,menubar,resizeable,scrollbars,status,titlebar,toolbar,hotkeys)
{
	var xposition = ((screen.availWidth - width)/2);
	var yposition = ((screen.availHeight - height)/2);
	var win;
	var args =	"width=" + width + "," 
					+ "height=" + height + "," 
					+ "location=" + location + "," 
					+ "menubar=" + menubar + ","
					+ "resizable=" + resizeable + ","  
					+ "scrollbars=" + scrollbars + "," 
					+ "status=" + status + ","
					+ "titlebar=" + titlebar + ","
					+ "toolbar=" + toolbar + ","
					+ "hotkeys=" + hotkeys + "," 
					+ "screenx=" + xposition + ","
					+ "screeny=" + yposition + ","
					+ "left=" + xposition + ","
					+ "top=" + yposition;     

	win = window.open(src, name, args);
	win.focus();
}
// end from OLG

$(function() {
  var cookie = readCookie("style");
  var size = cookie ? cookie : getFontSize();
  setFontSize(size);
});

