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

$(document).ready(function(){  
  
  //nav
  $(".nav").appendTo("#mymenu"); 
  $(".navbar.main-nav:first").remove(); 
  $("#logo:first").remove(); 
  
  //header
  $("#myheader").prependTo("body");
  var homepage = $("#home").length;
  if(homepage == 0){
    $(".inner-intro").remove(); 
  }
  
  
  //favicon
  $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href="http://cdn.myld.com.au/2/341/sea-breeze-marine_8ec75171e0.ico " />').appendTo('head');
  $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href="http://cdn.myld.com.au/2/296/sea-breeze-marine_b00cdbcf1b.png  " />').appendTo('head');
  
  
  //slider
  $('.carousel').carousel({ pause: "false", interval:5000 });  
    //randomise slides
  $(".item").removeClass("active"); 
  $('.item').eq(Math.floor((Math.random() * $('.item').length))).addClass("active");
  
  //404 page
  $("#page-not-found div#error").wrap("<div class='container'>").wrap("<div class='row-fluid'>").wrap("<div class='span12'>"); 

  //********Windows IE8 and below popup*********//   		     		
	$("body").browserDetect( {     	
		name: "Sea Breeze Marine",     
		logo: "http://cdn.myld.com.au/2/341/sea-breeze-marine_f4b93f8a9b.png",      
		phone: "(07) 4933 6366",     //optional
		fax: "(07) 4933 7590",      //optional
		email: "info@seabreezemarine.com.au",      //optional
		address: "150 Scenic Hwy Lammermoor Qld 4703",  //optional	
		ldprofile: "http://www.localdirectories.com.au/Rockhampton-Area,QLD/Sea-Breeze-Marine/profile/bTdu"  
	});  

  //function calls 
	
  iphone();
  ipad();
});//end of doc ready


function ipad(){
    var deviceAgent = navigator.userAgent.toLowerCase();
            var agentID = deviceAgent.match(/(ipad)/);  //if ipad
            if(agentID){
                //portrait on load
                if ( orientation == 0 || orientation == 180 || orientation == -180) {
                  $("#map-canvas-main").css("margin-top","40px");
                }

                //landscape on load
                if ( orientation == 90 || orientation == 270 || orientation == -90 || orientation == -270) {
                  $("#map-canvas-main").css("margin-top","0px");
                 }

                //if orientation changes
                $(window).bind('orientationchange', function(event) {
                    //landscape
                    if (orientation == 90 || orientation == 270 || orientation == -90 || orientation == -270 ) {
                         $("#map-canvas-main").css("margin-top","0px");
                    }
                    //portrait
                    if ( orientation == 0 || orientation == 180 || orientation == -180) {
                         $("#map-canvas-main").css("margin-top","40px"); 
                     }
                });
}
}

function iphone(){
  var deviceAgent = navigator.userAgent.toLowerCase();
            var iphone = deviceAgent.match(/(iphone)/);  //if iphone
            if(iphone){
             $("#map-canvas-main").remove();
                    //portrait
                    //if orientation changes
                $(window).bind('orientationchange', function(event) {
                    if ( orientation == 0 || orientation == 180 || orientation == -180) {
                       
                        var contactPage = $("#contact-us").length;
                        if(contactPage > 0){
                          location.reload(); 
                        }
                     }
                });  
  
  } 
}







