﻿$(document).ready(function() {
    $("#main-nav li ul").wrap("<div></div>");

    // Using the current path (e.g. /Section/Page)
    var path = location.pathname;

    // Handle links to the current path
    if (path) {
        $('a[href$="' + path + '"]').parents().filter('li').addClass('active').end().filter('ul').parents().filter('li').addClass('active');
    }

    // Handle links to parts of the current path
    var parts = path.split('/')
    for (i = 0; i < parts.length; i++) {
        $('a[href$="/' + parts[i] + '"]').parents().filter('li').addClass('active').end().filter('ul').parents().filter('li').addClass('active');
    }

    var inthumb = '<img src="http://images.websnapr.com/?url=http://www.inwilmingtonde.us alt="Loading thumbnail..." height="152" width="202" />';

    $(".inbanner").qtip({ content: false, show: { delay: 0 }, hide: { fixed: false, delay: 0 }, position: { corner: { target: 'leftBottom', tooltip: 'rightTop' }, adjust: { x: 0, y: -11} }, style: { name: 'dark', zIndex: 50, fontSize: '16px', width: 300, background: '#000000', border: { width: 6, radius: 16, color: "#000000" }, tip: { corner: 'rightTop', color: '#000000'}} });
    
	$("input[value='Skip payment']").hide();
	$("span[id$='lblBillingCountry']", "#billingAddrTable").parents().filter("tr:first").after($("input[id$='txtBillingZip']", "#billingAddrTable").parents().filter("tr:first"));

    // Play youtube videos inline
    $('.col-2 a[href*="youtube."]').each(function() {
        // Grab video ID from the url
        var videoID = $(this).attr('href').match(/watch\?v=(.+)+/);
        videoID = videoID[1];

        // Create content using url as base
        $(this).qtip(
      {
          // Create content DIV with unique ID for swfObject replacement
          content: '<div id="youtube-embed-' + videoID + '">You need Flash player 8+ to view this video.</div>',
          position: {
              corner: {
                  tooltip: 'rightMiddle', // ...and position it center of the screen
                  target: 'leftMiddle' // ...and position it center of the screen
              },
              adjust: { x: -6, y: 0 }
          },
          show: {
              when: 'click', // Show it on click...
              solo: true // ...and hide all others when its shown
          },
          hide: 'unfocus', // Hide it when inactive...
          style: {
              width: 504,
              height: 260,
              padding: 0,
              tip: true,
              name: 'dark',
              border: { width: 6, radius: 16, color: "#00929F" }
          },
          api: {
              onRender: function() {
                  // Setup video paramters
                  var params = { allowScriptAccess: 'always', allowfullScreen: 'false' };
                  var attrs = { id: 'youtube-video-' + videoID };

                  // Embed the youtube video using SWFObject script
                  swfobject.embedSWF('http://www.youtube.com/v/' + videoID + '&enablejsapi=1&playerapiid=youtube-api-' + videoID,
                                 'youtube-embed-' + videoID, '425', '264', '8', null, null, params, attrs);
              },

              onHide: function() {
                  // Pause the vide when hidden
                  var playerAPI = this.elements.content.find('#youtube-video-' + videoID).get(0);
                  if (playerAPI && playerAPI.pauseVideo) playerAPI.pauseVideo();
              }
          }
      }
      ).attr('href', '#');
    });

    // Play vimeo videos inline
    $('.col-2 a[href*="vimeo."]').each(function() {
        // Grab video ID from the url
        var videoID = $(this).attr('href').match(/vimeo\.com\/(.+)+/);
        videoID = videoID[1];

        // Create content using url as base
        $(this).qtip(
      {
          // Create content DIV with unique ID for swfObject replacement
          content: '<div id="vimeo-embed-' + videoID + '">You need Flash player 8+ to view this video.</div>',
          position: {
              corner: {
                  tooltip: 'rightMiddle', // ...and position it center of the screen
                  target: 'leftMiddle' // ...and position it center of the screen
              },
              adjust: { x: -6, y: 0 }
          },
          show: {
              when: 'click', // Show it on click...
              solo: true // ...and hide all others when its shown
          },
          hide: 'unfocus', // Hide it when inactive...
          style: {
              width: 504,
              height: 260,
              padding: 0,
              tip: true,
              name: 'dark',
              border: { width: 6, radius: 16, color: "#00929F" }
          },
          api: {
              onRender: function() {
                  // Setup video paramters
                  var params = { allowScriptAccess: 'always', allowfullScreen: 'false' };
                  var attrs = { id: 'vimeo-video-' + videoID };

                  // Embed the youtube video using SWFObject script
                  swfobject.embedSWF('http://vimeo.com/moogaloop.swf?clip_id=' + videoID + '&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=D6E03D&amp;fullscreen=0', 'vimeo-embed-' + videoID, '473', '260', '9', null, null, params, attrs);
              },

              onHide: function() {
                  // Pause the video when hidden
                  //var playerAPI = this.elements.content.find('#vimeo-video-' + videoID).get(0);
                  //if (playerAPI && playerAPI.pauseVideo) playerAPI.pauseVideo();
              }
          }
      }
      ).attr('href', '#');
    });

});

