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

// Custom JavaScript Document
$(window).load(function() {
  $('.flash_success').text('Thank you, one of our staff will respond to your enquiry at the first opportunity');

 $('#nav .nav > li').eq(1).addClass('dropdown').append('<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">'+
      '<li><a href="denture-repairs">Denture Repairs</a></li>'+
    '</ul>').children('a').addClass('dropdown-toggle').append('<b class="caret"></b>');
  $('#nav .nav > li').eq(3).remove();

  if ($('body#denture-repairs').is('*')) {
    $('#nav .nav > li').eq(2).addClass('active');
  };
});

$(document).ready(function() {
  $('.match').matchHeight();
    //START SPEEDLOADERJS//

    //MOVE
    $('#slider').prependTo('body');
    $('header').prependTo('body');

    //INJECT NAV
    $('.navbar').prependTo('.navbarcontainer');

    //WRAPPER
    //$('body').children().not('.scripts').wrapAll('<div id="wrapper" class="container-fluid" />');

    //REMOVE
    $('.default_header').remove();
    $('.default_footer').remove();

    //FAVICON
    /*$('<link id="favicon" type="image/x-icon" rel="shortcut icon" href="http://cdn.myld.com.au/2/528/smith-street-dental-practice_2f85b4ce3e.png" />').appendTo('head');
    $('<link rel="shortcut icon" href="http://cdn.myld.com.au/2/529/smith-street-dental-practice_17243f693a.ico" type="image/x-icon" />').appendTo('head');
    $('<link rel="icon" href="http://cdn.myld.com.au/2/529/smith-street-dental-practice_17243f693a.ico" type="image/x-icon" />').appendTo('head');*/
    
    $('head').append('<link rel="shortcut icon" type="image/x-icon" href="http://cdn.myld.com.au/2/529/smith-street-dental-practice_17243f693a.ico">');

    $('body#contact-us #slider').remove();

    //404
    $("#page-not-found div#error").wrap("<div class='container'>").wrap("<div class='row-fluid'>").wrap("<div class='span12'>");

    //END SPEEDLOADERJS//

    //********Windows IE8 and below popup*********//                      
    $("body").browserDetect({
        name: "Smith Street Dental Practice",
        logo: "http://cdn.myld.com.au/2/528/smith-street-dental-practice_4a70e9b439.png",
        phone: "08 8981 9149", //optional
        fax: "08 8981 5646", //optional
        email: "reception@smithstreetdental.com", //optional
        address: "111 Smith Street, Darwin NT 0800", //optional    
        ldprofile: "http://www.localdirectories.com.au/Port-Stephens-Area,NSW/Adept-Pools/profile/titT"
    });

    //********Mobile Telephone*********//  
    mobileTel(0889819149); //edit phone number

    //Favicon
    $('<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />').appendTo('head');


    jQuery('.camera_wrap').camera({
        loader: 'none',
        navigation: false,
        playPause: false,
        pagination: false,
        minHeight: 290,
    });

    jQuery('.camera_wrap').cameraStop();

    // $('#slideshow').bjqs({
    //     randomstart: false,
    //     height: 290,
    //     showcontrols: false,
    //     showmarkers: false
    // });

    // Contact Map

    function map() {
        var myLatlng = new google.maps.LatLng(-12.45730, 130.83488);
        var mapOptions = {
            zoom: 14,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            scrollwheel: false
        }

        if ($('#map').length > 0) {
            var map = new google.maps.Map(document.getElementById('map'), mapOptions);
            var image = 'http://cdn.myld.com.au/2/528/smith-street-dental-practice_6ea3f865bf.png';
            var marker = new google.maps.Marker({
                position: myLatlng,
                map: map,
                icon: image
            });

            google.maps.event.addDomListener(window, 'resize orientationchange', function() {
                map.setCenter(myLatlng);
            });
        }
    }

    google.maps.event.addDomListener(window, 'load', map);

    $('#custom_form').formValidation({
        validateText: ["name", "enquiry", "phone"],
        validateEmail: ["email"],
        validateSpam: true
    });



});