/* ==================================================== *
 * TITLE   : Miracle League  | common.js                *
 * AUTHOR  : Kevin Scholl    | kscholl@comcast.net      *
 * CREATED : 20 Nov 2006     | UPDATED: 22 Nov 2006     *
 * ==================================================== */

/* ==================================================== *
 * GLOBAL VARIABLE(S)
 * ==================================================== */

var POPWIN = null;

/* =================================================== *
 * POPUP WINDOW: CLOSE EXISTING POPUP WINDOW
 * =================================================== */

function closePopWin(wndw) {
  if ((wndw != null) && (wndw.closed != true))
  	wndw.close();
	}

/* =================================================== *
 * POPUP WINDOW: DISPLAY POPUP WINDOW
 * =================================================== */

function popWindow(loc,w,h) {

  closePopWin(POPWIN);	// closes an existing popup window if user opens 
                				// new window before closing existing window
	
	if (!(w)) var winW = screen.width - 110; 
		else var winW = w;
	if (!(h)) var winH = screen.height - 160; 
		else var winH = h;
		
	var params  = "width=" + winW + ",height=" + winH + ",status=yes,toolbar=no,directories=no,scrollbars=yes,resizable=yes,menubar=no,location=no,top=50,left=50,screeny=50,screenx=50";

	POPWIN = window.open(loc,"MLR",params);
	POPWIN.focus;
	}
	
/* ==================================================== *
 * DISPLAY LARGE PHOTO
 * ==================================================== */
 
function viewPhoto(whichPhoto,w,h) {

  var picW = w; 
	var picH = h; 
		
	var params  = "width=" + picW + ",height=" + picH + ",status=no,toolbar=no,directories=no,scrollbars=no,resizable=1,menubar=no,location=no,top=50,left=50,screeny=50,screenx=50"

	POPWIN = window.open("","MLR",params);

  POPWIN.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
  POPWIN.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml">');
	POPWIN.document.writeln('<head><title>Miracle League of Richmond</title></head>');
  POPWIN.document.writeln('<body style="margin: 0; background-color: #FFF; padding: 0;">');
  POPWIN.document.writeln('  <div style="margin: 0; border: 0; padding: 0; background: transparent;">');
  POPWIN.document.writeln('    <a href="javascript:window.close();"><img src="' + whichPhoto + '" style="border: 0; width: '+ picW + '; height: '+ picH + ';" alt="Click to Close" title="Click to Close"></a>');
  POPWIN.document.writeln('  </div>');
  POPWIN.document.writeln('</body>');
  POPWIN.document.writeln('</html>');

	POPWIN.document.close();
  }
	
/* ==================================================== *
 * SEARCH, POWERED BY GOOGLE
 * ==================================================== */

function submitSearch() {
	var theForm = document.forms['srchMLR'];
  var kywrd   = theForm.srchTerms.value;
	var srchRng = theForm.srchRange.options[theForm.srchRange.selectedIndex].value;
	var srchLnk = "http://www.google.com/";
	
	switch (srchRng) {
		case "MLR":
		  srchLnk = srchLnk + "custom?sitesearch=www.miracleleagueofrichmond.com&q=" + kywrd;
			top.location = srchLnk;
			break;
		case "WWW":
		  srchLnk = srchLnk + "search?q=" + kywrd;
			top.location = srchLnk;
			break;
		default:
		  alert("Please select where you'd like to search...");
			return false;
		}

	}

function submitLogin() {
  document.forms['loginMLR'].submit();
	}