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

$(document).ready(function(){  
  
  //nav
  $(".nav").appendTo("#mymenu"); 
  $(".navbar.main-nav:first").remove();
  $("#logo:first").remove(); 

  //booking link
  var navlinks = $('.nav li a');
  $(navlinks[navlinks.length - 1]).removeClass('last');
  $('.nav').append('<li><a class="border menu_link_' + (navlinks.length + 1) + ' last" href="https://www.thebookingbutton.com.au/properties/leichhardtaccodirect" target="_blank">Book Now</a></li>');

  //header
  $("#myheader").prependTo(".container-fluid:first"); 
  
  //favicon
  $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href="http://cdn.myld.com.au/2/358/leichhardt-accommodation_d353d6d4e7.ico" />').appendTo('head'); 
  $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href="http://cdn.myld.com.au/2/358/leichhardt-accommodation_99cc010651.png" />').appendTo('head');
  
  
  //404
  $("#page-not-found div#error").wrap("<div class='container-fluid'>").wrap("<div class='row-fluid'>");
  $("#error").insertAfter("#myheader");
  
  //********Windows IE8 and below popup*********//   		     		
	$("body").browserDetect( {     	
		name: "Leichhardt Accommodation",     
		logo: "http://cdn.myld.com.au/2/358/leichhardt-accommodation_71a66c8dec.png",      
		phone: "07 4743 3323",     //optional
		fax: "07 4743 3327",      //optional
		email: "admin@leichhardtaccommodation.com",      //optional
		address: "3-5 Camooweal Street Mount Isa QLD 4825",  //optional	
		ldprofile: "http://www.localdirectories.com.au/Mount-Isa,QLD/Leichhardt-Accommodation/profile/3pJ5"  
	});  

	 //my img animation function
   animateImg();
   
   (function() {
      setTimeout(function(){
          $('html, body').animate({
              scrollTop: $("footer").offset().top
          }, 2000);
          setTimeout(function(){
              $('html, body').animate({
                  scrollTop: $("body").offset().top
              }, 1000);
      
          },2000);      
      }, 500);
   })();
	
});//end of doc ready
$(function(){

   $('body').css('position','relative');
   $('body').append('<div id="toTop" class="" style="display: block; position: fixed; right: 20px; top: 100px;z-index:2; "><img src="http://cdn.myld.com.au/2/395/leichhardt-accommodation_8c2545136a.png"></div>');
     
var scrollBottom = $(window).scrollTop() + $(window).height();
if(!(/Android|webOS|iPhone|iPad|iPod|IEMobile|Opera Mini|BlackBerry/i.test(navigator.userAgent)) ) {
    $(window).scroll(function(){
        if ($(this).scrollTop() < 600) {
            $('#toTop').fadeIn();
        } else{
            $('#toTop').fadeOut();
        }
    });
    $('#toTop').click(function(){
        $('body,html').animate({
            scrollTop:scrollBottom
        }, 600);
    });
}
});

  
function animateImg(){
   
    var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
        if (!agentID) {
            $(".bounce").addClass("animated bounceInDown");
            $(".slideFromLeft").addClass("animated fadeInLeftBig");  
        }
        //adding padding to the map on the contact page only for idevices
        if(agentID){
          $("#contact-us .container-fluid").css({"padding-left":"20px", "padding-right": "20px"});
          //putting the images on the about page below the text for display purposes only
          $("#aboutImages").insertAfter("#aboutContent");
        }
  }
  
