$j(document).ready(function(){
if ($j("#all_qusetion_done").length > 0){
$j('#all_qusetion_done').val('');
$j('#grants-loans-calculator input[type="radio"]').each(function(){
if ($j(this).is(':checked')){
$j(this).prop('checked', false);
}
});
}
});
function option_selected(id,opid,value){
_gaq.push(['_trackEvent', 'Grant Finder', 'Answer', value,id]);
var qid = $j("#"+id).attr('class');
var current_id = qid;
var nq_id = $j('#next_qusetion').val();
var all_done = $j('#all_qusetion_done').val();
var num=0;
num = Number(qid)+1;
var isEdit = $j('#edit_qusetion').val();
if(isEdit=='Edit'){
num = nq_id;
$j('#edit_qusetion').val("");
}else{
$j('#number_of_question').val(num);//Store the number of question selected
}
var ch_val = value;
var total_question = Number($j('#total_question').val());
var parsent_unit = (100/total_question);
var file_name_postfix = document.getElementById("file_name_postfix").value;
if(all_done=='AllDone'){
if(file_name_postfix == "qc"){
$j('#complited_caption_show').html('100% Complété  ');
}else{
$j('#complited_caption_show').html('You are 100% complete  ');
}
}else if(isEdit=='Edit'){
if(file_name_postfix == "qc"){
$j('#complited_caption_show').html(number_format(((nq_id-1)*parsent_unit)) + '% Complété  ');
}else{
$j('#complited_caption_show').html('You are '+ number_format(((nq_id-1)*parsent_unit)) + '% complete  ');
}
}else{
if(file_name_postfix == "qc"){
$j('#complited_caption_show').html(number_format((qid*parsent_unit)) + '% Complété  ');
}else{
$j('#complited_caption_show').html('You are '+ number_format((qid*parsent_unit)) + '% complete  ');
}
}
$j('#div_answer_box').show();
$j('#edit'+current_id).html(current_id+". "+ch_val);
$j('#ansc'+current_id).show();
var coplited_value ='';
for(i=1;i<=total_question;i++){
if(i <= qid || all_done=='AllDone'){
coplited_value += '
' + i + '
';
}else if(i' + i + '';
}else{
coplited_value += '' + i + '
';
}
}
$j('#complited_number_show').html(coplited_value);
var compare = total_question+1;
if(num == compare || all_done=='AllDone'){
$j('#all_qusetion_done').val("AllDone");
$j('#Q'+current_id).hide();
QulifyResultShow();
}else{
nex_id = num;
$j('#next_qusetion').val(nex_id);
$j('#Q'+current_id).hide();
$j('#Q'+nex_id).show();
}
}
function edit_option(id){
var eid = id;
$j('#show_result').hide();
$j('#subscribe-form').hide();
if($j('#edit_qusetion').val()=='Edit'){
$j('#Q'+$j('#edit_id').val()).hide();
}else{
$j('#Q'+$j('#next_qusetion').val()).hide();
}
$j('#edit_qusetion').val('Edit');
$j('#Q'+eid).show();
$j('#edit_id').val(eid);
}
function QulifyResultShow(){
//Get all the answers selected by the user
var answers = "";
for(var x=1;x0)
//var send_data = '[{"result-count":"'+option_count+'"},'+jsonObjects+',{"bonus_count":"'+ bonus_count +'"},'+bonus_jsonObjects+']';
var send_data = '[{"result-count":"'+option_count+'"},'+jsonObjects+',{"bonus_count":"'+ bonus_count +'"},'+bonus_jsonObjects+',{"answers":"'+answers+'"}]';
else
//var send_data = '[{"result-count":"'+option_count+'"},'+jsonObjects+',{"bonus_count":"'+ bonus_count +'"}]';
var send_data = '[{"result-count":"'+option_count+'"},'+jsonObjects+',{"bonus_count":"'+ bonus_count +'"},{"answers":"'+answers+'"}]';
var site_url = document.getElementById("site_url").value;
url = site_url+'/grants-loans-calculator/result.php';
//Remove any two commas sitting side by side;
send_data = send_data.replace(',,',',');
$j.ajax({
type: "POST",
url: url,
data: ({data : $j.parseJSON(send_data)}),
beforeSend: function(x) {
$j('#show_result').show();//Show the div that will contain results
$j('#show_result').html('');//Show a loader image while waiting for the results
if (x && x.overrideMimeType) {
x.overrideMimeType("application/j-son;charset=UTF-8");
}
},
success: function(msg){
var result = msg.split("##");
//$j('#show_result').html(msg);
var decoded_results = $j('').html(result[0]).val();
$j('#show_result').html(decoded_results).val();
//$j('#show_result').html(result[0]);
$j('#subscribe-form').show();
$j('#contact_comments').val(result[1]);
}
});
}
function number_format (number, decimals, dec_point, thousands_sep) {
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
s = '',
toFixedFix = function (n, prec) {
var k = Math.pow(10, prec);
return '' + Math.round(n * k) / k;
};
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0');
}
return s.join(dec);
}