// JavaScript Document
function gotoUrl(str){
	window.location.href = str;
}

function openWindows(str) {
	window.open(str);	
}
function submitlLink(){
	if(document.Frm_poll.chon==""){
		alert("Ban can phai chon tieu chi binh chon");
		return false;
	}
	return true;
}
function changeto(obj,strClass){
	if(strClass!=""){
		obj.className = strClass;		
	}
	obj.style.cursor = 'hand';
}

function dropCategory(obj){
	
	if(obj.className == "on"){
		obj.className = "off";
		document.frmTemp.objdrop.value = "";	
	}
	else{
		obj.className = "on";
		if(document.frmTemp.objdrop.value != ""){
			identity=document.getElementById(document.frmTemp.objdrop.value);
			identity.className = "off";
		}
		document.frmTemp.objdrop.value = obj.id;
	}
}

function winpopup(urlx,twidth,theight)
{
	var frmPoll = document.Frm_poll;
	var len = frmPoll.elements["chon"].length;
	var check = false;
	var id = 0;
	
	for(var i=0; i<len ; i++) 
		if(frmPoll.elements["chon"][i].checked)
			{
				check = true;
				id = frmPoll.elements["chon"][i].value;
				break;
			}
	
	if(!check) {
		alert("Xin vui long chon mot tieu chi binh chon !");		
	}
	else {
		var strurl= urlx + '?id=' + id;
		var tposx= (screen.width- twidth)/2
		var tposy= (screen.height- theight)/2;
	
		var newWin=window.open(strurl,"NVCOM","toolbar=no,width="+ twidth+",height="+ theight+ ",directories=no,status=no,scrollbars=yes,resizable=no, menubar=no")
		newWin.moveTo(tposx,tposy);
		newWin.focus();
	}
}

function winpopup2(urlx,twidth,theight)
{
	var strurl= urlx;
	var tposx= (screen.width- twidth)/2
	var tposy= (screen.height- theight)/2;

	var newWin=window.open(strurl,"NVCOM","toolbar=no,width="+ twidth+",height="+ theight+ ",directories=no,status=no,scrollbars=yes,resizable=no, menubar=no")
	newWin.moveTo(tposx,tposy);
	newWin.focus();
}

function submitSearch(field,e) {
	
	var frm = document.frmSearch1;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13) {
		if(frm.keyword.value == "") {
			alert("Xin vui lòng nhập từ khóa cần tìm  !");
			frm.keyword.focus();
			return false;
		}
		else{
		
		frm.action ='?mod=product&act=search&keyword='+frm.keyword.value;
		frm.submit();
		return true;
		}
	}

}

function checkSearch() {
	var frm = document.frmSearch1;
	
	if(frm.keyword.value == "") {
		alert("Xin vui lòng nhập từ khóa cần tìm !");
		frm.keyword.focus();
		retval = false;
		return false;
	}
	
	
	window.location.href = '?mod=product&act=search&keyword='+frm.keyword.value;
		
	return true;
}

function openNewImage(file)
{	 	
	picfile = new Image(); 
	picfile.src =(file);           
	width=picfile.width;
	height=picfile.height;
	
	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(height).concat(',').concat('width=').concat(width).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - height)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - width)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a style="cursor:pointer" href="javascript:window.close()"><img src="', file, '" border=0></a>');
	newwin.document.writeln('</body>');

}

function checkLogin() {
	var frm = document.frmLogin;
	if(frm.user_username.value == "" || frm.user_password.value == "")
		return false;
	else {
		frm.doLogin.value = "signin";
		frm.submit();
		return true;
	}
}

