function isaretle( element, id )
{
    
    var lilerinHepsi = document.getElementById('liler').getElementsByTagName("LI");
	var e = document.getElementById(element);
	
    for( i = 0; i < lilerinHepsi.length; i++ )
    {
        if( !e )
        {
            lilerinHepsi[i].className = 'current';
            return;
        }
        lilerinHepsi[i].className = '';
    }
    e.className='current';
	
	AltMenuGoster(element);
}

var oMenuler;
var oSag;
var oSol;
function SagKaydir()
{
    var mLeft = parseFloat(oMenuler.css("margin-left"));
    var mUzunluk = oMenuler[0].offsetWidth;
    var sliderMenuAlanUzunluk = $("#sliderMenuAlan")[0].offsetWidth;
    
    if(sliderMenuAlanUzunluk < (mUzunluk + mLeft))
    {
        oMenuler.css("margin-left", parseFloat(oMenuler.css("margin-left")) - 5);
        
	    $("#solKaydir").show();
    }
    else
    {
        clearInterval(oSag);
        $("#sagKaydir").hide();
    }

}

function SolKaydir()
{
    var mLeft = parseFloat(oMenuler.css("margin-left"));
    var mUzunluk = oMenuler[0].offsetWidth;
    var sliderMenuAlanUzunluk = $("#sliderMenuAlan")[0].offsetWidth;
    
    if(mLeft < 0)
    {
        oMenuler.css("margin-left", parseFloat(oMenuler.css("margin-left")) + 5);
        
	    $("#sagKaydir").show();
    }
    else
    {
        clearInterval(oSol);
        $("#solKaydir").hide();
    }
}

window.onload = function () {
    oMenuler = $("span:first", "#link1AltMenu");
    $("#sagKaydir").hover(
      function () {
        oSag = setInterval( "SagKaydir()", 5 );
      }, 
      function () {
        clearInterval(oSag);
      }
    );
    
    $("#solKaydir").hover(
      function () {
        oSol = setInterval( "SolKaydir()", 5 );
      }, 
      function () {
        clearInterval(oSol);
      }
    );
};

function AltMenuGoster(altMenu)
{
	var id = "#" + altMenu + "AltMenu";
	
	$(".altMenu").hide();
	$(id).show();
	oMenuler.css("margin-left", 0);
	oMenuler = $("span:first", id);
	var sliderMenuAlanUzunluk = $("#sliderMenuAlan")[0].offsetWidth;
	var menuUzunluk = $("span:first", id)[0].offsetWidth;
	if(sliderMenuAlanUzunluk < menuUzunluk)
	{
	    $("#sagKaydir").show();
	    $("#solKaydir").hide();
	}
	else
	{
	    $("#sagKaydir").hide();
	    $("#solKaydir").hide();
	}
    
}



function guncelle(tablo,id)
{
    
    var gonder = tablo + ":" + id;
    if(document.getElementById("txtGuncelle").value!=gonder)
    {
       document.getElementById("txtGuncelle").value=gonder;
       __doPostBack('txtGuncelle',gonder);
    }
    
}

function guncelle2(tablo,id,sayfaid)
{
    
    var gonder = tablo + ":" + id;
    if(document.getElementById("txtGuncelle").value!=gonder)
    {
       document.getElementById("txtGuncelle").value=gonder;
       __doPostBack('txtGuncelle',gonder);
    }
    
    isaretle( "link" + sayfaid, sayfaid );
    
}

function guncelle3(tablo)
{
    
    var gonder = tablo;
    if(document.getElementById("txtGuncelle").value!=gonder)
    {
       document.getElementById("txtGuncelle").value=gonder;
       __doPostBack('txtGuncelle',gonder);
    }
    
    
    
}
function random_getir()
{
    var ranNum= Math.floor(Math.random()*4);
    return ranNum;
}

function rasgeleResim()
{
    var index=random_getir();

    var resimler=new Array(4)
     resimler[0]="url('images/resim1.jpg')";
     resimler[1]="url('images/resim2.jpg')";
     resimler[2]="url('images/resim3.jpg')";   
     resimler[3]="url('images/resim4.jpg')";
    $('#icerik2sag').css("background-image",resimler[index]);
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function pageLoad()
{   
    if( document.getElementById("galeri") != null)
    {
    
        $('#galeri a').lightBox();
    }
    setInterval( "slideSwitch()", 5000 );
    
    clearInterval(oSag);
    clearInterval(oSol);
    
    $('.haberShow').cycle({ 
        fx:      'scrollUp', 
        speed:    1000, 
        timeout:  5000 
    });
    $('.haberShow2').cycle({ 
        fx:      'scrollUp', 
        speed:    1000, 
        timeout:  5000 
    });
    

    
    $("#sliderMenuAlan a").click(
      function () {
        $("#sliderMenuAlan a").css("color","#9f9e9e");
        $(this).css("color","#62afe5");
        
      });    
    
    $("#resimAni").hover(
      function () {
        $("#gizliResimAni").css("display","block");
      }, 
      function () {
        $("#gizliResimAni").css("display","none");
      }
    );
    
    $("#haberAlan").hover(
      function () {
        $("#gizliHaberAlan").css("display","block");
      }, 
      function () {
        $("#gizliHaberAlan").css("display","none");
      }
    );

    
    $("#ani").hover(
      function () {
        $("#gizliAni").css("display","block");
      }, 
      function () {
        $("#gizliAni").css("display","none");
      }
    );
    
    $("#footer").hover(
      function () {
        $("#gizliFooter").css("display","block");
      }, 
      function () {
        $("#gizliFooter").css("display","none");
      }
    );
    
    
    $("#menu").hover(
      function () {
        $("#gizlimenu").css("display","block");
      }, 
      function () {
        $("#gizlimenu").css("display","none");
      }
    );
    
    if( document.getElementById("upload_button4") != null)
    {
    
    new Ajax_upload('#upload_button4', {
        action: 'UploadHandler4.ashx',
        onSubmit: function(file, ext) {
            //checking file extension
            if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                // extension is not allowed
                alert('Sadece resim formatlarını kaydedebilirsiniz. (jpg,png,jpeg,gif)');
                // cancel upload
                return false;
            }
            this.disable();
            $('#yukleniyor').css('display', 'block');
        },
        onComplete: function(file, response) {
            $('#imgResim').attr('src','../images/' + file);
            $('#yukleniyor').css('display', 'none');
            this.enable();
        }
    });
    }
    
    
    if( document.getElementById("upload_button3") != null)
    {
    
    new Ajax_upload('#upload_button3', {
        action: 'UploadHandler3.ashx',
        onSubmit: function(file, ext) {
            //checking file extension
            if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                // extension is not allowed
                alert('Sadece resim formatlarını kaydedebilirsiniz. (jpg,png,jpeg,gif)');
                // cancel upload
                return false;
            }
            this.disable();
            $('#yukleniyor').css('display', 'block');
        },
        onComplete: function(file, response) {
            $('#imgResim').attr('src','../images/' + file);
            $('#yukleniyor').css('display', 'none');
            this.enable();
            window.location="galeri.aspx";
        }
    });
    }
    
    if( document.getElementById("upload_button2") != null)
    {
    
    new Ajax_upload('#upload_button2', {
        action: 'UploadHandler2.ashx',
        onSubmit: function(file, ext) {
            //checking file extension
            if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                // extension is not allowed
                alert('Sadece resim formatlarını kaydedebilirsiniz. (jpg,png,jpeg,gif)');
                // cancel upload
                return false;
            }
            this.disable();
            $('#yukleniyor').css('display', 'block');
        },
        onComplete: function(file, response) {
            $('#imgResim').attr('src','../images/' + file);
            $('#yukleniyor').css('display', 'none');
            this.enable();
            window.location="galeri.aspx";
        }
    });
    }
    
    if( document.getElementById("upload_button") != null)
    {
    
    new Ajax_upload('#upload_button', {
        action: 'UploadHandler.ashx',
        onSubmit: function(file, ext) {
            //checking file extension
            if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                // extension is not allowed
                alert('Sadece resim formatlarını kaydedebilirsiniz. (jpg,png,jpeg,gif)');
                // cancel upload
                return false;
            }
            this.disable();
            $('#yukleniyor').css('display', 'block');
        },
        onComplete: function(file, response) {
            $('#imgResim').attr('src','../images/' + file);
            $('#yukleniyor').css('display', 'none');
            this.enable();
        }
    });
    }
    
}

