﻿var currentM = "10"; 
var currentV = "10"; 
var manset_interval;
var cacheTime = new Date().getTime();
var currentPuan = "2"; 
var currentMail = "Kapali"; 
 
$(document).ready(function(){
var i;
for(i=0; i<9; i++) thumbHover(i);
for(i=0; i<3; i++) videoHover(i);
thumbDegis(0);
videoDegis(0);
TarihBul();
$('img.redOk').attr({ src: "/images/redOk.gif" });
$('img.ayirac').attr({ src: "/images/ayirac.jpg" });

$("#aOkunan").click(function() { CokOkunanDegis("Okunan"); } );
$("#aYorumlanan").click(function() { CokOkunanDegis("Yorumlanan"); } );
CokOkunanDegis("Okunan");

$('div.lightBlueLine').html("<!-- -->");

$.get("/haber/incs/dovizTop.htm?dt=" + cacheTime, function(_Str){ $('div.griTop').html(_Str); });

$('#surReklam').hover( function() { reklamGoster(); } , function() {reklamGizle();});

});

function MailAc() { if(currentMail == "Kapali") { $('#mailDiv').show("slow"); currentMail= "Acik"; } else { $('#mailDiv').hide("slow"); currentMail= "Kapali"; } }

function MailYolla(haberId, haberType) {
$('#mailSonuc').html("Lütfen bekleyiniz...");
 var mailAdres = document.getElementById('ctl00$ortayer$txtMail').value;
 if(mailAdres != "")  $.get("/user/mailGonder.aspx?id=" + haberId + "&mail=" + mailAdres + "&type=" + haberType , function(_Str){ $('#mailSonuc').html(_Str); }); 
 else $('#mailSonuc').html("Mail alanı boş");
}

function Open(mypage, myname, w, h, scroll) 
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
	win = window.open(mypage, myname, winprops)
}

function MansetBasla()
{
    $("img.mansetResim").hover( function() { clearInterval(manset_interval); } , function() { manset_interval = setInterval(MansetRotate,6000);  });
    manset_interval = setInterval(MansetRotate,6000); //time in milliseconds
}

function EkoPiyasaGetir()
{
    $.get("/haber/incs/dovizEko.htm?dt=" + cacheTime, function(_Str){ $('div.katSolDiv').html(_Str); });
}

function EkoPiyasaGetir2()
{
    $.get("/haber/incs/dovizEko.htm?dt=" + cacheTime, function(_Str){ $('div.katMansetSag').html(_Str); });
}

function anketGetir(id)
{
    $.get("/anket/anket.aspx?id=" + id + "&dt=" + cacheTime, function(_Str){ $('#anketDiv').html(_Str); });
}

function oyKullan(anketId, id)
{
   $.get("/anket/anketSonuc.aspx?id=" + anketId + "&cId=" + id + "&dt=" + cacheTime, function(_Str){ $('#anketDiv').html(_Str); });
}

function sonucGetir(id)
{
   $.get("/anket/anketSonuc.aspx?id=" + id + "&dt=" + cacheTime, function(_Str){ $('#anketDiv').html(_Str); });
}

function testet(id, id2) 
{
 alert(id + "  " + id2);
}

function PuanGetir(id)
{
    if(id != currentPuan)
    {
        $("#puanTab" + id).removeClass("puanBos").addClass("puanSecili");
        $("#puanTab" + currentPuan).removeClass("puanSecili").addClass("puanBos");
    }
    $.get("/haber/incs/puan" + id + ".htm?dt=" + cacheTime, function(_Str){ $('#puanTeDe').html(_Str); });
    currentPuan = id;
}

function PuanTamGetir(id) { $.get("/haber/incs/puanTam" + id + ".htm?dt=" + cacheTime, function(_Str){ $('#puanTeDe').html(_Str); });   }


function HavaGetir(sehir) 
{ 
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])

    if ((version >= 5.5) && (document.body.filters)) 
    {
        $.get("/haber/havaGetir.aspx?type=ie&sehir=" + sehir + "&dt=" + cacheTime, function(_Str){ $('#havaDiv2').html(_Str); }); 
    }
    else
    {
        $.get("/haber/havaGetir.aspx?type=fire&sehir=" + sehir + "&dt=" + cacheTime, function(_Str){ $('#havaDiv2').html(_Str); }); 
    }
}

function TarihBul()
{
    var tarih = new Date();
    $("#tarihTop").html(tarih.toLocaleDateString() + " " + tarih.toLocaleTimeString().substring(0, 5));
}

function MenuDegis(katId)
{
    $("#menuTdMain").removeClass("menuSecili").addClass("menuNormal");
    $("#menuMain").removeClass("menuLinkSecili").addClass("menuLinkNormal");
    if(katId != 'Foto' && katId != 'Video')
    {
        $("#menuTd" + katId).removeClass("menuNormal").addClass("menuSecili");
        $("#menu" + katId).removeClass("menuLinkNormal").addClass("menuLinkSecili");       
       
        $('#logoDiv').html("<a href=\"/\"><img src=\"/images/top/bugun_logo_k.gif\" style=\"margin-bottom:4px\"  alt=\"Bugün Gazetesi\" /></a><a href=\"" + document.getElementById("menu" + katId).href + "\" ><img src=\"/images/kategori/" + katId + ".gif\" /></a>");
        
    }
    else 
    {
        $("#menuTd" + katId).removeClass("menuBlue").addClass("menuSecili");
        $("#menu" + katId).removeClass("menuLinkBlue").addClass("menuLinkSecili");       
    }
}

function LogoDegis(katId)
{
    $('#logoDiv').html("<a href=\"/\"><img src=\"/images/top/bugun_logo_k.gif\" style=\"margin-bottom:4px\"  alt=\"Bugün Gazetesi\" /></a><a href=\"/" + katId + "/\" ><img src=\"/images/kategori/" + katId + ".gif\" /></a>");
}
  
function CokOkunanDegis(adres)
{
    if(adres == "Okunan") 
    {
        $("#aOkunan").removeClass("grayTitle").addClass("redTitle");
        $("#aYorumlanan").removeClass("redTitle").addClass("grayTitle");
    }
    else 
    {
        $("#aYorumlanan").removeClass("grayTitle").addClass("redTitle");
        $("#aOkunan").removeClass("redTitle").addClass("grayTitle");
    }
    $.get("/haber/incs/cok" + adres + ".htm?dt=" + cacheTime, function(_Str){ $('#cokDiv').html(_Str); });
}
function thumbHover(id)
{ 
    $('#mt' + id).hover( function() { thumbDegis(id); clearInterval(manset_interval); } , function() { manset_interval = setInterval(MansetRotate,6000);  });
    $("#ma" + id).attr({ href: $("div.mansLink:eq(" + id + ")").text() });
}

function thumbDegis(id)
{ 
    if(id != currentM)
    {
         $("img.mansetResim").attr({ src: $("div.mansPict:eq(" + id + ")").text() });
         $("#mansetLink").attr({ href: $("div.mansLink:eq(" + id + ")").text() });
         var soldan = (51 * id) + 16;
         $("#mansetOk").css('left', soldan + 'px');
         $('#mt' + currentM).removeClass("mansetThumb2");  $('#mt' + currentM).addClass("mansetThumb");
         
         $('#mt' + id).removeClass("mansetThumb");
         if(id != 8) $('#mt' + id).addClass("mansetThumb2");
         else $('#mt' + id).addClass("mansetThumb3");
         currentM = id;
         Gelecek(1);
         Gelecek(2);
    }
}

function Gelecek(numm)
{
    var fId = currentM + numm;
    fId = fId % 8;
    $("#future" + numm).attr({ src: $("div.mansPict:eq(" + fId + ")").text() });
}

function MansetRotate()
{
    var mId = currentM + 1;
    mId = mId % 8;
    thumbDegis(mId)
}

function videoHover(id)
{ 
    $('#vT' + id).hover( function() { videoDegis(id); } , function() {  });
    $('#vT' + id).addClass("videoThumbs");
    $("#vTL" + id).attr({ href: $("div.vidLink:eq(" + id + ")").text() });
}

function videoDegis(id)
{ 
    if(id != currentV)
    {
         $("img.videoResim").attr({ src: $("div.vidPict:eq(" + id + ")").text() });
         $("#videoLink").attr({ href: $("div.vidLink:eq(" + id + ")").text() });
         $("div.videoTitle").html($("div.vidTitle:eq(" + id + ")").text());

         $('#vT' + currentV).removeClass("videoThumbs2");  $('#vT' + currentV).addClass("videoThumbs");
         $('#vT' + id).removeClass("videoThumbs"); $('#vT' + id).addClass("videoThumbs2");
         currentV = id;
    }
}
  
function addBookmark(title,url) 
{
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

function SarkiBul() { findSong(); song_interval = setInterval(findSong,30000); }
function findSong() { $.get("/haber/sarkiBul.aspx?dt=" + cacheTime, function(_Str){ $('#sarkiInfo').html(_Str); }); }

///function findSong() {  $('#sarkiInfo').html("Kanaltürk - Türkiye'nin radyosu..."); }

///$("div.surReklam").css('zIndex', zIndexNumber); }

//function reklamGoster(){ $("#surReklam").css('zIndex', '999');}
//function reklamGizle() { alert("ss"); $("#surReklam").css('zIndex', '0');  }

function reklamGoster(){  $('#surReklam').removeClass("sr1"); $('#surReklam').addClass("sr2");}
function reklamGizle() {   $('#surReklam').removeClass("sr2"); $("#surReklam").addClass("sr1"); }


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
                var today = new Date();
                today.setTime( today.getTime() );
 
                if ( expires )
                {
                               expires = expires * 1000 * 60 * 60 * 8;
                }
                var expires_date = new Date( today.getTime() + (expires) );
 
                document.cookie = name + "=" + escape( value ) +
                               ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
                               ( ( path ) ? ";path=" + path : "" ) + 
                               ( ( domain ) ? ";domain=" + domain : "" ) +
                               ( ( secure ) ? ";secure" : "" );
}
function Get_Cookie( name )
{
                var start = document.cookie.indexOf( name + "=" );
                var len = start + name.length + 1;
                if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
                {
                               return null;
                }
                if ( start == -1 )
                               return null;
                var end = document.cookie.indexOf( ";", len );
                if ( end == -1 )
                               end = document.cookie.length;
                return unescape( document.cookie.substring( len, end ) );
}
function Delete_Cookie( name, path, domain )
{
                if ( Get_Cookie( name ) )
                               document.cookie = name + "=" +
                                               ( ( path ) ? ";path=" + path : "") +
                                               ( ( domain ) ? ";domain=" + domain : "" ) +";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
