// JavaScript Document
/*-----------------------------------\
|Welcome to VietStyle Co.,Ltd        |
|Website:http://thegioiwebsite.net   |
|Email:info@thegioiwebsite.net       |
|Tel:04 273 0711                     |
|Fax:04 273 0711                     |
------------------------------------*/
//Ham opup 1
//cach dung: <a href="javascript:displayInfo('http://abc.com.vn',500,500)">Link</a>
function displayInfo(url,w,h)
{
 settings ='height='+h+',width='+w+',scrollbars='+scroll+',resizable';
 window.open(url,'',settings);
}
//Ham popup 2
//Cach dung:<a href="http://abc.com.vn" onclick="NewWindow(this.href,'name','400','400','yes');return false" >Link</a>
function NewWindow(mypage,myname,w,h,scroll)
{
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
}

/*function kiem tra email co hop le khong*/
function isEmail( text )
{
	var pattern = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp( pattern );
	return regex.test( text );
}

function isNumber(field) {
	var re = /^[0-9-'.'-',']*$/;
	if (!re.test(field.value)){
		field.value = field.value.replace(/[^0-9-'.'-',']/g,"");
	}
}

function SearchOnFocus(field)
{
	if(field.value=='Search')
	{
		field.value = '';
	}
}

function SearchOnBlur(field)
{
	if(field.value=='')
	{
		field.value='Search';
	}
}
/*---------------------------------*/
/*Gioi han textarea number:<textarea maxlength="40" onkeyup="return ismaxlength(this)"></textarea> chi go duoc 40 ky tu */
function ismaxlen(obj){
  var maxlen=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>maxlen)
obj.value=obj.value.substring(0,maxlen)
}

// Page load function
function loadImages() 
{
	document.getElementById('vs').innerHTML="Designed by <a href=http://thegioiwebsite.net target=_blank title='http://thegioiwebsite.net - Nha thiet ke web chuyen nghiep!'>VietStyle</a>";
	if (document.getElementById) { 
	// DOM3 = IE5, NS6
	document.getElementById('hidepage').style.visibility = 'hidden';
	}
	else {
	if (document.layers) { 
	// Netscape 4
	document.hidepage.visibility = 'hidden';
	}
	else { // IE 4
	document.all.hidepage.style.visibility = 'hidden';
	}
	}
}

function showFriendBox(friendBox)
{
	$('#'+friendBox).toggle('slow');
}

function loadAjax(type,dataType,dataString,url,targetId,hidden)
{
	$(targetId).html('Loading...');
	if(hidden==1)
	{
		 $.ajax({
			   type:type,
			   dataType:dataType,
			   url:url,
			   data:dataString,
			   success: function(html){
					$("#"+targetId).css({backgroundColor:"#40B220"});
					$("#"+targetId).css({color:"#FFFFFF"});
					$("#"+targetId).html(html)
					.fadeIn(1500,'')
					.fadeOut(2500,'');
				}
		});
	}
	else{
		  $.ajax({
			   type:type,
			   dataType:dataType,
			   url:url,
			   data:dataString,
			   success: function(html){
					$("#"+targetId).html(html)
				}
			});
		}
}


function clear(id)
{
	document.getElementById(id)	.value="";
}


// Lam 1 cai dong ho de chay.
var dayarray=new Array("Chủ nhật","Thứ hai","Thứ ba","Thứ tư","Thứ năm","Thứ sáu","Thứ bảy")
var montharray=new Array("01","02","03","04","05","06","07","08","09","10","11","12")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
/*var cdate="<font color='000000' face='Arial' size='2'>"+dayarray[day]+",ngày "+daym+", "+montharray[month]+", năm "+year+", "+hours+":"+minutes+":"+seconds+" "+dn
+"</font>"*/
var cdate="<span style='corlor:#000; font-size:12px;'>"+dayarray[day]+" ngày "+daym+"/ "+montharray[month]+"/ "+year+" ,"+hours+":"+minutes+":"+seconds+" "+dn
+"</span>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()

function loadClock(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000);

}

//De chay dong ho trong BODY lam nhu sau:
/*
<body onLoad="load_clock()">
<span id="clock"></span>
</body>
*/