// JavaScript Document
$(document).ready(function () {
    var loc = window.location;
    var pageTitle = document.title;
    $('#emailPage').attr("href", "mailto:?subject=Check out " + pageTitle + " from AJG&body=" + loc);

    $(".contactPage").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 600,
        'speedOut': 200,
        'overlayShow': true,
        'overlayOpacity': 0.8,
        'overlayColor': '#000',
        'scrolling': 'no',
        'type': 'ajax',
        'ajax': {
            dataFilter: function (data) {
                return $(data).find('#contactContent')[0];
            }
        },
        'width': 775,
        'height': 470
       
    });

    var topnav = $('#topnav');
    topnav.css('width', topnav.width() + 'px');
    topnav.parent().css('width', topnav.width() - 8 + 'px');

	$('#dropNav').bind('change', function () {
	  var url = $(this).val(); // get selected value
	  if (url) { // require a URL
		  window.open(url,'NEW'); // open url in a new tab
	  }
	  return false;
    });

    //Campaign Tracking
    //Check if Cookie Already Exists If it does just skip it.
    var existingCampCode = $.cookie('webLeadCode');

    if (existingCampCode == null) {
        var campCode = getURLParameter("f9tc");

        if (campCode !== null) {
            $.cookie('webLeadCode', campCode, { expires: 30, path: '/' });
        }
    }

    //source: http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery
    function getURLParameter(name) {
        return decodeURIComponent((RegExp('[?|&]' + name + '=' + '(.+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
    }




});

