/***********************
*  Site Specific JS   *
************************/

$(document).ready(function() {
    // Mobile Nav

    //MOBILE NAVIGATION
    if ($().mobileMenu) {
        $('ul.nav').each(function() {
            $(this).mobileMenu();
        });
    }
    /* header */
    $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href="http://cdn.myld.com.au/2/146/maranco-earthmoving_31ba00c211.png" />').appendTo('head');
    $(".myheader").prependTo("body");
    $(".nav  ").appendTo("#menu");

    // dom manipulating
    $('.nav-collapse_ .nav ul').remove();
    $('#social').remove();

    //unkown page
    $("#page-not-found div#error").wrap("<div class='container'>").wrap("<div class='row-fluid'>").wrap("<div class='span12'>");
  
      //function calls
      //applefix(); This was breaking the from validation
      moverimg();
      moverimg2();
      moverimg3();
      moverimg4();
      unkownpage();
      detectIE();

    
}); //end of doc ready

function unkownpage() {
    var errorpage = $("#page-not-found").length;
    if (errorpage > 0) {
        $("#myslider").remove();
    }
}



function detectIE() {
    if ($.browser.msie) {
        var contactpage = $("#contact").length;
        var ua = parseInt(jQuery.browser.version.substring(0, 2));

        if (ua < 9) {
            $("#myslider").remove();
            if (contactpage === 0) {
                $("<div style='background:#efefef;'><div class='container'><div class='flexslider' style='margin-top: 40px;'> <ul class='slides'> <li><img src='http://cdn.myld.com.au/2/250/maranco-earthmoving_0e44fb7316.png' /></li><li><img src='http://cdn.myld.com.au/2/250/maranco-earthmoving_0e44fb7316.png' /></li><li><img src='http://cdn.myld.com.au/2/250/maranco-earthmoving_0e44fb7316.png' /></li></ul></div></div></div").insertAfter(".myheader");
                $('.flexslider').flexslider();
            }

            $(".navbar-inner").css("filter", "alpha(opacity=100)");
            $(".nav li:nth-child(5) a ").text("HIRE");
        }

        if (ua < 10) {
            if (ua > 8) {
                $(".navbar-inner").css("filter", "alpha(opacity=100)");
            }

        }

    }
}

function moverimg() {
    $('#serv0').mouseover(function() {
        $("#serv0 > .serva > div > h2").css("color", "#ed1c24");
    }).mouseout(function() {
        $("#serv0 > .serva > div > h2").css("color", "#fff");
    });
}

function moverimg2() {
    $('#serv1').mouseover(function() {
        $("#serv1 > .serva > div > h2").css("color", "#ed1c24");
    }).mouseout(function() {
        $("#serv1 > .serva > div > h2").css("color", "#fff");
    });
}

function moverimg3() {
    $('#serv2').mouseover(function() {
        $("#serv2 > .serva > div > h2").css("color", "#ed1c24");
    }).mouseout(function() {
        $("#serv2 > .serva > div > h2").css("color", "#fff");
    });
}

function moverimg4() {
    $('#serv3').mouseover(function() {
        $("#serv3 > .serva > div > h2").css("color", "#ed1c24");
    }).mouseout(function() {
        $("#serv3 > .serva > div > h2").css("color", "#fff");
    });
}

