$(document).ready(function () {

    $.preloadCssImages();
    $("#homei, #abouti, #contacti, #corpi, #cani, #searchi, .menu").css({ "visibility": "hidden" });
    QueryLoader.init();

    $('.home').click(
					function (e) {
					    $('html, body').animate({ scrollLeft: '0px' }, { duration: 3000, easing: 'easeInOutQuint' });
					}
				);

    $('.about').click(
					function (e) {
					    $('html, body').animate({ scrollLeft: '2560px' }, { duration: 3000, easing: 'easeInOutQuint' });
					}
				);

    $('.corp').click(
					function (e) {
					    $('html, body').animate({ scrollLeft: '5120px' }, { duration: 3000, easing: 'easeInOutQuint' });
					}
				);

    $('.search').click(
          function (e) {
              $('html, body').animate({ scrollLeft: '7680px' }, { duration: 3000, easing: 'easeInOutQuint' });
          }
        );


    $('.can').click(
					function (e) {
					    $('html, body').animate({ scrollLeft: '10240px' }, { duration: 3000, easing: 'easeInOutQuint' });
					}
				);

    $('.contact').click(
					function (e) {
					    $('html, body').animate({ scrollLeft: '12800px' }, { duration: 3000, easing: 'easeInOutQuint' });
					}
				);

    //Jobs
    $('.left_content .button').click(function () {
        $.blockUI({ message: $('#job_pop'), css: { width: '680px', padding: '10px', top: '20px'} });
        $("div.hj-content").jScrollPane();

    });

    $('#exit').click(function () {
        $.unblockUI();
        return false;
    });


    //adds sharkfin class
    $('.menu a').click(function () {
        $('.menu a').removeClass('highlight');
        $(this).addClass('highlight');
    });


    //Adds class to current selection onload
    var pound = window.location.href.slice(window.location.href.indexOf('#'));

    if (pound == '/') {
        $('.home').addClass("highlight");
    }

    if (pound == '#home') {
        $('.home').addClass("highlight");
    }

    else if (pound == '#about-us') {
        $('.about').addClass("highlight");
        $('.about').click();
    }

    else if (pound == '#corporate-assistance') {
        $('.corp').addClass("highlight");
        $('.corp').click();
    }

    else if (pound == '#recruiter-profile') {
        $('.can').addClass("highlight");
        $('.can').click();
    }

    else if (pound == '#search-jobs') {
        $('.search').addClass("highlight");
        $('.search').click();
    }

    else if (pound == '#contact-us') {
        $('.contact').addClass("highlight");
        $('.contact').click();
    }

    var jid = window.location.href.slice(window.location.href.indexOf('?'));

    if (jid.length > 4) {
        var newjid = jid.substring(5);

        var url = "http://services.skyfirmjobs.net/testapp/default.aspx?d=1004&jid=";
        window.frames["jobPortal"].location.href = url + newjid;
        $('.search').click();
    }

    //Scroll Planes
    $('.links').jScrollPane();
    $('.feed').jScrollPane();

    //Bio Section
    $("div.people a:last").css({ "border-right": "none" });
    $("div.people a:first").addClass('highlight');
    $("#bio-wrapper > div").not(":first").hide();


    $("div.people a").click(function () {

        $("div.people a").removeClass('highlight');
        $(this).addClass('highlight');
        var idToLoad = $(this).attr("id").split('-');
        $("#bio-wrapper").find("div:visible").fadeOut("fast", function () {
            $(this).parent().find("#" + idToLoad[0]).fadeIn();
            $("#" + idToLoad[0]).children().fadeIn();
            $('.right_content').jScrollPane();
            $("#" + idToLoad[0] + " div").show();
            $("#" + idToLoad[0] + " .links").jScrollPane();
            $("#" + idToLoad[0] + " .feed").jScrollPane();


        });

    });



    //Keeps every thing center
    var w = $(window).width() / 2;
    var h = $(window).height() / 2;
    var nav = w - 440;
    $("div.menu").css({ 'padding-left': nav });

    var logo = w + 210;
    $("div.logo").css({ 'margin-left': logo });

    var copy = w - 150;
    $("div#copyright").css({ 'padding-left': copy });

    var content = w - 440;
    $("div.content-wrapper").css({ 'margin-left': content });

    var info = w - 430;
    $("div.info").css({ 'margin-left': info });

    var jobs = w - 350;
    $.blockUI.defaults.css.left = jobs;

    var whitebg = h + 160;
    var topinfo = h + 190;
    $("#homei, #abouti, #contacti, #corpi, #cani, #searchi").css({ 'height': whitebg });

    $("div.info-wrapper").css({ "top": topinfo });

    var rightH = h - 60;

    $(".right_content").css({ "height": rightH });
    $("div.content-wrapper").css({ 'height': rightH +120 });

    var portalH = h;

    if (w <= 720) {
        var portalW = w + 600;
        var portalL = -$(window).width() / 6 + 60;
    } else if (w > 720 && w < 1400) {
        var portalW = w + 500;
        var portalL = -$(window).width() / 5 + 60;
    } else {
        var portalW = w + 700;
        var portalL = -$(window).width() / 4;
    }


    $("#jobPortal").css({ "height": portalH });
    $("#jobPortal").css({ "width": portalW });
    $("#jobPortal").css({ "margin-left": portalL });

    var job_popupH = h;
    $("#job_pop").css({ "height": job_popupH });
    $("div.hj-content").css({ "height": job_popupH - 100 });

    $(window).resize(function () {
        var w = $(window).width() / 2;
        var h = $(window).height() / 2;

        var nav = w - 440;
        $("div.menu").css({ 'padding-left': nav });

        var logo = w + 210;
        $("div.logo").css({ 'margin-left': logo });

        var copy = w - 150;
        $("div#copyright").css({ 'padding-left': copy });

        var content = w - 440;
        $("div.content-wrapper").css({ 'margin-left': content });

        var info = w - 430;
        $("div.info").css({ 'margin-left': info });

        var jobs = w - 350;
        $.blockUI.defaults.css.left = jobs;

        var whitebg = h + 260;
        var topinfo = h + 290;
        $("#homei, #abouti, #contacti, #corpi, #cani, #searchi").css({ 'height': whitebg });

        $("div.info-wrapper").css({ "top": topinfo });

        var portalH = h;
        if (w <= 720) {
            var portalW = w + 600;
            var portalL = -$(window).width() / 6 + 60;
        } else if (w > 720 && w < 1400) {
            var portalW = w + 500;
            var portalL = -$(window).width() / 5 + 60;
        } else {
            var portalW = w + 700;
            var portalL = -$(window).width() / 4;
        }

        $("#jobPortal").css({ "height": portalH });
        $("#jobPortal").css({ "width": portalW });
        $("#jobPortal").css({ "margin-left": portalL });


        var rightH = h + 100;

        $(".right_content").css({ "height": rightH });

        $('.right_content').jScrollPane();
    });

    $('.right_content').jScrollPane();



    //fixees dotted random border
    $("a").bind("focus", function () {
        if (this.blur) this.blur();
    });

    $(".jScrollPaneContainer").bind("focus", function () {
        if (this.blur) this.blur();
    });

    $("#exit").bind("focus", function () {
        if (this.blur) this.blur();
    });


    //Iframe redirects

    $("a.recjobID").click(function () {
        var title = $(this).attr("title");
        var url = "http://services.skyfirmjobs.net/testapp/default.aspx?d=1004&jid=";
        window.frames["jobPortal"].location.href = url + title;
        $('.search').click();

    });

    $("a.by-jobID").click(function () {
        var title = $(this).attr("title");
        var url = "http://services.skyfirmjobs.net/testapp/default.aspx?d=1004&jid=";
        window.frames["jobPortal"].location.href = url + title;
        $('.search').click();
        $.unblockUI();

    });

    $("a.by-type").click(function () {
        var url = "http://services.skyfirmjobs.net/testapp/default.aspx?d=1004&f=by-type";
        window.frames["jobPortal"].location.href = url;
        $('.search').click();
        $.unblockUI();
    });

    $("a.by-region").click(function () {
        var url = "http://services.skyfirmjobs.net/testapp/default.aspx?d=1004&f=by-region";
        window.frames["jobPortal"].location.href = url;
        $('.search').click();
        $.unblockUI();
    });

    $("a.by-experience").click(function () {
        var url = "http://services.skyfirmjobs.net/testapp/default.aspx?d=1004&f=by-experience";
        window.frames["jobPortal"].location.href = url;
        $('.search').click();
        $.unblockUI();
    });

    $("a.view_page").click(function () {
        var title = $(this).attr("title");
        var url = "http://services.skyfirmjobs.net/testapp/default.aspx?d=1004&r=";
        window.frames["jobPortal"].location.href = url + title;
        $('.search').click();

    });



    ///////////// Fix Chrome /////////////

    var chrome = /chrome/.test(navigator.userAgent.toLowerCase());

    if (chrome) {

        //Home
        $('.home').click(
              function (e) {
                  $('.menu a').hide();
                  $('.info-wrapper .info').hide();
                  $('.logo').hide();
                  $('#copyright').css({ "color": "#000" });

                  setTimeout(function () {
                      $('.menu a').show();
                      $('.info-wrapper .info').show();
                      $('.logo').show();
                      $('#copyright').css({ "color": "#fff" });
                  }, 3000);

                  var pound = window.location.href.slice(window.location.href.indexOf('#'));
                  if (pound == '#home') {
                      $('.menu a').hide();
                      $('.info-wrapper .info').hide();
                      $('.logo').hide();

                      setTimeout(function () {
                          $('.menu a').show();
                          $('.info-wrapper .info').show();
                          $('.logo').show();
                      }, 1);
                  } //end if home

              }
            ); //end home click


        //About
        $('.about').click(
              function (e) {
                  $('.menu a').hide();
                  $('.info-wrapper .info').hide();
                  $('.logo').hide();
                  $('#copyright').css({ "color": "#000" });

                  setTimeout(function () {
                      $('.menu a').show();
                      $('.info-wrapper .info').show();
                      $('.logo').show();
                      $('#copyright').css({ "color": "#fff" });
                  }, 3000);

                  var pound = window.location.href.slice(window.location.href.indexOf('#'));
                  if (pound == '#about-us') {
                      $('.menu a').hide();
                      $('.info-wrapper .info').hide();
                      $('.logo').hide();

                      setTimeout(function () {
                          $('.menu a').show();
                          $('.info-wrapper .info').show();
                          $('.logo').show();
                      }, 1);
                  } //end if about us

              }
            ); //end about click


        //corp
        $('.corp').click(
              function (e) {
                  $('.menu a').hide();
                  $('.info-wrapper .info').hide();
                  $('.logo').hide();
                  $('#copyright').css({ "color": "#000" });

                  setTimeout(function () {
                      $('.menu a').show();
                      $('.info-wrapper .info').show();
                      $('.logo').show();
                      $('#copyright').css({ "color": "#fff" });
                  }, 3000);

                  var pound = window.location.href.slice(window.location.href.indexOf('#'));
                  if (pound == '#corporate-assistance') {
                      $('.menu a').hide();
                      $('.info-wrapper .info').hide();
                      $('.logo').hide();

                      setTimeout(function () {
                          $('.menu a').show();
                          $('.info-wrapper .info').show();
                          $('.logo').show();
                      }, 1);
                  } //end if corp us

              }
            ); //end corp click            


        //can
        $('.can').click(
              function (e) {
                  $('.menu a').hide();
                  $('.info-wrapper .info').hide();
                  $('.logo').hide();
                  $('#copyright').css({ "color": "#000" });

                  setTimeout(function () {
                      $('.menu a').show();
                      $('.info-wrapper .info').show();
                      $('.logo').show();
                      $('#copyright').css({ "color": "#fff" });
                  }, 3000);

                  var pound = window.location.href.slice(window.location.href.indexOf('#'));
                  if (pound == '#recruiter-profile') {
                      $('.menu a').hide();
                      $('.info-wrapper .info').hide();
                      $('.logo').hide();

                      setTimeout(function () {
                          $('.menu a').show();
                          $('.info-wrapper .info').show();
                          $('.logo').show();
                      }, 1);
                  } //end if can us

              }
            ); //end can click

        //search
        $('.search').click(
              function (e) {
                  $('.menu a').hide();
                  $('.info-wrapper .info').hide();
                  $('.logo').hide();
                  $('#copyright').css({ "color": "#000" });

                  setTimeout(function () {
                      $('.menu a').show();
                      $('.info-wrapper .info').show();
                      $('.logo').show();
                      $('#copyright').css({ "color": "#fff" });
                  }, 3000);

                  var pound = window.location.href.slice(window.location.href.indexOf('#'));
                  if (pound == '#search-jobs') {
                      $('.menu a').hide();
                      $('.info-wrapper .info').hide();
                      $('.logo').hide();

                      setTimeout(function () {
                          $('.menu a').show();
                          $('.info-wrapper .info').show();
                          $('.logo').show();
                      }, 1);
                  } //end if search us

              }
            ); //end search click                


        //Contact
        $('.contact').click(
              function (e) {
                  $('.menu a').hide();
                  $('.info-wrapper .info').hide();
                  $('.logo').hide();
                  $('#copyright').css({ "color": "#000" });

                  setTimeout(function () {
                      $('.menu a').show();
                      $('.info-wrapper .info').show();
                      $('.logo').show();
                      $('#copyright').css({ "color": "#fff" });
                  }, 3000);

                  var pound = window.location.href.slice(window.location.href.indexOf('#'));
                  if (pound == '#contact-us') {
                      $('.menu a').hide();
                      $('.info-wrapper .info').hide();
                      $('.logo').hide();

                      setTimeout(function () {
                          $('.menu a').show();
                          $('.info-wrapper .info').show();
                          $('.logo').show();
                      }, 1);
                  } //end if contact

              }
            ); //end contact click


        var pound = window.location.href.slice(window.location.href.indexOf('#'));

        if (pound == '/') {
            $('.menu a').hide();
            $('.info-wrapper .info').hide();
            $('.logo').hide();

            setTimeout(function () {
                $('.menu a').show();
                $('.info-wrapper .info').show();
                $('.logo').show();
            }, 1);
        }

        if (pound == '#home') {
            $('.menu a').hide();
            $('.info-wrapper .info').hide();
            $('.logo').hide();

            setTimeout(function () {
                $('.menu a').show();
                $('.info-wrapper .info').show();
                $('.logo').show();
            }, 1);
        }

        else if (pound == '#about-us') {
            $('.menu a').hide();
            $('.info-wrapper .info').hide();
            $('.logo').hide();

            setTimeout(function () {
                $('.menu a').show();
                $('.info-wrapper .info').show();
                $('.logo').show();
            }, 3000);
        }

        else if (pound == '#corporate-assistance') {
            $('.menu a').hide();
            $('.info-wrapper .info').hide();
            $('.logo').hide();
            setTimeout(function () {
                $('.menu a').show();
                $('.info-wrapper .info').show();
                $('.logo').show();
            }, 3000);
        }

        else if (pound == '#recruiter-profile') {
            $('.menu a').hide();
            $('.info-wrapper .info').hide();
            $('.logo').hide();
            setTimeout(function () {
                $('.menu a').show();
                $('.info-wrapper .info').show();
                $('.logo').show();
            }, 3000);
        }

        else if (pound == '#search-jobs') {
            $('.menu a').hide();
            $('.info-wrapper .info').hide();
            $('.logo').hide();

            setTimeout(function () {
                $('.menu a').show();
                $('.info-wrapper .info').show();
                $('.logo').show();
            }, 3000);
        }

        else if (pound == '#contact-us') {
            $('.menu a').hide();
            $('.info-wrapper .info').hide();
            $('.logo').hide();

            setTimeout(function () {
                $('.menu a').show();
                $('.info-wrapper .info').show();
                $('.logo').show();
            }, 3000);
        }

        else if (pound == '#contact-us') {
            $('.menu a').hide();
            $('.info-wrapper .info').hide();
            $('.logo').hide();
            setTimeout(function () {
                $('.menu a').show();
                $('.info-wrapper .info').show();
                $('.logo').show();
            }, 3000);
        } //contact link




    } ///////////// End Chrome /////////////


    //End Global Function
});


function ClearForm(name){ 
  if($("#"+name).attr("value") =='Full Name' ){
    $("#"+name).attr({ value: '' });
   }
   else if($("#"+name).attr("value") =='Email Address' ){
    $("#"+name).attr({ value: '' });
   }
   
   else if($("#"+name).val() =='Message' ){
     $("#"+name).val('');
   }
}

//Cufon.replace('h1', { fontFamily: 'Bebas' });
Cufon.replace('h2', { fontFamily: 'Bebas' });

