try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

if (typeof jQuery == 'undefined') {
	alert('bir sorun algilandi!');
}

function css3() {
	$('.content p:has(a.more-link)').css({'text-align' : 'right', 'margin-bottom' : '0px'});
	$('.regionalnews_item:last').css({'margin-bottom' : '10px'});
	
}

function global_nav() {
	nav_root = $('#global_nav div:has(a#nav_products)');
	nav_root.bind('mouseover', function () { $(this).attr('class', 'over'); });
	nav_root.bind('mouseout', function () { $(this).attr('class', 'last'); });
}

function bind_triggers() {
	
	$('#home_search_submit').mousedown(function(){
		if(typeof eval(validateSearchKey)=='function'){	
			if(validateSearchKey()==true)
				$('#home_search').submit();
		}else{
			$('#home_search').submit();
		}
	});
	
	$('.list_menu li').mousedown(function() {
		var count = 0;
		var items = new Array();
		$('.list_menu li').each(function() { 
			if ($(this).attr('class') != 'current nobind') {
				items.push($(this).attr('title'));
			}
		});
		
		while (count < items.length) {
			if ($(this).attr('title') == items[count]) {
				$('#' + items[count] + '_container').show();
				$('li[title="' + items[count] + '"]').attr('class', 'current');
			} else {
				$('#' + items[count] + '_container').hide();
				$('li[title="' + items[count] + '"]').attr('class', '');
			}
			count++;
		}
	});
	
	function form() {
		$('input.toinput').bind('focus', function() {
			if ($(this).attr('value') == $(this).attr('alt')) {
				$(this).attr('value', '');
			}
		});
		
		$('input.toinput').bind('blur', function() {
			if ($(this).attr('value') == '') {
				$(this).attr('value', $(this).attr('alt'));
			}
		});
	}
	
	form();
}
	

function slideshow(target) {
	duration = 12000; // sanye geçisi
	
	rotate = function() {
		active = $('#slideshow div.active');
		active_menu = $('#slideshow_nav a.current');
		next = active.next().length ? active.next() : $('#slideshow div:first');
		next_menu = active_menu.next().length ? active_menu.next() : $('#slideshow_nav a:first');
		
		active.addClass('last-active');
		$('#slideshow_nav a').removeClass('current');
		next_menu.addClass('current');
				
		next.css({opacity: 0}).addClass('active').animate({opacity: 1}, 500 /*Otomatik giderken efekt saniyesi!*/, function() {
			active.css({opacity: 0}).removeClass('active last-active');
		});
	}
	
	if (target != null) {
		clearInterval(rotatetick);
		target_div = $('#slideshow div:eq(' + target + ')');
		target_menu = $('#slideshow_nav a:eq(' + target + ')');
		
		if ($(target_div).attr('class') != 'active') {
			active = $('#slideshow div.active');
			active.addClass('last-active');
			$('#slideshow_nav a').removeClass('current');
			target_menu.addClass('current');
			
			target_div.css({opacity: 0}).addClass('active').animate({opacity: 1}, 250, /*OTOMATIK GITMEZKEN SADEEC SEÇILIYLEN GIDECEK OLAN SANIYE!*/function() {
				active.css({opacity: 0}).removeClass('active last-active');
			});
		}
		rotatetick = setInterval(rotate, duration);
	} else {
		rotatetick = setInterval(rotate, duration);
	}
}

function slideshow_nav() {
	count = 0;
	
	$('#slideshow div').each(function() {
		$('#slideshow_nav').append('<a href="javascript:slideshow('+count+');">&nbsp;</a>');
		count++;
	});
	
	$('#slideshow_nav a:first').addClass('current');
}

function loading() {
	window.onload = function() {
		$('#loading').css('display', 'none');
	}
}

function startup() {
	loading();
	global_nav();
	css3();
	bind_triggers();
	slideshow_nav();
	slideshow();
	
}
