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

$(document).ready(function(){  
  //nav
  $(".nav").appendTo("#mymenu");
  $(".navbar.main-nav:first").remove();
  $("#logo:first").remove(); 
  

 
  
  //header
  $("#myheader").prependTo("body"); 
  
  //favicon
  $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href=" http://cdn.myld.com.au/2/342/complete-fencing_556b24e8f8.ico" />').appendTo('head');
  $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href=" http://cdn.myld.com.au/2/215/complete-fencing_b2968b148a.png" />').appendTo('head');
  
  //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: "Complete Fencing",     
		logo: "http://cdn.myld.com.au/2/658/web_complete-fencing_95c4a4fdb7.JPG",      
		phone: "08 8953 8427",     //optional
		fax: "08 8953 0861",      //optional
		email: "complete.fencing@bigpond.com",      //optional
		address: "31 Wilkinson Street, Alice Springs, NT 0870",  //optional	
		ldprofile: "http://www.localdirectories.com.au/Alice-Springs-Area,NT/Complete-Fencing/profile/DuDb"  
	});  
   
  
  if(Modernizr.touch && $(".fancybox").length > 0 )
  { 
     var myPhotoSwipe = $(".fancybox").photoSwipe({ enableMouseWheel: false , enableKeyboard: false });
  }
  else
  {
      /* Apply to single image */
      $("a.fancybox").fancybox();
  
     /* Apply fancybox to multiple items */
      $("a.fancybox[rel='gallery_group']").fancybox({
          'transitionIn'    :    'elastic',
          'transitionOut'    :    'elastic',
          'speedIn'        :    600, 
          'speedOut'        :    200 
      });
  }
  
  
  

 //function calls
 iphone();
	
});//end of doc ready
 
 function iphone(){
    var deviceAgent = navigator.userAgent.toLowerCase();
            var isIphone = deviceAgent.match(/(iphone)/);  //if iphone
            if(isIphone){
               $("#mylastrow").hide();
               $("#hidemenow").show(); 
                //if orientation changes
                $(window).bind('orientationchange', function(event) {
                    //landscape
                    
                    //portrait
                    if ( orientation == 0 || orientation == 180 || orientation == -180) {
                        var contactpage = $("#contact-us").length;
                        if(contactpage > 0){
                          location.reload(); 
                        }
                     }
                });

            }
 }
 

$(document).ready(function(){ 
  		$.backstretch("http://cdn.myld.com.au/2/342/complete-fencing_e8d27ac07a.png");
});
 
$(document).ready(function(){
	$('.flexslider').flexslider({
		animation: "slide",
		controlNav: false, 
		directionNav: true,
    randomize: true
	});
	
});

window.setInterval(function(){
	var c = 0;
	
	$( '.service-desc' ).each(function() {
	   var h = $( this ).height();
	   if( h > c ) c = h;
	});
	$( '.service-desc' ).css( 'min-height', c );
},1);

$( window ).resize(function(e) {
    $( '.service-desc' ).css( 'min-height', 0 );
});
 $(document).ready(function(){ 
    $('#custom_form').formValidation({ 
        validateText: ["name"],
        validateEmail: ["email"],
        validateSpam: true
    });
});