﻿function GetMetaData() {

    var locationId = $('*[ID$="hfLocationId"]').val();
    var metaType = $('*[ID$="hfMetaType"]').val();
    var subLocationId = $('*[ID$="hfSubLocationId"]').val();
    var contentType = $('*[ID$="hfContentType"]').val();    
    if (locationId == null) {
        return;
    }
    var params = { 'MetaTagType': metaType, 'LocationID': locationId, 'SubLocationID' : subLocationId, 'ContentType' : contentType };
    var jsonString = "{JsonMetaData: '" + JSON.stringify(params) + "'}";
    var serviceURL = resolveURL("WebServices/MetaService.asmx/GetMetaData");
    $.ajax({
        type: "POST",
        url: serviceURL,
        data: jsonString,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnMetaAddedSuccess                        
    });
}

function OnMetaAddedSuccess(result) {
    var metadata = JSON.parse(result.d);
    if (metadata.Title == null) {
        return;
    }
    document.title = metadata.Title;
    $("meta[name=keywords]").attr("content", metadata.Keywords);
    $("meta[name=description]").attr("content", metadata.Description);
}
                