// JavaScript Document

// INPUT ONCLICK SCRIPT
function clearText(field){
	if (field.defaultValue == field.value) {
		field.value = '';
		field.className='click';
	} else if (field.value == '') {
		field.value = field.defaultValue;
		field.className='blur';
}
}

// menu rollover effect (fade blue)
$(function(){
	$('#menubar .menu a')
		.css( {backgroundPosition: "0 -259px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:400})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 -259px)"}, {duration:400})
		})
});
$(function(){
	$('#menubar .menu dt')
		.css( {backgroundPosition: "0 -259px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:400})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 -259px)"}, {duration:400})
		})
});

// menu rollover effect (slide down in orange tag)
/*$(function(){
	$('#menubar .menu li')
		.mouseenter(function(){
			$(this).children().children('.left').animate({backgroundPosition:"(0 0)"}, {duration:300});
			$(this).children().children('.right').animate({backgroundPosition:"(0 0)"}, {duration:300});
			$(this).children().children('.mid').animate({backgroundPosition:"(0 0)"}, {duration:300})
		})
		.mouseleave(function(){
			$(this).children().children('.left').animate({backgroundPosition:"(0 -67px)"}, {duration:300});
			$(this).children().children('.right').animate({backgroundPosition:"(0 -67px)"}, {duration:300});
			$(this).children().children('.mid').animate({backgroundPosition:"(0 -67px)"}, {duration:300})
		})
});*/

// menu rollover effect (fade in orange tag)
/*$(function(){
	$('#menubar .menu li')
		.mouseenter(function(){
			$(this).children().children('.left').fadeIn(300);
			$(this).children().children('.right').fadeIn(300);
			$(this).children().children('.mid').animate({backgroundPosition:"(0 0)"}, {duration:300});
		})
		.mouseleave(function(){
			$(this).children().children('.left').fadeOut(300);
			$(this).children().children('.right').fadeOut(300);
			$(this).children().children('.mid').animate({backgroundPosition:"(0 -67px)"}, {duration:300});
		})
});*/


// CROSS-SLIDE
/*$(function() {
	if ($('#slideshow').length) {
	  $('#slideshow').crossSlide({
		  sleep: 3,
		  fade: 1
	  }, [
		  {
			  src:  'images/photos/slide01.jpg',
			  alt:  'τίτλος φωτογραφίας'
		  }, {
			  src:  'images/photos/slide02.jpg',
			  alt:  'slide 2'
		  }, {
			  src:  'images/photos/slide03.jpg',
			  alt:  'slide 3'
		  }, {
			  src:  'images/photos/slide04.jpg',
			  alt:  'slide 4'
		  }
	  ], function(idx, img, idxOut, imgOut) {
		if (idxOut == undefined)
		{
		  // starting single image phase, put up caption
		  $('div.caption').text(img.alt).animate({ opacity: 1 })
		}
		else
		{
		  // starting cross-fade phase, take out caption
		  $('div.caption').animate({ opacity: 0 })
		}
	  });
	  $('div.caption').show().css({ opacity: 0 })
	}
});*/

// SCROLLABLE HEADLINES


$(document).ready(function(){
	
	// JCAROUSELLITE
	if ($('.list2.jCarouselLite').length) {
	  $(".list2.jCarouselLite").jCarouselLite({
		  vertical: true,
		  auto: 2000,
		  speed: 1500,
		  visible: 3,
		  scroll: 2,
		  hoverPause:true
	  });
	}
	
	// FANCYBOX
	if ($('.zoom1').length) {
	  $(".zoom1").fancybox({
		  titlePosition			: 'inside',
		  'transitionIn'			: 'fade',
		  'transitionOut'			: 'fade',
		  centerOnScroll          : true
	  });
	}
	if ($(".page").length) {
		$('.page').fancybox({
			'width'				: '75%',
			'height'			: '75%',
			'autoScale'     	: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
		});
	}
	if ($(".alert").length) {
	  $('.alert').fancybox({
		  'transitionIn' : 'fade',
		  'transitionOut' : 'fade',
		  centerOnScroll : true,
		  overlayShow :	true
	  });
	}
	
	
	// APPLY LARGEST HEIGHT IN EVERY LIST3 LI
	$(".list3").each(function() {
		var maxheight = 0;
		$("> li", this).each(function(){
			if (maxheight < $(this).height()) {
				maxheight = $(this).height();
			}
		});

		$("> li", this).height(maxheight);
	});
	
	// APPLY LARGEST HEIGHT IN EVERY LIST4 LI
	$(".list4").each(function() {
		var maxheight = 0;
		$("> li", this).each(function(){
			if (maxheight < $(this).height()) {
				maxheight = $(this).height();
			}
		});

		$("> li", this).height(maxheight);
	});
	
	
	// animated faq scroll
	$('a.topbtn').click(function(){
	  $('html, body').animate({scrollTop:0}, 'slow');
	  return false;
	});
	
	
	// apply variable widths in dropdown menus
	$("#menubar .menu .dropdown dt").each(function(){
		var itemwidth = $(this).width();
		$(this).parent().children('dd').css( {width: itemwidth + 'px'} );
		$(this).parent().children().children('ul').css( {width: itemwidth + 'px'} );
	});
});


