function showClock(strID){
var dt = new Date();
var def = dt.getTimezoneOffset()/60;
var gmt = (dt.getHours() + def);

//var ending = ":" + IfZero(dt.getMinutes()) + ":" +  IfZero(dt.getSeconds());
var ending = ":" + IfZero(dt.getMinutes()) ;

var ukTime =check24(((gmt  ) > 24) ? ((gmt  ) - 24) : (gmt  ));
ukTime = (IfZero(ukTime) + ending);

var cyprusTime =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
cyprusTime = (IfZero(cyprusTime) + ending);

var moscowTime =check24(((gmt + 3) > 24) ? ((gmt + 3) - 24) : (gmt + 3));
moscowTime = (IfZero(moscowTime) + ending);

var nyTime =check24(((gmt -5 ) > 24) ? ((gmt -5 ) - 24) : (gmt -5 ));
nyTime = (IfZero(nyTime) + ending);

//var tokyoTime =check24(((gmt +9) > 24) ? ((gmt + 9) - 24) : (gmt + 9));
//tokyoTime = (IfZero(tokyoTime) + ending);

//var sydTime =check24(((gmt + 11) > 24) ? ((gmt + 11) - 24) : (gmt + 11));
//sydTime = (IfZero(sydTime) + ending);

var perthTime =check24(((gmt + 9) > 24) ? ((gmt + 9) - 24) : (gmt + 9));
perthTime = (IfZero(perthTime) + ending);

var beijingTime =check24(((gmt + 8) > 24) ? ((gmt + 8) - 24) : (gmt + 8));
beijingTime = (IfZero(beijingTime) + ending);

/*var 	strTime = 'GMT: ' + ukTime + '&nbsp;&nbsp;&nbsp;&nbsp;<br>';
	strTime += 'Cyprus: ' + cyprusTime  + ' +2<br>';
	strTime += 'Moscow: ' + moscowTime + ' +3<br>' ;
	strTime += 'New York: ' + nyTime + '&nbsp; -5<br>' ;
	strTime += 'Perth: ' + perthTime + ' +9<br>'  ;
	strTime += 'Beijing: ' + beijingTime + ' +8<br>'  ;
*/
var 	strTime = '<table>';
	strTime += '<tr><td align="right">GMT:</td><td align="left">' + ukTime + '</td></tr>';
	strTime += '<tr><td align="right">Cyprus:</td><td align="left">' + cyprusTime  + ' +2</td></tr>';
	strTime += '<tr><td align="right">Moscow:</td><td align="left">' + moscowTime + ' +3</td></tr>' ;
	strTime += '<tr><td align="right">New York:</td><td align="left">' + nyTime + '&nbsp; -5</td></tr>' ;
	strTime += '<tr><td align="right">Perth:</td><td align="left">' + perthTime + ' +9</td></tr>'  ;
	strTime += '<tr><td align="right">Beijing:</td><td align="left">' + beijingTime + ' +8</td></tr>'  ;
	strTime += '</table>';

xbSetInnerHTML(window,strID, strTime)


setTimeout("showClock('" + strID + "')", 1000);
}
function IfZero(num) {return ((num <= 9) ? ("0" + num) : num);}
function check24(hour) {return (hour >= 24) ? hour - 24 : hour; }

function addToFaves(urlAddress,pageName){
  if (window.external) window.external.AddFavorite(location.href, document.title);
  else alert("Sorry! Your browser doesn't support this function.");
 }
function pagePrint(){
	if ( window.print ){
	 	window.event.cancelBubble = true;
		window.focus();
		window.print( );
	}
	else alert("Sorry! Your browser doesn't support this function.");
}
function pageLoaded(){};	
function xpageLoaded(){if(iLastBanner>0) rotateTextBanner(iBannerTime);}	
 
function setFormFocus(){
var frm = document.forms[0];		
var done = false;
	if (document.forms.length == 0) return;
 	for (f = 0; f < frm.elements.length; f++){
 		if (! done){
		 	if ( frm.elements[f].type.substr(0,5) != "selec" && frm.elements[f].type != "hidden" && frm.elements[f].type != "reset" && frm.elements[f].type != "submit" && ! frm.elements[f].disabled && ! frm.elements[f].readOnly){
				frm.elements[f].focus();
	 			done = true;
	  		 }		
 		}
 	} 	
}
function preSubmit(){
var errMsg = '';
// Find the first form
var frm = document.forms[0];	
 
	// Button the user pressed
 	actionKey=arguments[0];
	actionKey=actionKey.toUpperCase();
	actionKey=actionKey.substring(0,4);		
	res = false;
 	if (actionKey == 'DELE'){
 		res = window.confirm('Are you sure you want to delete this record?');
	 	return(res);
 	}
 	
	altTextLen=0;
	altTextErrText = '';
	for (var i=1;i < arguments.length; i++) {
		arData =  arguments[i].split('|'); 
		arButtons = arData[0].split('/'); 
		altTextErr = false;
		for (var b=0;b < arButtons.length; b++) {
			valBtnKey=arButtons[b].toUpperCase();
			valBtnKey=valBtnKey.substring(0,4);	// get the first four letters of the val buttons text			
			if (valBtnKey==actionKey){	
  				fldName=arData[1];	//[0] is the button/list of buttons we need to test
  				fldData = frm.elements[fldName].value;
  				fldData = trim(fldData);
  				funcName=arData[2];
  				errText=arData[3];
  				ok=true;
  				myErr='';
	  			switch (funcName){
	  				case 'isFileName':
		  				ok = isFileName(fldData);
	  					break;
	  				case 'isAltText':
	  					altTextLen = altTextLen + fldData.length;
	  					altTextErrText = errText;
	  					break;
	  				case 'isText':
	  					ok = 	fldData.length > 0;
	  					break;
	  				case 'isNum':
	  					ok = isInteger(fldData);
	  					break;
	  				case 'isDate':
	  					ok = isDate(fldData);
	  					break;
	  				case 'isOptEmail':
	  					if ( fldData.length > 0 ) ok = isEmailAddr(fldData);
	  					else ok = true;
	  					break;
	  				case 'isEmail':
	  					ok = isEmailAddr(fldData);
	  					break;
	  				case 'isDirName':
	  					ok=isDirName(fldData);
	  					break;
	  				case 'isYes':
	  					ok=(fldData=='Yes');
	  					break;
	  			}
	  			if (! ok) errMsg +=  errText  + '\n';
			}	  			
  		} // End of for loop parsing validators

 	}
	if (altTextErrText) { // There was an altText test - did it pass?
		  					
		if (altTextLen < 1 ) errMsg +=  altTextErrText  + '\n';
	} 	
 	if (errMsg) alert( 'Data input errors: \n' + errMsg );
 	else res=true;
 	return(res);
}
function isFileName(fileName){
	if(fileName.length < 1) return(false);
	dots = fileName.split(".")
	myFileType = dots[dots.length-1];
	myFileType = myFileType.toUpperCase();
	if (myFileType != 'JPG' && myFileType != 'GIF' ) return (false);
	return(true);
}
function isDirName(dirName){
   if (! dirName) return false;
   var iChars = " *|,\":<>[]{}`\';()@&$#%";

   for (var i = 0; i < dirName.length; i++) {
      if (iChars.indexOf(dirName.charAt(i)) != -1)
         return false;
   }
   return true;
}
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
function isDate(dtStr){
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strDay=dtStr.substring(0,pos1)
var strMonth=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
	return true
} 
//
function isEmailAddr(email){
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0){
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}
function checkMaxLength (textarea, evt, maxLength) {
   // ignore shift click for select
  if (textarea.selected && evt.shiftKey)  return true;
  var allowKey = false;  
  if (textarea.selected && textarea.selectedLength > 0) allowKey = true;
  else {
  		var keyCode =  document.layers ? evt.which : evt.keyCode;
  	 	// Look for special keys
 
  		if ( ! isAlphaNum(keyCode)) return true;
  		allowKey = (textarea.value.length < maxLength);
  }
  if ( textarea.value.length >= maxLength) {
  		textarea.value = textarea.value.substring(0,maxLength+1);
  }
  textarea.selected = false;
 
  return allowKey;
}
function isAlphaNum(keyCode){
	if ( (keyCode>=48 && keyCode <= 90) || keyCode >= 144 || keyCode==13 || keyCode==32 ) return true;
	else return false;
}
//
function rotateTextBanner(secs){
	if (! iShowBanners) return;
	strID= "divBanner";
	elBanner = xbGetElement(window,strID)
	if ( elBanner != null  ){
 		if ( iBannerFirst == 1 ) {
			strFirstText = xbGetInnerHTML(window,strID);
			arBanners[0] = strFirstText;
			// start with a random banner
			iBannerNo = 0; //Math.floor(Math.random() * iLastBanner);
			iBannerFirst =0;
		}
		strText= arBanners[iBannerNo];
  		xbSetInnerHTML(window,strID,strText)
  		iBannerNo++;
		if ( iBannerNo >= arBanners.length ) iBannerNo = 0;
		// Callback in 10 seconds
		if (arBanners.length > 1 ) setTimeout('rotateTextBanner(' + iBannerTime + ')', iBannerTime * 1000) 
	}
}
function openImgWindow(theURL,winName,w,h){
	// adjust w & h
    if (w || h){
    	if (w<300) w = 300;
    	w += 50;
    	h += 150;
    }
    return(openWindow(theURL,winName,null, w,h));
}
function infoWin(theURL){
 	w=400;h=300;
	return(openWindow(theURL,'winInfo',null,w,h));
}
function openWindow(theURL,winName,strOptions,w, h ){
	if (parseInt(navigator.appVersion)>3) {
 		if (navigator.appName=="Netscape") {
  			winW = window.innerWidth;
  			winH = window.innerHeight;
 		}
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
  			winW = screen.availWidth - 20; //document.body.offsetWidth;
  			winH = screen.availHeight - 50 ; // document.body.offsetHeight;
 		}
	}

	if ( ! w ) w = winW * .9;
	if ( ! h ) h=winH*.9;
	if ( w > winW) w = winW;
	if ( h > winH) h = winH;
	x=(winW - w ) / 2;
	y=(winH - h ) / 2 ;
	if (! strOptions){	
		strOptions = "toolbar=no,"; //no
	   strOptions += "location=no,"; //no
	   strOptions += "directories=no,"; //no
	   strOptions += "status=no,"; //no
	   strOptions += "menubar=no,"; //no
	   strOptions += "scrollbars=yes,"; //no
	   strOptions += "resizable=no"; //no
	}
	   
   strOptions += ",width=" + w + ",";
   strOptions += "height=" + h + ",";
	strOptions += ",left=" + x + ",top=" + y;
	strOptions += ",screenX=" + x + ",screenY=" + y;
     
	if (!window.imageWindow){ // window has not yet been defined
		try{
			imageWindow = window.open(theURL,winName,strOptions);
		}
		catch(e){
			window.alert("Popup window blocked " + e.number);
		}
	} else { // has been defined
		if (!imageWindow.closed){ // window still open
			imageWindow.location=(theURL);
			imageWindow.focus();
		} else {
			try{
				imageWindow = window.open(theURL,winName,strOptions);
			}
			catch(e){
				window.alert("Popup window blocked " + e.number);	
			}
		}
	}
	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

function entsub(event,ourform) {
 
  if (event.which == 13 || window.event.keyCode==13) {
  		ourform.enter.value=1;
  }
 
}
    
var IE = (document.all);
var NS4 = false;
var NS6 = false;
var MAC = (navigator.appVersion.indexOf('Mac') != -1);
var MOZ = (navigator.userAgent.toUpperCase().substr(0,3) == "MOZ");
var overArea = 0;
var activeArea = 0;
var activePage = 0;
var overPage = 0;
var overSubPage = 0;
var formAction = String(""); 
if(navigator.appName.toUpperCase().substr(0,3) == "NET"){
	if (navigator.appVersion.indexOf("4.") > -1)NS4 = true;
	if (navigator.appVersion.indexOf("5.") > -1) NS6 = true
}
var iLastBanner=3;
var iBannerNo=0;
var iBannerFirst=1;
var iShowBanners=  (IE || MOZ);
var iBannerTime=10;

if (navigator.appName.indexOf("Microsoft")!=-1) {
 
	document.oncontextmenu = function(){return false} 
	if(document.layers) { 
	    window.captureEvents(Event.MOUSEDOWN); 
	    window.onmousedown = function(e){ 
	   if(e.target==document)return false; 
	    } 
	} 
	else { 
	    document.onmousedown = function(){return false} 
	} 
}
