var month=new Array(12);
month[1]="January";
month[2]="February";
month[3]="March";
month[4]="April";
month[5]="May";
month[6]="June";
month[7]="July";
month[8]="August";
month[9]="September";
month[10]="October";
month[11]="November";
month[12]="December";
$(document).ready(
		
		function(){
			
			// sayfa ilk yuklendiginde acilan haber
			sayfaYukle("0");
			});
			
			function sayfaYukle(gunDegeri){
			$('#calismaListesi').html("");
			$('#icerikAlaniSag').html("");
			no = 0;
			adres = location.href;
			adres = adres.split("/");
			adres=adres[adres.length-1];
			adres=adres.split(".");
			
            jQuery.ajax({
                url: 'data/'+ adres[0] +'.xml', //xml dosyamiz
                type: 'GET',
                dataType: 'xml',
                timeout: 15000,
                success: function(xml){
						var deger = $(xml).find('news');
						
                        $(xml).find('news').each(function(index){ //menu node ve altında ki verileri alıyoruz
						var newsTitle = jQuery(this).find('title').text();
						var worksTitle = jQuery(this).find('wtitle').text();
						var newsDate = jQuery(this).find('date').text();
						var newsImage = jQuery(this).find('image').text();
						var launch = jQuery(this).find('launch').text();
						var client = jQuery(this).find('client').text();
						var agency = jQuery(this).find('agency').text();
						var screenshotResimleri = new Array();

							  jQuery('<li />')
                             .html('<a href=javascript:sayfaYukle('+ index +')>'+ worksTitle +'</a>')
                             .appendTo('#calismaListesi');
							 newsDate = newsDate.split(',',3);
							 var yil = newsDate[0];
							 var ay = newsDate[1];
							 var gun = newsDate[2];
							var today = new Date(yil, ay, gun);
							
						      jQuery('<div />')
                             .html('<ul class="newsBilgi"><li class="newsDate">'+ month[today.getMonth()]+ ' '+today.getFullYear() +'</li><li><h2>'+ worksTitle + ' </h2></li></ul><ul id="resimAlaniSketch" style="display:block"><li><ul id="resimListesi'+ index +'"></ul></li></ul><p class="resimBilgisi" style="display:block"><strong>client:</strong> '+ client +' <strong>agency:</strong> '+ agency +'</p>')
                             .appendTo('#icerikAlaniSag');
							 if(gunDegeri == index)
							 {
								//lightbox icin acilan resimleri diziyoruz
								$(this).find('screenshot').each(function(j){
								screenshotResimleri[j] = jQuery(this).find('screenshotResim').text();
								});
								
								for (x in screenshotResimleri)
								{
									$('#resimListesi'+ index).append(
									$('<li />')
										.append('<img src='+ screenshotResimleri[x] +' />')
									);
									
								 }
								 
								 // soldaki linki secili hale getirmek icin 
								 $("#calismaListesi li:eq("+ index +") a").attr('class', 'seciliCalisma');
								 $("#icerikAlaniSag div:eq("+ gunDegeri +")").attr('class', 'seciliHaberKatmani');
							}
// SIFR							
    var can = {
      src: 'images/can.swf'
      ,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
    };
    sIFR.activate(can);

    sIFR.replace(can, {
      selector: 'h2'
      ,css: {
        '.sIFR-root': { 'color': '#FFFFFF', 'background-color': '#0a0a0a', 'width': '150px' }
      }
    });								
							 
                    });
                },
                error: function(){
                    alert('Error loading XML document');
                }
				
            });
		}