//total money
function getTotal(){

	
//	if($('s_type_1').checked)
//	{
//		
//		var s_type="a";
//	}
//	else if($('s_type_2').checked)
//	{
//		
//		var s_type="b";
//	}
//	else if($('s_type_3').checked)
//	{
//		
//		var s_type="c";
//	}
//	else if($('s_type_4').checked)
//	{
//		
//		var s_type="d";
//	}else{
//		
//		return false;
//	}
	var s_type="-1";
	with(document.algb_form)
	{
		if(algb_type==null){
			s_type = "-1";
		}else{
			if(algb_type.length==null)
			{
				s_type = algb_type.value;
			}else{
				for(var i=0;i<algb_type.length;i++)
				{
					if(algb_type[i].checked == true){
						s_type = algb_type[i].value;
						break;
					}
				}
			}
		}
	}
	
	if($F('input_total_day')<1){
		return false;
	}
	var url="./algb_ajax.asp";
	var pars="date_start="+$F('departure_date')+"&date_end="+$F('arrivalDate')+"&total_day="+$F('input_total_day')+"&s_type="+s_type+"&"+Math.random();
	
var myAjax=new Ajax.Updater(
'span_messages',
url,
{
method:'get',
parameters:pars
});

	
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function date_input_onchange(){
	
	if($F('departure_date')==""){
		
		return false;
	}
	if($F('arrivalDate')==""){
		
		return false;
	}
	
  var   str_1   =trim($F('departure_date'));

  var   str_2	=trim($F('arrivalDate'));
  var   re   =  /^(\d{4})\S(\d{1,2})\S(\d{1,2})$/; 
  var   dt_1;  
  var   dt_2;
  if (re.test(str_1))  
  {  
    dt_1   =   new   Date(RegExp.$1,RegExp.$2   -   1,RegExp.$3);  
  }
  if (re.test(str_2))  
  {  
    dt_2   =   new   Date(RegExp.$1,RegExp.$2   -   1,RegExp.$3);  
  }  
  
  
  var total=Math.floor((dt_2-dt_1)/(1000 * 60 * 60 * 24))+1;  
  $('span_total_day').innerHTML=total;
  $('input_total_day').value=total;
	getTotal();
}



function auto_copy_t(){
	
	$('b_name').value=$F('t_name');
	
	$('b_idno').value=$F('t_idno');
	$('b_birthday').value=$F('t_birthday');
	$('b_destination').value=$F('t_destination');
	
	$('b_tel').value=$F('t_tel');	
	$('b_email').value=$F('t_email');
	$('b_address').value=$F('t_address');
	$('b_zip').value=$F('t_zip');
}

function tbsq_post_check(){
		
	
	var error_msg="";
	var error_num=0;
		

		
	if($F('input_total_day')==0){

		error_num=1;
		error_msg=error_msg+"请选择正确的保险日期!"+"\n";
		
	}
	
	if(trim($F('t_name'))==""){
		
		error_num=1;
		error_msg=error_msg+"投保人姓名不能为空!"+"\n";
		
	}
	
	if(trim($F('t_idno'))==""){
		
		error_num=1;
		error_msg=error_msg+"投保人护照号/身份证号不能为空!"+"\n";
		
	}
	
	if(trim($F('t_birthday'))==""){
		
		error_num=1;
		error_msg=error_msg+"投保人出生日期不能为空!"+"\n";
		
	}
	
	if(trim($F('t_destination'))==""){
		
		error_num=1;
		error_msg=error_msg+"投保人计划目的地不能为空!"+"\n";
		
	}
	
	if(trim($F('t_tel'))==""){
		
		error_num=1;
		error_msg=error_msg+"投保人姓名联系电话不能为空!"+"\n";
		
	}
	
	if(trim($F('b_name'))==""){
		
		error_num=1;
		error_msg=error_msg+"被投保人姓名不能为空!"+"\n";
		
	}
	
	if(trim($F('b_tel'))==""){
		
		error_num=1;
		error_msg=error_msg+"被投保人姓名联系电话不能为空!"+"\n";
		
	}
	
	if(error_num==1){
		
		alert(error_msg);
		return false;
	}
}



function dayin()   
{ 

  var b_type=0;
  b_type=getOs();
  if(b_type!=1){
  	window.print();
	return false;
  }
  
  var code="<body onload=window.print()>" 
  code+=document.all.p_content.innerHTML; 
  code=code.toUpperCase(); 
  code=code.replace(/<A[^>]*>删除<\/A>/gi, ""); 
  code=code.toLowerCase(); 
  var newwin=window.open('','',''); 
  newwin.opener = null; 
  newwin.document.write(code); 
  newwin.document.close(); 
}

function getOs()
{
   if(navigator.userAgent.indexOf("MSIE")>0)return 1;
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2;
   if(isSafari=navigator.userAgent.indexOf("Safari")>0)return 3;  
   if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 4;
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0)return 5;
   return 0;
}
