
function brand_onchange(div,catid,name)
{
	
//alert (catid);	
var url="loadModel.php?catid="+catid+"&name="+name;
//alert (url);
var oXmlHttp = zXmlHttp.createRequest();
     oXmlHttp.open("get",url,true);
     oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                div = document.getElementById(div);				
                div.innerHTML = oXmlHttp.responseText;
                div.style.display = "";
            }
        }
    }
    oXmlHttp.send(null);
}

function brand_onchange2(div,catid,name)
{
var url="loadModel2.php?catid="+catid+"&name="+name;
//alert (url);
var oXmlHttp = zXmlHttp.createRequest();
     oXmlHttp.open("get",url,true);
     oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                div = document.getElementById(div);				
                div.innerHTML = oXmlHttp.responseText;
                div.style.display = "";
            }
        }
    }
    oXmlHttp.send(null);
}



function brand_onchange3(div,catid,name)
{
var url="loadModel3.php?catid="+catid+"&name="+name;
//alert (url);
var oXmlHttp = zXmlHttp.createRequest();
     oXmlHttp.open("get",url,true);
     oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                div = document.getElementById(div);				
                div.innerHTML = oXmlHttp.responseText;
                div.style.display = "";
            }
        }
    }
    oXmlHttp.send(null);
}
function brand_onchange4(div,catid,name)
{
var url="loadModel4.php?catid="+catid+"&name="+name;
//alert (url);
var oXmlHttp = zXmlHttp.createRequest();
     oXmlHttp.open("get",url,true);
     oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                div = document.getElementById(div);				
                div.innerHTML = oXmlHttp.responseText;
                div.style.display = "";
            }
        }
    }
    oXmlHttp.send(null);
}


function binhchon(id,thietke,tinhnang,hieuqua)
{
/*alert  (id);
alert  (thietke);
alert  (tinhnang);
alert  (hieuqua);*/
var url="dtc_add_comment.php?id="+id+"&thietke="+thietke+"&tinhnang="+tinhnang+"&hieuqua="+hieuqua;
				//alert (url);
				var oXmlHttp = zXmlHttp.createRequest();
			 oXmlHttp.open("get",url,true);
			 oXmlHttp.onreadystatechange = function () {
				if (oXmlHttp.readyState == 4)
				{
					if (oXmlHttp.status == 200)
					{
						alert ('Cảm ơn đã bình chọn cho sản phẩm này');							
					}
				}
			}
			oXmlHttp.send(null);
}
function isEmail(s)
{   
  if (s=="") return false;
  if(s.indexOf(" ")>0) return false;
  var i = 1;
  var sLength = s.length;
  if (s.indexOf(".")==sLength) return false;
  if (s.indexOf(".")<=0) return false;
  if (s.indexOf("@")!=s.lastIndexOf("@")) return false;

  while ((i < sLength) && (s.charAt(i) != "@"))
  { i++
  }

  if ((i >= sLength) || (s.charAt(i) != "@")) return false;
  else i += 2;

  while ((i < sLength) && (s.charAt(i) != "."))
  { i++
  }

  if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
   var str="abcdefghikjlmnopqrstuvwxyz0123456789-@._";
   for(var j=0;j<s.length;j++)
    if(str.indexOf(s.charAt(j))==-1)
        return false;
   return true;
}
function checkEmail()
{
	var content = document.getElementById("txtcontent").value;	
	var email = document.getElementById("txtemail").value;
	var id = document.getElementById("txtid").value;
	content.replace('/n','<br>');
	
	
	//alert (content);
	//alert (nmail);
	//alert (id);
//	alert ("1");
	
    if (isEmail(email))
   {
		if( content =='')
		{
		alert ('Mời nhập nội dung');
		
		return false
		}	
		else
		{	
			//var url="dtc_add_comment.php?id="+a+"&email="+email+"&content="+content;
				//alert (url);
			//	var oXmlHttp = zXmlHttp.createRequest();
			// oXmlHttp.open("get",url,true);
			// oXmlHttp.onreadystatechange = function () {
			//	if (oXmlHttp.readyState == 4)
			//	{
				//	if (oXmlHttp.status == 200)
			//		{
				//		alert ('Nội dung đã được gửi cho quản trị viên');							
				//	}
			//	}
			//}
			//oXmlHttp.send(null);
			//}
			return true
	   }
   }
   else
   {
    alert ('Mời nhập lại email');    
	return false
   }
}





function loadsearch(catid,producename){
	var url="loadphukien.php?catid="+catid+"&producename="+producename;
//alert (url);
	var oXmlHttp = zXmlHttp.createRequest();
     oXmlHttp.open("get",url,true);
     oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                var disPlayPhuKien = document.getElementById("disPlayPhuKien");
                disPlayPhuKien.innerHTML = oXmlHttp.responseText;
                disPlayPhuKien.style.display = "block";
            }
        }
    }
    oXmlHttp.send(null);

}


