$(document).ready(function() {
	// Anytime a radio button is clicked in a ranking row, make sure no other radio buttons are clicked in the same row.
	$('tr.rankingrow td input').click( function(){ 
		var selectedInput = $(this);
		$(this).parent().parent().find('input').each(function(){
			if ($(this).attr('name') != selectedInput.attr('name'))
				$(this).attr('checked', false);
		});
	});
	
	// If a writein option is selected from a dropdown, need to display the write in box, and it needs to be required
	$('tr.selectrow td select').change( function(){ 
		if ($(this).find('option.other:selected').length){
			$(this).parent().parent().parent().find('td.otherrow').show();
			$(this).parent().parent().parent().find('td.otherrow input.otherrequire').attr('value','true');
		} else {
			$(this).parent().parent().parent().find('td.otherrow').hide();
			$(this).parent().parent().parent().find('td.otherrow input.other').attr('value','');
			$(this).parent().parent().parent().find('td.otherrow input.otherrequire').attr('value','false');
		}
	});
});


var popUpWin = 0;
function popup(url, width, height, bars, uleft, utop) {
	var left, top;

  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }

  if(!isNumber(uleft)){
		left = (screen.width/2) - width/2;
	} else {
		left = uleft;
	}

  if(!isNumber(utop)){
		top = (screen.height/2) - height/2;
	} else {
		top = utop;
	}

	agent = navigator.userAgent;
	windowName = 'popUpWin';
	params  = '';
	params += 'toolbar='+ bars +',';
	params += 'location=0,';
	params += 'directories=0,';
	params += 'status=0,';
	params += 'menubar='+ bars +',';
	params += 'scrollbars=1,';
	params += 'resizable=1,';
	params += 'width='+ width +',';
	params += 'height='+ height +',';
	params += 'left='+ left +',';
	params += 'top='+ top;
	popUpWin = window.open(url, windowName , params);
	if (!popUpWin.opener) {
		popUpWin.opener = window;
	}

	function isNumber(inputString)
	{
		return (!isNaN(parseInt(inputString))) ? true : false;
	}
}