 jQuery.fn.fadeSliderToggle = function(settings) {
 	 settings = jQuery.extend({
		speed:500,
		easing : "swing"
	}, settings)
	
	caller = this
 	if($(caller).css("display") == "none"){
 		$(caller).animate({
 			opacity: 1,
 			height: 'toggle'
 		}, settings.speed, settings.easing, function(){$.scrollTo($(this).parent(), 500, {easing: "swing"});});
	}else{
		$(caller).animate({
 			opacity: 0,
 			height: 'toggle'
 		}, settings.speed, settings.easing);
	}
}; 

  

var Frontpage = {
	
	initialize: function()	{
		if($('div.home').length == 0) return;
		
		$('#nav li').click(function(e) { 		
			Frontpage.toggle(e.currentTarget); 
		});
	},
	
	startFlash: function()	{
		if($('#main').length == 0) return;		
		var flashvars = false;
		var attributes = {data: "/swf/feature.swf", width:"866", height:"360" };
		var id = "flashcontent";
		var params = {align: "t", wmode: "transparent", salign: "tl", bgcolor: "#ffffff", flashvars:""};
		swfobject.createSWF(attributes, params, id);
	},
	
	toggle : function(element)	{
		var what = element.id.substring(4);
			
		// close other active modules
		$('#nav li').each(function() { 
			if(element === this) return;
			
			if($(this).hasClass('active')) 
				Frontpage.close(this);
		});

		$(element).toggleClass('active');	
		$('#hidden-' + what).toggle();
	},
	
	close : function(element)	{
		var what = element.id.substring(4);
		
		$(element).removeClass('active');	
		$('#hidden-' + what).hide();
	}
};

var Modules = {

	initialize: function()	{
	
		if(!$('.modules') || !$('.modules .zoomer')) return;
		
		// attach events
		$('.modules .zoomer').click(function() {$('.hidden-info').slideUp("slow");  Modules.toggle(this); });
		$('.module-more').click(function(){Modules.toggleInfo(this)})
	},
	
	
	toggleInfo : function(element){
		
		var parent = $(element).parent().parent().parent();
		var hidden = $(parent).find('.hidden-info');
		
		if(hidden.is(':hidden')){
			hidden.slideDown("slow", function(){$.scrollTo(hidden, 500, {easing: "swing"})});
		}else{
			hidden.slideUp("slow");
		}
		
	},
	
	toggle	: function(element)	{
		
		
		var parent 	= $(element).parent();
		var hidden	= $(parent).find('.hidden');
	
		// change zoom img src
		if(hidden.is(':hidden'))	{
			$(element).html('<img src="/img/zoom-big-out.png" width="22" height="22" />');
			$(element).pngFix();
		}
		else{
			$(element).html('<img src="/img/zoom-big.png" width="22" height="22" />');
			$(element).pngFix();
		}
		
		// show hidden div
		hidden.fadeSliderToggle();
	}
};

$(document).ready(function(){
	//Frontpage.initialize();
	//Frontpage.startFlash();
	//Modules.initialize();
	//$('div.module-gallery a').lightBox(); 
	//$(document).pngFix(); 
	Cufon.replace('h1');
	Cufon.replace('h2',{'hover': true});
	Cufon.replace('h3',{'hover': true});
	Cufon.replace('h5',{hover: true});
	Cufon.replace('div.pollQuest');
	Cufon.replace('#side_menu ul li',{'hover': true});
	$('#header').click(function(){window.location.href = "http://www.hagitegas.gr";});
	
	$("a.iframe").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false,
		'width'			:	750,
		'height'		:	$(document).height() - 40
	});

	
});
