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

$(document).ready(function() {
  $('#logo').remove();
 
  
  
//FEATURE HOVER FIX
    $('.feat-rollover').hover(
      function () {
        $(this).animate({opacity:'1'});
      },
      function () {
        $(this).animate({opacity:'0'});
      }
    );
});

$(window).load(function() {
	//FEATURE HOVER FIX
    $('.feat-rollover').css('opacity', 0);
});

$(document).ready(function() {
  // scripts across the site
  var global_handler = new window.GlobalHandler();
  global_handler.init();
  
  // scripts specific to Home page
  var home_handler = window.HomeHandler();
  home_handler.init();
});




/*** Global Handler ***/
window.GlobalHandler = function(config) {
  config = config || {};
  
  function detect_browser() {
    // Windows IE8 and below popup
  	$("body").browserDetect( {     	
  		name: "DP Cleaning Supplies ",     
  		logo: "http://cdn.myld.com.au/2/223/dp-cleaning-supplies-pty-ltd_d6bfa39866.JPG",      
  		phone: "0418 187 811",                          // optional
  		fax: "(07) 4092 6476",                          // optional
  		email: "linda@dpcleaning.com.au",               // optional
  		address: "1 Atherton St Mareeba Qld 4880",      // optional	
  		ldprofile: "http://www.localdirectories.com.au/Tablelands,QLD/DP-Cleaning-Supplies-Pty-Ltd/profile/jZgu"  
  	});
  }
  
  function embed_favicon() {
    $('<link id="favicon" type="image/x-icon" rel="shortcut icon" href="http://cdn.myld.com.au/2/241/dp-cleaning-supplies-pty-ltd_5037ce1670.png" />').appendTo('head');
    $('<link rel="shortcut icon" href="http://cdn.myld.com.au/2/335/dp-cleaning-supplies-pty-ltd_4823a4ec53.ico" type="image/x-icon" />').appendTo('head');
    $('<link rel="icon" href="http://cdn.myld.com.au/2/335/dp-cleaning-supplies-pty-ltd_4823a4ec53.ico" type="image/x-icon" />').appendTo('head');
  }
  
  function embed_site_header_and_main_nav() {
    // inject site header to body as its first child
    $('#Site_Header_and_Nav').prependTo('body');
    
    // inject main nav to site header
    $(".navbar.main-nav").appendTo("#navmenu");
    $(".nav").addClass("pull-right custom_menu");
    $('.nav.custom_menu').css({
      'font-size': '150%',
      'font-weight': 'bold'
    });
  }
  
  function do_init() {
    // Mobile Telephone
    mobileTel(+61740927582);
    
    detect_browser();
    embed_favicon();
    embed_site_header_and_main_nav();
  }
  
  var _self = {
    init: function() {
      do_init();
    }
  };

  return _self;
};


/*** Home Handler ***/
window.HomeHandler = function(config) {
  config = config || {};
  
  function start_feature_image_slider() {
    var carousel = $("#carousel").featureCarousel({
      // include options like this:
      // (use quotes only for string values, and no trailing comma after last option)
      // option: value,
      // option: value
    });
  
    // prev img
    $("#but_prev").click(function () {
      carousel.prev();
    });
    
    // stop slide show
    $("#but_pause").click(function () {
      carousel.pause();
    });
    
    // start slideshow
    $("#but_start").click(function () {
      carousel.start();
    });
    
    // next img
    $("#but_next").click(function () {
      carousel.next();
    });
  }
  
  function style_slider() {
    $('#slider').css({
      'background': 'url("http://cdn.myld.com.au/2/295/dp-cleaning-supplies-pty-ltd_f009ec8ea9.jpg")',
      'overflow': 'hidden'
    });
  }
  
  function style_title_div() {
    $('.gram').css({
      'background': 'none'
    });
  }

  function do_init() {
    start_feature_image_slider();
    style_slider();
    style_title_div();
  }
  
  var _self = {
    init: function() {
      do_init();
    }
  };
  
  return _self;
};
