// BEGIN: center window
/*	function: newWin - opens a new window
		newWin takes on 7 values:
			WinURL: 		URL to be loaded into the new window
			WinNAME:		NAME of the popup window
			WinRESIZE:	"yes" or "no" value for the resize window property
			WinMENUBAR:	"yes" or "no" value for the menu window property
			WinLOCATION "yes" or "no" value for the location/address bar property
			WinTOOLBAR: "yes" or "no" value for the toolbar property
			WinSCROLL:	"yes" or "no" value for the scrollbars window property
			WinSTATUS:	"yes" or "no" value for the status bar window property
			WinWIDTH: 	WIDTH of the popup window
			WinHEIGHT:	HEIGHT of the popup window
			*/

function PopWin(WinURL, WinNAME, WinWIDTH, WinHEIGHT, WinSCROLL, WinMENU) {	
	//	variables passed by the link calling the function
	var URL = WinURL;
	var WINDOW_NAME = WinNAME;
	var WINDOW_WIDTH = WinWIDTH;
	var WINDOW_HEIGHT = WinHEIGHT;
	var WINDOW_SCROLL = WinSCROLL;
	var WINDOW_MENU = WinMENU;

	var POPUP_WIDTH = 320;
	var POPUP_HEIGHT = 410;
	var POPUP_RESIZE = "yes";
	var POPUP_MENUBAR = "no";
	var POPUP_LOCATION = "no";
	var POPUP_TOOLBAR = "no";
	var POPUP_SCROLL = "yes";
	var POPUP_STATUS = "no";

	//	window properties that determine the window attributes depending on what values are passed by the link calling the function
	var window_width = POPUP_WIDTH;
	var window_height = POPUP_HEIGHT;
	var window_resize = POPUP_RESIZE;
	var window_menubar = POPUP_MENUBAR;
	var window_location = POPUP_LOCATION;
	var window_toolbar = POPUP_TOOLBAR;
	var window_scroll = POPUP_SCROLL;
	var window_status = POPUP_STATUS;
	
	// check if parameters are passed
	if ((URL != null) || (URL != "")) {
		if ((WinWIDTH != null) || (WinWIDTH != "")) {
			window_width = WinWIDTH;
		}
		if ((WinHEIGHT != null) || (WinHEIGHT != "")) {
			window_height = WinHEIGHT;
		}
		if ((WinSCROLL != null) || (WinSCROLL != "") || (WinSCROLL != "undefined")) {
			window_scroll = WinSCROLL;
		}
		if ((WinMENU != null) || (WinMENU != "") || (WinMENU != "undefined")) {
			window_menubar = WinMENU;
		}

		var screen_balance_w = ((screen.width)-(window_width))/2;
		var screen_balance_h = ((screen.height)-(window_height))/2;
		var set_top = screen_balance_h;
		var set_left = screen_balance_w;	
	
		win = window.open(URL,WINDOW_NAME,'dependent=yes,resizable=' + window_resize + ',menubar=' + window_menubar + ',location=' + window_location + ',toolbar=' + window_toolbar + ',scrollbars=' + window_scroll + ',status=' + window_status + ',width=' + window_width + ',height=' + window_height + ',top=' +	set_top + ',left=' + set_left + '');
		win.focus();
	}
}
// END


// BEGIN: display year
function DispYear() {
	var date = new Date();
	var yy = date.getYear();
	var year = (yy < 1000) ? yy + 1900 : yy;
	
	document.write(year);
}
// END


// BEGIN: browser detection
function Is() {
	agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns6 = (this.ns && (this.major >= 5));
	this.ie = (agent.indexOf("msie") != -1);
	this.ie3 = (this.ie && (this.major < 4));
	this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
	this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
	this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
	this.ie6 = (this.ie && (agent.indexOf("msie 6.0")!=-1) );
}
// END


// BEGIN: print this page
function PrintPage() {
	window.print();
}
// END: print this page


// BEGIN: stylesheet switcher
// function for changing stylesheets using
// document.getElementsByTagName("link")
function setLinkedStyleSheet(title) {
	var linkNodes = document.getElementsByTagName("link");
	for ( i = 0; i < linkNodes.length; i++ ) {
		linkNode = linkNodes[i];
		relAttr = linkNode.getAttribute('rel');
		if ( relAttr && ( relAttr.indexOf("style") != -1 ) && linkNode.getAttribute("title") ) {
			linkNode.disabled = true;
			if ( linkNode.getAttribute("title") == title )
				linkNode.disabled = false;
		}
	}
}

// function for changing stylesheets using document.styleSheets
function setStyleSheet(theme) {
	for ( i = 0; i < document.styleSheets.length; i++ ) {
		if ( document.styleSheets[i].title ) {
			document.styleSheets[i].disabled = true;
			if ( document.styleSheets[i].title == theme )
				document.styleSheets[i].disabled = false;
		}
	}
}

function SwitchCSS() {
	var pgUrl = document.location.href.toLowerCase();

	setLinkedStyleSheet("printPrint");
	
	if (pgUrl.indexOf("?printver") > -1) {
		setLinkedStyleSheet("printAll");
	}
}

function PrintVersion() {
	var pgUrl = document.location.href.toLowerCase();
			pgUrl += "?printVer";

	PopWin(pgUrl,'print',744,'','yes','yes');
}

function viewPrivacyPolicy() {
   var openwin = "/fdp/resources/html/privacy-policy.html";
   var winviewattach = window.open(openwin, "View_Service_Info", "toobars=no,directories=no,location=no,menubar=no,resizable=yes,status=no,scrollbars=yes,width=500,height=600");
   winviewattach.moveTo(60,60);
}

function viewLegalNotice() {
   var openwin = "/fdp/resources/html/legal-notice.html";
   var winviewattach = window.open(openwin, "View_Service_Info", "toobars=no,directories=no,location=no,menubar=no,resizable=yes,status=no,scrollbars=yes,width=500,height=600");
   winviewattach.moveTo(60,60);
}
// END: style sheet switcher
