﻿
function show_datetime()
{
var d=new Date();
var thu=new Array("Chủ nhật","Thứ hai","Thứ ba","Thứ tư","Thứ năm","Thứ sáu","Thứ bảy");
var thang=new Array("01","02","03","04","05","06","07","08","09","10","11","12");

ngay=d.getDate()
gio=d.getHours()
phut=d.getMinutes()
giay=d.getSeconds()

 if (ngay<10)
 	   {
	 	ngay="0"+ngay
      }
	  
if (gio<10)
 	   {
	 	gio="0"+gio
      }
	  
if (phut<10)
 	   {
	 	phut="0"+phut
      }	  
if (giay<10)
 	   {
	 	giay="0"+giay
      }	  
	  
var TODAY = thu[d.getDay()] + ", ngày " + ngay + "/"+thang[d.getMonth()]+"/" + d.getFullYear()+', '+gio+":" +phut+":"+giay +" (GMT +" + -d.getTimezoneOffset()/60+")"; 

var TODAY2 = gio+":" +phut+":"+giay +" (GMT+" + -d.getTimezoneOffset()/60+")"; 

if (document.getElementById("iddateTimer"))
{
	document.getElementById('iddateTimer').innerHTML = TODAY;
}

t = setTimeout('show_datetime()',1000);
}


function openpage(pagename)
{
	open(pagename,"_parent");
	}
	

function open_Dafault()
	{	
		setInterval("loadpage()", 5000) 
	}
	
function loadpage()
	{	
  	itime++;
		if (itime=360)
		{ 
			open(ipage,"_parent");
		}
	}


function ShowGoldPrice(){
	var sHTML = '';	

	sHTML = sHTML.concat('<table border="0px" cellpadding="2px" cellspacing="1px" class="tbl-goldprice">');
	sHTML = sHTML.concat('	<tr>');
	sHTML = sHTML.concat('		<td class="td-weather-title" style="font-size:10px;width:46%;">'+Weather_GoldType+'</td>');
	sHTML = sHTML.concat('		<td class="td-weather-title" style="text-align:center;font-size:10px;width:27%;">'+Weather_Buy+'</td>');
	sHTML = sHTML.concat('		<td class="td-weather-title" style="text-align:center;font-size:10px;width:27%;">'+Weather_Sell+'</td>');
	sHTML = sHTML.concat('	</tr>');
	sHTML = sHTML.concat('	<tr>');
	sHTML = sHTML.concat('		<td class="td-weather-title">SBJ</td>');
	sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSbjBuy).concat('</td>');
	sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSbjSell).concat('</td>');
	sHTML = sHTML.concat('	</tr>');
	sHTML = sHTML.concat('	<tr>');
	sHTML = sHTML.concat('		<td class="td-weather-title">SJC</td>');
	sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSjcBuy).concat('</td>');
	sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSjcSell).concat('</td>');
	sHTML = sHTML.concat('	</tr>');
	sHTML = sHTML.concat('</table>');
	gmobj('s_Gold_unit').innerHTML = Weather_Unit;
	gmobj('s_Gold').innerHTML = sHTML;
	
	
}

function ShowForexRate(){
	var sHTML = '';
	sHTML = sHTML.concat('<table border="0px" cellpadding="2px" cellspacing="1px" class="tbl-weather">');
	for(var i=0;i<vForexs.length;i++){
		if (!vForexs[i]==''){
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="td-weather-title">').concat(vForexs[i]).concat('</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vCosts[i]).concat('</td>');
		sHTML = sHTML.concat('	</tr>');
		}
	}
	sHTML = sHTML.concat('</table>');
	gmobj('s_Forex').innerHTML = sHTML;
}

function ValidateDate(dateStr) {
  var re = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{2,4})$/;
  if (re.test(dateStr)) return true;
  return false;
}


function ValidateAcc(source)
{
	var re = /^[\w._]+$/;
	
	if (!re.test(source.value))
	{
		
		return false;
	}
	return true;
}


function ValidateEmail(source)
{
	if  (!ValidateRegular(source, "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
	{
		//source.select();
		//source.focus();
		return false;
	}
	return true;
}

function ValidateRegular(source, reg)
{
	value = source.value;
	if (value.length == 0)
		return true;
	var rx = new RegExp(reg);
	var matches = rx.exec(value);
    return (matches != null && value == matches[0]);
}


function ValidatePhone(source)
{

	
	var re = /(\(?(\d|(\d[- ]\d))\)?[-. ]?)?(\d\.?\d\.?\d)/;
	
	if (!re.test(source.value))
	{
		
		return false;
	}
	return true;
}

function setstyle(pobject,pset)
{
	if 	(pset==true)
	{
	document.getElementById(pobject).style.border="#FF7979 solid 1px";
	 document.getElementById("msg_1").style.display='block';
	}
	
	
	else{
	
	 document.getElementById(pobject).style.border=" #CCCCCC 1px solid";		
	 document.getElementById("msg_1").style.display='none';
	}
}

function opensendemail(burl)
{
	 var tposx= (screen.width- 390)/2
	     var tposy= (screen.height- 236)/2;
			
	popupWin =window.open('SendEmail.asp?'+burl,'','height=390,width=336,resizable=0,location=0,scrollbar=0');
	popupWin.moveTo(tposx,tposy);
	popupWin.focus();
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function CheckUsernameChar(stringIn)
{
	retval = false
     var i;
     for ( i=0; i <= stringIn.length-1; i++) 
	 {
         if ( ( ( stringIn.charCodeAt(i) >= 48)&&(stringIn.charCodeAt(i) <= 57)) || ((stringIn.charCodeAt(i) > 64)&&(stringIn.charCodeAt(i) <= 90)) || ((stringIn.charCodeAt(i) >= 97)&&(stringIn.charCodeAt(i) <= 122)) || (stringIn.charCodeAt(i) == 95) || (stringIn.charCodeAt(i) == 45) )
		 {
           	retval = true;
         }
		 else
		 {
			retval = false;
			break;
         }
     }
     return retval;
}
function CheckEmail(stringIn)
{
	var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@[A-Za-z0-9\_\-]+(\.[A-Za-z0-9\_\-]+)+$/;
	if ( stringIn.search(re) == -1 )
	{
		return false;
	}
	else
	{
		return true;
	}
}
// kiem tra so dien thoai
function CheckTel(str)
{
	var pattern = "0123456789-+() ";
	if (str.length > 0) {
		if (str.length < 5) {
			return false;
		} else {
			for (var a=0; a<pattern.length; a++) {
				if (pattern.indexOf(str.charAt(a),0) == -1) return false;
			}
		}
	}
	return true;	
}

//kiem tra cac ky tu dat biet @,<,>,!,$,%,(,),=,#,{,},[,],",^,~,`,,/,\,|,*,.,+,: cho fullname CheckChar
function CheckCharFullName(stringIn) 
{
	if ((stringIn.indexOf("@") >= 0)||(stringIn.indexOf("<") >= 0)||(stringIn.indexOf(">") >= 0)||(stringIn.indexOf("!") >= 0)||(stringIn.indexOf("$") >= 0)||(stringIn.indexOf("%") >= 0)||(stringIn.indexOf("(") >= 0)||(stringIn.indexOf(")") >= 0)||(stringIn.indexOf("=") >= 0)||(stringIn.indexOf("#") >= 0)||(stringIn.indexOf("{") >= 0)||(stringIn.indexOf("}") >= 0)||(stringIn.indexOf("[") >= 0)||(stringIn.indexOf("]") >= 0)||(stringIn.indexOf("|") >= 0)||(stringIn.indexOf('"') >= 0) ||(stringIn.indexOf(".") >= 0) ||(stringIn.indexOf(";") >= 0) ||(stringIn.indexOf("?") >= 0) ||(stringIn.indexOf(",") >= 0) ||(stringIn.indexOf("+") >= 0) ||(stringIn.indexOf("&") >= 0) ||(stringIn.indexOf(":") >= 0) ||(stringIn.indexOf("\\") >= 0) ||(stringIn.indexOf("/") >= 0) ||(stringIn.indexOf("*") >= 0) ||(stringIn.indexOf("`") >= 0) ||(stringIn.indexOf("~") >= 0) ||(stringIn.indexOf("^") >= 0) ||(stringIn.indexOf("-") >= 0)||(stringIn.indexOf("_") >= 0))
	{
		return false;
	}
	return true;
}
//cat bo hai dau khoang trang
function trim(val)
{ 
	return val.replace(/^\s+|\s+$/g,"");
}
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function openwindows(url)
{
	window.open(url,'','toolbar=no,menubar=no,scrollbars=yes,location=no');
}
