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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/610/qelc_e0e93a6794.ico');
    
    menu.contactDetails({
      phone: '(02) 6653 1038',
      email: 'admin@lpelc.com.au',
      address: '42 Amaroo Cres, Toormina, NSW 2452', 
      hours: [[ 'Mon-Fri', '7.30am - 6.30pm']] 
    });
     
     $('header').prependTo('#jmm-content');
  if(!$('body#home').is('*')) {
    $('header').prepend(' <div id="logo" class="text-center">'+
    '<a href="/"><img src="http://cdn.myld.com.au/2/606/qelc_bd93b0cdd1.png " alt="Qelc"></a>'+
  '</div>');
  }
  if($('body#home').is('*')) {
  $('#slideshow').bjqs({
    randomstart : true,
    responsive: true,
    width : 647,
height : 500,
    showcontrols : false, // show next and prev controls
    showmarkers : true // Show individual slide markers
});
}
  /* $('.navbar .navbar-nav > li').eq(1).addClass('dropdown').append('<ul class="dropdown-menu">'+
      '<li><a href="#welcome">Welcome Letter</a></li>'+
      '<li><a href="#meet">Meet Our Educators</a></li>'+
      '<li><a href="#ourPhilosophy">Our Philosophy</a></li>'+
    '</ul>');
  $('.navbar .navbar-nav > li').eq(2).addClass('dropdown').append('<ul class="dropdown-menu">'+
      '<li><a href="#hours">Hours of Operation</a></li>'+
      '<li><a href="#fees">Fees</a></li>'+
      '<li><a href="#curriculum">Curriculum</a></li>'+
      '<li><a href="#extraCurricular">Extra Curricular Activities</a></li>'+ 
    '</ul>');
  $('.navbar .navbar-nav > li').eq(3).addClass('dropdown').append('<ul class="dropdown-menu">'+
      '<li><a href="#enrolmentInfo">Enrolment Information</a></li>'+
      '<li><a href="#parentHandbook">Parent Handbook</a></li>'+
      '<li><a href="#enrolmentForm">Enrolment Form</a></li>'+
       '<li><a href="#eziDept">Ezi Debt Form</a></li>'+
       '<li><a href="#gettingTo">Getting To Know You Survey</a></li>'+         
      '<li><a href="#newParent">New Parent Checklist</a></li>'+                                                            
    '</ul>');
     $('.navbar .navbar-nav > li').eq(4).addClass('dropdown').append('<ul class="dropdown-menu">'+
      '<li><a href="#calendar">Calendar of Events</a></li>'+
      '<li><a href="#newsletter">Newsletter</a></li>'+
      '<li><a href="#parentPortfolio ">Link to Secure Parent Portfolio</a></li>'+
       '<li><a href="#parentFeedback">Parent Feedback</a></li>'+                                                        
    '</ul>');
     $('.navbar .navbar-nav > li').eq(5).addClass('dropdown').append('<ul class="dropdown-menu">'+
      '<li><a href="#introduction">Introduction</a></li>'+
      '<li><a href="#routine">Routine</a></li>'+
      '<li><a href="#fastFeet ">Fast Feet, Speed & Agility</a></li>'+
       '<li><a href="#athletics">Athletics</a></li>'+   
       '<li><a href="#equipment">Equipment</a></li>'+                                                        
    '</ul>');
    
    

    
menu.reset();*/

 $('.dropdown-menu li a').click(function() {
      var target = $(this).attr('href');
      $('body,html').animate({
            scrollTop:$(target).offset().top - 86
        }, 600);
     });

/*$('.dropdown-menu li a').click(function() {
    event.preventDefault();
    var target = $('this').attr('href');
    console.log(target);
    //var scrollTarget = $(target).offset().top - 66;
    $('html,body').animate({scrollTop: $(target).offset().top },'slow');
});*/
$('.navbar-example').insertAfter('nav');
$('body').scrollspy({ target: '.navbar-example', offset: 95 });
  
var clndr = {};

$( function() {

  // PARDON ME while I do a little magic to keep these events relevant for the rest of time...
  var currentMonth = moment().format('YYYY-MM');
  var nextMonth    = moment().add('month', 1).format('YYYY-MM');

  var events = [{ date:'2014-03'+'-'+'04', title: 'Pancake Day: The children will be cooking pancakes to celebrate the start of Easter'},
                { date:'2014-03'+'-'+'17', title: 'St Patricks Day: Its dress up day where was come to Lilly Pilly wearing a green shirt or clothes. We will be participating in St Patricks day celebrations. We will do this in the way of craft and stories. We will be reading stories, pictures of Ireland using the Ipads and listening to Irish music.'},
                { date:'2014-03'+'-'+'20', title: 'World Story: Telling Day: we will be telling stories through drama, reading a story and having children recreate this story through Drama. Encourage children to tell their own stories. '},
                { date:'2014-03'+'-'+'21', title: 'Harmony Day: Its dress up day where we wear Orange clothing and participate in stories, songs and craft experiences'},
                
               { date:'2014-04'+'-'+'14', title: '14th - 17th Easter Celebrations - Throughout the week the children will participate in craft, stories, cooking and games.'},
               { date:'2014-04'+'-'+'18', title: 'Good Friday Centre Closed'},
               { date:'2014-04'+'-'+'21', title: 'Easter Monday Centre Closed'},
               { date:'2014-04'+'-'+'22', title: '22nd - 24th Earth Day: Children will participate in a variety of activities and experiences that will continue to build on their knowledge of caring for the environment.'},
                { date:'2014-04'+'-'+'25', title: 'Anzac Day Centre Closed'},
              
               { date:'2014-05'+'-'+'03', title: 'Mother\'s Day Event - morning tea for the mums at Garden Mainia.'},
                { date:'2014-05'+'-'+'06', title: 'Pyjama Day (World Asthma Day): The children are invited to wear their PJ\'s to Lilly Pilly and make a gold coin donation to the Asthma Foundation.'},
               { date:'2014-05'+'-'+'23', title: 'Biggest Morning Tea: Parents and extended family members will be invited to the centre to participate in the Biggest Morning Tea. '},
                
                { date:'2014-06'+'-'+'05', title: 'World Environment Day'},
               { date:'2014-06'+'-'+'09', title: 'Public Holiday Centre Closed'},
               { date:'2014-06'+'-'+'27', title: 'Red Nose Day: Today the children are invite to wear Red and make a gold coin donation to the SIDS foundation. Red Nose Merchanise will also be available to purchase.'},
               
               { date:'2014-07'+'-'+'06', title: '6th - 13th Naidoc Week: celebrate the traditional land owners of our beautiful country. Lilly Pilly will celebrate through stories, Dance, music, learn some new words in Gumbaragi and invite a Koori member from the Community to visit the centre.'},
               { date:'2014-07'+'-'+'25', title: 'National Tree Day: plant some plants or a small tree. Look at the importance of our trees in the environment.'},
               
               { date:'2014-08'+'-'+'01', title: 'Jeans for Genes Day: Staff and children are invited to wear Jeans for the day.'},
               { date:'2014-08'+'-'+'07', title: 'Centre closes 12 midday for 1/2 day local public holiday (Coffs Cup)'},
               { date:'2014-08'+'-'+'16', title: '16th - 24th Book Week: Dressing up in our favourite book character costumes.'},
               { date:'2014-08'+'-'+'22', title: 'Daffodil Day: make some yellow craft flowers. Wear yellow on this day'},
               
               { date:'2014-09'+'-'+'01', title: 'National Wattle Day: Wattle is our National emblem. We can celebrate this day through making a wattle tree on canvas, Wattle is Australian and represents us all. Unlike other national days, National Wattle Day excludes no one.'},
               { date:'2014-09'+'-'+'04', title: 'Daddy and Me Evening (Father\'s Day Event) Dads/Grandads/other significant males will be invited to the centre for a bbq.'},
               { date:'2014-09'+'-'+'05', title: 'Footy Colours Day : wear our favourite footy colours, play some ball games using a footy.'},
               //{ date:'2014-09'+'-'+'12', title: 'A Toast to Art on Amaroo (Art Exhibition preview evening)'},
               //{ date:'2014-09'+'-'+'13', title: 'Lilly Pilly Art Exhibition'},
               { date:'2014-09'+'-'+'19', title: 'International Talk like a Pirate Day: dress up like pirates, talk like pirates, stories about pirates.'},
               
               { date:'2014-10'+'-'+'04', title: '4th - 10th World Space Week'},
               { date:'2014-10'+'-'+'06', title: 'Centre Closed Public Holiday'},
               { date:'2014-10'+'-'+'13', title: '13th - 17th - School Photos'},
               { date:'2014-10'+'-'+'20', title: '20th and 23rd - Grandparent\'s Day'},
               
               { date:'2014-11'+'-'+'08', title: 'A Toast to Art on Amaroo (Art Exhibition preview evening)'},
               { date:'2014-11'+'-'+'09', title: 'Lilly Pilly Art Exhibition'},
               { date:'2014-11'+'-'+'10', title: '10-16th - World Recycling week'},
               
               { date:'2014-12'+'-'+'04', title: 'End of Year Concert and Graduation Ceremony'},
               { date:'2014-12'+'-'+'14', title: '14th - 19th - Party Week '},
               { date:'2014-12'+'-'+'19', title: '19th - Centre\'s last Day'}];
 
 clndr = $('.cal').clndr({ 
   template: $('.cal-template').html(),
   events: events    
  });
});
  if($('.fancybox').length > 0) {
  if(jQuery.browser.mobile)
{
   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 footerMap() {
  var myLatlng = new google.maps.LatLng(-30.35569, 153.08554);
  var image = 'http://cdn.myld.com.au/2/605/qelc_014ee3448d.png';
  var mapOptions = {
    zoom: 13,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  
  if ($('#footerMap').length > 0) {
      var map = new google.maps.Map(document.getElementById('footerMap'), mapOptions);
    
      var marker = new google.maps.Marker({
          position: myLatlng,
          map: map,
          icon: image
      });
      
      google.maps.event.addDomListener(window, 'resize', function() {
            map.setCenter(myLatlng);
});         
      google.maps.event.addDomListener(window, 'orientationchange', function() {
            map.setCenter(myLatlng);
});   
    }
}
function contactmap() {
  var myLatlng = new google.maps.LatLng(-30.35569, 153.08554);
  var image = 'http://cdn.myld.com.au/2/605/web_qelc_014ee3448d.png';
  var mapOptions = {
    zoom: 13,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  
  if ($('#contact-map').length > 0) {
      var map = new google.maps.Map(document.getElementById('contact-map'), mapOptions);
    
      var marker = new google.maps.Marker({
          position: myLatlng,
          map: map,
          icon: image
      });
      
      google.maps.event.addDomListener(window, 'resize', function() {
            map.setCenter(myLatlng);
      });         
      google.maps.event.addDomListener(window, 'orientationchange', function() {
            map.setCenter(myLatlng);
      });   
    }
}


$(window).load(function(){
    footerMap();
  contactmap();
  
  $('#feedback_form').formValidation({ 
  validateText: ["name","feeback"],
  validateEmail: ["email"],
  validateSpam: true
}); 
  $('#contact_form').formValidation({ 
  validateText: ["name","enquiry","phone"],
  validateEmail: ["email"],
  validateSpam: true
}); 
 $('#careers_form').formValidation({ 
  validateText: ["name","phone"],
  validateEmail: ["email"],
  validateRadiobutton: ["employment"],
  validateSpam: true
}); 

$('li.dropdown').hover(function() {
  $('ul.dropdown-menu').hide();
  $(this).find('ul.dropdown-menu').show();
},
function() {
  $('ul.dropdown-menu').hide();
  $('li.active.dropdown').find('ul.dropdown-menu').show();
});
});    

$(window).load(function(){
    // Initialize portfolio isotope 
        var $container          = $('.filter-feed');
        var selector = '*';
        isotopeFilter(selector, $container);
        
        $(window).resize(function(){    
            isotopeFilter(selector, $container);
        });
        
        function isotopeFilter(selector, $container) {
            $container.isotope({
                filter              : selector, 
                animationOptions    : {
                    duration            : 450,
                    easing              : 'linear',
                    queue              : false
                }
            });         
        }
        
        
  $(function() {

        var a = function() {
            var d = $("#nav").offset().top + 66;
            var b = $(window).scrollTop();

            var c = $("body");
            if (b > d) {
                c.addClass('scrolled');

            } else {
                if (b <= d) {
                    c.removeClass('scrolled');
                }
            }
        };
        a();
        $(window).scroll(a);
    });
});