var dc = {};
dc.genSessId = function(){
	return parseInt(new Date().getTime().toString().substring(0, 10));
}
dc.s8 = function () {
	var st = {};
	var hasErrors = false;
	st.sid = dc.genSessId()+'';
	st.origin = 'mobile_contact';

	$('.form-15605 input[type=text]').not('input[name=acct_num]').each(function(){
		if($(this).val() == '' || $(this).val() == $(this).siblings('label').text()){
			$(this).css('border-color', 'red');
			hasErrors = true;
		}else{
			$(this).css('border-color', '');
			st[$(this).attr('name')] = ($(this).val());
		}
	});
	
	$('.form-15605 select option:selected').each(function(){
		st[$(this).parent('select').attr('name')] = ($(this).val());
	});
	$('.form-15605 textarea').each(function(){
		st["message"] = ($(this).val());
	});
	if(hasErrors) return false;
	$.post('/tempdatas/mobile', {
	    "data[Tempdata][sid]":st.sid,
	    "data[Tempdata][data]":JSON.stringify(st),
	    "data[Tempdata][stage]":'4'
    }, function(data){
		window.location = "http://coffeeservice.com/mobile#home";
    });
}

$(function(){
$("#state").bind( "change", function(event, ui) {
  console.log($(this).selectmenu('close'));
});

	$('#mobContactFormSubmit').click(function(){dc.s8();});
});

