function qvn_guidulieu(url,id, parameters) {  
http_request = false;  
if (window.XMLHttpRequest) { // Mozilla, Safari,...  
http_request = new XMLHttpRequest();  
if (http_request.overrideMimeType) {  
http_request.overrideMimeType('text/html');  
}  
} else if (window.ActiveXObject) { // IE  
try {  
http_request = new ActiveXObject("Msxml2.XMLHTTP");  
} catch (e) {  
try {  
http_request = new ActiveXObject("Microsoft.XMLHTTP");  
} catch (e) {}  
}  
}  
if (!http_request) {  
alert('Cannot create XMLHTTP instance');  
return false;  
}  
http_request.onreadystatechange = function()  
   {    
       document.getElementById('loading').innerHTML = '<div style="background: #ffffff; color: red; margin-top: 1px; padding: 2px 16px;"><img src="img/loading1.gif" align="absmiddle" height="25"> Loading, please...</div>';
       if (http_request.readyState == 4) {  
       if (http_request.status == 200) {  
       //alert(http_request.responseText);  
       result = http_request.responseText;  
       document.getElementById('loading').innerHTML = '';
       document.getElementById(id).innerHTML = result;
       } else {  
       alert('There was a problem with the request.');  
       return false;
       }  
       }  
   }  
http_request.open('POST', url, true);  
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");  
http_request.setRequestHeader("Content-length", parameters.length);  
http_request.setRequestHeader("Connection", "close");  
http_request.send(parameters);  
return true;
}
function qvnContact(){
poststr="DATA="+    encodeURIComponent(document.getElementById("name").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("address").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("phone").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("email").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("comments").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("securitycode").value);
qvn_guidulieu('home.php?qvn=contact','qvn_contact',poststr);
}
function qvnDealer(){
poststr="DATA="+    encodeURIComponent(document.getElementById("name").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("phone").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("email").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("compamy").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("address").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("city").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("state").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("country").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("comments").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("securitycode").value);
qvn_guidulieu('home.php?qvn=dealer','qvn_contact',poststr);
}
function AddCart(){
poststr="DATA="+ encodeURIComponent(document.getElementById("qty").value)+  
"QVN_SPACE" + encodeURIComponent(document.getElementById("pd_id").value);
qvn_guidulieu('cart.php?qvn=add','qcart_shopping',poststr);
}
function qvn_search(url,id, parameters) {  
http_request = false;  
if (window.XMLHttpRequest) { // Mozilla, Safari,...  
http_request = new XMLHttpRequest();  
if (http_request.overrideMimeType) {  
http_request.overrideMimeType('text/html');  
}  
} else if (window.ActiveXObject) { // IE  
try {  
http_request = new ActiveXObject("Msxml2.XMLHTTP");  
} catch (e) {  
try {  
http_request = new ActiveXObject("Microsoft.XMLHTTP");  
} catch (e) {}  
}  
}  
if (!http_request) {  
alert('Cannot create XMLHTTP instance');  
return false;  
}  
http_request.onreadystatechange = function()  
   {    
       document.getElementById('loading_search').innerHTML = '<div align="center" style="padding: 2px;"><img src="img/loading_search.gif"></div>';
       if (http_request.readyState == 4) {  
       if (http_request.status == 200) {  
       //alert(http_request.responseText);  
       result = http_request.responseText;  
       document.getElementById('loading_search').innerHTML = '';
       document.getElementById(id).innerHTML = result;
       } else {  
       alert('There was a problem with the request.');  
       return false;
       }  
       }  
   }  
http_request.open('POST', url, true);  
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");  
http_request.setRequestHeader("Content-length", parameters.length);  
http_request.setRequestHeader("Connection", "close");  
http_request.send(parameters);  
return true;
}
function search(){
poststr="DATA="+ encodeURIComponent(document.getElementById("search").value);
qvn_search('home.php?qvn=search','qdisplay',poststr);
}
function qvnShopping(){
poststr="DATA="+    encodeURIComponent(document.getElementById("name").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("email").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("company").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("address").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("address2").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("city").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("zipcode").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("country").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("phone").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("mobile").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("comments").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("fax").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("product").value)+  
"QVN_SPACE"+ encodeURIComponent(document.getElementById("securitycode").value);
//qvn('cart.php', 'qcart_shopping');
qvn_guidulieu('shoppingcart.php?qvn=done','qdisplay',poststr);
}

function isEmail(s)
{   
  if (s=="") return false;
  if(s.indexOf(" ")>0) return false;
  if(s.indexOf("@")==-1) return false;
  var i = 1;
  var sLength = s.length;
  if (s.indexOf(".")==-1) return false;
  if (s.indexOf("..")!=-1) return false;
  if (s.indexOf("@")!=s.lastIndexOf("@")) return false;
  if (s.lastIndexOf(".")==s.length-1) return false;
  var str="abcdefghikjlmnopqrstuvwxyz1234567890-@._"; 
  for(var j=0;j<s.length;j++)
	if(str.indexOf(s.charAt(j))==-1)
		return false;
   return true;
}
function checkSearch()	{
	var SearchText = 'Search Product';
	var SearchText_Error = '<div style="margin-top: -20px;" id="search_error"><div style="text-align: left; position: relative"><img src="img/tip.gif" border="0"></div><div style="background:#ffcf9c; border: 1px solid #ff8629; padding: 5px 15px; float: left; margin-top: -1px; position: relative; z-index: -111"><a href="javascript: search_error(0)" title="Close">Please enter Keyword</a></div></div>';
	var Length_Error = '<div style="margin-top: -20px;" id="search_error"><div style="text-align: left; position: relative"><img src="img/tip.gif" border="0"></div><div style="background:#ffcf9c; border: 1px solid #ff8629; padding: 5px 15px; float: left; margin-top: -1px; position: relative; z-index: -222"><a href="javascript: search_error(0)" title="Close">Minimum 3 characters</a></div></div>';
	//var Length = 'Minimum 3 characters';
	if(document.qvnsearch.search.value == "") {
	document.getElementById('qsearch').style.border = '1px solid #ff8000';
	document.getElementById('qsearch').style.background = '#ffeeb3';
	document.qvnsearch.search.focus();
	document.getElementById('loading').innerHTML  = SearchText_Error;
	return false;
	} else if(document.qvnsearch.search.value == SearchText) {
	document.getElementById('qsearch').style.border = '1px solid #ff8000';
	document.getElementById('qsearch').style.background = '#ffeeb3';
	document.qvnsearch.search.focus();
	document.getElementById('loading').innerHTML  = SearchText_Error;
	return false;
	} else if(document.qvnsearch.search.value.length < 3) {
	document.qvnsearch.search.focus();
	document.getElementById('loading').innerHTML  = Length_Error;
	return false;
	} else {
	document.getElementById('qsearch').style.border = '1px solid #97c4ff';
	document.getElementById('qsearch').style.background = '#eff6ff';
	document.getElementById('loading').innerHTML  = '';
	}
return true;
}
function search_error(s){
if(s == '0'){
document.getElementById('loading').innerHTML  = '';
document.qvnsearch.search.focus();
}
}
function checkShop()	{
	if(document.shop.name.value == "") {
		var textError = 'Please enter you name';
		document.getElementById('name').style.border = '1px solid #ef8520';
		document.getElementById('name').style.background = '#f9d8b9';
		document.shop.name.focus();
		document.getElementById('name_error').innerHTML  = textError;
		document.getElementById('name_error').style.color = 'red';
		document.getElementById('name_error').style.padding = '2px';
		return false;
	} else {
		document.getElementById('name').style.border = '1px solid #97c4ff';
		document.getElementById('name').style.background = '#eff6ff';
		document.getElementById('name_error').style.display = 'none';		
	}
	if(document.shop.email.value == "") {
		var textError = 'Please enter Email';
		document.getElementById('email').style.border = '1px solid #ef8520';
		document.getElementById('email').style.background = '#f9d8b9';
		document.shop.email.focus();
		document.getElementById('email_error').innerHTML  = textError;
		document.getElementById('email_error').style.color = 'red';
		document.getElementById('email_error').style.padding = '2px';
		return false;
	} else if (!isEmail(document.shop.email.value))
		{
		var error_text = 'Invalid Email, please enter Email';
		document.getElementById('email').style.border = '1px solid #ef8520';
		document.getElementById('email').style.background = '#ffe3ce';
		document.shop.email.focus();
		document.getElementById('email_error').style.color = 'red';
		document.getElementById('email_error').innerHTML  = error_text;
		return false;
		}
	else {
		document.getElementById('email').style.border = '1px solid #97c4ff';
		document.getElementById('email').style.background = '#eff6ff';
		document.getElementById('email_error').style.display = 'none';		
	}
	if(document.shop.company.value == "") {
		var textError = 'Please enter Company';
		document.getElementById('company').style.border = '1px solid #ef8520';
		document.getElementById('company').style.background = '#f9d8b9';
		document.shop.company.focus();
		document.getElementById('company_error').innerHTML  = textError;
		document.getElementById('company_error').style.color = 'red';
		document.getElementById('company_error').style.padding = '2px';
		return false;
	} else {
		document.getElementById('company').style.border = '1px solid #97c4ff';
		document.getElementById('company').style.background = '#eff6ff';
		document.getElementById('company_error').style.display = 'none';		
	}
	if(document.shop.address.value == "") {
		var textError = 'Please enter Address';
		document.getElementById('address').style.border = '1px solid #ef8520';
		document.getElementById('address').style.background = '#f9d8b9';
		document.shop.address.focus();
		document.getElementById('address_error').innerHTML  = textError;
		document.getElementById('address_error').style.color = 'red';
		document.getElementById('address_error').style.padding = '2px';
		return false;
	} else {
		document.getElementById('address').style.border = '1px solid #97c4ff';
		document.getElementById('address').style.background = '#eff6ff';
		document.getElementById('address_error').style.display = 'none';		
	}
	var phone = document.shop.phone.value;
	var soDienthoai=/(^\d+$)|(^\d+\.\d+$)/
	
	if(document.shop.phone.value == "") {
		var textError = 'Please enter Phone number';
		document.getElementById('phone').style.border = '1px solid #ef8520';
		document.getElementById('phone').style.background = '#f9d8b9';
		document.shop.phone.focus();
		document.getElementById('phone_error').innerHTML  = textError;
		document.getElementById('phone_error').style.color = 'red';
		document.getElementById('phone_error').style.padding = '2px';
		return false;
	}
	else if (soDienthoai.test(phone)) {
		document.getElementById('phone').style.border = '1px solid #97c4ff';
		document.getElementById('phone').style.background = '#eff6ff';
		document.getElementById('phone_error').style.display = 'none';
		}
		else{
		var textError = 'Invalid Phone, please enter Phone';
		document.getElementById('phone').style.border = '1px solid #ef8520';
		document.getElementById('phone').style.background = '#f9d8b9';
		document.contact.shop.focus();
		document.getElementById('phone_error').innerHTML  = textError;
		document.getElementById('phone_error').style.color = 'red';
		document.getElementById('phone_error').style.padding = '2px';
		return false;
		}
	if(document.shop.securitycode.value == "") {
		var textError = 'Please enter Security Code';
		document.getElementById('securitycode').style.border = '1px solid #ef8520';
		document.getElementById('securitycode').style.background = '#f9d8b9';
		document.shop.securitycode.focus();
		document.getElementById('securitycode_error').innerHTML  = textError;
		document.getElementById('securitycode_error').style.color = 'red';
		document.getElementById('securitycode_error').style.padding = '2px';
		return false;
	}
	else {
		document.getElementById('securitycode').style.border = '1px solid #97c4ff';
		document.getElementById('securitycode').style.background = '#eff6ff';
		document.getElementById('securitycode_error').style.display = 'none';		
	}
	document.shop.submit.disabled = true;
	document.shop.submit.value = 'Process, please...';
	document.shop.cancel.disabled = true;
	return true;
	}
function checkContact()	{
	if(document.contact.name.value == "") {
		var textError = 'Please enter you name';
		document.getElementById('name').style.border = '1px solid #ef8520';
		document.getElementById('name').style.background = '#f9d8b9';
		document.contact.name.focus();
		document.getElementById('name_error').innerHTML  = textError;
		document.getElementById('name_error').style.color = 'red';
		document.getElementById('name_error').style.padding = '2px';
		return false;
	} else {
		document.getElementById('name').style.border = '1px solid #97c4ff';
		document.getElementById('name').style.background = '#eff6ff';
		document.getElementById('name_error').style.display = 'none';		
	}
	if(document.contact.address.value == "") {
		var textError = 'Please enter Address';
		document.getElementById('address').style.border = '1px solid #ef8520';
		document.getElementById('address').style.background = '#f9d8b9';
		document.contact.address.focus();
		document.getElementById('address_error').innerHTML  = textError;
		document.getElementById('address_error').style.color = 'red';
		document.getElementById('address_error').style.padding = '2px';
		return false;
	} else {
		document.getElementById('address').style.border = '1px solid #97c4ff';
		document.getElementById('address').style.background = '#eff6ff';
		document.getElementById('address_error').style.display = 'none';		
	}
	
	var phone = document.contact.phone.value;
	var soDienthoai=/(^\d+$)|(^\d+\.\d+$)/
	
	if(document.contact.phone.value == "") {
		var textError = 'Please enter Phone number';
		document.getElementById('phone').style.border = '1px solid #ef8520';
		document.getElementById('phone').style.background = '#f9d8b9';
		document.contact.phone.focus();
		document.getElementById('phone_error').innerHTML  = textError;
		document.getElementById('phone_error').style.color = 'red';
		document.getElementById('phone_error').style.padding = '2px';
		return false;
	}
	else if (soDienthoai.test(phone)) {
		document.getElementById('phone').style.border = '1px solid #97c4ff';
		document.getElementById('phone').style.background = '#eff6ff';
		document.getElementById('phone_error').style.display = 'none';
		}
		else{
		var textError = 'Invalid Phone, please enter Phone';
		document.getElementById('phone').style.border = '1px solid #ef8520';
		document.getElementById('phone').style.background = '#f9d8b9';
		document.contact.phone.focus();
		document.getElementById('phone_error').innerHTML  = textError;
		document.getElementById('phone_error').style.color = 'red';
		document.getElementById('phone_error').style.padding = '2px';
		return false;
		}
	if(document.contact.email.value == "") {
		var textError = 'Please enter Email';
		document.getElementById('email').style.border = '1px solid #ef8520';
		document.getElementById('email').style.background = '#f9d8b9';
		document.contact.email.focus();
		document.getElementById('email_error').innerHTML  = textError;
		document.getElementById('email_error').style.color = 'red';
		document.getElementById('email_error').style.padding = '2px';
		return false;
	} else if (!isEmail(document.contact.email.value))
		{
		var error_text = 'Invalid Email, please enter you Email';
		document.getElementById('email').style.border = '1px solid #ef8520';
		document.getElementById('email').style.background = '#ffe3ce';
		document.contact.email.focus();
		document.getElementById('email_error').style.color = 'red';
		document.getElementById('email_error').innerHTML  = error_text;
		return false;
		}
	else {
		document.getElementById('email').style.border = '1px solid #97c4ff';
		document.getElementById('email').style.background = '#eff6ff';
		document.getElementById('email_error').style.display = 'none';		
	}
	
	if(document.contact.comments.value == "") {
		var textError = 'Please enter comments';
		document.getElementById('comments').style.border = '1px solid #ef8520';
		document.getElementById('comments').style.background = '#f9d8b9';
		document.contact.comments.focus();
		document.getElementById('comments_error').innerHTML  = textError;
		document.getElementById('comments_error').style.color = 'red';
		document.getElementById('comments_error').style.padding = '2px';
		return false;
	}
	else {
		document.getElementById('comments').style.border = '1px solid #97c4ff';
		document.getElementById('comments').style.background = '#eff6ff';
		document.getElementById('comments_error').style.display = 'none';		
	}
	if(document.contact.securitycode.value == "") {
		var textError = 'Please enter Security Code';
		document.getElementById('securitycode').style.border = '1px solid #ef8520';
		document.getElementById('securitycode').style.background = '#f9d8b9';
		document.contact.securitycode.focus();
		document.getElementById('securitycode_error').innerHTML  = textError;
		document.getElementById('securitycode_error').style.color = 'red';
		document.getElementById('securitycode_error').style.padding = '2px';
		return false;
	}
	else {
		document.getElementById('securitycode').style.border = '1px solid #97c4ff';
		document.getElementById('securitycode').style.background = '#eff6ff';
		document.getElementById('securitycode_error').style.display = 'none';		
	}
	document.contact.submit.disabled = true;
	document.contact.submit.value = 'Process, please...';
	document.contact.reset.disabled = true;
	return true;
	}
function addcart(){
return hs.htmlExpand(this, { objectType: 'ajax', preserveContent: true} );
qvn('cart.php','qcart_shopping');
}

