var popupClasses = {
	poll: 				"height=580,width=580,scrollbars=1,resizable=1",
	pollaladdin:		"height=580,width=280,scrollbars=1,resizable=1",
	multipoll: 			"height=580,width=580,scrollbars=1,resizable=1",
	sendto: 			"height=700,width=580,scrollbars=1,resizable=1",
	print: 				"height=700,width=580,scrollbars=1,resizable=1",
	standard: 			"height=700,width=580,scrollbars=1,resizable=1",
	mailinglist:		"width=500,height=300",
	dntv:				"width=940,height=620,scrollbars=0,resizable=0",
	efreg:				"width=400,height=300,scrollbars=0",
	efremind:			"width=400,height=200,scrollbars=0",
	svtplay:			"width=790,height=600,scrolling=no,resizable=no,status=yes",
	largevideoplayer:	"width=790,height=600,scrolling=no,resizable=no,status=yes"
};

/*
   Method used to handle popups and external links
 */
function process_links() {
	
	// regex
	var regex = /([A-Za-z0-9]+)w([0-9]{2,4})h([0-9]{2,4})([sr])?([sr])?/g;
	
	// function for processing popup links
	$("a.popup").click(function(event) {
		var classNames = this.className.split(' ');
		var popupName = null;
		var popupProps = null;
		for(var index in classNames) {
			var key = classNames[index];
			var arr;
			if(popupClasses[key] != null) {
				popupName = key;
				popupProps = popupClasses[popupName];
				break;
			}
			else if(arr = regex.exec(key)) {
				popupName = arr[1];
				var width = arr[2];
				var height = arr[3];
				var scrolling = (arr[4] == 's' || arr[5] == 's');
				var resizable = (arr[4] == 'r' || arr[5] == 'r');
				popupProps = "width="+width+",height="+height+",scrolling="+scrolling+",resizable="+resizable;
			}
		}
		if (popupName == null) {
			popupName = "standard";
			popupProps = popupClasses[popupName];
		} 
		// open new window
		var popup = window.open(this.href, popupName, popupProps);
		if(window.focus)
			popup.window.focus();
		// prevent browser from following link
		event.preventDefault();
		return false;
	});
	
	// functions for processing external links
	$("span.external_link a").attr("target", "_blank");
	$("a.external").attr("target", "_blank");
	$("a.blank").attr("target", "_blank");
}

/*
	 Method used to submit form data to new windows.
 */
function submitToNewWindow(form, winName, noSubmit) {
		if( ! winName)
			winName = "standard";
    if (form) {
			// get windows params
			var winParams = popupClasses[winName];
			if(winParams == null)
				winParams = popupClasses["standard"];
			// open new window
      newWindow = window.open("", winName, winParams);
			// submit to this window
      form.target = winName;
			if(noSubmit==true) return;
      form.submit();
    }
}