<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
	newWin = window.open(theURL,winName,features);
	newWin.focus();
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
}

function hkec_showHideLayers() {
	if (typeof(hkec_disable_hideshow) == "undefined" || hkec_disable_hideshow == 1) {
		return;
	}
	var i,p,v,d,oIframe,oParent,oDiv,args=hkec_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) {
		if (oDiv = document.getElementById(args[i])) {
			v=args[i+2];
			if (oDiv.style) {
				/*@cc_on
				@if (@_jscript_version >= 5)
				try {
					oIframe = document.getElementById('o'+args[i]);
					oIframe.scrolling = 'no';
				}
				catch (e) {
					oIframe = document.createElement('iframe');
					oIframe.id = 'o'+args[i];
					oParent = oDiv.parentNode;
					oParent.appendChild(oIframe);
				}
    			oIframe.frameborder = 0;
    			oIframe.style.position = 'absolute';
    			oIframe.style.top = 0;
    			oIframe.style.left = 0;
    			oIframe.style.display = 'none';
				@end @*/
				if (v=='show') {
					var layer_top = parseInt(oDiv.style.top);
					var layer_height = parseInt(oDiv.style.height);
					if (document.all)
						var scrollY = document.body.scrollTop;
					else
						var scrollY = self.pageYOffset;
					if (document.body.clientHeight)
						var iheight = document.body.clientHeight;
					else if (window.innerheight)
						var iheight = window.innerheight;
					else if (document.documentElement.clientHeight)
						var iheight = document.documentElement.clientHeight;
					var total_height = layer_top + layer_height - scrollY;
					if (total_height > iheight)
						oDiv.style.top = (layer_top - total_height + iheight) + "px";
					else if (layer_top - scrollY < 0)
						oDiv.style.top = scrollY + "px"
        			oDiv.style.display = 'block';
        			oDiv.style.visibility = 'visible';
        			/*@cc_on
        			@if (@_jscript_version >= 5)
        			oIframe.style.top = oDiv.style.top;
        			oIframe.style.left = oDiv.style.left;
        			oIframe.style.zIndex = oDiv.style.zIndex - 1;
        			oIframe.style.width = parseInt(oDiv.offsetWidth);
        			oIframe.style.height = parseInt(oDiv.offsetHeight);
        			oIframe.style.display = 'block';
        			@end @*/
				}
				else {
        			oDiv.style.visibility = 'hidden';
    				oDiv.style.display = 'none';
        			/*@cc_on
        			@if (@_jscript_version >= 5)
        			oIframe.style.display = 'none';
        			@end @*/
				}
			}
		}
	}
	return;
}

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];
		}
	}
}
preloadFlag = false;

// Set the banner image and URL in English campus
function set_banner(image, url) {
	var i;

	document.adbanner.src = image;

	for (i=0; i<document.links.length; i++) {
		if (document.links[i].name=="adlink") {
			document.links[i].href = url;
		}
	}
}

// Open url in opener window
function opener_go(url)
{
	opener.location = url;
	window.close();
}

function show_hide_category() {
		var i,p,v,obj,args=show_hide_category.arguments;
		for (i=0; i<(args.length-2); i+=3)
			if ((obj=MM_findObj(args[i]))!=null) {
				v=args[i+2];
				if (obj.style) {
					obj=obj.style;
					v=(obj.display=='none')?'block':(obj.display='block')?'none':v;
				}
					obj.display=v;
				}
}

function MM_nbGroup(event, grpName) { //v6.0
	var i,img,nbArr,args=MM_nbGroup.arguments;
	if (event == "init" && args.length > 2) {
		if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
			img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
			if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
			nbArr[nbArr.length] = img;
			for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
				if (!img.MM_up) img.MM_up = img.src;
				img.src = img.MM_dn = args[i+1];
				nbArr[nbArr.length] = img;
		} }
	} else if (event == "over") {
		document.MM_nbOver = nbArr = new Array();
		for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
			if (!img.MM_up) img.MM_up = img.src;
			img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
			nbArr[nbArr.length] = img;
		}
	} else if (event == "out" ) {
		for (i=0; i < document.MM_nbOver.length; i++) {
			img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
	} else if (event == "down") {
		nbArr = document[grpName];
		if (nbArr)
			for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
		document[grpName] = nbArr = new Array();
		for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
			if (!img.MM_up) img.MM_up = img.src;
			img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
			nbArr[nbArr.length] = img;
	} }
}

function checkbox_is_checked(obj, name){

	name = name.replace(/\[/, "\\[");
	name = name.replace(/\]/, "\\]");

	for (var i=0;i<obj.elements.length;i++) {
		var e   = obj.elements[i];
				str = e.name;

		if(str.search("^"+name) != -1) {
			if (e.checked > 0)
				return true;
		}
	}
	return false;
}

function button_is_checked(obj, name){

	obj_name = "document."+ obj.name + "." +name ;
	this_obj = eval(obj_name);
	var len_of_object  = this_obj.length ;

	for(i=0; i < len_of_object ; i++){
		if(this_obj[i].checked)
			return true;
	}

	return false;

}

function trim(inputString) {
	 // Removes leading and trailing spaces from the passed string. Also removes
	 // consecutive spaces and replaces it with one space. If something besides
	 // a string is passed in (null, custom object, etc.) then return the input.

	 if (typeof inputString != "string") { return inputString; }
	 var retValue = inputString;
	 var ch = retValue.substring(0, 1);

	 while (ch == " ") { // Check for spaces at the beginning of the string
			retValue = retValue.substring(1, retValue.length);
			ch = retValue.substring(0, 1);
	 }

	 ch = retValue.substring(retValue.length-1, retValue.length);
	 while (ch == " ") { // Check for spaces at the end of the string
			retValue = retValue.substring(0, retValue.length-1);
			ch = retValue.substring(retValue.length-1, retValue.length);
	 }

	 while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
			retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	 }

	 return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function


///Get Selected index of the radio button. If nothing selected, return -1;
function get_selected_index(obj) {
	for(var i=0; i<obj.length; i++) {
		if(obj[i].checked) {
			return i;
		}
	}
	return -1; //not checked
}

function validateForm_is_email(str) {
	p=str.indexOf('@');
	if (p<1 || p==(str.length-1)) {
		return false;
	}
	else {
		return true;
	}
}

function bas_getScrollPos() {
	if (window.pageYOffset) {
		return {y:window.pageYOffset, x:window.pageXOffset};
	}
	if (document.documentElement && document.documentElement.scrollTop) {
		return {y:document.documentElement.scrollTop, x:document.documentElement.scrollLeft};
	}
	if (document.body) {
		return {y:document.body.scrollTop, x:document.body.scrollLeft};
	}
	return {x:0, y:0};
}

function bas_getWindowDims() {
	if (window.innerWidth) {
		return {w:window.innerWidth, h:window.innerHeight};
	}
	if (document.documentElement && document.documentElement.clientWidth) {
		return {w:document.documentElement.clientWidth, h:document.documentElement.clientHeight};
	}
	if (document.body) {
		return {w:document.body.clientWidth, h:document.body.clientHeight};
	}
	return {w:0, h:0}
}

function bas_URLEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				alert( "Unicode Character '"
						+ ch
						+ "' cannot be encoded using standard URL encoding.\n" +
						  "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
};

function bas_URLDecode(encoded)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef";
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
	   var ch = encoded.charAt(i);
	   if (ch == "+") {
		   plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2)
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
};

function bas_in_array(needle, haystack) {
	var n = haystack.length;
	for (var i=0; i<n; i++) {
		if (haystack[i]==needle) {
			return true;
		}
	}
	return false;
}
//-->