$(document).ready(function() {


// input focus in login-form

$('.login-form .input-txt').focusin(function() {
	$(this).parent().addClass('field-focusin');
}).focusout(function() {
	$(this).parent().removeClass('field-focusin');
});

var l = document.getElementById('login') ;
if (l && l.value == '') {
    l.focus() ;
}



$('#more-pros').click(function(){
    showPros() ;
    return false;
}) ;   


    
$('#more-changes, #pros-more-changes').click(function(){    
    showChanges () ;
    return false ;
});

$('h1').click(function() {
	$('#mail-changes-all, #mail-pros-all').hide();
	$('#main-content').show();
	return false ;
}) ;

if (!!document.location.hash && document.location.hash === $('#more-pros')[0].hash) {
    showPros() ;
} else if (readCookie && readCookie('logcount_2') > 3) {
    showChanges () ;
} else {
	$('#main-content').show();
}


// slider
$('.anythingSlider').show () ;
if ($('.anythingSlider li').length > 1) {
	$('.anythingSlider').anythingSlider({
		easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 5000,                    // How long between slide transitions in AutoPlay mode
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 10,             // How long the slide transition takes
		hashTags: false,                 // Should links change the hashtag in the URL?
		buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "Go",             // Start text
		stopText: "Stop"               // Stop text
	});
}

// lightbox

$("a.fancybox").fancybox();

/* fetch answer for question mark from new faq system
$('#helpLoginForm').bind('click',function(event){
	event.preventDefault();
	var element = $('#helpLoginForm');
	var sub_element = element.children('span');
	if( sub_element.length > 0 ){
		sub_element.toggle();
	}else{
		getQuestion('webmailLoginForm', function(data){
			$('#helpLoginForm').append('<span>' + data[0].answer + '</span>');	
		});
	}
});
*/
});

function showPros () {
    $('#main-content, #mail-changes-all').hide();
    $('#mail-pros-all').show();
    document.body.scrollTop = 0 ;
} 

function showChanges () {
    $.ajax({
      url: WEBMAIL_PATH+"ajax-changelog.html",
      cache: true,
      success: function(html){
		if (html) {
			$('#main-content, #mail-pros-all').hide();
			$("#mail-changes-all").empty().append(html).show();
			$('#changes-more-pros').click(function(){
				showPros() ;
				return false;
			}) ; 
			$(".log-more-content").quickPager({pageSize:5});    
		}
      }
    }) ;
}



