﻿<!--
if (pullArray == null)	var pullArray;

function changeLanguage(target) {
	var nowL = 'chi';
	var url = location.href.replace((nowL+'/'), (target+'/'));
	location.href = url;
}

var tempFolder;
function btnOver(id, over, pulldownGo) {
	if (section == 0) {
		tempFolder = "common";
	} else {
		tempFolder = "common";
	}
	if (over == 1) {
		eval('mainBtn_'+id).src = path+'images/'+tempFolder+'/btn_'+sectionIdArray[id-1]+'_f2.gif';
		
		if (pulldownGo == 1 && document.getElementById('pulldown_'+id))	document.getElementById('pulldown_'+id).style.visibility = 'visible';
	} else {
		if (pulldownGo == 1) {
			eval('mainBtn_'+id).src = path+'images/'+tempFolder+'/btn_'+sectionIdArray[id-1]+'.gif';
		}
		
		if (document.getElementById('pulldown_'+id))	document.getElementById('pulldown_'+id).style.visibility = 'hidden';
	}
}

function NewWindow(mypage, myname, w, h, scroll,resizable) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resizable+','
	win = window.open(mypage, myname, winprops)
	win.self.focus()
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

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();
}
MM_reloadPage(true);

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_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 MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpEventMenu(targ,url,selObj,restore){ //v3.0, modified by Sam Wong
  eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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_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_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 genFlash(file, width, height, id, vars) {	
	tempHTML = '	<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'">';
	tempHTML += '	<param name="movie" value="'+file+'">';
	tempHTML += '	<param name="quality" value="high">';
	tempHTML += '	<param name="menu" value="false">';
	tempHTML += '	<param name="wmode" value="opaque">';
	tempHTML += '	<param name="scale" value="noscale">';
	tempHTML += '	<param name="salign" value="TL">';
	
	if (vars != null) {
		tempHTML += '	<param name="flashVars" value="'+vars+'">';
		tempHTML += '	<embed src="'+file+'" flashVars="'+vars+'" salign="TL" quality="high" scale="noscale" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	} else {
		tempHTML += '	<embed src="'+file+'" salign="TL" quality="high" scale="noscale" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	}
	
	tempHTML += '	</object>';
	
	document.write(tempHTML);
}

var motion;
var motion1;
var goSpeed = 30;
var tempNum;
var tempNum1;
var frameBody;
var frameBody1;
var temp1 = 0;
var temp2 = 0;
var isIFrame = false;

function autoScrollStart(name, name1) {
	setTimeout("autoScrollGo()", 4000);
//	scrollStop();
	frameBody  = document.getElementById(name);
	frameBody1  = document.getElementById(name1);
	
	//window.status = frameBody.scrollWidth;
}

function autoScrollGo() {
	autoScrollMotion();
	autoScrollMotion1();
}

function autoScrollMotion(){
	if (frameBody.scrollTop < (frameBody.scrollHeight - 68)) {
		frameBody.scrollTop += 1;
	} else {
		if (temp1 - frameBody.scrollHeight > 25) {
			frameBody.scrollTop = 0
			temp1 = 0;
			clearTimeout(motion);
			setTimeout("autoScrollMotion()", 4000);
			return false;
		}
	}
	temp1 += 1;
	
	//window.status = frameBody.scrollTop + "  :  " + frameBody.scrollHeight;
	//window.status = temp1;
	
	
	motion = setTimeout("autoScrollMotion()", (goSpeed*3));
}

function autoScrollMotion1(){
	if (frameBody1.scrollTop < (frameBody1.scrollHeight - 68)) {
		frameBody1.scrollTop += 1;
	} else {
		if (temp2 - frameBody1.scrollHeight > 25) {
			frameBody1.scrollTop = 0
			temp2 = 0;
			clearTimeout(motion1);
			setTimeout("autoScrollMotion1()", 4000);
			return false;
		}
	}
	temp2 += 1;	
	
	motion1 = setTimeout("autoScrollMotion1()", (goSpeed*3));
}

function scrollStart(name, goNum, iFrame) {
	scrollStop();
	tempNum = goNum;
	if (navigator.appName.indexOf("Microsoft") > -1) {
		if (iFrame != null) {
    		frameBody  = document.frames(name).document.body;
    		isIFrame = true;
    	} else {
    		frameBody  = document.getElementById(name);
    	}
	} else {
		if (iFrame != null) {
    		frameBody  = document.all(name);
    	//	frameBody.contentWindow.scrollTo(0, 0);
    		isIFrame = true;
    	} else {
    		frameBody  = document.getElementById(name);
    	}
	}
	scrollMotion();
}

function scrollMotion(){
//	window.status = document.getElementById("contentIFrame").document.body.scrollHeight +"  :  "+ frameBody.offsetHeight;
	if (navigator.appName.indexOf("Microsoft") > -1) {
		frameBody.scrollTop += tempNum;
	} else {
		if (isIFrame) {
			tempX = frameBody.contentWindow.pageXOffset;
			tempY = frameBody.contentWindow.pageYOffset;
			tempY += tempNum;
			frameBody.contentWindow.scrollTo(tempX, tempY);
		} else {
			frameBody.scrollTop += tempNum;
		}
	}
	
	motion = setTimeout("scrollMotion()", goSpeed);
}

function scrollStart1(name, goNum, iFrame) {
	scrollStop1();
	tempNum1 = goNum;
	if (navigator.appName.indexOf("Microsoft") > -1) {
		if (iFrame != null) {
    		frameBody1  = document.frames(name).document.body;
    		isIFrame = true;
    	} else {
    		frameBody1  = document.getElementById(name);
    	}
	} else {
		if (iFrame != null) {
    		frameBody1 = document.all(name);
    	//	frameBody.contentWindow.scrollTo(0, 0);
    		isIFrame = true;
    	} else {
    		frameBody1  = document.getElementById(name);
    	}
	}
	scrollMotion1();
}

function scrollMotion1(){
//	window.status = document.getElementById("contentIFrame").document.body.scrollHeight +"  :  "+ frameBody.offsetHeight;
	if (navigator.appName.indexOf("Microsoft") > -1) {
		frameBody1.scrollTop += tempNum1;
	} else {
		if (isIFrame) {
			tempX = frameBody1.contentWindow.pageXOffset;
			tempY = frameBody1.contentWindow.pageYOffset;
			tempY += tempNum1;
			frameBody1.contentWindow.scrollTo(tempX, tempY);
		} else {
			frameBody1.scrollTop += tempNum1;
		}
	}
	
	motion1 = setTimeout("scrollMotion1()", goSpeed);
}

function scrollStop() {
	temp1 = frameBody.scrollTop;
	clearTimeout(motion);
}

function scrollStop1() {
	temp2 = frameBody1.scrollTop;
	clearTimeout(motion1);
}


function topMenuOver(i, over) {
	if (document.getElementById('topNavMenu'+i))	var layer = document.getElementById('topNavMenu'+i);
	if (over == 1) {
		document.getElementById('topNavText'+i).style.backgroundColor = '#B78900';
		document.getElementById('topNavBtn'+i).src = path+'images/common/arrow_white_b.gif';
		if (layer)	layer.style.visibility = 'visible';
	} else {
		document.getElementById('topNavText'+i).style.backgroundColor = '';
		document.getElementById('topNavBtn'+i).src = path+'images/common/arrow_white_r.gif';
		if (layer)	layer.style.visibility = 'hidden';
	}
}

function topSubMenuOver(i, j, over) {
	if (document.getElementById('topNavMenu'+i+j))	var layer = document.getElementById('topNavMenu'+i+j);
	if (over == 1) {
		document.getElementById('topNavText'+i+j).style.color = '#996600';
		document.getElementById('topMenuLine'+i+j).style.backgroundColor = '#D5D7DA';
		if (layer)	layer.style.visibility = 'visible';
	} else {
		document.getElementById('topNavText'+i+j).style.color = '#101F41';
		document.getElementById('topMenuLine'+i+j).style.backgroundColor = '';
		if (layer)	layer.style.visibility = 'hidden';
	}
}


function mainMenuOver(i, over, isSect) {
	if (document.getElementById('mainNavMenu'+i))	var layer = document.getElementById('mainNavMenu'+i);
	if (over == 1) {
		if (!isSect)	document.getElementById('mainNavText'+i).style.color = '#996600';
		if (layer) {
			if (!isSect)	document.getElementById('mainMenuLine'+i).style.backgroundColor = '#CC9900';
			layer.style.visibility = 'visible';
		}
		if (pullArray) {
			for (var i=0; i<pullArray.length; i++) {
				document.getElementById(pullArray[i]).style.visibility = 'hidden';
			}
		}
	} else {
		if (!isSect)	document.getElementById('mainNavText'+i).style.color = '#101F41';
		if (layer) {
			if (!isSect)	document.getElementById('mainMenuLine'+i).style.backgroundColor = '';
			layer.style.visibility = 'hidden';
		}
		if (pullArray) {
			for (var i=0; i<pullArray.length; i++) {
				document.getElementById(pullArray[i]).style.visibility = 'visible';
			}
		}
	}
}


function mainSubMenuOver(i, j, over, isSect) {
	if (document.getElementById('mainNavMenu'+i+j))	var layer = document.getElementById('mainNavMenu'+i+j);
	if (over == 1) {
		if (!isSect)	document.getElementById('mainNavText'+i+j).style.color = '#996600';
		document.getElementById('mainMenuLine'+i+j).style.backgroundColor = '#D5D7DA';
		if (layer)	layer.style.visibility = 'visible';
	} else {
		if (!isSect)	document.getElementById('mainNavText'+i+j).style.color = '#1A2B4E';
		document.getElementById('mainMenuLine'+i+j).style.backgroundColor = '';
		if (layer)	layer.style.visibility = 'hidden';
	}
}


function insideMainMenuOver(i, j, over, isSect) {
	if (document.getElementById('insideMainMenu'+i+j))	var layer = document.getElementById('insideMainMenu'+i+j);
	if (over == 1) {
		if (!isSect) {
			document.getElementById('insideMainText'+i+j).style.color = '#996600';
			document.getElementById('insideMainBg'+i+j).style.backgroundColor = '#DCB36D';
		}
		if (layer) {
			layer.style.visibility = 'visible';
		}
	} else {
		if (!isSect) {
			document.getElementById('insideMainText'+i+j).style.color = '#101F41';
			document.getElementById('insideMainBg'+i+j).style.backgroundColor = '';
		}
		if (layer) {
			layer.style.visibility = 'hidden';
		}
	}
}



function quickLinkMenuOver(i, over) {
	if (over == 1) {
		document.getElementById('quickLinkMenu').style.visibility = 'visible';
		if (i) {
			eval('btn_arrow_b').src = path+'images/common/btn_arrow_b.gif';
		} else {
			eval('btn_arrow_b').src = path+'images/common/btn_arrow_b_f2.gif';
		}
	} else {
		document.getElementById('quickLinkMenu').style.visibility = 'hidden';
		if (i) {
			eval('btn_arrow_b').src = path+'images/common/btn_arrow_b_f3.gif';
		} else {
			eval('btn_arrow_b').src = path+'images/common/btn_arrow_b.gif';
		}
	}
}


function searchOver (i, over) {
	if (over) {
		i.value = "";
	} else {
		if (i.value == "")	i.value = " Search";
	}
}

function popupHtml(file, w, h, name) {
 var popUpPage2 = window.open('', ''+name+'', 'width='+(Number(w)+20)+',height='+h+',left=0,top=0,screenX=0,screenY=0,scrollbars=1,resizable=0');
 popUpPage2.document.open();
 popUpPage2.document.write('<html>');
 popUpPage2.document.write('<head><title>Hong Kong</title></head>');
 popUpPage2.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
 popUpPage2.document.write(' <img src="'+path+file+'" width="'+w+'" height="'+h+'">');
 popUpPage2.document.write('</body>');
 popUpPage2.document.write('</html>');
 popUpPage2.document.close();
 popUpPage2.focus();
}

function emailAFriend() {
	var emailFriendSubject = "你收到以下連接香港科技大學網站的超連結";
	
	var emailFriendBody = "請按這裏以連接送上的超連結﹕";
	
	var winEF = window.open("mailto:?subject="+ emailFriendSubject +"&body="+ emailFriendBody + escape("\n\n") + window.location.href);
}



function Clickheretoprint()
{ 
	var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
	disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
	var content_vlue = document.getElementById("content").innerHTML; 

	if (!(content_vlue)) return;
	
	var docprint=window.open("","",disp_setting); 
	docprint.document.open(); 
	docprint.document.write('<html><head><title>香港科技大學</title>'); 
	docprint.document.write('<link href="../include/styles.css" rel="stylesheet" type="text/css">'); 
	docprint.document.write('</head><body onLoad="self.print()" style="background:url('+path+'images/common/spacer.gif);"><center>'); 
	docprint.document.write('<table width="572" border="0" cellpadding="0" cellspacing="0">');
	docprint.document.write('	<tr>');
	docprint.document.write('		<td><img src="'+path+'images/common/logo.gif" alt="香港科技大學" width="246" height="60"></td>');
	docprint.document.write('	</tr>');
	docprint.document.write('</table>'); 
	docprint.document.write(' 	<table width="572" border="0" cellpadding="0" cellspacing="0">');  
	disablehref(docprint.document);
	var content_new = content_vlue;


	content_new = removeHTMLblock(content_new, 'script');
	content_new = removeHTMLblock(content_new, 'MAP');
	
	if (content_new.indexOf('href')!=-1)
		{
			content_new = removeHREFs(content_new);
		}
	//content_new = removeMouseOver(content_new);
	//content_new = removeMouseOut(content_new);

	docprint.document.write(content_new);
	docprint.document.write('</table>');

	docprint.document.write('<table width="572" border="0" cellpadding="0" cellspacing="0">');
	docprint.document.write('	<tr>');
	docprint.document.write('		<td class="footer" align="right">&copy;2012 香港科技大學 版權所有</td>');
	docprint.document.write('	</tr>');
	docprint.document.write('</table>');
	
	docprint.document.write('</center></body></html>'); 
	docprint.document.close(); 
	docprint.focus();
}


function sliceText(content_vlue)
{
	var len = content_vlue.length;
	var content_array = new Array();
	var c1 = content_vlue.slice(0,100);
	var c2 = content_vlue.slice(100,len);
	var i = 0;
	var sLen = 100;
	var lastIndex = i*sLen;
	var nextIndex = lastIndex;
	while (nextIndex < len)
		{
			i++;
			var nextIndex = i*sLen;
			content_array[i] = content_vlue.slice(lastIndex, nextIndex);
			lastIndex = nextIndex;
		}

	//var content_new = content_vlue;

	var content_new = content_array.join("");
}

function disablehref(doc)
{ 
 for (var i=0; i<doc.getElementsByTagName("a").length; i++)
	{
		doc.getElementsByTagName("a")[i].disabled = true;
		doc.getElementsByTagName("a")[i].removeAttribute("href");
	}
 
 return true;
}

function removeHREFs(aSourceHTML)
{
	var regexp=/href\s*=\s*\"*[^\s>]*/ig;
	var vArray = aSourceHTML.match(regexp);

	if(vArray != null)
	{
		for(i = 0; i < vArray.length; i++)
			{
				aSourceHTML = aSourceHTML.replace(vArray[i], "");
			}
		return aSourceHTML;
	}
}

function removeTarget(aSourceHTML)
{
	var regexp=/target\s*=\s*\"*[^\">]*/ig;
	var vArray = aSourceHTML.match(regexp);
	
	
	if(vArray != null)
	{
		var vLinks = vArray.join("\n").replace(/target\s*=\s*\"*/g,"");
		
		var mySplitResult = vLinks.split("\n");
		for(i = 0; i < mySplitResult.length; i++)
			aSourceHTML = aSourceHTML.replace(mySplitResult[i], "_self");
		return aSourceHTML;
	}
}

function removeMouseOver(aSourceHTML)
{
	var regexp=/onmouseover\s*=\s*\"*[^\s>]*/ig;
//	var regexp = new RegExp (attr + '\\s*=\\s*\\"*[^\\s>]*', "ig");
	var vArray = aSourceHTML.match(regexp);

	if(vArray != null)
	{
		for(i = 0; i < vArray.length; i++)
			{
				aSourceHTML = aSourceHTML.replace(vArray[i], "");
			}
		return aSourceHTML;
	}
}

function removeMouseOut(aSourceHTML)
{
	var regexp=/onmouseout\s*=\s*\"*[^\s>]*/ig;
//	var regexp = new RegExp (attr + '\\s*=\\s*\\"*[^\\s>]*', "ig");
	var vArray = aSourceHTML.match(regexp);

	if(vArray != null)
	{
		for(i = 0; i < vArray.length; i++)
			{
				aSourceHTML = aSourceHTML.replace(vArray[i], "");
			}
		return aSourceHTML;
	}
}

function removeHTMLblock(aSourceHTML, aTagName)
{
	var regexp= new RegExp ("<" + aTagName + "[^.]*\/" + aTagName + ">", "gi");
	aSourceHTML = aSourceHTML.replace(regexp,"");
	return aSourceHTML;
}	
-->
