
function initArray() {
	for(i=0;i<initArray.arguments.length; i++) {
		this[i] = initArray.arguments[i];
	}
}
function getFullYear(d) { // d is a date object
	yr = d.getYear();
	if (yr < 1000)
	yr+=1900;
	return yr;
}
function outDate(){
	var isnMonths=new initArray("01","02","03","04","05","06","07","08","09","10","11","12");
	var isnDays= new initArray("Ch&#7911; nh&#7853;t","Th&#7913; 2","Th&#7913; 3","Th&#7913; 4","Th&#7913; 5","Th&#7913; 6","Th&#7913; 7","Ch&#7911; nh&#7853;t");
	today=new Date();		
	document.write((today.getDate()<10?("0"+today.getDate()):(today.getDate())) + "." +isnMonths[today.getMonth()]+"." + getFullYear(today));

}
function checkTextBoxSearch (str) {
	var textVal = str.value;	
	if (textVal == '') {
		alert("Nhap vao noi dung tim kiem");
		str.focus();
		return false;
	}
	return true;
}
function checkPassword(str) {
	var textVal = str.value;	
	if (textVal == '') {
		alert("Nhap vao mat khau");
		str.focus();
		return false;
	}
	return true;

}
function checkEmail(str){
	var textValue = str.value;
	var err=''
	if (textValue == ''){
		err += "Dia chi email khong hop le";
		alert(err);
		str.focus();
		return false
	}
	if (textValue.indexOf('@') <= 0 || textValue.indexOf('@') == textValue.length -1){
		err += "Dia chi email khong hop le";		
	} else {
		var substr = textValue.substring(textValue.indexOf('@'),textValue.length);
		if (textValue.indexOf('.') <= 0) {
			err += "Dia chi email khong hop le\n";
		}
	}
	if (err != '') { 
		alert(err); 
		str.focus();
		return false;
	}
	return true;
}	
function checkWebLink(str) {
	var textVal = str.value;
	if (textVal == '0') {
		alert('Chon website chuyen toi');
		str.focus();
		return false;
	} else {
		window.open(textVal);
	}
	return true;

}
function showStatus() {
	window.status='http://www.mainguyenmobile.com';
}

function newWindow(url,title,tool) {
	window.open(url,title,tool);
}

function fnCategories(s){	
	
	var whereIs = document.frm_main.category.options[document.frm_main.category.selectedIndex].value;	
	var mainCat = document.frm_main.main_category.value;
	var subCat = document.frm_main.sub_category.value;	
	var url = s + "?main_category=" + mainCat + "&sub_category=" + subCat + "&whereIs=" + whereIs;
	document.location = url;
	
}

function openVote() {
	var len = document.frm_vote.vote.length;
	var i = 0
	var found = false;
	var valueStr;	
	while (i < len && !found) {
		if (document.frm_vote.vote[i].checked == true){
			found = true;
			valueStr = document.frm_vote.vote[i].value;
		}
		i++;
	}
	window.open("votes.php?vote=" + valueStr,"VOTE","width=300,height=220");
}

showStatus();