var CALENDAR_TIMER;
var CALENDAR_TIMEOUT_MS = 2000;

function calendarHide()
{
    $("#calendar").slideUp('slow', function () {$("#calendar-button").fadeIn();});
}

function goTop()
{
    $('html, body').animate({scrollTop: $("#top-bar").offset().top}, 1000);
}


function isValidEmailAddress(emailAddress)
{
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

// -----------------------------------------------------------------------------


$(document).ready(function () {

    // left menu last element hover effect
    if ($("#page-left-menu ul li").size()!=0) {
        if ($("#page-left-menu ul li a:last").hasClass('active'))
            $("#page-left-menu-last").addClass('active-strong');

        $("#page-left-menu ul li:last a").hover(
            function () { $('#page-left-menu-last').addClass('active'); },
            function () { $('#page-left-menu-last').removeClass('active'); }
        );
    }

    // ---- calendar
    $("#calendar-button").click(function () {
        $(this).hide();
        $("#calendar").slideDown();
        //CALENDAR_TIMER = setTimeout('calendarHide()', CALENDAR_TIMEOUT_MS);
    });

//    $("#calendar").mousemove(function () {
//        clearTimeout(CALENDAR_TIMER);
//    });
//
//    $("#calendar").mouseout(function () {
//        CALENDAR_TIMER = setTimeout('calendarHide()', CALENDAR_TIMEOUT_MS);
//    });
    // ---- calendar END


    // fancy box gallery
    /*
    $("a.g-fancybox").fancybox({
      'transitionIn'    : 'elastic',
      'transitionOut'   : 'elastic',
      'speedIn'         : 600,
      'speedOut'        : 200,
      'overlayShow'     : true,
      'titleShow'       : false
    });
    */
    

	$("#page-right-content a").has('img').fancybox();

});

function goToAsk() {
	
	$("#ask-question-button").click();
	var x = $('#ask-question-button').offset().top - 100;
	$('html, body').animate({
		scrollTop: x
		}, 1000);
}
