// RESULTS PAGE, currency converter
function newWin(url,win_name,par_width,par_height,par_resize,par_menubar,par_location,par_toolbar,par_status,par_scroll){
	remote = window.open(url,win_name,"top=10,left=10,width="+par_width+",height="+par_height+",resizable="+par_resize+",menubar="+par_menubar+",location="+par_location+",toolbar="+par_toolbar+",status="+par_status+",scrollbars="+par_scroll);
}

function popUp(){
	popWin = open('map_coords.php?map=$row[map]&x=$x&y=$y','myWin','width=$size[0],height=$size[1],resizable=1')
	popWin.focus() // brings the new window to the front
}
    
    
function moveUpDownList(listRight, direction){
	if(listRight.length == -1){
		alert("There are no values which can be moved!");
	}else{
		var selected = listRight.selectedIndex;
		if(selected == -1){
			alert("You must select an entry to be moved!");
		}else{
			if(listRight.length == 0 ){
				alert("There is only one entry!\nThe one entry will remain in place.");
			}else{
				// got past error checking and are ready to move item
				if(direction == 0){
					// down
					if(selected == listRight.length-1 ){
						alert("The last entry in the list cannot be moved down.");
					}else{
						// Get the text/value of the one directly below the hightlighted entry as
						// well as the highlighted entry; then flip them
						var moveText1 = listRight[selected+1].text;
						var moveValue1 = listRight[selected+1].value;
						var moveText2 = listRight[selected].text;
						var moveValue2 = listRight[selected].value;
						listRight[selected].text = moveText1;
						listRight[selected].value = moveValue1;
						listRight[selected+1].text = moveText2;
						listRight[selected+1].value = moveValue2;
						listRight.selectedIndex = selected+1; // Select the one that was selected before
					}
				}else if(direction == 1){
					// up
					if(selected==0){
					   alert("The first entry in the list cannot be moved up.");
					}else{
					   // Get the text/value of the one directly above the hightlighted entry as
					   // well as the highlighted entry; then flip them
					   var moveText1 = listRight[selected-1].text;
					   var moveValue1 = listRight[selected-1].value;
					   var moveText2 = listRight[selected].text;
					   var moveValue2 = listRight[selected].value;
					   listRight[selected].text = moveText1;
					   listRight[selected].value = moveValue1;
					   listRight[selected-1].text = moveText2;
					   listRight[selected-1].value = moveValue2;
					   listRight.selectedIndex = selected-1; // Select the one that was selected before
					}
				}
			}
		}
	}
}

function selectAll(list){
	//alert('list length='+list.length);
	for(var i=0; i<=list.length; i++){
		if(list.options[i].disabled == true){
			//alert('disabled');
			list.options[i].disabled = false;
		}
		list.options[i].selected = true;
	}
	return false;
}


function calendar(date){
	//If no parameter is passed use the current date.
	if(date == null)
		date = new Date();

	day = date.getDate();
	month = date.getMonth();
	year = date.getFullYear();

	months = new Array('January',
					'February',
					'March',
					'April',
					'May',
					'June',
					'July',
					'August',
					'September',
					'October',
					'November',
					'December');
         
	this_month = new Date(year, month, 1);
	next_month = new Date(year, month + 1, 1);

	//Find out when this month starts and ends.         
	first_week_day = this_month.getDay();
	days_in_this_month = Math.floor((next_month.getTime() - this_month.getTime()) / (1000 * 60 * 60 * 24));

	calendar_html = '<table class="jsCalTable" cellspacing="1" cellpadding="1">';
	calendar_html += '<tr><td colspan="7" align="center">' + months[month] + ' ' + year + '</td></tr>'
	calendar_html += '<tr>';
	calendar_html += '<tr align="center"><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>'
	calendar_html += '<tr>';

	//Fill the first week of the month with the appropriate number of blanks.       
	for(week_day = 0; week_day < first_week_day; week_day++){
		calendar_html += '<td class="jsCalBlanks">&nbsp; </td>';   
	}
            
	week_day = first_week_day;
	for(day_counter = 1; day_counter <= days_in_this_month; day_counter++){
		week_day %= 7;
		if(week_day == 0)
			calendar_html += '</tr><tr>';

		//Do something different for the current day.
		if(day == day_counter)
			calendar_html += '<td align="center" class="jsCalToday"><b>' + day_counter + '</b></td>';
		else
			calendar_html += '<td align="center"  class="jsCalDays"> ' + day_counter + ' </td>';
		
		week_day++;
	}

	calendar_html += '</tr>';
	calendar_html += '</table>';
         
	//Display the calendar.     
	document.write(calendar_html);                  
}
