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

function openWindows(str) {
	window.open(str);	
}

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,param,twidth,theight)
{
	var strurl= urlx + '?param=' + param;
	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.frmSearch;
	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;
		}
		
		frm.action = '?mod=products&act=search&keyword='+frm.keyword.value;
		frm.submit();
		return true;
	}
	
}

function checkSearch() {
	var frm = document.frmSearch;
	
	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;
	}
	
	
	frm.action = '?mod=products&act=search&keyword='+frm.keyword.value;
	frm.submit();
	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 Sosanh() {	
	var dem=0;
	for (var i=0;i<document.frmList.elements.length;i++){
		e = document.frmList.elements[i];
		if (e.checked) dem++;			
	}
	
	if(dem<2){
		alert("Xin vui lòng chọn ít nhất 2 sản phẩm để so sánh !");
	} 
	else if(dem>3) 
		{
			alert("Bạn chỉ được phép chọn tối đa 3 sản phẩm để so sánh !");	
		}
	else
	 {
			document.frmList.action = "?mod=products&act=compare";
			document.frmList.submit();
	}
}


