var _disable_empty_list=false;
var _hide_empty_list=false;
function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}
if (navigator.cookieEnabled == 0) {
  alert("Bạn chưa bật Cookies do đó một số chức năng sẽ không hoạt động!");
}
function save_cookieline(cookie_name, cookie_value){
	document.cookie = cookie_name + "=" + cookie_value;
}

function getCookieline(c_name){
	if(document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if(c_start!=-1){ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}
function CheckNumber(number)
{
	var pattern = "0123456789";
	var len = number.value.length;
	if (len != 0)
	{
		var index = 0;
		
		while ((index < len) && (len != 0))
			if (pattern.indexOf(number.value.charAt(index)) == -1)
			{
				if (index == len-1)
					number.value = number.value.substring(0, len-1);
				else if (index == 0)
					 	number.value = number.value.substring(1, len);
					 else number.value = number.value.substring(0, index)+number.value.substring(index+1, len);
				index = 0;
				len = number.value.length;
			}
			else index++;
	}
}

function setPaymentInfo(isChecked)
{
	with (window.document.form1) {
		if (isChecked) {
			name2.value  = name.value;
			gioitinh2.value  = gioitinh.value;
			add2.value  = add.value;
			tinhthanh2.value  = tinhthanh.value;
			tel2.value  = tel.value;
			email2.value  = email.value;
						
			name2.readOnly  = false;
			gioitinh2.readOnly  = false;
			add2.readOnly  = false;
			tinhthanh2.readOnly  = false;
			tel2.readOnly  = false;
			email2.readOnly  = false;
			
		} else {
			name2.readOnly  = false;
			gioitinh2.readOnly  = false;
			add2.readOnly  = false;
			tinhthanh2.readOnly  = false;
			tel2.readOnly  = false;
			email2.readOnly  = false;
					
		}
	}
}
function changeActiveStates(ele) {
if (prevLink) byId(prevLink).className = "";
ele.className = 'activate';
prevLink = ele.id;
}
var shop_info=0;
function shopshow(){
if(shop_info==0){
document.getElementById("createshop").style.display='block';
shop_info=1;
}else{;
document.getElementById("createshop").style.display='none';
shop_info=0;
}
}
function numberFormat(nStr){
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1))
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
  return x1 + x2;
}

window.jQueryPatchIPadOffset = false;
var amznJQ = {
_a: [], _s: [], _d: [], _l: [], _o: [], _c: [], _cs: [],
addLogical: function() {
this._l.push(arguments)
},
addStyle: function() {
this._s.push(arguments)
},
declareAvailable: function() {
this._d.push(arguments)
},
available: function() {
this._a.push(arguments)
},
onReady: function() {
this._o.push(arguments)
},
onCompletion: function() {
this._c.push(arguments)
},
completedStage: function() {
this._cs.push(arguments)
},
metrics: 0,
strings: {},
chars: {
EOL: String.fromCharCode(0x0A),
SQUOTE: String.fromCharCode(0x27),
DQUOTE: String.fromCharCode(0x22),
BACKSLASH: String.fromCharCode(0x5C),
YEN: String.fromCharCode(0xA5)
}
}
window.AmazonPopoverImages = { 
pixel: '/images/blank-pixel._V192192429_.gif'
};	
amznJQ.addLogical('navbarCSSUSSA185', []);
amznJQ.addLogical('navbarJS-jQuery', []);   	


if (typeof window.Navbar == 'undefined') {
window.Navbar = function(options) {
options = options || {};
this._loadedCount = 0;
this._hasUedata = (typeof uet == 'function');
this._finishLoadQuota = options['finishLoadQuota'] || 2;
this._startedLoading = false;
this._btfFlyoutContents = [];

this._saFlyoutHorizOffset = -16;
this._saMaskHorizOffset = -17;
this._saMenuItemHt = 28;
this.addToBtfFlyoutContents = function(content, callback) {
this._btfFlyoutContents.push({content: content, callback: callback});
}
this.getBtfFlyoutContents = function() {
return this._btfFlyoutContents;
}
this.loading = function() {
if (!this._startedLoading && this._isReportingEvents()) {
uet('ns');
}
this._startedLoading = true;
}
this.componentLoaded = function() {
this._loadedCount++;
if (this._startedLoading && this._isReportingEvents() && (this._loadedCount == this._finishLoadQuota)) {
uet('ne');
}
}
this._isReportingEvents = function() {
return this._hasUedata;
}
}
window._navbar = new Navbar({ finishLoadQuota: 1});
window.navSAFlyoutDelay = 0;
}
  
var isIE		= (navigator.userAgent.toLowerCase().indexOf("msie") == -1 ? false : true);
var isIE6	= (navigator.userAgent.toLowerCase().indexOf("msie 6") == -1 ? false : true);
var isIE7	= (navigator.userAgent.toLowerCase().indexOf("msie 7") == -1 ? false : true);
// Show sản phẩm theo độ phân giải màn hình
function changeDataMatchResolution(sel){
	
	if(sel == "") sel = ".listproduct";
	$(sel).each(function(index){
		
		width		= (typeof($(this).attr("dataWidth")) != "undefined" ? $(this).attr("dataWidth") : (isIE ? 157 : 158));
		col		= (typeof($(this).attr("dataCol")) != "undefined" ? $(this).attr("dataCol") : 8);
		
		numCol	= parseInt($(this).width() / width);
		if(numCol < 3) numCol = 3;
		if(numCol > col) numCol = col;
		colWidth	= 100 / numCol;
		if(isIE6 || isIE7) colWidth = colWidth - 0.1;
		
		$(this).find(".fl").width(colWidth + "%");
		n = $(this).attr("dataLine") * numCol;
		
		$(this).find(".fl:lt(" + n + ")").removeClass("hidden");
		if(n > 0) $(this).find(".fl:gt(" + (n-1) + ")").addClass("hidden");
		
		// Trường hợp page_div nằm bên trong
		$(this).find(".page_div a, .page_div_top a").each(function(index2){
			$(this).attr("href", function(index3, attr){
				return changePageSize(attr, n);
			});
		});
		
		// Trường hợp page_div nằm bên ngoài
		if($(this).hasClass("view_thumbnail_table") == true){
			$(this).parent().find(".page_div a, .page_div_top a").each(function(index2){
				$(this).attr("href", function(index3, attr){
					return changePageSize(attr, n);
				});
			});
		}
		
	});
	
}
// Resize window về đúng độ phân giải màn hình (Full Screen)
function resizeWindow(){
	
	minWidth	= 996;
	width		= ($("body").width() < minWidth ? minWidth : $("body").width());
	if($("#box_body").width() == 1000) width = 1000;	
	$("#box_body").width(width);	
	changeDataMatchResolution("");
	
}

function initLoad(){	
	if(!isIE6){
		resizeWindow();
		$(window).resize(function(){
			resizeWindow();
		});
	}	
}
// JavaScript Document
function Footerinbottom(){
	$(".footer_bottom").height(0);
	// Fix lại chiều cao #box_left để tránh trường hợp bên phải thấp hơn bên trái footer sẽ bị đè
	if($(".box_left").height() !== null){
		if($(".box_center").height() !== null){
			height	= ($(".box_center").height() < $(".box_right").height() ? $(".box_right").height() : $(".box_center").height());
			if(height < $(".box_left").height()){
				footer_bottom	= $(".box_left").height() - height;
				$(".footer_bottom").height(footer_bottom);
			}
		}
		else{
			if($(".box_center_shop").height() < $(".box_left").height()){
				footer_bottom	= $(".box_left").height() - $(".box_center_shop").height();
				$(".footer_bottom").height(footer_bottom);
			}
		}
	}
}
function initLoaded(){	
	if($("#box_body").width() >= 900) $().css("width", "auto");	
	Footerinbottom();	
}
//menu left
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
	}

		function getmenucap2(strURL,idmenu) {		
		var req = getXMLHTTP();		
		if (req) {			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById(idmenu).innerHTML=req.responseText;						
					} else {
						disabled = false;
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
			
				
	}
	// end menu

function getbinhluanphanhoi(strURL,idmenu) {		
		var req = getXMLHTTP();		
		if (req) {			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById(idmenu).innerHTML=req.responseText;						
					} else {
						disabled = false;
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}	
				
	}
function searchtype(strURL) {		
		var req = getXMLHTTP();		
		if (req) {			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('').innerHTML=req.responseText;						
					} else {
						disabled = false;
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}	
				
	}
function keywordseach(theF){
if (theF.keywords.value==""){
alert ("Bạn chưa nhập từ khóa cần tìm!");
theF.keywords.focus();
return (false);
}
return (true);
}
function menuover(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}
function buildsubmenus(){
for (var i=0; i<menuleft.length; i++){
  var ultags=document.getElementById(menuleft[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
    ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
		if (ultags[t].parentNode.parentNode.id==menuleft[i])
			ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px"
		else //else if this is a sub level submenu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" 
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.display="block"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.display="none"
    }
    }
		for (var t=ultags.length-1; t>-1; t--){
		ultags[t].style.visibility="visible"
		ultags[t].style.display="none"
		}
  }
}
