/* ImageReady Rollover Functions */

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		homeover = newImage("/images/nav/homeover.gif");
		contestsover = newImage("/images/nav/contestsover.gif");
		problemsover = newImage("/images/nav/problemsover.gif");
		resourcesover = newImage("/images/nav/resourcesover.gif");
		aboutover = newImage("/images/nav/aboutover.gif");
		contestsover2 = newImage("/images/homemap/contestsover.gif");
		problemsover2 = newImage("/images/homemap/problemsover.gif");
		resourcesover2 = newImage("/images/homemap/resourcesover.gif");
		aboutover2 = newImage("/images/homemap/aboutover.gif");
		poweredbycomap = newImage("/images/poweredbycomapover.gif");
		myprint = newImage("/images/printover.gif");
		preloadFlag = true;
	}
}

/* Functions to print a frame */
/* from http://www.webreference.com/js/tips/991123.html */

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage(frame, arg) {
//    alert("Use the File menu to print the window that opens, then close that window to return to this page.");
//    window.open(frame.location,"_blank","width=600,height=420,menubar=1,toolbar=1,scrollbars=1,status=1,location=1,resizable=1");
  if (frame == window) {
    printThis(frame);
  } else {
    link = arg; // a global variable 
    printFrame(frame);
  }
  return false;
}

function printThis(frame) {
  if (pr) { // NS4, IE5
    window.print();
  } else if (da && !mac) { // IE4 (Windows)
    vbPrintPage();
  } else { // other browsers
    alert("Use the File menu to print the window that opens, then close that window to return to this page.");
    window.open(frame.location,"_blank","width=600,height=420,menubar=1,toolbar=1,scrollbars=1,status=1,location=1,resizable=1");
  }
}

function printFrame(frame) {
  if (pr && da) { // IE5
    frame.focus();
    window.print();
    link.focus();
  } else if (pr) { // NS4
    frame.print();
  } else if (da && !mac) { // IE4 (Windows)
    frame.focus();
    setTimeout("vbPrintPage(); link.focus();", 100);
  } else { // other browsers
    alert("Use the File menu to print the window that opens, then close that window to return to this page.");
    window.open(frame.location,"_blank","width=600,height=420,menubar=1,toolbar=1,scrollbars=1,status=1,location=1,resizable=1");
  }
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}

// -->
