

$(document).ready(function() {
			
	// menu
	$('ul.closed').hide();
	$('a.expand').toggle(
		function() {
		  $('ul.subcategories').show();
		  $('a.opener').addClass('opened');
		},  
		function() {
		  $('ul.subcategories').hide();
		  $('a.opener').removeClass('opened');
		}
	);      
	$('a.opener').click(function () {		
		$(this).next().slideToggle();
		$(this).toggleClass('opened');
    });
	// -- menu
	
	$(".lightbox").fancybox({
		'overlayOpacity' : 0.6, 
		'overlayColor' : '#000',
		'titlePosition' : 'inside'
	});
	
	$("a[rel=article_photos]").fancybox({
		'overlayOpacity' : 0.6, 
		'overlayColor' : '#000',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' &nbsp; ' + title + '</span>';
		}
	});
	
	$("a.gallery_photos").fancybox({
		'overlayOpacity' : 0.6, 
		'overlayColor' : '#000',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' &nbsp; ' + title + '</span>';
		}
	});

	$('.tip_north').tipsy({gravity: 'n'});
	$('.tip_south').tipsy({gravity: 's'});
	$('.tip').tipsy();
	
	

});



function only_caps(u){
	q=u.value;
	q=q.replace( /ς/g , "Σ");
	q=q.replace( /ά/g , "α");
	q=q.replace( /έ/g , "ε");
	q=q.replace( /ή/g , "η");
	q=q.replace( /ί/g , "ι");
	q=q.replace( /ό/g , "ο");
	q=q.replace( /ύ/g , "υ");
	q=q.replace( /ώ/g , "ω");
	u.value = q.toUpperCase();
}

function required_fields() {
	var argv = required_fields.arguments;
	var argc = argv.length;
	var missing_fields = false;
	var found_first_field = 0;
	for (var i = 0; i < argc; i++) {
		if (!$("#" + argv[i]).val()) {
			missing_fields = true;
			if (!found_first_field) {
				found_first_field=argv[i];	
			}
		}
	}
	if (missing_fields) {
		alert('Παρακαλώ συμπληρώστε τα απαραίτητα πεδία.');
		$("#" + found_first_field).focus();
		return false;	
	} else {
		$("#submit_holder").hide();
		$("#submit_loading").show();
		return true;
	}
}

function window_opener(windowWidth, windowHeight, windowName, windowUri){
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;
    newWindow = window.open(windowUri, windowName, 'toolbar=0,scrollbars=0,statusbar=0,menubar=0,width=' + windowWidth + 
        ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight);
    newWindow.focus();
    return newWindow.name;
}
