﻿function m_bank_datetime(){
//	serverdate();clock1();clock2();clock3();clock4();clock5();clock6();fn47();	
	m_myclock();
}

/**********************************************************************/
function displayobj(objName){
	var obj = document.getElementById(objName);
	if(obj != null){
		if(obj.style.display == 'none'){
			obj.style.display = 'block';
		}
		else{
			obj.style.display = 'none';
		}
	}
}
/**********************************************************************/
/**********************************************************************/
function doViewByDate(){
	var obj = document.frmExh;
	var vDay = obj.vDay.value;
	var vMonth = obj.vMonth.value;
	var vYear = obj.vYear.value;
	vDate = vMonth + '/' + vDay + '/' + vYear;
	getExchRateByDate(vDate);
	obj = null;
}
/**********************************************************************/
function getExchRateByDate(curDate){
	
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var szURL = "XML_GetExchangeRateByDate.asp";
	var szRequest = curDate;
	var szHttpMethod = "POST";
	objHTTP.Open(szHttpMethod, szURL, false);
	objHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");	
	objHTTP.Send(szRequest);
	var szReply = objHTTP.ResponseText;
	if (szReply != 'false'){
		var splitpos = szReply.search(String.fromCharCode(27));
		strExchRate = szReply.substring(0, splitpos);
		strDate = szReply.substring(splitpos + 1, szReply.length);
		div_Exch.innerHTML = strExchRate;				
		
	}
	objHTTP = null;	
}

function checkSearchDate(frm){
	var day = frm.SDay.value;
	var month = frm.SMonth.value;
	var year = frm.SYear.value;
	
	if(day == ""&&month == ""&&year == ""){
		alert("Bạn phải nhập ngày hoặc tháng hoặc năm");
		return false;
	}
	return true;
}
//////////////////////////////////////////////////////////////////////
var zone;
var szone = 0;

function wrMyClock(m_city_name,m_hours,m_minutes,m_seconds){
	var dispTime = '';
	var amOrPm = "";

	if(m_seconds>=59){
		m_seconds = 0;
		m_minutes+=1;
	}
	else{
		m_seconds+=1;
	}
	if(m_minutes>=59){
		m_minutes = 0;
		m_hours+=1;
	}
	
	if(m_hours>=59){
		m_hours = 0;
		m_days+=1;
	}
//Format-----------------------------------------------------------------
	if (m_hours > 24) 		m_hours = m_hours-24;
	if (m_hours < 0) 		m_hours = m_hours+24;
	if (m_hours == 0) 		m_hours = 12;	
	if (m_hours >= 12)		amOrPm	= "PM";
	else					amOrPm	= "AM";
	if (m_hours > 12)		m_hours	= m_hours-12;	
	if (m_seconds <= 9) 	m_seconds = "0" + m_seconds;
	if (m_hours <= 9) 		m_hours = "" + m_hours;

	dispTime = m_hours + ":" + m_minutes + ":" + m_seconds + " " + amOrPm ;
	dispTime="<p style='font-family:verdana;font-size:7pt;color:#FFFFFF;margin:0;padding:5 0 0 0;'><b>" + m_city_name + ": </b>" + dispTime + "</p>";

	return dispTime;
}

function m_myclock() {
	var digital = new Date();
	var ofst_h;
	var ofst_m;
	var hours;
	var minutes;
	var seconds;
	var strTime;
//HaNoi-----------------------------------------------------------------
	zone = 6;
	ofst_h	= digital.getTimezoneOffset()/60;
	ofst_m	= digital.getTimezoneOffset()%60;
	hours 	= digital.getHours() + parseInt(ofst_h) + parseInt(zone) + parseInt(szone);
	minutes = digital.getMinutes() + parseInt(ofst_m);
	seconds = digital.getSeconds();
	
	strTime = wrMyClock('HaNoi',hours,minutes,seconds);
	document.getElementById("pendule3").innerHTML=strTime;
//Sydney-----------------------------------------------------------------
	zone = 10;
	ofst_h	= digital.getTimezoneOffset()/60;
	ofst_m	= digital.getTimezoneOffset()%60;
	hours 	= digital.getHours() + parseInt(ofst_h) + parseInt(zone) + parseInt(szone);
	minutes = digital.getMinutes() + parseInt(ofst_m);
	seconds = digital.getSeconds();
	
	strTime = wrMyClock('Sydney',hours,minutes,seconds);
	document.getElementById("pendule1").innerHTML=strTime;
//Tokyo-----------------------------------------------------------------
	zone = 9;
	ofst_h	= digital.getTimezoneOffset()/60;
	ofst_m	= digital.getTimezoneOffset()%60;
	hours 	= digital.getHours() + parseInt(ofst_h) + parseInt(zone) + parseInt(szone);
	minutes = digital.getMinutes() + parseInt(ofst_m);
	seconds = digital.getSeconds();
	
	strTime = wrMyClock('Tokyo',hours,minutes,seconds);
	document.getElementById("pendule2").innerHTML=strTime;
//FrankFurt-----------------------------------------------------------------
	zone = 1;
	ofst_h	= digital.getTimezoneOffset()/60;
	ofst_m	= digital.getTimezoneOffset()%60;
	hours 	= digital.getHours() + parseInt(ofst_h) + parseInt(zone) + parseInt(szone);
	minutes = digital.getMinutes() + parseInt(ofst_m);
	seconds = digital.getSeconds();
	
	strTime = wrMyClock('Frankfurt',hours,minutes,seconds);
	document.getElementById("pendule4").innerHTML=strTime;
//London-----------------------------------------------------------------
	zone = 0;
	ofst_h	= digital.getTimezoneOffset()/60;
	ofst_m	= digital.getTimezoneOffset()%60;
	hours 	= digital.getHours() + parseInt(ofst_h) + parseInt(zone) + parseInt(szone);
	minutes = digital.getMinutes() + parseInt(ofst_m);
	seconds = digital.getSeconds();
	
	strTime = wrMyClock('London',hours,minutes,seconds);
	document.getElementById("pendule5").innerHTML=strTime;
//NewYork-----------------------------------------------------------------
	zone = -5;
	ofst_h	= digital.getTimezoneOffset()/60;
	ofst_m	= digital.getTimezoneOffset()%60;
	hours 	= digital.getHours() + parseInt(ofst_h) + parseInt(zone) + parseInt(szone);
	minutes = digital.getMinutes() + parseInt(ofst_m);
	seconds = digital.getSeconds();
	
	strTime = wrMyClock('NewYork',hours,minutes,seconds);
	document.getElementById("pendule6").innerHTML=strTime;
	
	setTimeout("m_myclock()",1000);
}
//////////////////////////////////////////////////////////////////////

