﻿/* ----------------------------------------------------------
  Project 	: IDKK Web Portal / www.idkk.gov.tr
  Author	: Locksmith Software Technologies / www.lstyazilim.com
  ---------------------------------------------------------- */

$(function(){
	
$("#navigationcontainer .navigation li").dropdown();
$('#header-content h1').bind('click',function(){window.location = '/';});
$('#s4-ribbonrow #RibbonContainer').length ? $('#s4-ribbonrow').show() : $('#s4-ribbonrow').hide();

$('.date').datepicker();

$('.gridview tr').each(function(){
	$(this).find('th:first, td:first').hide();
});

/* LANGUAGE */ 	
var substrURL = window.location.pathname.split('/');
var sc = substrURL.length;		
for(i=0;i<=sc-1;i++){
	if(substrURL[i] == "English"){
		$('#wrapper').addClass('eng');			
		$('#footer .right').html('Ministry of Finance Internal Audit Coordination Board 4. Street (Kazakistan Street) No:112 Emek / Ankara <br/>Phone : +90(312) 215 58 32  E-Mail : <a href="mailto:iletisim@idkk.gov.tr">iletisim@idkk.gov.tr</a>');
		$('#top-menu ul li a').each(function(){
			var lc = $(this).html();
			if(lc == 'Site Haritası'){$(this).remove();}
			if(lc == 'Yeni Üyelik'){$(this).remove();}
		});			
		$('#breadcrumbs .breadcrumbRootNode').text('Main Page');			
		$('#top-menu ul li:nth-child(1)').remove();
		$('#top-menu ul li:nth-child(2)').remove();			
		$('#info-button').remove();
		$('#birimler').html('<img src="/Style Library/images/birim_button_en.png">');
	}				
}
	
/* LOGO CLICK */
$('.eng #header-container h1').html('Republic of Turkey Ministry of Finance Internal Audit Coordination Board');	
$('#header-content h1').bind('click',function(){$('#wrapper').hasClass('eng') ? window.location = '/Sayfalar/English/AnaSayfa.aspx' : window.location = '/';});
		
/* LANGUAGE CONTROL */			
$('.lang-container input').bind('click',function(){
	if( $(this).val() == 'English' ){OnSelectionChange(1033);}
	else if( $(this).val() == 'Türkçe' ){OnSelectionChange(1055);}
}); 
		
/* COLORBOX */
$("a.colorbox").colorbox({width:"75%", height:"75%", display:"block"});
$(".uyaripopup").colorbox({inline:true, width:"50%"});
	
/* FLASH NEWS */
var newsInterval = 5000;
$('.news-photo-content a:first').show();
$('.news-content > div:first').show();
$('.news-links a:first').addClass('current');
$('.news-links a').each(function(){
	$(this).bind('click',function(){
		var index = $(this).prevAll().length;
		$('.news-links a').removeAttr('class');
		$(this).addClass('current');
		$('.news-content > div').hide();
		$('.news-content > div:eq('+index+')').fadeIn();
		$('.news-photo-content a').hide();
		$('.news-photo-content a:eq('+index+')').fadeIn();
		return false;
	});								
});
function slideNews(e){
	var currentIndex = $('.news-links a.current').prevAll().length;
	currentIndex++;
	if(currentIndex == 1){currentIndex = 2;}
	slide = setInterval(function(){
		if(e == 1){currentIndex++;e=0;}
		if(currentIndex == 6){currentIndex = 1;}
		$('.news-links a').removeAttr('class');
		$('.news-links a:nth-child('+currentIndex+')').attr('class','current');
		$('.news-content > div').hide();
		$('.news-content > div:nth-child('+currentIndex+')').fadeIn();
		$('.news-photo-content a').hide();
		$('.news-photo-content a:nth-child('+currentIndex+')').fadeIn();
		currentIndex++;
	},newsInterval);	
}
$('#news-container').hover(
	function(){clearInterval(slide);},
	function(){currentIndx=0;slideNews(1);}
);
if($('#news-container').length){slideNews(0);}

/*  MAP */	
$('#map-area area').each(function(){	
	$(this).mousemove(function(e){
		var selectedCity = $(this).attr('alt');
		if($('.info-popup-container #'+ selectedCity +'').length){
			$(this).css('cursor','pointer');
			$('.city-popup').html('<b>'+selectedCity+'</b> ilinde <b>'+$('.info-popup-container #'+ selectedCity +'').attr('title')+'</b> adet birim ba&#351;kanl&#305;&#287;&#305; bulunmaktad&#305;r. &#304;leti&#351;im bilgileri i&#231;in t&#305;klay&#305;n...');
			$('.city-popup').show();
			$('.city-popup').css({left:e.pageX + 15, top:e.pageY + 15});
			$(this).colorbox({width:"400", inline:true, href: '.info-popup-container #'+ selectedCity +'' });
			return false;
		}
		else{$(this).click(function(){return false;});}			
	});
	$(this).mouseout(function(){$('.city-popup').hide();});		
});

/* SURVEY FIX */
$('.survey-container .ms-formbodysurvey:first').parent().remove();	
$('.survey-container .ms-formtoolbar:first').remove();
$('.survey-container .ms-formlabel:first').addClass('message');	

/* BANNER */
$('.banner-container').each(function(){$('div:first',this).addClass('active');});
function bannerSwitch(){
	bannerInterval = setInterval(function(){
		$('.banner-container').each(function(){
			if($('img',this).length > 1){
				var $active = $('div.active',this);
				if ( $active.length == 0 ){ $active = $('div:last',this);}
				var $next = $active.next().length ? $active.next() : $('div:first',this);	
				$active.addClass('last-active');
				$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function(){
					$active.removeClass('active last-active');
				});
			 }else{return false;}			    
		});		
	},5000);
}
if($('.banner-container div').length > 1){bannerSwitch();}

/* SELECT ALL */
$('.check-master input').bind('click',function(){
	var checked_status = this.checked;
	$(".check-cell input").each(function(){this.checked = checked_status;});
});
if($('#page-title .left').html() == 'Sınav Formu '){ $('#page-title .right').hide();}

});

$.fn.dropdown = function() {
	$(this).hover(function(){
		$(this).addClass("hover");
		$('> .dir',this).addClass("open");
		$('ul:first',this).css('visibility', 'visible');
		
	},function(){
		$(this).removeClass("hover");
		$('.open',this).removeClass("open");
		$('ul:first',this).css('visibility', 'hidden');
	});
}

$.datepicker.regional['tr'] = {
		closeText: 'kapat',
		prevText: '&#x3c;geri',
		nextText: 'ileri&#x3e',
		currentText: 'bugün',
		monthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran',
		'Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],
		monthNamesShort: ['Oca','Şub','Mar','Nis','May','Haz',
		'Tem','Ağu','Eyl','Eki','Kas','Ara'],
		dayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],
		dayNamesShort: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
		dayNamesMin: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
		weekHeader: 'Hf',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['tr']);



