function fnSet(){
	oHomePage.setHomePage(oHomeHref.value);
	event.returnValue = false;
}

function getCookie(name)
{
	var search;
	search = name + "=";
	offset = document.cookie.indexOf(search);
	if (offset != -1) {
		offset += search.length ;
		end = document.cookie.indexOf(";", offset) ;
		if (end == -1)
			end = document.cookie.length;
		return unescape(document.cookie.substring(offset, end));
	}
	else
	{
		return "";
	}
}

function homepage(domain,cname,alt)
{
	var stored;
	var lv;
	if (alt == "" || !alt)
		alt = "http://www.chohanoi.com";
	if ((stored = getCookie(cname)) == "")
	{
		var nextWeek = new Date();

		nextWeek.setTime (nextWeek.getTime() + (86400000*14));
		if ((lv = getCookie(cname + "_lastvisit")) == "")
		{
			document.cookie = cname + "=1" + "; expires=" + nextWeek.toGMTString() + "; path=/ ; domain=" + domain;
			document.body.style.behavior='url(#default#homepage)';
			document.body.setHomePage("http://" + domain + "/");
		}
	}
	var lastVisit = new Date();
	lastVisit.setTime (lastVisit.getTime() + 86400);
	document.cookie = cname + "_lastvisit=1" + "; expires=" + lastVisit.toGMTString() + "; path=/ ; domain=" + domain;
	return;
}

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 fnCategories(s){

	var whereId = document.frm_main.location.options[document.frm_main.location.selectedIndex].value;
	var catId = document.frm_main.category.value;
	var url = s + "category=" + catId + "&location=" + whereId;
//	var url = s + "&location=" + whereId;
	document.location = url;

}

function clickHelp() {
	message = '--------------------   HUONG DAN TIM KIEM   --------------------\n\nVi du tim tu: Nokia 8210\n+ De tim dung tu go: "Nokia 8210"\n+ De tim binh thuong: Nokia 8210\n+ De xem chi tiet ve search click "HOI & DAP" tu menu chinh ';
	alert(message);
}