	function ShowPrice2(price, index, active, unit)
	{
		var currencies = new Array("vnd", "sjc", "usd");
		for(var i in currencies)
		{
			var obj = document.getElementById(currencies[i] + index);
			if(currencies[i] == active)
				obj.className = "selected " + currencies[i];
			else
				obj.className = currencies[i];
			if(IsNumeric(price))
				document.getElementById("price" + index).innerHTML = price+" <span class='date'>"+unit+"</span>";
			else
				document.getElementById("price" + index).innerHTML = price;
		}
	}
		


	function ShowPrice(price, index, active, unit)
	{
		var currencies = new Array("vnd", "sjc", "usd");
		for(var i in currencies)
		{
			var obj = document.getElementById(currencies[i] + index);
			if(currencies[i] == active)
				obj.className = "selected " + currencies[i];
			else
				obj.className = currencies[i];
			if(IsNumeric(price))
				document.getElementById("price" + index).innerHTML = price+" <span class='date'>"+unit+"</span>";
			else
				document.getElementById("price" + index).innerHTML = price;
		}
	}
	function IsNumeric(sText)
	{
	   var ValidChars = "0123456789,.";
	   var IsNumber=true;
	   var Char;
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
		  { 
		  Char = sText.charAt(i); 
		  if (ValidChars.indexOf(Char) == -1) 
			 {IsNumber = false;}
		  }
	   return IsNumber;
	}
	
	function AddCondition(name, value)
	{
		if(!conditions) return;
		if(!name) return;
		conditions[name] = value;
		FilterByConditions()
	}
	
	function AddConditions(cons)
	{
		if(!conditions) return;
		if(!cons) return;
		for(var i in cons)
		{
			var condition = cons[i];
			if(condition) conditions[condition.name] = condition.value;
		}
		FilterByConditions();
	}
	
	function RemoveConditions(names)
	{
		if(!conditions) return;
		if(!names) return;
		names = names.split(",")
		for(var i in names)
		{
			conditions[names[i]] = null;
		}
		FilterByConditions();
	}
	
	function FilterByConditions()
	{
		if(!conditions) return;
		var url = "";
		var params = new Array();
		for(var i in conditions)
		{
			var param = conditions[i];
			if(param) params[params.length] = i + "=" + escape(param);
		}
		url = "/web/sieuthi/loc/" + params.join(",");
		location = url;
	}
   
	function ParseParams(params)
	{
		params = params.split(",");
		for(var i in params)
		{
			var param = params[i];
			if(param)
			{
				param = param.split("=");
				if(param[0]) conditions[param[0]] = param[1];
			}                
		}
	}
	
	var conditions = new Array();
	ParseParams("");


function clearText(thefield)
{
	alert('OK');
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}
function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


var newwindow;
function openwindow(url,name)//Mở cửa xỏ mới
{
	newwindow=window.open(url,name,'height=350,width=500,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=yes');
	if (window.focus) {newwindow.focus()}
}
	
function destination(route)//Điểm kết thúc
	{
	switch (route)
		{
			case "0": divdestination.innerHTML="";
			break;
			case "1": divdestination.innerHTML="<select onchange=\"javascript:timego(theForm.txtstart.value,this.options[this.selectedIndex].value)\;\" name=txtdestination class='selectoption' style='width:100px;'><option value='0'>Nơi đến</option><option value='2'>Lào Cai</option></select>";
			break;
			case "2": divdestination.innerHTML="<select onchange=\"javascript:timego(theForm.txtstart.value,this.options[this.selectedIndex].value)\;\" name=txtdestination class='selectoption' style='width:100px;'><option value='0'>Nơi đến</option><option value='1'>Hà Nội</option></select>";
			break;
		}	
	}	
	
	

function destination_admin(route)//Điểm kết thúc
	{
	switch (route)
		{
			case "0": divdestination.innerHTML="";
			break;
			case "1": divdestination.innerHTML="<select name=txtdestination class='selectoption' style='width:100px;'><option value='0'>Nơi đến</option><option value='2'>Lào Cai</option></select>";
			break;
			case "2": divdestination.innerHTML="<select name=txtdestination class='selectoption' style='width:100px;'><option value='0'>Nơi đến</option><option value='1'>Hà Nội</option></select>";
			break;
		}	
	}		
	
	
	
	
function destination_updateticket(route)//Điểm kết thúc
	{
	switch (route)
		{
			case "0": divdestination.innerHTML="";
			break;
			case "1": divdestination.innerHTML="Đến:&nbsp;<select onchange=\"javascript:ajaxpage('cnnel.php?cid=22,29&txtstart='+theForm.txtstart.value+'&txtdestination='+this.options[this.selectedIndex].value, 'divchairtype');\" name=txtdestination class='selectoption' style='width:100px;'><option value='0'>Nơi đến</option><option value='2'>Lào Cai</option></select>";
			break;
			case "2": divdestination.innerHTML="Đến:&nbsp;<select onchange=\"javascript:ajaxpage('cnnel.php?cid=22,29&txtstart='+theForm.txtstart.value+'&txtdestination='+this.options[this.selectedIndex].value, 'divchairtype');\" name=txtdestination class='selectoption' style='width:100px;'><option value='0'>Nơi đến</option><option value='1'>Hà Nội</option></select>";
			break;			
		}	
	}	
function timego(start,destination)//Khi mình chọn điểm đi, điểm đến, nó sẽ show ra mấy thông tin này cho khách hàng xem nhé
	{
		if(start=="1")
			{
				if(destination=="0")
					divtimego.innerHTML="";				
				if(destination=="2")
					divtimego.innerHTML="Khởi hành: 23:00,<br>Đến nơi: 08:00";								
			}
		if(start=="2")
			{
				if(destination=="0")
					divtimego.innerHTML="";
				if(destination=="1")
					divtimego.innerHTML="khởi hành: 12:15,<br> Đến nơi: 21:00";								
			}		
	}	
	
	
	function getCheckedValue(radioObj) 
	{
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) 
		{
			if(radioObj[i].checked) 
			{
				return radioObj[i].value;
			}
		}
		return "";
	}
