function GetOfferRecipientsVal() {
	if ($("#offer_recipients_custom").attr("checked")) return "custom";
	if ($("#offer_recipients_agencies").attr("checked")) return "agencies";
	if ($("#offer_recipients_freelancers").attr("checked")) return "freelancers";
	if ($("#offer_recipients_all").attr("checked")) return "all";
	return false;
}

function SearchQuoteSubmit() {
	BotJSBeforeSubmit( "BotJS" );
	// check for empty language
	var emptylang = false;
	$("select.multilangsel").each( function() {
			if (!emptylang) {
				if (!parseInt( $(this).val() ) ) {
					$(this).focus();
					emptylang = true;
				}
			}
		}
	);
	if (emptylang) {
		alert( aJSLangDefs.quotepage_error_One_or_more_language_not_defined );
		return false;
	}
	/*
	if (!($("#offer_title").val().length)) {
		alert( aJSLangDefs.quotepage_error_Title_not_filled );
		$("#offer_title").focus();
		return false;
	}
	*/
	// check for service
	if (!ValidateJobServices( "offer_services" ))
		return false;
	// check description
	if (!$("#offer_description").val().length) {
		alert( aJSLangDefs.quotepage_error_Description_not_filled );
		$("#offer_description").focus();
		return false;
	}

	// check for quote deadline
	


	// check for contact name
	if (typeof $("#offer_contact_name").val() != "undefined" ) {
		if (!($("#offer_contact_name").val().length)) {
			alert( aJSLangDefs.quotepage_error_Contact_name_not_filled );
			$("#offer_contact_name").focus();
			return false;
		}
	}
	// check for contact email
	if (typeof $("#offer_contact_email").val() !="undefined" ) {
		if (!($("#offer_contact_email").val().length) ) {
			alert( aJSLangDefs.quotepage_error_Contact_email_not_filled );
			$("#offer_contact_email").focus();
			return false;
		}
	}
	// check for contact phone
	if (typeof $("#offer_contact_phone").val() !="undefined" ) {
		if (!($("#offer_contact_phone").val().length) ) {
			alert( aJSLangDefs.quotepage_error_Contact_phone_not_filled );
			$("#offer_contact_phone").focus();
			return false;
		}
	}

	// check for recipients
	if (GetOfferRecipientsVal()=="custom") {
		var numofcustoms = $("input[name^=offer_recipients_]:checked").length;
		if (!numofcustoms) {
			alert( aJSLangDefs.quotepage_error_No_custom_recipient );
			return false;
		}
	}
	return true;
}

function QuotePaneChangeSpecialty( o ) {
	var vis = (o.val()=="0");
	if (vis) {
		$("#offer_custom_specialty").removeClass( "invis" );
	} else {
		$("#offer_custom_specialty").addClass( "invis" );
	}
}

function QuotePaneChangeQuoteDeadline( o ) {
	var quote_deadline = $("#offer_quote_deadline");
	var deadline = $("#offer_deadline");

	if (quote_deadline.val().length!=16) return;
	if (deadline.val()<quote_deadline.val()) {
		deadline.datepicker( "option" , "minDate" , quote_deadline.val() );
		deadline.val( quote_deadline.val() );
	}
}

function InitQuotePane( id ) {
	$("#offer_specialty").change( function() { QuotePaneChangeSpecialty( $(this) ); } );
	$("#offer_quote_deadline").change( function() { JobQuoteDeadlineOnChange( $(this) ); } );
}
