function validateLogin(){var username=document.getElementById('username').value;var password=document.getElementById('password').value;if(username==''||username==null||password==''||password==null){alert('Vui lòng nhập tên đăng nhập và mật khẩu');return false;}else return true;}
function checkSearchValue(){var searchKeyword=document.searchForm.keyword
if((searchKeyword.value==null)||(searchKeyword.value=="")){alert("Bạn cần nhập từ khóa để tìm kiếm")
searchKeyword.focus()
return false}
return true}
function httpRequest(reqType,url,asynch){var xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}
catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;}
function fixImgs(whichId,maxW){var pix=document.getElementById(whichId).getElementsByTagName('img');for(i=0;i<pix.length;i++){w=pix[i].width;h=pix[i].height;if(w>maxW){f=1-((w-maxW)/w);pix[i].width=w*f;pix[i].height=h*f;}}}
function show_more_address(sellerId){var check_open=document.getElementById('open_box_address_'+sellerId).style.display;if(check_open=="none"){document.getElementById('open_box_address_'+sellerId).style.display="block";document.getElementById('open_address_'+sellerId).style.display="block";document.getElementById('close_box_address_'+sellerId).style.display="none";document.getElementById('close_address_'+sellerId).style.display="none";}else{document.getElementById('open_box_address_'+sellerId).style.display="none";document.getElementById('open_address_'+sellerId).style.display="none";document.getElementById('close_box_address_'+sellerId).style.display="block";document.getElementById('close_address_'+sellerId).style.display="block";}}//minifie

//Cookies
function checkBrowserEnableCookie(){var cookieEnabled=(navigator.cookieEnabled)?true:false
if(typeof navigator.cookieEnabled=="undefined"&&!cookieEnabled){document.cookie="testcookie"
cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)?true:false}
if(cookieEnabled)return true;else return false;}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
function countShoppingCart(name){if(readCookie(name)==null){createCookie(name,'-',1);document.getElementById('count_shopping_cart').innerHTML=0;}else{var current_cart=readCookie(name);var ca=current_cart.split(',');number_product=ca.length;document.getElementById('count_shopping_cart').innerHTML=number_product-1;}}
function emptyShoppingCart(name){createCookie(name,'-',1);}
function addToShoppingCart(sellid,quantity){if(readCookie('shopping_cart')==null){createCookie('shopping_cart',',',1);}
var current_cart=readCookie('shopping_cart');if(current_cart.search(','+sellid+'-')==-1){var new_cart=current_cart+','+sellid+'-'+quantity;createCookie('shopping_cart',new_cart,1);countShoppingCart('shopping_cart');document.getElementById('item_'+sellid).innerHTML='Đã thêm vào giỏ hàng';}else{alert('Sản phẩm đã có trong giỏ hàng!');}}
function checkItemInCart(sellid){var current_cart=readCookie('shopping_cart');if(current_cart != null && current_cart.search(','+sellid+'-')!=-1){document.write('Trong giỏ hàng');}else{document.write('<a href=\"javascript:addToShoppingCart('+sellid+',1);\">Thêm giỏ hàng</a>');}}
function deleteShoppingCartItem(sellid,quantity){if(confirm('Bạn muốn xóa bỏ sản phẩm này khỏi giỏ hàng ? ')){var current_cart=readCookie('shopping_cart');new_cart=current_cart.replace(","+sellid+'-'+quantity,"");createCookie('shopping_cart',new_cart,1);countShoppingCart('shopping_cart');window.location.href='gio-hang.html';}}//minified


//Java khi di chuot vao DANH MUC SAN PHAM THI HIEN RA
 function showMenuit(f){
	 if(f){visi="visible";}
	 else{visi="hidden";}
	 if(document.layers){document.menuit.visibility=visi;}
	 if(document.all){document.all.menuit.style.visibility=visi;}
	 if(document.getElementById){document.getElementById("menuit").style.visibility=visi;}
 } 
 