﻿

function lookupcountry(inputString) {
if (inputString.length == 0) {
    // Hide the suggestion box.
    $('#suggestions').hide();
} else {
$.post("/rpc.aspx?lookupcountry=" + inputString , function(data) {
    if (data.length > 0){ 
        $('#suggestions').show();
        $('#autoSuggestionsList').html(data);
    }
});
}
} // lookup


function fill(thisValue) {
$('#ctl00_body_txtCountry').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}

function updateParentHeadingResponse(id, questionID, instanceID, resultID) {

    var value = document.getElementById(id).value;
/*        document.getElementById(resultID).value = "";
    $.ajax({
        url: "SavePropertySurveyResponses.aspx?value=" + value + "&qID=" + questionID + "&instID=" + instanceID,
        cache: false,
        success: function(html) {
            $("#" + resultID).append(html);
        }
    });
    
    */
    if (value == 1)
    {
        DisplayControl(resultID);
    }
    else if (value == 0)
    {
        HideControl(resultID);
    }
}
function updateSurveyMetricResponse(id, questionID, instanceID, resultID, type, propertyID) {
/*
    var value = document.getElementById(id).value;
    $.ajax({
        url: "SavePropertySurveyResponses.aspx?value=" + value + "&qID=" + questionID + "&instID=" + instanceID + "&qtype=" + type + "&pID=" + propertyID ,
        cache: false,
        success: function(html) {
            $("#" + resultID).append(html);
        }
    });
    */
}



function updateSurveyResponse(id, questionID, instanceID, resultID) {
    var value = document.getElementById(id).value;
    if (value != null && value != "") {
        $.ajax({
            url: "SavePropertySurveyResponses.aspx?value=" + value + "&qID=" + questionID + "&instID=" + instanceID,
            cache: false,
            success: function(html) { renderCharts(resultID, html); }
        });
    }
    else {
        document.getElementById(resultID).innerHTML = "";
    }
}

function renderCharts(target, values) {
    document.getElementById(target).innerHTML = "";
    $('#' + target).empty();
    $('#' + target).append(values);
    $('#' + target).sparkline('html', { type: 'bar', barColor: 'red' });
}


function DisplayControl(controlName){
    var control = document.getElementById(controlName);
    control.style.display="block";
}
function HideControl(controlName){
    var control = document.getElementById(controlName);
    control.style.display="none";
}


