/**
 * LimoxOnline application
 *
 * @copyright	Copyright (c) 2007, LimoxOnline.
 * @link		http://www.limoxonline.com
 * @since		Version 1.0
 * @filesource
 */

function add_time(addM, from_hours, from_mins, from_am_pm, return_type) {
  addH = 0;
  addS = 0;

  var am_pm = from_am_pm;

//  alert(hour3 + " {} "+from_am_pm);
  if(from_am_pm == 'PM' && from_hours<12){
	from_hours = parseInt(from_hours) + 12;
  }

  if(from_am_pm == 'AM' && parseInt(from_hours) == 12){
	from_hours = 24;
  }

  hour3 = parseInt(addH) + parseInt(from_hours);
  min3  = parseInt(addM) + parseInt(from_mins);


  if (min3>=60) { min3 = -(60 - min3); hour3 = parseInt(hour3)+1; }
  if (hour3>=24) { hour3 = -(24 - hour3); }
  if (min3<=9) { min3="0"+min3; }
  if (hour3<=9) { hour3="0"+hour3; }

//  alert(hour3);

  if(hour3>=12){
  	am_pm = 'PM';
  	if(hour3>12){
  		hour3 = hour3 - 12;
  	}
  }

  hour3 = parseInt(hour3);

  if(hour3 == 0 ){
  	am_pm = 'AM';
  	hour3 = 12;
  }

  if(return_type == 'hour'){
	return hour3;
  }
  if(return_type == 'minute'){
	return min3;
  }
  if(return_type == 'am_pm'){
	return am_pm;
  }
}


function new_do_display(event, show_hide, i){
    if(show_hide == '1'){
		eval("document.all.new_tr_do_link_extra_"+i+".style.display = 'none'");
		eval("document.Form1.new_is_visible_do_extra_"+i+".value = 1");
		eval("document.all.new_tr_do_label_extra_"+i+".style.display = ''");
		//eval("document.all.new_tr_do_date_time_"+i+".style.display = ''");
		eval("document.all.new_tr_do_location_extra_"+i+".style.display = ''");

		eval("document.all.new_tr_do_address_"+i+".style.display = ''");
		j= i+1;
		eval("document.all.new_tr_do_link_extra_"+j+".style.display = ''");

		if(document.Form1.ast.value == 'ARoundtrip' && document.Form1.ev.value == '9'){
			if(i == 0){
				document.Form1.new_PickUpTime12_extra_0.value = add_time(30, document.Form1.new_PickUpTime12.value, document.Form1.new_PickUpTime22.value, document.Form1.new_PickUpTime32.value, 'hour');
				document.Form1.new_PickUpTime22_extra_0.value = add_time(30, document.Form1.new_PickUpTime12.value, document.Form1.new_PickUpTime22.value, document.Form1.new_PickUpTime32.value, 'minute');
				document.Form1.new_PickUpTime32_extra_0.value = add_time(30, document.Form1.new_PickUpTime12.value, document.Form1.new_PickUpTime22.value, document.Form1.new_PickUpTime32.value, 'am_pm');;
			}else{
				var j = i-1;
				eval("document.Form1.new_PickUpTime12_extra_"+i+".value = add_time(30, document.Form1.new_PickUpTime12_extra_"+j+".value, document.Form1.new_PickUpTime22_extra_"+j+".value, document.Form1.new_PickUpTime32_extra_"+j+".value, 'hour');");
				eval("document.Form1.new_PickUpTime22_extra_"+i+".value = add_time(30, document.Form1.new_PickUpTime12_extra_"+j+".value, document.Form1.new_PickUpTime22_extra_"+j+".value, document.Form1.new_PickUpTime32_extra_"+j+".value, 'minute');");
				eval("document.Form1.new_PickUpTime32_extra_"+i+".value = add_time(30, document.Form1.new_PickUpTime12_extra_"+j+".value, document.Form1.new_PickUpTime22_extra_"+j+".value, document.Form1.new_PickUpTime32_extra_"+j+".value, 'am_pm');");
			}
		}

	}else{
		eval("document.all.new_tr_do_link_extra_"+i+".style.display = ''");
		eval("document.Form1.new_is_visible_do_extra_"+i+".value = ''");
		eval("document.all.new_tr_do_label_extra_"+i+".style.display = 'none'");
		eval("document.all.new_tr_do_date_time_"+i+".style.display = 'none'");
		eval("document.all.new_tr_do_location_extra_"+i+".style.display = 'none'");

		eval("document.all.new_tr_do_address_"+i+".style.display = 'none'");
		j= i+1;
		eval("document.all.new_tr_do_link_extra_"+j+".style.display = 'none'");
	}
}



function do_display(event, show_hide, i){
    if(show_hide == '1'){
		//i++;
		//alert(i);
		eval("document.all.tr_do_link_extra_"+i+".style.display = 'none'");
		eval("document.Form1.is_visible_do_extra_"+i+".value = 1");
		eval("document.all.tr_do_label_extra_"+i+".style.display = ''");
//		eval("document.all.tr_do_date_time_"+i+".style.display = ''");
		eval("document.all.tr_do_location_extra_"+i+".style.display = ''");

		eval("document.all.tr_do_address_"+i+".style.display = ''");
		//eval("document.all.tr_do_instruction_"+i+".style.display = ''");

		if(event != '1'){
			if(i == 0){
				document.Form1.PickUpTime12_extra_0.value = add_time(30, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'hour');
				document.Form1.PickUpTime22_extra_0.value = add_time(30, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'minute');
				document.Form1.PickUpTime32_extra_0.value = add_time(30, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'am_pm');;
			}else{
				var j = i-1;
				eval("document.Form1.PickUpTime12_extra_"+i+".value = add_time(30, document.Form1.PickUpTime12_extra_"+j+".value, document.Form1.PickUpTime22_extra_"+j+".value, document.Form1.PickUpTime32_extra_"+j+".value, 'hour');");
				eval("document.Form1.PickUpTime22_extra_"+i+".value = add_time(30, document.Form1.PickUpTime12_extra_"+j+".value, document.Form1.PickUpTime22_extra_"+j+".value, document.Form1.PickUpTime32_extra_"+j+".value, 'minute');");
				eval("document.Form1.PickUpTime32_extra_"+i+".value = add_time(30, document.Form1.PickUpTime12_extra_"+j+".value, document.Form1.PickUpTime22_extra_"+j+".value, document.Form1.PickUpTime32_extra_"+j+".value, 'am_pm');");
			}
//
				document.Form1.PickUpTime12.value = add_time(30, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'hour');
				document.Form1.PickUpTime22.value = add_time(30, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'minute');
				document.Form1.PickUpTime32.value = add_time(30, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'am_pm');;
		}

		j= i+1;
		eval("document.all.tr_do_link_extra_"+j+".style.display = ''");
		//alert("document.all.tr_do_link_extra_"+j+".style.display = ''");

		if(document.Form1.ast.value == 'ARoundtrip' && document.Form1.ev.value == '9'){
			last_i = get_last_index('is_visible_do_extra_');
//			alert("asdasd = "+last_i)

			eval("document.Form1.new_PickUpTime1.value = add_time(60, document.Form1.PickUpTime12_extra_"+last_i+".value, document.Form1.PickUpTime22_extra_"+last_i+".value, document.Form1.PickUpTime32_extra_"+last_i+".value, 'hour');");
			eval("document.Form1.new_PickUpTime2.value = add_time(60, document.Form1.PickUpTime12_extra_"+last_i+".value, document.Form1.PickUpTime22_extra_"+last_i+".value, document.Form1.PickUpTime32_extra_"+last_i+".value, 'minute');");
			eval("document.Form1.new_PickUpTime3.value = add_time(60, document.Form1.PickUpTime12_extra_"+last_i+".value, document.Form1.PickUpTime22_extra_"+last_i+".value, document.Form1.PickUpTime32_extra_"+last_i+".value, 'am_pm');");

			document.Form1.new_PickUpTime12.value = add_time(60, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'hour');
			document.Form1.new_PickUpTime22.value = add_time(60, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'minute');
			document.Form1.new_PickUpTime32.value = add_time(60, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'am_pm');

		}

	}else{
		eval("document.all.tr_do_link_extra_"+i+".style.display = ''");
		eval("document.Form1.is_visible_do_extra_"+i+".value = ''");
		eval("document.all.tr_do_label_extra_"+i+".style.display = 'none'");

		if(event != '1'){
			eval("document.all.tr_do_date_time_"+i+".style.display = 'none'");
		}

		eval("document.all.tr_do_location_extra_"+i+".style.display = 'none'");

		eval("document.all.tr_do_address_"+i+".style.display = 'none'");
		//eval("document.all.tr_do_instruction_"+i+".style.display = 'none'");
		j= i+1;
		eval("document.all.tr_do_link_extra_"+j+".style.display = 'none'");
	}
}



function check_extra_dos(){
	for (i=0;i<document.Form1.elements.length;i++){
		if(document.Form1.elements[i].id.slice(0,20) == 'is_visible_do_extra_'){
			if(document.Form1.elements[i].value == '1'){
				var curr_i = document.Form1.elements[i].id.slice(20, 21);
				curr_j = curr_i;
				curr_j++;
				curr_j++;

				eval("var do_extra_loc     = document.Form1.PickUpCity2_extra_"+curr_i+".value ");
				eval("var do_extra_address = document.Form1.PickUpAddress2_extra_"+curr_i+".value ");

				if(do_extra_loc == ''){
					alert('Please Enter the Drop Off Location/City #'+curr_j+'.')
					eval("document.Form1.PickUpCity2_extra_"+curr_i+".focus() ");
					return false;
				}

				if(do_extra_address == ''){
					alert('Please Enter the Drop Off Address #'+curr_j+'.')
					eval("document.Form1.PickUpAddress2_extra_"+curr_i+".focus() ");
					return false;
				}
			}
		}
	}
	return true;
}



function get_last_index(var_name){
	var curr_i = '';
	for (i=0;i<document.Form1.elements.length;i++){
		if(document.Form1.elements[i].id.slice(0, var_name.length) == var_name){
			if(document.Form1.elements[i].value == '1'){
				var curr_i = document.Form1.elements[i].id.slice(var_name.length, var_name.length+1);
			}
		}
	}
 return curr_i;
}



function check_extra_pus(){
	for (i=0;i<document.Form1.elements.length;i++){
		if(document.Form1.elements[i].id.slice(0,20) == 'is_visible_pu_extra_'){
			if(document.Form1.elements[i].value == '1'){
				var curr_i = document.Form1.elements[i].id.slice(20, 21);
				curr_j = curr_i;
				curr_j++;
				curr_j++;

				eval("var pu_extra_loc     = document.Form1.PickUpCity_extra_"+curr_i+".value ");
				eval("var pu_extra_address = document.Form1.PickUpAddress_extra_"+curr_i+".value ");

				if(pu_extra_loc == ''){
					alert('Please Enter the Pick Up Location/City #'+curr_j+'.')
					eval("document.Form1.PickUpCity_extra_"+curr_i+".focus() ");
					return false;
				}

				if(pu_extra_address == ''){
					alert('Please Enter the Pick Up Address #'+curr_j+'.')
					eval("document.Form1.PickUpAddress_extra_"+curr_i+".focus() ");
					return false;
				}
			}
		}
	}
	return true;
}

//p2p roundtrip

function new_pu_display(event, show_hide, i){
    if(show_hide == '1'){
		eval("document.all.new_tr_pu_link_extra_"+i+".style.display = 'none'");
		eval("document.Form1.new_is_visible_pu_extra_"+i+".value = 1");
		eval("document.all.new_tr_pu_label_extra_"+i+".style.display = ''");
		//eval("document.all.new_tr_pu_date_time_"+i+".style.display = ''");
		eval("document.all.new_tr_pu_location_extra_"+i+".style.display = ''");
		eval("document.all.new_tr_pu_date_address_"+i+".style.display = ''");
		j= i+1;
		eval("document.all.new_tr_pu_link_extra_"+j+".style.display = ''");

		if(document.Form1.ast.value == 'ARoundtrip' && document.Form1.ev.value == '9'){
			if(i == 0){
				document.Form1.new_PickUpTime1_extra_0.value = add_time(30, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'hour');
				document.Form1.new_PickUpTime2_extra_0.value = add_time(30, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'minute');
				document.Form1.new_PickUpTime3_extra_0.value = add_time(30, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'am_pm');;
			}else{
				var j = i-1;
				eval("document.Form1.new_PickUpTime1_extra_"+i+".value = add_time(30, document.Form1.new_PickUpTime1_extra_"+j+".value, document.Form1.new_PickUpTime2_extra_"+j+".value, document.Form1.new_PickUpTime3_extra_"+j+".value, 'hour');");
				eval("document.Form1.new_PickUpTime2_extra_"+i+".value = add_time(30, document.Form1.new_PickUpTime1_extra_"+j+".value, document.Form1.new_PickUpTime2_extra_"+j+".value, document.Form1.new_PickUpTime3_extra_"+j+".value, 'minute');");
				eval("document.Form1.new_PickUpTime3_extra_"+i+".value = add_time(30, document.Form1.new_PickUpTime1_extra_"+j+".value, document.Form1.new_PickUpTime2_extra_"+j+".value, document.Form1.new_PickUpTime3_extra_"+j+".value, 'am_pm');");
			}


			last_i = get_last_index('new_is_visible_pu_extra_');
			//alert("last_i = "+ last_i);
			eval("document.Form1.new_PickUpTime12.value = add_time(60, document.Form1.new_PickUpTime1_extra_"+last_i+".value, document.Form1.new_PickUpTime2_extra_"+last_i+".value, document.Form1.new_PickUpTime3_extra_"+last_i+".value, 'hour');");
			eval("document.Form1.new_PickUpTime22.value = add_time(60, document.Form1.new_PickUpTime1_extra_"+last_i+".value, document.Form1.new_PickUpTime2_extra_"+last_i+".value, document.Form1.new_PickUpTime3_extra_"+last_i+".value, 'minute');");
			eval("document.Form1.new_PickUpTime32.value = add_time(60, document.Form1.new_PickUpTime1_extra_"+last_i+".value, document.Form1.new_PickUpTime2_extra_"+last_i+".value, document.Form1.new_PickUpTime3_extra_"+last_i+".value, 'am_pm');");

		}

	}else{
		eval("document.all.new_tr_pu_link_extra_"+i+".style.display = ''");
		eval("document.Form1.new_is_visible_pu_extra_"+i+".value = ''");
		eval("document.all.new_tr_pu_label_extra_"+i+".style.display = 'none'");
		eval("document.all.new_tr_pu_date_time_"+i+".style.display = 'none'");
		eval("document.all.new_tr_pu_location_extra_"+i+".style.display = 'none'");
		eval("document.all.new_tr_pu_date_address_"+i+".style.display = 'none'");
		j= i+1;
		eval("document.all.new_tr_pu_link_extra_"+j+".style.display = 'none'");
	}
}



function pu_display(event, show_hide, i){
    if(show_hide == '1'){

		eval("document.all.tr_pu_link_extra_"+i+".style.display = 'none'");
		eval("document.Form1.is_visible_pu_extra_"+i+".value = 1");
		eval("document.all.tr_pu_label_extra_"+i+".style.display = ''");
		//eval("document.all.tr_pu_date_time_"+i+".style.display = ''");

		if(event != '1'){
			if(i == 0){
				document.Form1.PickUpTime1_extra_0.value = add_time(30, document.Form1.PickUpTime1.value, document.Form1.PickUpTime2.value, document.Form1.PickUpTime3.value, 'hour');
				document.Form1.PickUpTime2_extra_0.value = add_time(30, document.Form1.PickUpTime1.value, document.Form1.PickUpTime2.value, document.Form1.PickUpTime3.value, 'minute');
				document.Form1.PickUpTime3_extra_0.value = add_time(30, document.Form1.PickUpTime1.value, document.Form1.PickUpTime2.value, document.Form1.PickUpTime3.value, 'am_pm');;
			}else{
				var j = i-1;
				eval("document.Form1.PickUpTime1_extra_"+i+".value = add_time(30, document.Form1.PickUpTime1_extra_"+j+".value, document.Form1.PickUpTime2_extra_"+j+".value, document.Form1.PickUpTime3_extra_"+j+".value, 'hour');");
				eval("document.Form1.PickUpTime2_extra_"+i+".value = add_time(30, document.Form1.PickUpTime1_extra_"+j+".value, document.Form1.PickUpTime2_extra_"+j+".value, document.Form1.PickUpTime3_extra_"+j+".value, 'minute');");
				eval("document.Form1.PickUpTime3_extra_"+i+".value = add_time(30, document.Form1.PickUpTime1_extra_"+j+".value, document.Form1.PickUpTime2_extra_"+j+".value, document.Form1.PickUpTime3_extra_"+j+".value, 'am_pm');");
			}
		}

		eval("document.all.tr_pu_location_extra_"+i+".style.display = ''");
		eval("document.all.tr_pu_date_address_"+i+".style.display = ''");
		j= i+1;
		eval("document.all.tr_pu_link_extra_"+j+".style.display = ''");
		//alert("document.all.tr_pu_link_extra_"+j+".style.display = ''");

		last_i = get_last_index('is_visible_pu_extra_');

		if(event != '1'){
			eval("document.Form1.PickUpTime12.value = add_time(60, document.Form1.PickUpTime1_extra_"+last_i+".value, document.Form1.PickUpTime2_extra_"+last_i+".value, document.Form1.PickUpTime3_extra_"+last_i+".value, 'hour');");
			eval("document.Form1.PickUpTime22.value = add_time(60, document.Form1.PickUpTime1_extra_"+last_i+".value, document.Form1.PickUpTime2_extra_"+last_i+".value, document.Form1.PickUpTime3_extra_"+last_i+".value, 'minute');");
			eval("document.Form1.PickUpTime32.value = add_time(60, document.Form1.PickUpTime1_extra_"+last_i+".value, document.Form1.PickUpTime2_extra_"+last_i+".value, document.Form1.PickUpTime3_extra_"+last_i+".value, 'am_pm');");
		}

		if(document.Form1.ast.value == 'ARoundtrip' && document.Form1.ev.value == '9'){
			//last_i = get_last_index('is_visible_do_extra_');
			//alert("asdasd = "+last_i)
			document.Form1.new_PickUpTime1.value = add_time(60, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'hour');
			document.Form1.new_PickUpTime2.value = add_time(60, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'minute');
			document.Form1.new_PickUpTime3.value = add_time(60, document.Form1.PickUpTime12.value, document.Form1.PickUpTime22.value, document.Form1.PickUpTime32.value, 'am_pm');

			document.Form1.new_PickUpTime12.value = add_time(60, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'hour');
			document.Form1.new_PickUpTime22.value = add_time(60, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'minute');
			document.Form1.new_PickUpTime32.value = add_time(60, document.Form1.new_PickUpTime1.value, document.Form1.new_PickUpTime2.value, document.Form1.new_PickUpTime3.value, 'am_pm');
		}

	}else{
		eval("document.all.tr_pu_link_extra_"+i+".style.display = ''");
		eval("document.Form1.is_visible_pu_extra_"+i+".value = ''");
		eval("document.all.tr_pu_label_extra_"+i+".style.display = 'none'");
		//eval("document.all.tr_pu_date_extra_"+i+".style.display = 'none'");
		if(event != '1'){
			eval("document.all.tr_pu_date_time_"+i+".style.display = 'none'");
		}
		if(event == '9'){
			//eval("document.all.tr_pu_hrs_service_extra_"+i+".style.display = 'none'");
		}
		eval("document.all.tr_pu_location_extra_"+i+".style.display = 'none'");
		eval("document.all.tr_pu_date_address_"+i+".style.display = 'none'");
		j= i+1;
		eval("document.all.tr_pu_link_extra_"+j+".style.display = 'none'");
	}
}

//MouseOver functions
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_jumpMenu(targ,selObj,restore){ //v3.0

    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
// checks for valid date.
	function ValidateDate(oSrc,args)
	{
		if(CheckValidDate(args.Value))
			args.IsValid = true;
		else
			args.IsValid = false;

	}
	function CheckValidDate(strDate)
	{

		var strDateArr = strDate.split("/");
		mm = strDateArr[0];
		dd = strDateArr[1];
		yy = strDateArr[2];

		if (isNaN(mm) == true || isNaN(dd) == true || isNaN(yy) == true)
			return false;
		if(parseFloat(yy) < 0 )
			return false;
		// first check for valid month
		if(parseFloat(mm) > 0 && parseFloat(mm) <= 12)
		{
			var dt = new Date(mm + "/" + dd + "/" + yy);
			if (dt.getDate() == dd)
			{
				return true;
			}
		}

		return false;
	}
	function trim(txtstr)
	{
	  	while(txtstr.charAt(0)==' ')
			txtstr=txtstr.substring(1,txtstr.length);
		while(txtstr.charAt(txtstr.length-1)==' ')
			txtstr=txtstr.substring(0,txtstr.length-1);
		return(txtstr);

	}

	function convmonth(mon)
	{
		var i
		mon = mon + '';
		for(i=1;i <= 2-(mon.length);i++ )
			mon = '0' + mon;

			return mon ;
	}

	// This Function Compare two dates
	// If dateStr1 > dateStr2 then returns 1, If dateStr1 < dateStr2 then returns -1 If dateStr1 = dateStr2 then returns 0
	// Dates should be in the format MM/DD/YYYY
	function dateCompare(dateStr1, dateStr2)
	{
		var day1, day2, month1, month2, yr1, yr2;
		var months = new Array('1','2','3','4','5','6','7','8','9','10','11','12');

		arr1 = dateStr1.split('/');
		arr2 = dateStr2.split('/');

		for(i=0;i<months.length;i++)
		{
			if (months[i] == arr1[0])
				month1 = i;

			if (months[i] == arr2[0])
				month2 = i;
		}

		var date1 = new Date();
		var date2 = new Date();

		day1 = parseInt(arr1[1], 10);
		yr1	 = parseInt(arr1[2], 10);

		day2 = parseInt(arr2[1], 10);
		yr2	 = parseInt(arr2[2], 10);


		if (yr1 == yr2)
			{
				if (month1 == month2)
					{
						if (day1 == day2)
							return 0;
						else if (day1 > day2)
							return 1;
						else if (day1 < day2)
							return -1;
					}
				else if (month1 > month2)
					return 1;
				else if (month1 < month2)
					return -1;
			}
		else if (yr1 > yr2)
			return 1;
		else if (yr1 < yr2)
			return -1;

	}


function GetCallFormName()
	{

		var control;
	   	control = document.forms ;
			var j;
			for (j=0; j < control.length; j++)
			{
				var inner = control[j];
				if (typeof(inner.name) != "")
				{
					return inner.name;
				}

			}

		return "";
	}

	// returns the objects ref variable when the name is passed.
	function getControlName(controlName)
	{
		var control;
		var formname =GetCallFormName();
//		alert(formname);
	   	control = eval('document.' + formname+ '.elements') ;
	   	var j;
		for (j=0; j < control.length; j++)
		{
			var inner = control[j];
			//alert("name " + inner.name + "controlName " +  controlName);
			if (inner.name.toUpperCase() == controlName.toUpperCase())
			{
				return inner;
			}
		}
		return "";
	}


	// returns the objects ref variable when the name is passed.
	function getControlName2(controlName,formname)
	{
		var control;
//		var formname =GetCallFormName();
//		alert(formname);
	   	control = eval('document.' + formname+ '.elements') ;
	   	var j;
		for (j=0; j < control.length; j++)
		{
			var inner = control[j];
			//alert("name " + inner.name + "controlName " +  controlName);
			if (inner.name.toUpperCase() == controlName.toUpperCase())
			{
				return inner;
			}
		}
		return "";
	}



function MoveNext(objFrom,objTo,len)
	{
		var strFrom="";
		strFrom=objFrom.value;

		var FromLen;
		FromLen=strFrom.length;
		if(FromLen==parseInt(len))
		{
			objTo.focus();
		}
}

function sh(){
	var t=document.search.selEvent.value;
if (t=="1" || t=="1-to" || t=="1-from"){
//		document.all.share_ride.style.display='';
		document.all.share_ride.style.display='none';
		sr4();
	}
	else{
		document.all.share_ride.style.display='none'
//		if (document.search.sr[0].checked==true)
			sr3();
		document.search.sr[0].checked=false
		document.search.sr[1].checked=true
	}
}

function sr2(){
	document.search.selVehicle[1] = null;
	document.search.selVehicle.options.length = 0;

	var option = new Option("Luxury Sedan (Share Ride)","70");
	document.search.selVehicle.options[0] = option

	var option = new Option("Minibus 20-24 Passenger (Share Ride)","77");
	document.search.selVehicle.options[1] = option

	var option = new Option("Van - Airport Shuttle (Share Ride)","74");
	document.search.selVehicle.options[2] = option

	document.search.selVehicle[0].selected=true;
}


function sr3(){
	document.search.selVehicle[1] = null;
	document.search.selVehicle.options.length = 0;
	var l=document.search.lgth.value
	var n=new Array();
	var v=new Array();
	for (i=0;i<l;i++){
		eval("n["+i+"]=document.search.nm_"+i+".value")
		eval("v["+i+"]=document.search.vl_"+i+".value")
		var option = new Option(n[i],v[i]);
		document.search.selVehicle.options[i] = option
	}//for
	document.search.selVehicle[0].selected=true;
}


function sr4(){
	document.search.selVehicle[1] = null;
	document.search.selVehicle.options.length = 0;

//	var option = new Option("Luxury Sedan (1-3 Passengers)","70");
	var option = new Option("3 Passenger Luxury Sedan","49");
	document.search.selVehicle.options[0] = option

	var option = new Option("6 Passenger Limousine","2");
	document.search.selVehicle.options[1] = option

	var option = new Option("8 Passenger Limousine","3");
	document.search.selVehicle.options[2] = option

	var option = new Option("10 Passenger Limousine","4");
	document.search.selVehicle.options[3] = option

	var option = new Option("SUV Sedan","36");
	document.search.selVehicle.options[4] = option

	var option = new Option("Van -  7 Passenger","83");
	document.search.selVehicle.options[5] = option

	var option = new Option("Van - 10 Passenger","75");
	document.search.selVehicle.options[6] = option

	var option = new Option("Van - 14 Passenger","7");
	document.search.selVehicle.options[7] = option

	document.search.selVehicle[0].selected=true;


}

function template_popup(t){
	window.open('template_popup.php?t='+t,'template_popup','scrollbars=yes,resizable=no,width=650,height=610')
}