﻿//Titleları okuyan function.
function Menu(Id){
    $("#" + Id).css("backgroundPosition", "Bottom")
}

function MenuHover(Id){
    $("#" + Id).css("backgroundPosition", "Top")
}

function acilkapan(id){

    $('#' + id).slideToggle("slow");
    
}

$(document).ready(function(){


    $(".menu a").append("<em></em>");
    
    $(".menu a").hover(function(){
        $(this).find("em").animate({
            opacity: "show",
            top: "-43"
        }, "slow");
        var hoverText = $(this).attr("title");
        $(this).find("em").text(hoverText);
    }, function(){
        $(this).find("em").animate({
            opacity: "hide",
            top: "-85"
        }, "fast");
    });
    
    
});
function AdetArtir(id){
	 $('#txtAdet', '#Foto_' + id).val(parseInt($('#txtAdet', '#Foto_' + id).val())+parseInt(1));
	
	
}

function UploadResuld(){
    $.post("Moduller/Ajax/KucukResim.php", function(data){
        $('#UploadResult').html(data + $('#UploadResult').html());
        TutarHesapla();
        //$("input[@name=isaret]").fadeOut();
        //  
    
    });
}

function UploadClose(){
    swfu.cancelQueue();
    $('#FileLoading').fadeOut();
    Transparan(10);
    
    
}

function PencereSurukle(id){
    $().mousemove(function(e){
        $('#' + id).css('top', (e.pageY + 20) + 'px').css('left', (e.pageX + 20) + 'px');
        
    });
}

function PageCenter(id){
    var width = $('#' + id).width();
    var height = $('#' + id).height();
    Left = ($(window).width() / 2) - (width / 2);
    Top = ($(window).height() / 2) - (height / 2);
    $('#' + id).css('position', 'absolute');
    $('#' + id).fadeIn();
    $('#' + id).css('top', Top + 'px');
    $('#' + id).css('left', Left + 'px');
}

function Mesaj(Message, Tur, Sure){
    $('#Mesaj').removeClass();
    if (Tur == 1) {
        $('#Mesaj').toggleClass("MesajOk");
    }
    else 
        if (Tur == 2) {
            $('#Mesaj').toggleClass("MesajComment");
        }
        else 
            if (Tur == 3) {
                $('#Mesaj').toggleClass("MesajError");
            }
    
    $('#Mesaj').css('margin-top', $(window).scrollTop() + 'px');
    $('#Mesaj').html(Message);
    $('#Mesaj').fadeIn();
    setTimeout("$('#Mesaj').fadeOut()", Sure);
}

function Transparan(Sure){
    $("#TransparanBg").width($(window).width() - 1);
    $("#TransparanBg").height($(window).height());
    if ($("#TransparanBg").css("display") == "block") {
        setTimeout("$('#TransparanBg').fadeOut()", Sure);
    }
    else {
        $("#TransparanBg").fadeIn();
    }
}

function BoyutDegistir(FotoId, Boyut){
    $.post("Moduller/Ajax/BoyutDegistir.php?FotoId=" + FotoId + "&Boyut=" + Boyut, function(data){
        if (data != "3") {
            TutarHesapla();
        }
        else {
        
            Mesaj("HATA:Boyut değitirilemedi.", "3", 1000);
        }
    });
}

function TutarHesapla(){
    $.post("Moduller/Ajax/Tutar.php", function(data){
        if (data != "3") {
            $("#Tutar").html(data+" TL");
        }
        else {
        
            Mesaj("HATA: Tutar hesaplanamadı.", "3", 1000);
        }
    });
}

function AdetDegistir(FotoId, Adet){
    if (Adet != "") {
        $.post("Moduller/Ajax/AdetDegistir.php?FotoId=" + FotoId + "&Adet=" + Adet, function(data){
            if (data != "3") {
                TutarHesapla();
            }
            else {
            
                Mesaj("HATA: Baskı adeti değitirilemedi.", "3", 1000);
            }
        });
    }
    
}

function FotografKopyala(FotoId){
    $('#Foto_' + FotoId + ' #btnKopyala').attr("src", "Images/LoadMini.gif");
    $.post("Moduller/Ajax/ResimKopyala.php?FotoId=" + FotoId, function(data){
        if (data != 3) {
            $('#Foto_' + FotoId + ' #btnKopyala').attr("src", "Images/Kopyala.jpg");
            $('#Foto_' + FotoId).clone(true).insertAfter('#Foto_' + FotoId);
            $("#Foto_" + FotoId).animate({
                width: '0px'
            }, 1).fadeOut(0);
            $("#Foto_" + FotoId).animate({
                width: '269px'
            }, 300);
            $('#Foto_' + FotoId).next("div").attr("id", 'Foto_' + data);
            $('#btnKopyala', '#Foto_' + data).attr("alt", data);
            $('input', '#Foto_' + data).attr("title", data);
            $('#txtAdet', '#Foto_' + data).attr("alt", data);
            $('#sbBoyut', '#Foto_' + data).attr("name", data);
            $('#btnFotoSil', '#Foto_' + data).attr("alt", data);
            $('#sbBoyut', '#Foto_' + data).attr("value", 1);
            $('#txtAdet', '#Foto_' + data).attr("value", 1);
            $('#cbSec', '#Foto_' + data).attr("checked", "");
            TutarHesapla();
            return 1;
        }
        else {
            Mesaj('HATA : Kopyalana yapılamadı.', "3", 1000);
        }
    });
}

function FotoSil(FotoId){
    $.post("Moduller/Ajax/FotoSil.php?FotoId=" + FotoId, function(data){
        if (data != "3") {
            TutarHesapla();
            $("#Foto_" + FotoId).animate({
                width: '0'
            }, 300).fadeOut(0).html("");
            
            
        }
        else {
        
            Mesaj('HATA : Fotograf silinemedi.', "3", 1000);
        }
    });
    
    
}

$(document).ready(function(){
    $("#TumunuSec").click(function(){
        var checked_status = this.checked;
        
        
        $("input[name^='FotoSec']").each(function(){
            this.checked = checked_status;
        });
    });
});

function SiraylaKopyala(title, max, i){
    var sonuc = FotografKopyala(title[i]);
    i = i + 1;
    if (i < max && sonuc != "") {
        setTimeout(function(){
            SiraylaKopyala(title, max, i)
        }, 750);
        
    }
    
}

function SiraylaSil(title, max, i){
    var sonuc = FotoSil(title[i]);
    i = i + 1;
    if (i < max && sonuc != "") {
        setTimeout(function(){
            SiraylaSil(title, max, i);
        }, 750);
        
        
    }
}

function SiraylaBoyutlandir(title, max, i, Boyut){
    var sonuc = BoyutDegistir(title[i], Boyut);
    $('#sbBoyut', '#Foto_' + title[i]).attr("value", Boyut);
    i = i + 1;
    if (i < max && sonuc != "") {
    
        setTimeout(function(){
            SiraylaBoyutlandir(title, max, i, Boyut);
        }, 10);
        
        
    }
}

function SiraylaAdetDegistir(title, max, i, Adet){
    var sonuc = AdetDegistir(title[i], Adet);
    $('#txtAdet', '#Foto_' + title[i]).attr("value", Adet);
    i = i + 1;
    if (i < max && sonuc != "") {
        setTimeout(function(){
            SiraylaAdetDegistir(title, max, i, Adet);
        }, 1);
        
        
    }
}



function SecilileriBoyutlandir(Boyut){
    $("#TumunuSec").attr("checked", false);
    var title = [];
    var i = 0;
    $("input[name^='FotoSec']").each(function(){
        if (this.checked == true) {
            title[i] = this.title;
            i = i + 1;
        };
            });
    if (title != "") {
        SiraylaBoyutlandir(title, title.length, 0, Boyut);
    }
    else {
        Mesaj('HATA : Lütfen boyutlandırılacak fotoğrafları seçiniz.', "2", 1000);
    }
}

function SecililerAdetDegistir(Adet){
    $("#TumunuSec").attr("checked", false);
    var title = [];
    var i = 0;
    $("input[name^='FotoSec']").each(function(){
        if (this.checked == true) {
            title[i] = this.title;
            i = i + 1;
        };
            });
    if (title != "") {
        SiraylaAdetDegistir(title, title.length, 0, Adet);
    }
    else {
        Mesaj('HATA : Lütfen adeti değişecek fotoğrafları seçiniz.', "2", 1000);
    }
}

function SecilileriKopyala(){
    $("#TumunuSec").attr("checked", false);
    var title = [];
    var i = 0;
    $("input[name^='FotoSec']").each(function(){
        if (this.checked == true) {
            title[i] = this.title;
            i = i + 1;
        };
            });
    if (title != "") {
        SiraylaKopyala(title, title.length, 0);
    }
    else {
        Mesaj('HATA : Lütfen kopyalanacak fotoğrafları seçiniz.', "2", 1000);
    }
}

function SecilileriSil(){
    $("#TumunuSec").attr("checked", false);
    var title = [];
    var i = 0;
    $("input[name^='FotoSec']").each(function(){
        if (this.checked == true) {
            title[i] = this.title;
            i = i + 1;
        };
            });
    if (title != "") {
        SiraylaSil(title, title.length, 0);
    }
    else {
        Mesaj('HATA : Lütfen silinecek fotoğrafları seçiniz.', "2", 1000);
    }
}



$(document).ready(function(){

    Slider(1);
    
    
});
function Slider(i){
    yeni_i = parseInt(i) + parseInt(1);
    if (yeni_i > $("#HaberKayitSayisi").html()) {
    yeni_i=1;
    
    }
    setTimeout(function(){
        $("#Slider").html($("#Haber" + i).html());
    }, 300);
    setTimeout(function(){
        $("#Slider").fadeIn(300);
    }, 2);
    setTimeout(function(){
        $("#Slider").fadeOut(300);
        Slider(yeni_i);
    }, 10000);
    
}
function IlceGetir(IlId){
			$.ajax({
   type: "POST",
   url: "Moduller/Ajax/IlIlce.php",
   data: "IlId="+IlId,
   success: function(msg){
   	$("#dvIlce").html(msg);
   }
 });
	
}
function Yonlendir(Message,Tur,Sure,Url){
	if (Message!="") { Mesaj(Message, Tur, Sure); } 
	setTimeout(function(){
  window.location.href = Url;
    }, Sure);
	
	
	
}

