$(document).ready(function() {
addHover();
initBoxes();
initSlider();
createMap();
$('div.equalContent').equalHeightColumns();
preload([
    '/media/images/HFL_hearForLife_hearing_button_hover.png',
    '/media/images/HFL_hearForLife_services_button_hover.png',
    '/media/images/HFL_hearForLife_promotions_button_hover.png',
  '/media/images/HFL_hearForLife_faq_button_hover.png',
  '/media/images/HFL_hearForLife_book_assessment_hover.png',
  '/media/images/HFL_hearForLife_hosecondaryPage_email_button_hover.png'
]);
});

function addHover(){
$("div.hearing a").bigTarget({
    hoverClass: 'hearing_hover', // CSS class applied to the click zone onHover
    clickZone : '.hearing' // jQuery parent selector
    });
$("div.services a").bigTarget({
    hoverClass: 'services_hover', // CSS class applied to the click zone onHover
    clickZone : '.services' // jQuery parent selector
    });
$("div.promotions a").bigTarget({
    hoverClass: 'promotions_hover', // CSS class applied to the click zone onHover
    clickZone : '.promotions' // jQuery parent selector
    });
$("div.faq a").bigTarget({
    hoverClass: 'faq_hover', // CSS class applied to the click zone onHover
    clickZone : '.faq' // jQuery parent selector
    });
}

function initBoxes(){
$('.hearing').mouseover(function(){
  $('.hearing_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_hearing_button_hover.png)');
});
$('.hearing').mouseout(function(){
  $('.hearing_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_hearing_button.png)');
});
$('.services').mouseover(function(){
  $('.services_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_services_button_hover.png)');
});
$('.services').mouseout(function(){
  $('.services_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_services_button.png)');
});
$('.promotions').mouseover(function(){
  $('.promotions_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_promotions_button_hover.png)');
});
$('.promotions').mouseout(function(){
  $('.promotions_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_promotions_button.png)');
});
$('.faq').mouseover(function(){
  $('.faq_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_faq_button_hover.png)');
});
$('.faq').mouseout(function(){
  $('.faq_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_faq_button.png)');
});
}

function initSlider(){
$('#slider').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:15,
        animSpeed:500, //Slide transition speed
        pauseTime:3000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:true, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
}


function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
        // Alternatively you could use:
        // (new Image()).src = this;
    });
}

function createMap() {
  var myLatlng = new google.maps.LatLng(43.6836, -79.3237);
  var myOptions = {
    zoom: 14,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
var map = new google.maps.Map(document.getElementById("map"), myOptions);
  
var contentString = '<div id="map_info">'+
  '<h3>Hear For Life</h3>'+
  '<p style="margin:0">'+
  '1573 Danforth Avenue<br/>'+
  'Toronto, ON M4J 1N8<br/>'+
  '416-466-9866'+
  '</p>'+
  '</div>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});

var markerLatlng = new google.maps.LatLng(43.6833, -79.3237);

var marker = new google.maps.Marker({
  title: "some text",
  position: markerLatlng,
    map: map,
    title:"Hear For Life"
});

google.maps.event.addListener(marker, 'click', function() {
  infowindow.open(map,marker);
});
  
// To add the marker to the map, call setMap();
marker.setMap(map);
//infowindow.open(map,marker);
 
}

