// JavaScript Document
function send_quote_req1()
{
	var postdata = 'req_name='+escape($id('trip_name').value);
	postdata += '&start_date='+escape($id('start_date').value);
	postdata += '&duration='+escape($id('duration').value);
	postdata += '&no_of_adults='+escape($id('no_of_adults').value);
	postdata += '&no_of_child='+escape($id('no_of_child').value);
	postdata += '&start_place='+escape($id('start_place_id').value);
	
	var instructions = '';
	if($id('instructions').value != 'Include details such as: Number of rooms and rooming arrangements (such as 1 triple room, 1 twin room, and 1 double room) Changes to the Selected Itinerary, such as additional days, places or different hotels.')
		instructions = $id('instructions').value;
	postdata += '&instructions='+instructions;
	
	if($id('file_1_path') != null){
		postdata += '&attachment='+escape($id('file_1_path').value);
	}
	// postdata += '&file='+escape($id('file').value);
	postdata += '&itinerary_id='+escape($id('itinerary_id').value);
	if($id('logged_in').style.display=='none')
	{
		alert("Please Login to continue");
		$id('usename_QR').focus();
	}
	else if($id('trip_name').value == 'Enter Trip Name' || $id('start_date').value == 'Exact or approximate start date (or week/month)' || $id('duration').value == '' || $id('no_of_child').value == '' || $id('start_place').value == ''){
		alert('Please Fill in the Madatory Fields');
	}
	else
	{
		$.post(ROOT_PATH+'aj_request.php?aj=user.quote_req2',postdata,function(resp){
																		$('#quote_req').html(resp);
																		expand_logbook();
																	  });
	}
}

function send_quote_req2(){
		//   HOTEL & aCCOMODATION
	var postdata = 'hotel_pref_style='+escape($id('hotel_pref_style').value);
	postdata += '&pref_room_type='+escape($id('pref_room_type').value);
	postdata += '&past_hotel_names='+escape($id('past_hotel_names').value);
	var facilities = '';
	if($id('western_breakfast').checked == true)
		facilities += escape($id('western_breakfast').value);
	if($id('bar_area').checked == true){
		if(facilities != '') facilities += ',';
		facilities += escape($id('bar_area').value);
	}
	if($id('swimming_pool').checked == true){
		if(facilities != '') facilities += ',';
		facilities += escape($id('swimming_pool').value);
	}
	if($id('children_acts').checked == true){
		if(facilities != '') facilities += ',';
		facilities += escape($id('children_acts').value);
	}
	if($id('western_rest').checked == true){
		if(facilities != '') facilities += ',';
		facilities += escape($id('western_rest').value);
	}
	if($id('spa').checked == true){
		if(facilities != '') facilities += ',';
		facilities += escape($id('spa').value);
	}
	if($id('internet').checked == true){
		if(facilities != '') facilities += ',';
		facilities += escape($id('internet').value);
	}
	postdata += '&hotel_facilities='+facilities;
	postdata += '&hotel_further_info='+escape($id('hotel_further_info').value);
	
	//       FLIGHT PREFERENCES
	postdata += '&long_haul='+escape($id('long_haul').value);
	postdata += '&short_haul='+escape($id('short_haul').value);
	var airlines = '';
	if($id('air_fill_serv').checked == true)
		airlines += escape($id('air_fill_serv').value);
	if($id('air_lim_serv').checked == true){
		if(airlines != '') airlines += ',';
		airlines += escape($id('air_lim_serv').value);
	}
	if($id('air_low_cost').checked == true){
		if(airlines != '') airlines += ',';
		airlines += escape($id('air_low_cost').value);
	}
	postdata += '&flight_airline_type='+airlines;
	postdata += '&pref_airlines='+escape($id('pref_airlines').value);
	
	var aircraft = '';
	if($id('jet_craft').checked == true)
		aircraft += escape($id('jet_craft').value);
	if($id('turbo_craft').checked == true){
		if(aircraft != '') aircraft += ',';
		aircraft += escape($id('turbo_craft').value);
	}
	if($id('propeller_craft').checked == true){
		if(aircraft != '') airlines += ',';
		aircraft += escape($id('propeller_craft').value);
	}
	postdata += '&flight_aircraft_type='+aircraft;
	var flight_further_info = '';
	if($id('flight_further_info').value != 'e.g. Fully Flat Bed ... At least 32 inch seat pitch etc ....')
		flight_further_info = $id('flight_further_info').value;
	postdata += '&flight_further_info='+flight_further_info;
	//        OVERLAND TRAVEL
	postdata += '&class_vehicle='+escape($id('class_vehicle').value);
	postdata += '&max_length_journey='+escape($id('max_length_journey').value);
	postdata += '&max_time_between_rests='+escape($id('max_time_between_rests').value);
	postdata += '&want_train_journey='+escape($id('want_train_journey').value);
	postdata += '&want_overnight_train_journey='+escape($id('want_overnight_train_journey').value);
	var train_further_info = '';
	if($id('train_further_info').value != 'e.g. Scenic Routes v/s Shorter Routes etc...')
		train_further_info = $id('train_further_info').value;
	postdata += '&train_further_info='+train_further_info;
	
	//			SIGHTSEEING & GUIDES
	postdata += '&want_escorts='+escape($id('want_escorts').value);
	postdata += '&want_guide='+escape($id('want_guide').value);
	postdata += '&want_entrance_tickets='+escape($id('want_entrance_tickets').value);
	postdata += '&sightseeing_further_info='+escape($id('sightseeing_further_info').value);
	
	// 			FOOD/DIETARY PREFERENCES
	var want_food = '';
	if($id('full_board').checked == true)
		want_food += escape($id('full_board').value);
	else if($id('half_board').checked == true){
		want_food += escape($id('half_board').value);
	}
	else if($id('bed&breakfast').checked == true){
		want_food += escape($id('bed&breakfast').value);
	}
	else if($id('our_meals').checked == true){
		want_food += escape($id('our_meals').value);
	}
	else if($id('not').checked == true){
		want_food += escape($id('not').value);
	}	
	postdata += '&want_food='+want_food;
	var food_further_info = '';
	if($id('food_further_info').value != 'e.g Gluten Free Meals, No Nuts, Vegan etc ...')
		food_further_info = $id('food_further_info').value;
	postdata += '&food_further_info='+food_further_info;
	// 			REQUEST ID
	postdata += '&request_id='+$id('req_id').value;
	setLocation('getPage','user.quote_req3',postdata,function(){
	  var _actb = new actb('places_list','', ROOT_PATH+'aj_request.php?aj=user.aj_autosugest&exp&value=', as_appendResult );});

	//$.post(ROOT_PATH+'aj_request.php?aj=user.quote_req3',postdata,function(resp){$('#quote_req').html(resp);});
}

function send_quote_req3(){

	var default_agent = 0;
	var covering_all_places = 0;
	var covering_some_places = 0;
	var covering_these_places = 0;
	var tmh_admin = 0;
	
	var postdata = '';
	if($id('default_agent_name') != null){
		default_agent = 1;
		postdata += 'default_agent_id='+$id('default_agent_id').value;
/*		if($id('covering_all_places').checked != true){
			covering_all_places = 1;
		}
		if($id('covering_some_places').checked != true){
			covering_some_places = 1;
		}
*/	}
	postdata += '&request_id='+$id('request_id').value;
	postdata += '&default_agent='+default_agent;
/*	postdata += '&covering_all_places='+covering_all_places;
	postdata += '&covering_some_places='+covering_some_places;*/
	if($id('covering_these_places').checked == true){
		covering_these_places = 1;
			
		var places = document.getElementsByName('selected_suggested_places');
		if(places.length == 0){
			alert('Please select atleast one place');
			return false;
		}
		for(var i=0; i<places.length; i++){
			postdata += '&places['+i+']='+places[i].value ;
		}
	}
	postdata += '&covering_these_places='+covering_these_places;
	if($id('tmh_agent').checked == true)
		tmh_admin = 1;
	postdata += '&tmh_admin='+tmh_admin;
	setLocation('getPage','user.quote_req4',postdata,'Quotation Request');
}

function showRegistrationFrom(){
	$id('login_frm').style.display = 'none';
	$id('register').style.display = '';
}

function showLoginFrom(){
	$id('login_frm').style.display = '';
	$id('register').style.display = 'none';
}

function call_aj_login_QR(){
	$id('response').style.display='none';
	var username=$id('usename_QR').value;
	var password=$id('password_QR').value;
	var remember = 0;
	if($id('checkbox1_QR').checked == true)
		remember = 1;
	aj_login(username,password,remember);
}

function remove_itinerary(){
	$id('itinerary_id').value = "0";
	$id('agent_quote').style.display = 'none';
	$id('self_qoute').style.display = '';
}

function expand(id){
		var cur_state = $id(id).style.display;
		$id('hotel_accom').style.display = 'none';
		$id('flight_prefs').style.display = 'none';
		$id('overland_travel').style.display = 'none';
		$id('sightseeing').style.display = 'none';
		$id('food_prefs').style.display = 'none';
		$id(id).style.display = '';
		if(cur_state == 'none')
			$id(id).style.display = '';
		else
			$id(id).style.display = 'none';
	}

function show_send_quote_div(){
	showDisableDiv('send_quote_div');
	$('#send_quote_friends_emails').val('');
	
}
function send_quote_link(){
	$('#send_quote_send').val('Sending Message...');
	if($('#send_quote_friends_emails').val() == ''){
		alert("Please enter Your friend's E-mail IDs");
		return false;
	}
	if($('#send_quote_name').val() == ''){
		alert("Please enter Your Name");
		return false;
	}
	if($('#send_quote_email').val() == ''){
		alert("Please enter Your E-Mail");
		return false;
	}
	if(!echeck($('#send_quote_email').val())){
		alert('Invalid E-mail Address');
		return false;
	}
	$.post(ROOT_PATH+"aj_request.php?aj=user.aj_send_quote_link",'send_quote_friends_emails='+escape($('#send_quote_friends_emails').val())+'&send_quote_msg='+escape($('#send_quote_msg').val())+'&send_quote_name='+escape($('#send_quote_name').val())+'&send_quote_email='+escape($('#send_quote_email').val())+'&itinerary_id='+$('#send_quote_itinerary_id').val(),function(){
		alert("Message Successfully Sent to Your Friends");
		$('#send_quote_send').val('Send');
		hideDisableDiv('send_quote_div');
	});
}
	