window.$j = window.$ = jQuery;
$.browser.old_ie = $.browser.msie && $.browser.version < 8;

var scrollto = 0; 
//var initdisabled = false;

$j(document).ready(function() {

  // jQuery SmoothScroll | Version 10-04-30
	$('a[href*=#folyam], a[href*=#bio], a[href*=#blog], a[href*=#kozosseg], a[href*=#zene], a[href*=#kapcsolodj], a[href*=#esemeny], a[href*=#bogoz_text], a[href*=#the-gallery]').click(function() {
 
   // duration in ms
   var duration=1000;
 
   // easing values: swing | linear
   var easing='swing';
 
   // get / set parameters
   var newHash=this.hash;
   var target=$(this.hash).offset().top;
   var oldLocation=window.location.href.replace(window.location.hash, '');
   var newLocation=this;
 
   // make sure it's the same location   
      
   if(oldLocation+newHash==newLocation)
   {
      // set selector
      if($.browser.safari) var animationSelector='body:not(:animated)';
      else var animationSelector='html:not(:animated)';
 
      // animate to target and set the hash to the window.location after the animation
      $(animationSelector).animate({ scrollTop: target }, duration, easing, function() {
 
         // add new hash to the browser location
         window.location.href=newLocation;
      });
 
      // cancel default click action
      return false;
   }
	}); // $

	
	function toggle_nyil(id){
			var src = $('#'+id+' img').attr("src");
			if (src == "/kozos2.0a/fel.gif") {src = "/kozos2.0a/le.gif";var title = "kinyitom"} else {src = "/kozos2.0a/fel.gif";var title = "becsukom"};
			$('#'+id+' img').attr("src",src).attr("title",title);	
	}
	
	// blog iframe loaded when blog clicked
	$('#bloglink').click(function(){
		if (!$('#blogiframe').length) {
			var iframe = $('<iframe></iframe>').attr('id', 'blogiframe').attr('src', 'http://bogoz.blog.hu').attr('width', '1000').attr('height', '800');
			iframe.load();
			$('#blog').append(iframe);
			$('#blog').fadeIn();			
			$('#bloglink img').attr("src","/kozos2.0a/fel.gif").attr("title", "becsukom");
		}else{
			$('#blog').fadeToggle();
			toggle_nyil("bloglink");
		}
	});

	// init: bogsz zarva
	$('#kozosseg').hide();
	
	// kozosseg
	$('#kozosseglink').click(function(){
			$('#kozosseg').fadeToggle();
			toggle_nyil("kozosseglink");
	});	


// init nav opacity
	$('nav').fadeTo('fast', 0.5, function() {
      // Animation complete.
  });
	
// hover nav fade
	$('nav').hover(function(){
		$(this).fadeTo('fast', 1, function() {
      // Animation complete.
    });
	}, 
	function(){
		$(this).fadeTo('fast', 0.5, function() {
      // Animation complete.
    });	
	}	
	);

	
// init link t1 opacity
	$('a.linkt1').fadeTo('fast', 0.6, function() {
      // Animation complete.
  });	
	
	
// hover link t1 fade
	$('a.linkt1').hover(function(){
		$(this).fadeTo('fast', 1, function() {
      // Animation complete.
    });
	}, 
	function(){
		$(this).fadeTo('fast', 0.6, function() {
      // Animation complete.
    });	
	}	
	);

	
	// init link t2 opacity
	$('a.linkt2').fadeTo('fast', 0.8, function() {
      // Animation complete.
  });	
	
	
// hover link t2 fade
	$('a.linkt2').hover(function(){
		$(this).fadeTo('fast', 1, function() {
      // Animation complete.
    });
	}, 
	function(){
		$(this).fadeTo('fast', 0.8, function() {
      // Animation complete.
    });	
	}	
	);
	
	
		// init nyil opacity
	$('img.nyil').fadeTo('fast', 0.6, function() {
      // Animation complete.
  });	
	
	
// hover nyil fade
	$('img.nyil').hover(function(){
		$(this).fadeTo('fast', 1, function() {
      // Animation complete.
    });
	}, 
	function(){
		$(this).fadeTo('fast', 0.6, function() {
      // Animation complete.
    });	
	}	
	);
	

	
	
	
// enable circular scrollables with a click handler
$(".scroll").scrollable({ circular: true }).click(function() {
	$(this).data("scrollable").next();		
});

// esemenyek
	// initialize scrollable with mousewheel support - vertical - esemenyek 
	$(".scrollable").scrollable({ vertical: true, mousewheel: true, disabledClass: 'disabled', speed: 800 });
	// scroll to now()
/*
	var api = $(".scrollable").data("scrollable");
	api.onSeek(function()  {
		$('.next').removeClass('initdisabled');
		if(api.getIndex() <= scrollto) $('.next').addClass('disabled');
	});
	api.seekTo(scrollto,0);	
	*/
//	alert(api.getIndex());
//	api.next(0);
//api.end();
	
	
	$('.trigttip').each(function () {
		$(this).qtip({
			show: 'mouseover',
			hide: { when: 'mouseout', fixed: true, delay: 500 },
			content: { url: '/esemenyload.php', 
				data: { id: $(this).attr("id").split("_")[1] },
				method: 'get'
			},
			position: {
						corner: {
							 target: 'center', //'rightMiddle',
							 tooltip: 'leftMiddle'
						}
			},
			style: { 
//				name: 'dark',
				tip: 'leftMiddle',
		    background: '#f5c026',
				border: {
					 width: 1,
					 radius: 6,
					 color: '#f5c026'
				}
			}
		})	
	});


//	if(initdisabled) $('.next').addClass('initdisabled');
	
}); //ready 
/*
// iframe resize
function resizeIframeHeight(nHeight) {
	var iframe = document.getElementById('blogiframe');
	iframe.setAttribute('height', nHeight);
}
*/

