function mainPageSearch() {
    var SearchText = $("#txtSearchText").val();
    if (!(SearchText == "")) { window.location.href = '/Search.aspx?SearchText=' + SearchText; }
}

function submitenter(myfield, e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13) {
        mainPageSearch();
        return false;
    }
    else
        return true;
}

function ReactionSubscription(type, ReactionID, katilBTN, ayrilBTN) {
    var strData = "type=" + type + "&ReactionID=" + ReactionID;

    $.ajax({
        type: 'GET',
        url: '/ajx/ReactionSubscribe.ashx',
        data: strData,
        success: function (axjResponse) {
            $("#SubscriberCount").html(axjResponse);
        }
    })

    if (type == 'katil') {
        $("#" + katilBTN).hide();
        $("#" + ayrilBTN).show();
    } else {
        $("#" + katilBTN).show();
        $("#" + ayrilBTN).hide();
    }

    return false;
}

function CompareContent() {

    var selectedContentID = "";

    $('*[name=chkCompare]:checked').each(function () {
        var element = this;
        selectedContentID = selectedContentID + element.value + "/";
    })

    var strContentIDList = new String(selectedContentID);

    strContentIDList = strContentIDList.substr(0, strContentIDList.length - 1);

    if (strContentIDList.length > 0) {
        document.location.href = "/haberkarsilastir/" + strContentIDList;
    }
}

//-------- HeadLine ---------------


function ShowNextHeadline() {
    if (activeHeadlineNumber == 15) ShowHeadline(1);
    else ShowHeadline(activeHeadlineNumber + 1);
}
function ShowPreviousHeadline() {
    if (activeHeadlineNumber == 1) ShowHeadline(15);
    else ShowHeadline(activeHeadlineNumber - 1);
}


var autoHeadlineTimer = 15;
function AutoShowHeadline() {

    autoHeadlineTimer = setInterval('ShowNextHeadline()', 6000);
}




var activeHeadlineNumber = 1;
function ShowHeadline(Number) {
    $("[id^=MansetDiv]").hide();
    $("#MansetDiv" + Number).show();
    var silsileHTML = $("#MansetDiv" + activeHeadlineNumber).find("[id=MansetSilsile]").html();

    $("#page" + activeHeadlineNumber).removeAttr("style");
    if (silsileHTML != "") {
        $("#page" + activeHeadlineNumber).css("background", "url(/images/blue-hover-bg.gif) no-repeat center").css("color", "#fff");
    }

    $("#page" + Number).css("background", "url('/images/hover-bg.gif') no-repeat center").css("color", "#fff");
    activeHeadlineNumber = Number;
}

//-------- HeadLine ---------------
function ShowRightHeadLine(HeadLineID) {
    if ((HeadLineID != 0) && (HeadLineID != "")) {
        $("#first-headline").html($("#headline-" + HeadLineID).html());
    }
}


function showMenu(divID) {
    $('#div_list > div').hide();
    $('#divHideBottom').show();
    $('#divHideTop').show();
    $('#' + divID).show();
}


// ------- Weather ----------------

function getWeather(CityID, CityName) {
    $("#divWeatherCityList").hide();
    $("#divWeatherCity").hide();
    $("#divWeatherLoading").show();

    $.getJSON('/ajx/CityWeather.ashx?CityID=' + CityID, function (JSON) {
        if (JSON.weather.status == 1) {
            var imgSrc = "/images/weather/" + JSON.weather.Icon;

            $("#WeatherImage").removeAttr("src");
            $("#WeatherImage").attr("src", imgSrc);
            $("#WeatherTemperature").text(JSON.weather.Temperature);
            $("#WeatherCity").text(CityName);
        } else {
        }
    });

    $("#divWeatherLoading").hide();
    $("#divWeatherCity").show();
}

function changeWeatherCity() {
    var CityID = $("#slCityList").val();
    var CityName = $('#slCityList :selected').text();

    getWeather(CityID, CityName);
}

// ------- Weather ----------------
