//<![CDATA[
function initMenu() {
  $('#menu ul').hide();
  $('#menu ul:first').show();
  $('#menu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#menu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
$(document).ready(function() {initMenu();});
jQuery(document).ready(function(){
	/*Resim Tooltip*/
	var tmm = true;
	jQuery("#menu > li > ul > li").bind('mouseenter', function(){ 
		if(tmm)
			return;
		var div = '<div id="tooltip-img" style="display:none; width:106px; height:70px; position:relative; top:-105px; left:185px;">'
				+'<div style="padding-left:3px; padding-right:3px; width:100px; height:70px; padding-top:3px; padding-bottom:3px; background:#262626 url(img/loading-img.gif) 46px 30px no-repeat;">'
				+'<img src="'+jQuery(this).find('a:first').attr('img')+'" style="display:none;" onload="$(this).show();" width="100" height="70" />'
				+'</div>'
				+'<div style="position:relative; background: url(img/oktan.png) no-repeat right top; right:0px;">&nbsp;</div>'	
				+'</div>';
		jQuery('#tooltip-img').remove();
		jQuery(this).after(div);
		jQuery(this).next().css({'top':'-90px','display':'block','opacity':'0', 'height':'0px', 'z-index':99}).animate({
		opacity:1,
		top: '-99px',
		},300); 
		tmm = true;
	}).bind('mouseleave', function(){ 
		if(tmm)
			return;
		jQuery(this).next().animate({
		top: '-115px',
		opacity: '0'
		},300, function(){ $(this).remove(); }); 
		tmm = false;
	});	
	
	/*TAB MENU*/
	$("#"+$("#tabmenu1 > .tabcontent:first").attr('tabid')+", #"+$("#tabmenu2 > .tabcontent:first").attr('tabid')).parent().removeClass('tabpasif').addClass('tabaktif');
	$("#tabmenu1 > .tabcontent:first, #tabmenu2 > .tabcontent:first").slideDown('normal');
	$("#tabmenu1 > .tabbas > div, #tabmenu2 > .tabbas > div").click(function(e){
		if($("."+$(this).children().attr('id')).is(':visible'))
			return false;
		
		$("."+$(this).parent().find(".tabaktif").children().attr('id')).slideUp('normal');
		$("."+$(this).children().attr('id')).slideDown('normal');
		
		$(this).parent().find(".tabaktif").removeClass('tabaktif').addClass('tabpasif');
		$(this).addClass('tabaktif').removeClass('tabpasif');
		
		
	}).css('cursor','pointer');
	
	/*Resim Slider*/
	 var top = $(".resimalani_item").length;
     var t = 0;
     var tan = false;
 	$("#once").click(function(e){
     	if(e.target != 'javascript:;')
     		clearTimeout(timer);
 		if(top <= t+3)
 		{
 			tan = true;
     		return false;
 		}
 		var w = $(".kayanresimx > .resimalani_item:eq("+t+")").width()+5;
 		t = t+1;
 		p = '-='+w;
		$(".kayanresimx").animate({'marginLeft': p+'px'}, 500);
		return false;
     });
 	$("#sonra").click(function(e){
 		if(e.target != 'javascript:;')
     		clearTimeout(timer);
 		if(t <= 0)
 		{
 			tan = false;
     		return false;
 		}
 		var w = $(".kayanresimx > .resimalani_item:eq("+t+")").width()+5;
 		t = t-1;
     	p = '+='+w;
		$(".kayanresimx").animate({'marginLeft': p+'px'}, 500);
		return false;
     });
 	$(".kayanresimx").mouseover(function(){
 		clearTimeout(timer);
     });
		$(".kayanresimx").mouseout(function(){
			timer = setTimeout('basla();', 2500);
     });
     basla = function(){
     	if(tan)
 		{
     		$("#sonra").click(false);
 		}
     	else
     	{
     		$("#once").click(false);
         }
         clearTimeout(timer);
     	timer = setTimeout('basla();', 2500);
     };
     var timer = setTimeout('basla();', 2500);
     
     /*Arama Kutusu Submit*/
     $(".aramakutusu > .submit").bind('click', function(e){
    	 document.location.href = $(this).prev().prev().val()+$(this).prev().val();    	 
     });
     
     /* messages fade away when dismiss is clicked */
     $(".message > .dismiss > a").live("click", function (event) {
         var value = $(this).attr("href");
         var id = value.substring(value.indexOf('#') + 1);

         //$("#" + id).fadeOut('slow', function () { });
         $("#" + id).animate({height:'0px'}, 800, function(){ 
         	$(this).animate({width:'0px'}, 800, function(){ 
         		$(this).remove(); 
         	}) 
         });
         
         
         return false;
     });
     
     /* Yorum yazma alanını açar kapatır.. */
     $(".cevapyaz").click(function(e){
    	 $('.yorum').slideToggle('slow');    	 
     });
     
     $(".yoruma").live('submit',function(){
    	 
     });
     $(".yorumk").live('submit',function(){
    	 $.fancybox({
	 		 href	: "/uyeol.php?islem=yorum",
	 		 type   : "iframe"
         });
    	 return false;
     });
     
     
     /*Tavsiye*/
     tavsiye2 = function(puan, e){
    	 $.fancybox({
	 		 href	: "/uyeol.php?islem=tavsiye&puan="+puan+"&konuid="+$(e.target).attr('id'),
	 		 type   : "iframe"
         });
    	 return false;
     };
          
     begendim = function(puan, e){
    	 var id = $(e.target).attr('id');
    	 $.ajax({
    		 url: '/ajax/begen.php',
    		 type: 'POST',
    		 data: 'puan='+puan+'&konuid='+id,
    		 success: function(data){
    		 	window.location.reload(); 
    	 	 }
    	 });
    	 return false;
     };
     vazgectim = function(e){
    	 var id = $(e.target).attr('id');
    	 $.ajax({
    		 url: '/ajax/begen.php',
    		 type: 'POST',
    		 data: 'islem=vazgec&konuid='+id,
    		 success: function(data){
    		 	window.location.reload();
    	 	 }
    	 });
    	 return false;
     };
     
     tavsiye = function(puan, e){
    	 var id = $(e.target).attr('id');
    	 $.ajax({
    		 url: '/ajax/tavsiye.php',
    		 type: 'POST',
    		 data: 'puan='+puan+'&konuid='+id,
    		 success: function(data){
    		 	window.location.reload(); 
    	 	 }
    	 });
    	 return false;
     };
     vazgec = function(e){
    	 var id = $(e.target).attr('id');
    	 $.ajax({
    		 url: '/ajax/tavsiye.php',
    		 type: 'POST',
    		 data: 'islem=vazgec&konuid='+id,
    		 success: function(data){
    		 	window.location.reload();
    	 	 }
    	 });
    	 return false;
     };
     
     tavsiyeEt = function(uri){
    	 $.fancybox({
	 		 href	: "/tavsiyeet.php?uri="+uri,
	 		 type   : "iframe"
         });
    	 return false;
     };
     
     /*Yorum İhbar*/
     $('.ihbar').click(function(e){
    	 $.fancybox({
	 		 href	: "/sikayet.php?id="+$(e.target).attr('id'),
	 		 type   : "iframe"
         });
    	 return false;
     });
     
     $('.uyeol').live('click', function(){
    	 $.fancybox({
	 		 href	: "/uyeol.php",
	 		 type   : "iframe"
         });
    	 return false;    	 
     });
     
     /**/
    $(".tabicerik").hide();
    
 	$(".tabadiburda").click(function(e){
 		if($("."+$(e.target).attr('id')).is(':visible'))
 		{
 			$("."+$(".t_aktif").children().attr('id')).slideUp('normal');
 			$(".t_aktif").removeClass('t_aktif');//.addClass('t_pasif');
 			return;
 		}
 		
 		$("."+$(".t_aktif").children().attr('id')).slideUp('normal');
 		$("."+$(e.target).attr('id')).slideDown('normal');
 		
 		$(".t_aktif").removeClass('t_aktif');//.addClass('t_pasif');
 		$(this).parent().addClass('t_aktif');//.removeClass('t_pasif');
 	}).css('cursor','pointer');
 	
}); 
//]]>