﻿<!--//
/*Javascript File for Common Functions
Created on 1st Feb 2010
*/
//Capture Events
function getEvent(e){if(e==null){e=window.event;}if(e.srcElement){var o=e.srcElement;}if(e.currentTarget){var o=e.currentTarget;}if(e.target){var o=e.target;}return o;}
//------------------------------------------------------------------------------------------
//Checking Function(s)
function isArray(){if (typeof arguments[0] == 'object'){var c=arguments[0].constructor.toString().match(/array/i);return (c!= null);}return false;}
//------------------------------------------------------------------------------------------
function trim(s){return s.replace(/^\s*|\s*$/g,"");}
//------------------------------------------------------------------------------------------
//Layout Function(s)
function hideStatusBar(){return true;}
if (document.layers){document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);}
document.onmouseover=hideStatusBar;document.onmouseout=hideStatusBar;
//------------------------------------------------------------------------------------------
//Print innerHTML contents of given IDs
function printContent(id){
	var strTop=document.getElementById('cell_topMenu').innerHTML.toString();
	var strContent=document.getElementById(id).innerHTML.toString();
	var printWin=window.open('','printWin','width=650,location=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes,toolbar=yes');
	printWin.document.title='Innovation and Technology Fund | 創新及科技基金';
	printWin.document.open();
	printWin.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>');
	printWin.document.writeln('<title>Innovation and Technology Fund | 創新及科技基金</title>');
	printWin.document.writeln('<meta name="application-name" content="Innovation and Technology Fund | 創新及科技基金"/>');
	printWin.document.writeln('<meta name="description" content="Innovation and Technology Fund | 創新及科技基金">');
	printWin.document.writeln('<sc'+'ri'+'pt type="text/javascript" src="/Include/js_Common.js">'+'</'+'sc'+'ri'+'pt>');
	printWin.document.writeln('<sc'+'ri'+'pt type="text/javascript" src="/Include/js_Menu.js">'+'</'+'sc'+'ri'+'pt>');
	printWin.document.writeln('<sc'+'ri'+'pt language="javascript" type="text/javascript" defer\>'); 
	printWin.document.writeln('function Print(){document.body.offsetHeight;window.print()}');
	printWin.document.writeln('<\/'+'script\>'); 
	printWin.document.writeln('<link href="http://localhost/Include/CSS.css" rel="stylesheet">');
	printWin.document.writeln('<style type="text/css">img{border:none;}</style>');
	printWin.document.writeln('</head><body onload="Print();window.close();"><div style="width:604px;"><table id="printTable" border="0" cellpadding="0" cellspacing="0"><tr><td>');
	printWin.document.writeln('<table id="printTopTable" border="0" cellpadding="0" cellspacing="0" style="text-align: justify;"><tr><td>');
	printWin.document.writeln(strTop);
	printWin.document.writeln('</td></tr></table>');
	printWin.document.writeln('<table id="contentTable" border="0" cellpadding="0" cellspacing="0" style="text-align: justify;">');
	printWin.document.writeln(strContent);
	printWin.document.writeln('</table></td></tr></table></div></body>');
	printWin.document.writeln('</html>');
	printWin.document.close();
	//printWin.window.focus();
	//printWin.window.print();
	//printWin.window.close();
	return false
}
//------------------------------------------------------------------------------------------
//Enable Tool Tips
if (window.addEventListener){window.addEventListener("load", enableToolTip, false);}else if (window.attachEvent){window.attachEvent("onload", enableToolTip);}
function enableToolTip(){var a=document.getElementsByTagName("*");for(i=a.length-1;i>-1;i--){if (a[i].alt){a[i].title = a[i].alt;}}}
//------------------------------------------------------------------------------------------
//List Related Function
//Nested Order List
function genNestedOrderList(ol,prefix,indent,n){
	var intNum=n;
	var intIndent=indent,intIndentSize=14; //should be same as the font-size set in CSS
	var strPre=prefix;
	if(!intNum){intNum=1;}
	if(!intIndent){intIndent=0;}
	if(!strPre){strPre='';}
	if(ol){ol.style.listStyleType='none';}
	if(ol){
	for(var i=0;i<ol.childNodes.length;i++){
		if(ol.childNodes[i].nodeType==1 && ol.childNodes[i].tagName=='LI'){
			if(intIndent==0){
			ol.childNodes[i].innerHTML='<b>'+strPre+intNum.toString()+'.</b>'+ol.childNodes[i].innerHTML;
			}else{
			ol.childNodes[i].innerHTML=strPre+intNum.toString()+'.'+ol.childNodes[i].innerHTML;
			}
			ol.childNodes[i].style.textIndent=intIndent-intIndentSize;
			if(ol.childNodes[i].childNodes.length>0){
				var j=0, olFlag=false, child=ol.childNodes[i].childNodes;
				while(j<child.length && olFlag==false){
					if(child[j].tagName=='OL'){olFlag=true;}
					j++;
				}
				if(olFlag==true){genNestedOrderList(child[j-1],strPre+intNum.toString()+'.',intIndent-intIndentSize);}
			}
			intNum++;
		}
	}
	}
}
//------------------------------------------------------------------------------------------
function continueList(prevListID){	//Get the previous list last number, and +1 return
	var ol = document.getElementById(prevListID);
	var intCount=0; var liIndex=0;
	if(ol){
		if(ol.tagName=="OL"){
			for(var i=0;i<ol.childNodes.length;i++){
			if(ol.childNodes[i].nodeType==1 && ol.childNodes[i].tagName=='LI'){
				if(liIndex==0){liIndex=i;}
				intCount+=1; //count + 1
				alert(ol.childNodes[i].value);
			}
			}
			if(ol.childNodes[liIndex].value==0||ol.childNodes[liIndex].value==-1){return intCount+1;}
			else{return ol.childNodes[liIndex].value+intCount;}
		}
	}
	return 0;
}
//------------------------------------------------------------------------------------------
function setListStartValue(id,value){
	var ol = document.getElementById(id);
	var blnCheck=true;
	if(ol){
		if(ol.tagName=="OL"){
		var i=0
		while(i<ol.childNodes.length && blnCheck==true){
			if(ol.childNodes[i].nodeType==1 && ol.childNodes[i].tagName=='LI'&&blnCheck==true){
				ol.childNodes[i].value=value;
				blnCheck=false;
			}
			i++;
		}
		}
	}
}