jQuery(document).ready(function($){
    $('#features').cycle({
        timeout: 4000,
        speed: 1000,
        pause:true,
        fx: 'scrollHorz',
        next:'#featuresNext',
        prev:'#featuresPrev',
        pager:'#nav',
        easing:'easeInOutExpo',
        // callback fn that creates a thumbnail to use as pager anchor
        pagerAnchorBuilder: function(idx, slide) {
            return '<a href="#" class="pager-'+(idx+1)+'"><span>'+(idx+1)+'</span></a>';
        }
    });


    $('#subForm').validate();
    $('#subForm2').validate();

    $("a.small").click(function(){
          $("body").css('font-size','100%');
          $.ajax({ url: "/_assets/set-persistent-fontsize.php", data: {font_size: 100} });
          return false;
      });
    $("a.medium").click(function(){
        $("body").css('font-size','110%');
        $.ajax({ url: "/_assets/set-persistent-fontsize.php", data: {font_size: 110} });
        return false;
    });
    $("a.large").click(function(){
        $("body").css('font-size','122%');
        $.ajax({ url: "/_assets/set-persistent-fontsize.php", data: {font_size: 122} });
        return false;
    });

    $("a.text-only").click(function(){
        $.ajax({ 
            url: "/_assets/set-text-only.php" ,
            success:function(){
                window.location.href=window.location.href;
            }
        });
        return false;
        //window.location.href=window.location.href;
    });

    $("a.apply-now").click(function(){
        var form = $(this).parent().parent().find("form");        
        form.toggle();
        if(form.css('display')=='block'){
            $(this).html('<strong>Hide form</strong>');
        }else{
            $(this).html('<strong>Interested in the role? Apply now</strong>');
        }
        return false;
    });



});

function processJson(data) {
        // 'data' is the json object returned from the server
        //alert('GARRR');
        jQuery("#message-"+data.post_id).html(data.message);
        if(data.success == 1){
        //    alert('SUCCESS');
            jQuery("#message-"+data.post_id).addClass('success');
            jQuery("#message-"+data.post_id).removeClass('fail');
        }else{
        //    alert('FAIL');
            jQuery("#message-"+data.post_id).removeClass('success');
            jQuery("#message-"+data.post_id).addClass('fail');
        }

    }
