jQuery(function($) {


$('[name=offer]').attr('value','0.00');
$('[name=offer_by]').attr('value','0.00');
$('[name=offer_at]').attr('value','0.00');

$('[name=offer]').click(function(){$(this).val(''); });
$('[name=offer_by]').click(function(){$(this).val(''); });
$('[name=offer_at]').click(function(){$(this).val(''); });


$.get('jobs.php');


});

function refresh(location){

window.setTimeout("document.location='"+location+"'",2000);
	
}

function login_send(){

var fields = $("#login").serializeArray();

$.post('modules/login.php', fields,function(data){$('#result_login').html(data); $('#result_login').fadeOut();$('#result_login').fadeIn();$('#result_login').addClass('result_login');});


	
}



function send_offer(id){


var offer_val = $('#offer_'+id+' input[name=offer]').val();


	
$.get('modules/bid.php?act=info&id='+id+'&offer='+offer_val,function(data){

var check_data= $.evalJSON(data).result;

if(check_data == 'ko'){
	
alert($.evalJSON(data).feedback);
	
return null;
}
	
if(confirm($.evalJSON(data).feedback)){	

$.get('modules/bid.php?act=offer&id='+id+'&offer='+offer_val,function(data){
	
alert($.evalJSON(data).result);

refresh('page_user_clicks.html');

});

}
	
});

$('.info_box').load('page_home.html .info_box p');


}

function lost_password(username){

if(username == undefined){
	
var username = prompt('Username');
	
	
}

$.get('modules/lost_password.php?username='+username,function(data){ $('#result_lost').html(data); $('#result_lost').fadeOut();$('#result_lost').fadeIn();$('#result_lost').addClass('result_login'); });
	
}

function send_survey(){
	
var survey_option = $('input[name=survey]:checked').val();
var survey_others = $('input[name=survey_others]').val();

$.get('modules/survey.php?option='+survey_option+'&others='+survey_others,function(data){ $('.survey').html(data); });
	
}

function send_offers(id){


var offer_val_by = $('#offer_'+id+' input[name=offer_by]').val();
var offer_val_at = $('#offer_'+id+' input[name=offer_at]').val();

$.get('modules/bid.php?act=info&id='+id+'&offer_by='+offer_val_by+'&offer_at='+offer_val_at,function(data){

var check_data= $.evalJSON(data).result;

if(check_data == 'ko'){
	
alert($.evalJSON(data).feedback);
	
return null;
}

if(confirm($.evalJSON(data).feedback)){
	
$.get('modules/bid.php?act=offer&id='+id+'&offer_by='+offer_val_by+'&offer_at='+offer_val_at,function(data){

alert($.evalJSON(data).result);

refresh('page_user_clicks.html');

});

}

});

$('.info_box').load('page_home.html .info_box p');
}
