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

$(document).ready(function(){

    //Page Layout

      //Header (Move Header into place)
      $('header').prependTo('body');
      
      //Navigation (Move Bootstrap Navigation into place)
      $('.nav').prependTo('.pull-right');
      if($().mobileMenu) {
        $('#navigation').each(function(){
          $(this).mobileMenu();
        });
      } 
  
      //Wrappers (Wrap containing elements)
      $('body').wrapInner('<section id="body" />');
      $('#body').wrapInner('<div class="container wrapper" />');
      //$('#body').children().not('header, footer').wrapAll('<div class="container" />');
  
      //Removes (Remove Default Bootstrap elements)
      $('.default_header').remove();
      $('.default_footer').remove();
    
      //LD Footer (Add LD footer)
      $('#ldfooter').appendTo('footer');
  

  $('#slider').prependTo('.wrapper');
  
  $('#header').prependTo('.wrapper');
  $('div.phone a').removeClass('vella-logo');
  $('.mpaq').insertAfter('.wrapper');
  //Page Includes
  
    //Favicon
    $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href="http://cdn.myld.com.au/2/178/vella-chris-plumbing-and-gasfitting_095a19a285.png" />').appendTo('head');
    
    //CSS
  
      
      //Social Media
      $('<link href="http://cdn.myld.com.au/1/css/socialmedia.css" rel="stylesheet" />').appendTo('head');
      
      //Font Awesome
      //$('<link href="http://cdn.myld.com.au/1/css/bootstrap/plugins/font-awesome.css" rel="stylesheet" />').appendTo('head');
    
    //Bootstrap Responsive CSS (For template "Edge")
	  //$('<link href="http://cdn.myld.com.au/1/bootstrap/edge/css/edge-responsive.css" rel="stylesheet" />').appendTo('head');
	  
	  //Fancybox
	  $('<link href="http://cdn.myld.com.au/1/fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" />').appendTo('head');
    
  //Page Scripts
  
  
    //404 Page
    $("#page-not-found div#error").wrap("<div class='container'>").wrap("<div class='row-fluid'>").wrap("<div class='span12'>");
	
	//Load Bootstrap JS
	/*var bootstrap = document.createElement('script');
	bootstrap.type = "text/javascript";
	bootstrap.src = 'http://cdn.myld.com.au/1/js/bootstrap/2.2.1/bootstrap.js';
	document.body.appendChild(bootstrap);*/
  
   $(window).load(function() {
        // The slider being synced must be initialized first
        $('#carousel').flexslider({
          animation: "slide",
          controlNav: false,
          directionNav: true,
          animationLoop: false,
          slideshow: false,
          itemWidth: 100,
          itemMargin: 62,
          asNavFor: '#slider'
        });

        $('#slider').flexslider({
          animation: "slide",
          controlNav: false,
          directionNav: false,
          animationLoop: false,
          slideshow: true,
          sync: "#carousel"
        });
      });
      
      $('#custom_form').formValidation({
                        validateText: ["name", "enquiry"],
                        validateEmail: ["email"],
                        validateSpam: true
                    });
    
});  

$(document).ready(function(){ 
    $.backstretch("http://cdn.myld.com.au/2/232/vella-chris-plumbing-and-gasfitting_0c1f28e90a.jpg");
});