﻿

function postUrl(url, params)
{
    $.post(url, params,
        function(data){
            
    });
}

function renderReplace(url, params, id)
{
    $.post(url, params,
        function(data){
            $("#"+id).html(data);
    });
}

function refreshHavaDurumu(cityName) {
    renderReplace("HavaDurumu_AjaxProxy.aspx", { city: cityName }, "hava_durumu_container");
}

function postComment(articleId, body)
{
    renderReplace("Content_AjaxProxy.aspx", {method: "postComment", body: body, id: articleId}, "comment_form_div");
}

function postMessage(advertId, body)
{
    renderReplace("Advert_AjaxProxy.aspx", {method: "postMessage", body: body, id: advertId}, "advert_message_"+advertId);
}

function getCategoryList(parentId)
{
    renderReplace("Article_AjaxProxy.aspx", {method: "getCategories", id: parentId}, "search_category_list");
}

function searchAdverts()
{                                           
    url = "AdvertList.aspx?categoryId="+$('#ctl00_ContentPlaceHolder1_advertSearchForm_searchCategoryId').val()+'&cityId='+$('#ctl00_ContentPlaceHolder1_advertSearchForm_searchCityId').val()+'&keywords='+$('#ctl00_ContentPlaceHolder1_advertSearchForm_searchKeywords').val();
    window.location = url;
}

function searchFormSubmit(keyword, rootId, categoryId, topic)
{
    window.document.location = 'Search.aspx?keyword='+keyword+'&root_category_id='+rootId+'&category_id='+categoryId+'&topic='+topic;
}

function votePoll(pollId, answerId)
{
    $.post("Poll_AjaxProxy.aspx", { method: "votePoll", pollId: pollId, answerId: answerId },
        function(data){
            window.document.location = "Anket.aspx?id=" + pollId;    
        });
    
}

function addToArchive(aid)
{
    renderReplace("Article_AjaxProxy.aspx", {method: "addToArchive", articleId: aid}, "archive_span");
}

function addbookmark(url, desc) {

    var nonie = 'Sorry, only Internet Explorer supports this method to add a bookmark/favourite\n But please feel free to visit the site\'s home page to add a bookmark manually';

    if (!url && !desc) {
        var bookmarkurl = "http://www.kobifinans.com.tr/en/";
        var bookmarktitle = "KobiFinans - Resource Center for SMEs";
    } else {
        var bookmarkurl = url;
        var bookmarktitle = desc;
    }


    if (window.sidebar) { // Mozilla Firefox Bookmark
        alert('Due to security restrictions placed in Firefox, we are unable to automatically add a bookmark.\nPlease navigate to the home page and press: CTRL+D to add one manually.');
    } else if (document.all) { // IE Favourites
        window.external.AddFavorite(bookmarkurl, bookmarktitle);
    } else {
        alert(nonie);
    }
}


function setHome() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://www.kobıfinans.com.tr/tr/');

    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("this action was aviod by your browser，if you want to enable，please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', 'http://www.kobıfinans.com.tr/tr/');
    }
}