function getAllJobs() {
   // document.getElementById("status").value = "Searching...";
    JobServices.findJobs(handleFindJobs);
}

function handleFindJobs(searchResult) {
    var result = TrimPath.processDOMTemplate("searchResultsTemplate", searchResult);
    document.getElementById("jobs").innerHTML = result;
}

function getAllJobsByRegion(region) {
   // document.getElementById("status").value = "Searching...";
   // initTable("jpost1","null","1");  The sorting is not working
    JobServices.findJobsByRegion(region, handleFindJobs);
}

function getAllJobsByLocation(location) {
   // document.getElementById("status").value = "Searching...";
   JobServices.findJobsByLocation(location, handleFindJobs);
}

window.onload=function(  ){ JobServices.getRegionValues(populate);};

function populate(map){
    DWRUtil.removeAllOptions("region");
    addOptionValues("region", map);

}

function addOptionValues(_id,_map){
    var sel = document.getElementById(_id);
    var opt = null;

    if (_map.length == 0)
    {
    	alert("No matching products found");
    }

    if (sel == null)
    {
    	alert("SEL IS NULL");
    }

    if(sel != null){
        for(var prop in _map) {
            opt=document.createElement("option");
            opt.setAttribute("value",_map[prop]);
            opt.appendChild(document.createTextNode(prop));
            sel.appendChild(opt);
        }
    }
}

//function findProductsByDepartment() {
//    document.getElementById("status").value = "Searching...";
//    var department = document.getElementById("selectDepartment").value;
//    ProductService.findProductsByDepartment(department, handleFindProducts);
//}

//function handleFindProducts(searchResult) {
//    var result = TrimPath.processDOMTemplate("searchResultsTemplate"
//                                                            , searchResult);
//    document.getElementById("products").innerHTML = result;
//    document.getElementById("status").value = "Search Complete.";
//}

//function updatePrice(productId, price) {
//    if(!isValidDollarAmount(price)) {
//        alert("Not a valid dollar amount.");
//        return;
//    }

//    document.getElementById("status").value = "Updating...";
//    ProductService.updateProductPrice(productId, price, handleUpdatePrice);
//}

//function handleUpdatePrice(result) {
//    if(result.successful) {
//        document.getElementById("status").value = "Update Successful.";
//    }
//    else {
//        var errorMessage = "Updated failed. Error message: ";
//        var errorMessge = errorMessage + result.errorMessage;
//        document.getElementById("status").value = errorMessage;
//    }
//}

//function isValidDollarAmount(amount) {
//    var isValid =
//    RegExp(/^\$?\d+(\.\d{2})?$/)
//    .test(String(amount).replace(/^\s+|\s+$/g, ""));
//    return isValid;
//}