function ajaxPost(){
    var email = (document.getElementById("email").value);
	if(email==""){
		alert("Bạn chưa điền email !");
		return false;
	}else{
		if(email.indexOf("@")==-1 || email.indexOf(".")==-1){
			alert("Không fải Email ! Bạn hãy viết đầy đủ");
			return false;
		}else{
			document.getElementById("hienthiok").innerHTML = '<img src=/includes//images/awaiting1111.gif>';
			poststr=email;
			$("#hienthiok").load("/modules/ajax/email_register_ajax.php",{
				DATA : poststr
			});
		}
	}
	
}

function addFavorite(id,user_id){
	var poststr = id+"SPACE"+user_id;
	$("#favorite").load("modules/ajax/add_favorite.php",{
		DATA : poststr
	});
}


function choice_color(id,color){
	$(".color").load("/modules/ajax/choice_color_pro.php?proId=" + id +"&color="+color);
}



function choice_color_pro(color){
	//document.getElementById("proImageThum_"+list_color).style.display = "none";
	var current_color = document.getElementById('current_color').value;
	
	document.getElementById('current_color').value = color;
	document.getElementById("proImageThum_"+current_color).style.display = "none";
	//document.getElementById("default_thum_"+current_color).style.display = "none";

	
	document.getElementById("proImageThum_"+color).style.display = "block";
	//document.getElementById("default_thum_"+color).style.display = "block";
	
	document.getElementById("proImageThum").style.display = "none";
	//document.getElementById("default_thum").style.display = "none";
	
}

function choice_color_pro_default(){
	var current_color = document.getElementById("current_color").value;
	
	//document.getElementById("proImageThum_"+color).style.display = "block";
	document.getElementById("proImageThum").style.display = "block";
	document.getElementById("proImageThum_"+current_color).style.display = "none";
	
	//document.getElementById("default_thum").style.display = "block";
	//document.getElementById("default_thum_"+current_color).style.display = "none";

}

/*TIm kiem ajax*/
function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		$.post("modules/ajax/show_key_search.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup
function hiddenup() {
	$('#suggestions').hide();
}
function fill(thisValue) {
	$('#name').val(thisValue);
	setTimeout("$('#suggestions').hide();", 200);
}

function get_value(name){
	 document.getElementById("name").value = name;
}

function loadVideo(id){
	$("#loadVideo").load("modules/ajax/loadVideo.php?proId=" +id);
}

function open_ajax_360(storeId){tb_show(null, "modules/ajax/product_360.php?width=550&height=400&Id="+storeId+"&KeepThis=true&TB_iframe=true", null);}


function open_ajax_video(storeId, storeName){tb_show(null, "modules/ajax/video.php?width=550&height=400&proId="+storeId+"&KeepThis=true&TB_iframe=true", null);}
//&storeId="+storeId+"&storeName="+storeName+"&KeepThis=true&TB_iframe=true

// JavaScript Document
function goComparePage(categoryId){
    var compareList = document.getElementById("hdn_compare_product_list").value;
    var numberProduct = compareList.split(';').length;
    if(numberProduct > 3){
		window.location.href = "/?option=compare&catId="+ categoryId +"&hdn_compare_product_list="+compareList;
       // alert(numberProduct);
    }else{
        alert("Bạn cần chọn ít nhất 2 sản phẩm để so sánh\nChọn sản phẩm bằng tích ô dưới ảnh sản phẩm");
    }
}

function checkEmail(){
	var email = document.getElementById("email").value;
	if(email==""){
		alert("Bạn chưa điền email !");
		return false;
	}else{

		if(email.indexOf("@")==-1 || email.indexOf(".")==-1){
			alert("Không fải Email ! Bạn hãy viết đầy đủ");
			return false;
		}
	}
	return true;


}

function share_(giatri)
{

	var	u=location.href;
	var t=document.title;
	if(giatri=="facebook"){
		window.open("http://www.facebook.com/share.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t));
	}else if(giatri=="twitter"){
		window.open("http://twitter.com/home?status=" + encodeURIComponent(u));
	}

}
function lang(giatri)
{
	var	u=location.href;
	var t=document.title;
	if(giatri=="en"){
		window.open(u+"?lang="+giatri);
	}else if(giatri=="vn"){
		window.open(u+"?lang="+giatri);
	}

}
