<!--

function search_all_modules(the_form){
	var module_url	= the_form.smodule.options[the_form.smodule.selectedIndex].value;
	if ( module_url != ""){
		the_form.action	= module_url;
		return true;
	}
	alert("Vui lòng chọn trang cần tìm !");
	return false;
}

function search_hospital_modules(){	
	var the_form = window.document.LIST_HOSPITAL;	
	var module_url	= the_form.smodule_hospital.options[the_form.smodule_hospital.selectedIndex].value;	
	if ( module_url != ""){		
		the_form.action	= module_url;
		the_form.submit();	
		return true;
	}
	alert("Vui lòng chọn bệnh viện phòng khám cần tìm !");
	return false;
}

function search_hospital_other_modules(){	
	var the_form = window.document.LIST_HOSPITAL_OTHER;	
	var module_url	= the_form.smodule_other.options[the_form.smodule_other.selectedIndex].value;	
	if ( module_url != ""){		
		the_form.action	= module_url;
		the_form.submit();	
		return true;
	}
	alert("Vui lòng chọn bệnh viện phòng khám cần tìm !");
	return false;
}


//Open normal popup
function showme(the_url, the_width, the_height, the_menu) {
	if ( the_width == 0 ){
		the_width	= screen.width;
	}
	if ( the_height == 0 ){
		the_height	= screen.height;
	}

	left_val	= (the_width > 0) ? (screen.width - the_width)/2 : 0;
	top_val		= (the_height > 0) ? (screen.height - the_height)/2 - 30 : 0;
	if (top_val < 0){ top_val	= 0; }
	if (the_menu == ""){ the_menu	= "no";	}

	window.open(the_url, "", "menubar="+ the_menu +", toolbar="+ the_menu +", scrollbars=yes, resizable=yes, width="+ the_width +", height="+ the_height +", top="+ top_val +", left="+ left_val);
}

//Open popup when users submit form
function open_popup_form(the_url, targetName, the_width, the_height){
	left_val	= (the_width > 0) ? (screen.width - the_width)/2 : 0;
	top_val		= (the_height > 0) ? (screen.height - the_height)/2 - 30 : 0;
	if (top_val < 0){ top_val	= 0; }

	window.open(the_url, targetName, "menubar=no, toolbar=no, scrollbars=yes, resizable=yes, width="+ the_width +", height="+ the_height +", top="+ top_val +", left="+ left_val);
}

//Check and open popup when use chose web links
function weblink_openURL(the_url){
	if ( the_url != "" ){
		window.open(the_url);
	}
}

function select_list(the_value, the_list){
	var option_count = the_list.options.length;	
	for (i=0; i<option_count; i++){
		if (the_value == the_list.options[i].value){
			the_list.options[i].selected	= true;
			break;
		}
	}
}

function radio_list(the_value,the_list){
	var name_count = the_list.length;	
	for (i=0; i<name_count; i++){
		if (the_value == the_list[i].value){
			the_list[i].checked	= true;
			break;
		}
	}
}


function cart_update(){
	window.document.CARTFORM.submit();
}
function cart_check_login_form(the_form) {
	if ( (the_form.email.value == "") || (the_form.password.value == "") ){
		alert("Xin quý khách vui lòng nhập email và mật khẩu.")
		return false;
	}
	return true;
}
function cart_check_reg_form(the_form) {
	if ( (the_form.fullname.value == "") || (the_form.address.value == "") || (the_form.phone.value == "") || (the_form.email.value == "") ){
		alert("Xin quý khách vui lòng nhập đầy đủ thông tin yêu cầu.\n\nChú ý: các thông tin có dấu \"*\" là bắt buột.")
		return false;
	}
	return true;
}
function cart_edit_order(the_url){
	var the_form	= window.document.VERIFYFORM;
	the_form.action	= the_url;
	the_form.submit();
}
function cart_copy_shipping_info(the_form){
	if ( the_form.shipping_copy.checked ){
		the_form.shipping_fullname.value	= the_form.fullname.value;
		the_form.shipping_company.value		= the_form.company.value;
		the_form.shipping_address.value		= the_form.address.value;
		the_form.shipping_phone.value		= the_form.phone.value;

		the_form.shipping_fullname.disabled	= true;
		the_form.shipping_company.disabled	= true;
		the_form.shipping_address.disabled	= true;
		the_form.shipping_phone.disabled	= true;
	}
	else{
		the_form.shipping_fullname.disabled	= false;
		the_form.shipping_company.disabled	= false;
		the_form.shipping_address.disabled	= false;
		the_form.shipping_phone.disabled	= false;
	}
}

 function alert_mess(){
 	alert('Sản phẩm này sẽ được giới thiệu trong thời gian sớm nhất.');
 }
 
 function FormatNumber(str){
	 
	  var strTemp = GetNumber(str);
	  if(strTemp.length <= 3)
		  return strTemp;
	  strResult = "";
	  for(var i =0; i< strTemp.length; i++)
		  strTemp = strTemp.replace(".", "");		        
	  var m=strTemp.lastIndexOf(",");
	  
	 if(m==-1)
	 {    
		  for(var i = strTemp.length; i>=0; i--)
		  {
			  if(strResult.length >0 && (strTemp.length - i -1) % 3 == 0)
				  strResult = "." + strResult;			         
			  strResult = strTemp.substring(i, i + 1) + strResult;		                
		  }   
	 }
	 else
	 {
		  //phần nguyên
		  var strphannguyen=strTemp.substring(0,strTemp.lastIndexOf(","));
		  var strphanthapphan=strTemp.substring(strTemp.lastIndexOf(","),strTemp.length);
		  //phần thập phân
		  var tam=0;	               
		  for(var i = strphannguyen.length; i>=0; i--)
		  {

				 if(strResult.length>0 && tam==4)
				  {		                        
					  strResult = "." + strResult;
				  } 

									   
			  strResult = strphannguyen.substring(i, i + 1) + strResult;
			  tam=tam+1;		                		                
		  }
		  strResult =strResult + strphanthapphan;
	 }
	  
	  return strResult;
  }
  function GetNumber(str)
  {
	  for(var i = 0; i < str.length; i++)
	  {	
		  var temp = str.substring(i, i + 1);		
		  if(!(temp == "," || temp == "." || (temp >= 0 && temp <=9)))
		  {
			  alert("Vui lòng nhập số (0-9)!");
			  return str.substring(0, i);
		  }
		  if(temp == " ")
			  return str.substring(0, i);
	  }
	  return str;
  }
  
  function IsNumberInt(str)
  {
	  for(var i = 0; i < str.length; i++)
	  {	
		  var temp = str.substring(i, i + 1);		
		  if(!(temp == "," || (temp >= 0 && temp <=9)))
		  {
			  alert("Vui lòng nhập số (0-9)!");
			  return str.substring(0, i);
		  }
		  if(temp == ".")
		  {
			  alert("Bạn sử dụng dấu , nếu muốn nhập số lẻ!");
			  return str.substring(0, i);
		  } 
//		            if(temp == " " || temp == ",")
//		                return str.substring(0, i);
	  }
	  return str;
  }


        
function ConvertPriceText(strTemp)
{                  
   strTemp        = strTemp.replace(/,/g, "");
   var priceTy    = parseInt(strTemp/1000000000,0)
   var priceTrieu = parseInt((strTemp % 1000000000)/1000000,0)
   var priceNgan  = parseInt(((strTemp % 1000000000))%1000000/1000,0)
   var priceDong  = parseInt(((strTemp % 1000000000))%1000000%1000,0)
   var strTextPrice = ""      
   if(strTemp == "" || strTemp == "0")
	strTextPrice = "Thương lượng";
   if(priceTy > 0 && parseInt(strTemp,0) > 900000000)
	strTextPrice = strTextPrice  + "<b>" + priceTy + "</b> tỷ "
   if(priceTrieu > 0)
	strTextPrice = strTextPrice  + "<b>" + priceTrieu + "</b> triệu "
   if(priceNgan > 0)
	strTextPrice = strTextPrice  + "</b>" + priceNgan + "</b> ngàn "
   /*if(document.getElementById("ddlCurrency").value == "vnd")
   {
		if(priceTy > 0 || priceTrieu > 0 || priceNgan > 0 || priceDong > 0)
			strTextPrice = strTextPrice  + "<b>VNĐ</b>"
   }
   if(document.getElementById("ddlCurrency").value == "sjc")
   {
		 if(priceDong > 0)
			strTextPrice = strTextPrice + priceDong
		 if(priceTy > 0 || priceTrieu > 0 || priceNgan > 0 || priceDong > 0)
			strTextPrice = FormatNumber(strTemp) + "<b> lượng SJC</b>"
   }
   if(document.getElementById("ddlCurrency").value == "usd")
   {
		if(priceDong > 0)
			strTextPrice = strTextPrice + priceDong
		if(priceTy > 0 || priceTrieu > 0 || priceNgan > 0 || priceDong > 0)
			strTextPrice = FormatNumber(strTemp) + "<b> USD</b>"
   }
   if(document.getElementById("ddlDonViDienTich").value == "md")
   {
		strTextPrice = strTextPrice + "<b> / Tổng diện tích</b>";
   }
   if(document.getElementById("ddlDonViDienTich").value == "m2")
   {
		strTextPrice = strTextPrice + "<b> / Mét vuông</b>";
   }
	if(document.getElementById("ddlDonViDienTich").value == "thang")
   {
		strTextPrice = strTextPrice + "<b> / Tháng</b>";
   }     
  document.getElementById("priceText").innerHTML = strTextPrice*/ 
}   
-->	
