$(document).ready(function(){
  
  
  if($('.app-form').length) {
  $('.apply').click(function() {
    $('.app-form').slideToggle('slow', function() {
      // Animation complete.
    });
  });
}
  
  
  
  //Make gallery lightbox happen
  if($('.gallery').length) {
	$("a[rel='colorbox-1']").colorbox({transition:"fade"});
}


  if($('.wpcf7-form').length) {
  $("input,select,textarea").focus(function() {
          $(this).parents('div.form-row').addClass("focus")                         
  });
  $("input,select,textarea").blur(function() {
          $(this).parents('div.form-row').removeClass("focus")
  });
}

//Add active state to sidebar 
if($('ul.side').length) {
		$("ul.side li a").each(function() {
			if(this.href == window.location || this.href == document.location.protocol + "//" + window.location.hostname + window.location.pathname)
			$(this).addClass("current_page-item");
		});
	}

  
  // Home Image Cycle	
  		if($('#home-banner').length) {
  		//$('#slides').hide().delay(200).fadeIn('slow').cycle({
  		$('#slides').cycle({
  			fx:    'scrollHorz',
  			cleartype:  false, // disable cleartype corrections 
  			speed:  'slow',
  			timeout: 12000,
  			pager:  '.buttons'
  		});
  		}

  $("#nav ul").supersubs({ 
              minWidth:    14,   // minimum width of sub-menus in em units 
              maxWidth:    20,   // maximum width of sub-menus in em units 
              extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                                 // due to slight rounding differences and font-family 
          }).superfish();  // call supersubs first, then superfish, so that subs are 
                           // not display:none when measuring. Call before initialising 
                           // containing tabs for same reason.
 

  //Make .project div clickable
  if($('.home .project').length) {
    $(".project").click(function(){
    window.location=$(this).find("a").attr("href"); return false;
    });
    
    //Add class on hover to .project div
    		$('.project').hover(function() {
    			$(this).addClass('hover');
    				}, function() {
    			$(this).removeClass('hover');
    		});
  }

 $('#nav li:last,#sub li:last,#footer li:last').addClass('last');
 
 // Add print header to top of page
 	$("body").prepend("<h5 class=\"print\">DORAN STEWART<br /><span>Oilfield Services (1990) LTD</span></h5>");

 	// Add print footer to bottom of page
 	$("body").after("<h6 class=\"print\"><strong>Doran Stewart Oilfield Services (1990) LTD</strong><br />Phone: (403) 845-4044 | Rocky Mountain House<br />391043 Hwy 752 Rocky Mountain House, Alberta T4T 1B3</h5>");

});
