﻿// JScript File
var Newses = new Array();
function News(Index, ID, Title, SubTitle, Body, ImageFile, URL)
{
    this.nIndex = Index; 
    this.nID = ID; 
    this.sTitle = Title; 
    this.sSubTitle = SubTitle; 
    this.sBody = Body;
    this.sImageFile = ImageFile;
    this.sURL = URL;
}

var CurrentNewsHref;
function ShowNews(Index)
{
    document.getElementById('NewsIndexPanel1').className = 'NewsIndexPanelDisabled';
    document.getElementById('NewsIndexPanel2').className = 'NewsIndexPanelDisabled';
    document.getElementById('NewsIndexPanel3').className = 'NewsIndexPanelDisabled';
    document.getElementById('NewsIndexPanel4').className = 'NewsIndexPanelDisabled';
    document.getElementById('NewsIndexPanel' + (Index + 1)).className = 'NewsIndexPanelEnabled';
    var News = Newses[Index];
    if(News)
    {
        if(News.sImageFile != "")
            $('#NewsImagePanel').html("<div><img width='382' height='225' src='/Data/Album/Images/Size3/" + News.sImageFile + "' border=0 style='border-top:solid 1px #B02985;'></div>");
        else
            $('#NewsImagePanel').html("");
        if(News.sURL != "")
            document.getElementById('NewsHeading').innerHTML = "<a href='" + News.sURL + News.nID + "' class='NewsHeading'>" + News.sTitle + "</a>";
        else
            document.getElementById('NewsHeading').innerHTML = News.sTitle;
        CurrentNewsHref = News.sURL + News.nID;
        if(News.sTitle == "")
            document.getElementById('NewsHeading').innerHTML = "";
        if(News.sSubTitle != "")
            document.getElementById('NewsSubHeading').innerHTML = "<br><i>" + News.sSubTitle + "</i>";
        else
            document.getElementById('NewsSubHeading').innerHTML = "<br>";
        if(News.sBody != "")
            document.getElementById('NewsText').innerHTML = News.sBody + "<br><br><a href='" + News.sURL + News.nID + "'></a>";
        else
            document.getElementById('NewsText').innerHTML = "";
    }
    else
    {
        document.getElementById('NewsSubHeading').innerHTML = "";
        document.getElementById('NewsHeading').innerHTML = "";
        document.getElementById('NewsImagePanel').style.backgroundImage = "";
        document.getElementById('NewsText').innerHTML = "";
        CurrentNewsHref = "";
    }
}

function ShowBoxText(TextBox)
{
    TextBox.className = "LoginBoxDisabled";
}

function HideBoxText(TextBox)
{
    if(TextBox.id == "Email" && TextBox.value == "E-posta adresiniz")
    {
        TextBox.value = "";
    }
    else
    {
        if(TextBox.id == "PWD" && TextBox.value == "Şifreniz")
        {
            TextBox.value = "";
            if(window.ActiveXObject)
            {
                var NewBox = document.createElement("input");
                var parent = TextBox.parentNode;
                NewBox.type = "password";
                NewBox.value = "";
                NewBox.id = 'PWD';
                NewBox.name = 'PWD';
                NewBox.setAttribute('onblur', TextBox.getAttribute('onblur'));
                NewBox.setAttribute('onfocus', TextBox.getAttribute('onfocus'));
                parent.insertBefore(NewBox, TextBox);
                parent.removeChild(TextBox);
                TextBox = NewBox;
                TextBox.focus();
            }
            else
            {
                TextBox.type = 'password';
                TextBox.value = "";
                TextBox.focus();
            }
        }
    }
    TextBox.className = "LoginBox";
}

function Trim(Value)
{
    return Value.replace(/^\s*((?:[\S\s]*\S)?)\s*$/, '$1');
}

function ShowHidePanel(PanelID)
{
    $("#" + PanelID).slideToggle("slow");
}

var NewImageIndex = 1;
function NewImage()
{
    var Object = document.getElementById("NewImageButton");
    var parent = Object.parentNode;
    var NewSpan = document.createElement("div");
    NewSpan.id = 'AddedImagePanel' + NewImageIndex;
    NewSpan.innerHTML = "<table cellpadding=2 cellspacing=2 border=0 width=100%><tr><td width=100>Dosya</td><td><input class='SmartInput' style='width:300px;' type='file' name='NewImage" + NewImageIndex + "'></td><td><span style='cursor:pointer' onclick=\"RemovePanel('" + NewSpan.id + "');\">Sil</span></td></tr></table>";
    //NewSpan.innerHTML = "<input class='SmartInput' style='width:300px;' type='file' name='NewImage" + NewImageIndex + "'><span style='cursor:pointer' onclick=\"RemovePanel('" + NewSpan.id + "');\">Sil</span>";
    parent.insertBefore(NewSpan, Object);
    NewImageIndex++;
}

function RemovePanel(Panel)
{
    var Object = document.getElementById(Panel);
    var parent = Object.parentNode;
    Object.innerHTML = "";
    parent.removeChild(Object);
}

function LoadPanel(Panel, URL)
{
    var P = $('#' + Panel);
    P.append("<center><img src='/Images/IndicatorSmall.gif' border=0></center>");
    $.ajax( 
    { 
        type: "POST",
        url: URL, 
        cache: false, 
        success: function(message) 
        { 
            P.html(message);
        } 
    }); 
}

$().ready(function() {
    $("#Labels").autocomplete('/Search.aspx?Ajax=1&Type=Label', {
		width: 300,
		multiple: true,
		matchContains: true
	});
	$("#District").autocomplete('/Search.aspx?Ajax=1&Type=District', {
		width: 300,
		multiple: false,
		matchContains: true
	});
});

jQuery(document).ready
(
    function($) 
    {
      $('a[rel*=facebox]').each(
        function (){
            $(this).unbind("click");
            $(this).click(function(){ $(this).facebox(); return false;});
        }
      );
    }
);
