// JavaScript Document
// Copyright McCord Design Group 2010+

$(function() {
    //for home page
    $('#mccord-slides').after('<div id="scroll_nav">').cycle({
      fx: 'fade',
      timeout: 4000,
      speed: 1000,
      pager:'#scroll_nav'
    });

    //for individual portfolio slideshow
      $('#slideshow').after('<div id="thumbnails">').cycle({
        fx: 'fade',
        speed: 300,
        pager:'#thumbnails',

        pagerAnchorBuilder: function(idx, slide) {
          return '<li><a href="#"><img src="' + slide.src + '" width="60" height="41" /></a></li>';
        }
      });

    //stop slideshow from auto-progressing
      $('#portfolio-slider #slideshow').cycle('pause');

    //for studio slideshow
    //$('#studio-shots').after('<div id="thumbnails">').cycle({
    //  fx: 'fade',
    //  speed: 300,
    //  pager:'#thumbnails',
    //
    //  pagerAnchorBuilder: function(idx, slide) {
    //      return '<li><a href="#"><img src="' + slide.src + '" width="60" height="41" /></a></li>';
    //    }
    //  });

    //stop slideshow from auto-progressing
      $('#studio-slider #studio-shots').cycle('pause');

    //Client Testimonial Rotator
    // $('#testimonials').cycle({
    //   fx: 'fade',
    //   speed: 1500,
    //   timeout: 8000,
    //   prev:   '#prev',
    //   next:   '#next',
    // });

    $('#pause').click(function() {
      $(this).toggleClass("paused");
      $('#testimonials').cycle('pause');
        return false;
      });

      $('#testimonials').cycle({
              fx: 'fade',
              speed: 1500,
              timeout: 8000,
              next: '#next',
              prev: '#prev',
              cleartype: 1
      });

});




$(document).ready(function() {

    // Portfolio Sorter
    $("#categories a").click(function() {
      if ($(this).hasClass("active")) {
        $("#categories a").removeClass("active");
        $(this).removeClass("active");
        $("#portfolio .portfolio-piece").addClass("active");
      }
      else {
        // Disable all other active elements:
        $("#categories a").removeClass("active");
        $("#portfolio .portfolio-piece").removeClass("active");
        // Enable matched elements:
        $(this).addClass("active");
        var getTag = "." + $(this).attr("id");
        $("#portfolio .portfolio-piece").find(getTag).parents(".portfolio-piece").addClass("active");
      }
    });

    //Hover Effect for Portfolio
    $("#categories a").hover(
      function () {
        $(this).addClass("hover");
        var getTag = "." + $(this).attr("id");
        $("#portfolio .portfolio-piece").find(getTag).parents(".portfolio-piece").addClass("hover");
      },
      function () {
        $(this).removeClass("hover");
        var getTag = "." + $(this).attr("id");
        $("#portfolio .portfolio-piece").find(getTag).parents(".portfolio-piece").removeClass("hover");
      }
    );

    //Add commas to tags for portfolio pieces
      $("ul.portfolio-tags").each(function() {
        $(this).find('li').not(":last").append(", ");
      });

});

$(window).load(
  //Embedded Google Map for Contact Page
  function initialize() {
    var latlng = new google.maps.LatLng(38.5648950, -90.4030820);
    var settings = {
      zoom: 15,
      center: latlng,
      mapTypeControl: true,
      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
      navigationControl: true,
      navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
      mapTypeId: google.maps.MapTypeId.ROADMAP};
    var map = new google.maps.Map(document.getElementById("map-canvas"), settings);

    var companyLogo = new google.maps.MarkerImage('../assets/logo-map.png',
      new google.maps.Size(55,85),
      new google.maps.Point(0,0)
    );
    var companyShadow = new google.maps.MarkerImage('../assets/logo-map-shadow.png',
      new google.maps.Size(105,61),
      new google.maps.Point(-30,0)
    );

    var companyPos = new google.maps.LatLng(38.5648950, -90.4030820);
    var companyMarker = new google.maps.Marker({
      position: companyPos,
      map: map,
      icon: companyLogo,
      shadow: companyShadow,
      title:"McCord Design Group",
      zIndex: 4
    });


  });

//$(function() {
  //Add Blurb for links (using Tipsy)
  //$('#icons li a.facebook').tipsy({gravity: 'nw'});
//});




