/*

Quicksand 1.2.2

Reorder and filter items with a nice shuffling animation.

Copyright (c) 2010 Jacek Galanciak (razorjack.net) and agilope.com
Big thanks for Piotr Petrus (riddle.pl) for deep code review and wonderful docs & demos.

Dual licensed under the MIT and GPL version 2 licenses.
//github.com/jquery/jquery/blob/master/MIT-LICENSE.txt
//github.com/jquery/jquery/blob/master/GPL-LICENSE.txt

Project site: //razorjack.net/quicksand
Github site: //github.com/razorjack/quicksand

*/

(function ($) {
    $.fn.quicksand = function (collection, customOptions) {     
        var options = {
            duration: 750,
            easing: 'swing',
            attribute: 'data-id', // attribute to recognize same items within source and dest
            adjustHeight: 'auto', // 'dynamic' animates height during shuffling (slow), 'auto' adjusts it before or after the animation, false leaves height constant
            useScaling: true, // disable it if you're not using scaling effect or want to improve performance
            enhancement: function(c) {}, // Visual enhacement (eg. font replacement) function for cloned elements
            selector: '> *',
            dx: 0,
            dy: 0
        };
        $.extend(options, customOptions);
        
        if ($.browser.msie || (typeof($.fn.scale) == 'undefined')) {
            // Got IE and want scaling effect? Kiss my ass.
            options.useScaling = false;
        }
        
        var callbackFunction;
        if (typeof(arguments[1]) == 'function') {
            var callbackFunction = arguments[1];
        } else if (typeof(arguments[2] == 'function')) {
            var callbackFunction = arguments[2];
        }
    
        
        return this.each(function (i) {
            var val;
            var animationQueue = []; // used to store all the animation params before starting the animation; solves initial animation slowdowns
            var $collection = $(collection).clone(); // destination (target) collection
            var $sourceParent = $(this); // source, the visible container of source collection
            var sourceHeight = $(this).css('height'); // used to keep height and document flow during the animation
            
            var destHeight;
            var adjustHeightOnCallback = false;
            
            var offset = $($sourceParent).offset(); // offset of visible container, used in animation calculations
            var offsets = []; // coordinates of every source collection item            
            
            var $source = $(this).find(options.selector); // source collection items
            
            // Replace the collection and quit if IE6
            if ($.browser.msie && $.browser.version.substr(0,1)<7) {
                $sourceParent.html('').append($collection);
                return;
            }

            // Gets called when any animation is finished
            var postCallbackPerformed = 0; // prevents the function from being called more than one time
            var postCallback = function () {
                
                if (!postCallbackPerformed) {
                    postCallbackPerformed = 1;
                    
                    // hack: 
                    // used to be: $sourceParent.html($dest.html()); // put target HTML into visible source container
                    // but new webkit builds cause flickering when replacing the collections
                    $toDelete = $sourceParent.find('> *');
                    $sourceParent.prepend($dest.find('> *'));
                    $toDelete.remove();
                         
                    if (adjustHeightOnCallback) {
                        $sourceParent.css('height', destHeight);
                    }
                    options.enhancement($sourceParent); // Perform custom visual enhancements on a newly replaced collection
                    if (typeof callbackFunction == 'function') {
                        callbackFunction.call(this);
                    }                    
                }
            };
            
            // Position: relative situations
            var $correctionParent = $sourceParent.offsetParent();
            var correctionOffset = $correctionParent.offset();
            if ($correctionParent.css('position') == 'relative') {
                if ($correctionParent.get(0).nodeName.toLowerCase() == 'body') {

                } else {
                    correctionOffset.top += (parseFloat($correctionParent.css('border-top-width')) || 0);
                    correctionOffset.left +=( parseFloat($correctionParent.css('border-left-width')) || 0);
                }
            } else {
                correctionOffset.top -= (parseFloat($correctionParent.css('border-top-width')) || 0);
                correctionOffset.left -= (parseFloat($correctionParent.css('border-left-width')) || 0);
                correctionOffset.top -= (parseFloat($correctionParent.css('margin-top')) || 0);
                correctionOffset.left -= (parseFloat($correctionParent.css('margin-left')) || 0);
            }
            
            // perform custom corrections from options (use when Quicksand fails to detect proper correction)
            if (isNaN(correctionOffset.left)) {
                correctionOffset.left = 0;
            }
            if (isNaN(correctionOffset.top)) {
                correctionOffset.top = 0;
            }
            
            correctionOffset.left -= options.dx;
            correctionOffset.top -= options.dy;

            // keeps nodes after source container, holding their position
            $sourceParent.css('height', $(this).height());
            
            // get positions of source collections
            $source.each(function (i) {
                offsets[i] = $(this).offset();
            });
            
            // stops previous animations on source container
            $(this).stop();
            var dx = 0; var dy = 0;
            $source.each(function (i) {
                $(this).stop(); // stop animation of collection items
                var rawObj = $(this).get(0);
                if (rawObj.style.position == 'absolute') {
                    dx = -options.dx;
                    dy = -options.dy;
                } else {
                    dx = options.dx;
                    dy = options.dy;                    
                }

                rawObj.style.position = 'absolute';
                rawObj.style.margin = '0';

                rawObj.style.top = (offsets[i].top - parseFloat(rawObj.style.marginTop) - correctionOffset.top + dy) + 'px';
                rawObj.style.left = (offsets[i].left - parseFloat(rawObj.style.marginLeft) - correctionOffset.left + dx) + 'px';
            });
                    
            // create temporary container with destination collection
            var $dest = $($sourceParent).clone();
            var rawDest = $dest.get(0);
            rawDest.innerHTML = '';
            rawDest.setAttribute('id', '');
            rawDest.style.height = 'auto';
            rawDest.style.width = $sourceParent.width() + 'px';
            $dest.append($collection);      
            // insert node into HTML
            // Note that the node is under visible source container in the exactly same position
            // The browser render all the items without showing them (opacity: 0.0)
            // No offset calculations are needed, the browser just extracts position from underlayered destination items
            // and sets animation to destination positions.
            $dest.insertBefore($sourceParent);
            $dest.css('opacity', 0.0);
            rawDest.style.zIndex = -1;
            
            rawDest.style.margin = '0';
            rawDest.style.position = 'absolute';
            rawDest.style.top = offset.top - correctionOffset.top + 'px';
            rawDest.style.left = offset.left - correctionOffset.left + 'px';
            
            
    
            

            if (options.adjustHeight === 'dynamic') {
                // If destination container has different height than source container
                // the height can be animated, adjusting it to destination height
                $sourceParent.animate({height: $dest.height()}, options.duration, options.easing);
            } else if (options.adjustHeight === 'auto') {
                destHeight = $dest.height();
                if (parseFloat(sourceHeight) < parseFloat(destHeight)) {
                    // Adjust the height now so that the items don't move out of the container
                    $sourceParent.css('height', destHeight);
                } else {
                    //  Adjust later, on callback
                    adjustHeightOnCallback = true;
                }
            }
                
            // Now it's time to do shuffling animation
            // First of all, we need to identify same elements within source and destination collections    
            $source.each(function (i) {
                var destElement = [];
                if (typeof(options.attribute) == 'function') {
                    
                    val = options.attribute($(this));
                    $collection.each(function() {
                        if (options.attribute(this) == val) {
                            destElement = $(this);
                            return false;
                        }
                    });
                } else {
                    destElement = $collection.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                }
                if (destElement.length) {
                    // The item is both in source and destination collections
                    // It it's under different position, let's move it
                    if (!options.useScaling) {
                        animationQueue.push(
                                            {
                                                element: $(this), 
                                                animation: 
                                                    {top: destElement.offset().top - correctionOffset.top, 
                                                     left: destElement.offset().left - correctionOffset.left, 
                                                     opacity: 1.0
                                                    }
                                            });

                    } else {
                        animationQueue.push({
                                            element: $(this), 
                                            animation: {top: destElement.offset().top - correctionOffset.top, 
                                                        left: destElement.offset().left - correctionOffset.left, 
                                                        opacity: 1.0, 
                                                        scale: '1.0'
                                                       }
                                            });

                    }
                } else {
                    // The item from source collection is not present in destination collections
                    // Let's remove it
                    if (!options.useScaling) {
                        animationQueue.push({element: $(this), 
                                             animation: {opacity: '0.0'}});
                    } else {
                        animationQueue.push({element: $(this), animation: {opacity: '0.0', 
                                         scale: '0.0'}});
                    }
                }
            });
            
            $collection.each(function (i) {
                // Grab all items from target collection not present in visible source collection
                
                var sourceElement = [];
                var destElement = [];
                if (typeof(options.attribute) == 'function') {
                    val = options.attribute($(this));
                    $source.each(function() {
                        if (options.attribute(this) == val) {
                            sourceElement = $(this);
                            return false;
                        }
                    });                 

                    $collection.each(function() {
                        if (options.attribute(this) == val) {
                            destElement = $(this);
                            return false;
                        }
                    });
                } else {
                    sourceElement = $source.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                    destElement = $collection.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                }
                
                var animationOptions;
                if (sourceElement.length === 0) {
                    // No such element in source collection...
                    if (!options.useScaling) {
                        animationOptions = {
                            opacity: '1.0'
                        };
                    } else {
                        animationOptions = {
                            opacity: '1.0',
                            scale: '1.0'
                        };
                    }
                    // Let's create it
                    d = destElement.clone();
                    var rawDestElement = d.get(0);
                    rawDestElement.style.position = 'absolute';
                    rawDestElement.style.margin = '0';
                    rawDestElement.style.top = destElement.offset().top - correctionOffset.top + 'px';
                    rawDestElement.style.left = destElement.offset().left - correctionOffset.left + 'px';
                    d.css('opacity', 0.0); // IE
                    if (options.useScaling) {
                        d.css('transform', 'scale(0.0)');
                    }
                    d.appendTo($sourceParent);
                    
                    animationQueue.push({element: $(d), 
                                         animation: animationOptions});
                }
            });
            
            $dest.remove();
            options.enhancement($sourceParent); // Perform custom visual enhancements during the animation
            for (i = 0; i < animationQueue.length; i++) {
                animationQueue[i].element.animate(animationQueue[i].animation, options.duration, options.easing, postCallback);
            }
        });
    };
})(jQuery);
jQuery(document).ready(function($){

if (jQuery().quicksand) {

 	// Clone applications to get a second collection
	var $data = $(".portfolio").clone();
	
	//NOTE: Only filter on the main portfolio page, not on the subcategory pages
	$('.filter li').click(function(e) {
		$(".filter li").removeClass("active");	
		// Use the last category class as the category to filter by. This means that multiple categories are not supported (yet)
		var filterClass=$(this).attr('class').split(' ').slice(-1)[0];
		
		if (filterClass == 'all') {
			var $filteredData = $data.find('.item-thumbs');
		} else {
			var $filteredData = $data.find('.item-thumbs[data-type=' + filterClass + ']');
		}
		$(".portfolio").quicksand($filteredData, {
			duration: 600,
			adjustHeight: 'auto'
		}, function () {
		

			// Portfolio hover
			jQuery('ul.da-thumbs > li').hoverdir();
			
			// Portfolio fancybox
		$(".fancybox").fancybox({				
				padding : 0,
				beforeShow: function () {
					this.title = $(this.element).attr('title');
					this.title = '<h4>' + this.title + '</h4>' + '<p>' + $(this.element).parent().find('img').attr('alt') + '</p>';
				},
				helpers : {
					title : { type: 'inside' },
				}
			});
			
		$('.fancybox-media').fancybox({
			openEffect  : 'none',
			closeEffect : 'none',
			helpers : {
				media : {}
			}
		});
				
			$(".video:first a[data-pretty^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'pp_default',slideshow:3000, autoplay_slideshow: false});
			$(".video:gt(0) a[data-pretty^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});
			});		
			
		$(this).addClass("active"); 			
		return false;
	});
	
}//if quicksand

});/*
 * cond - v0.1 - 6/10/2009
 * //benalman.com/projects/jquery-cond-plugin/
 * 
 * Copyright (c) 2009 "Cowboy" Ben Alman
 * Licensed under the MIT license
 * //benalman.com/about/license/
 * 
 * Based on suggestions and sample code by Stephen Band and DBJDBJ in the
 * jquery-dev Google group: //bit.ly/jqba1
 */
(function($){$.fn.cond=function(){var e,a=arguments,b=0,f,d,c;while(!f&&b<a.length){f=a[b++];d=a[b++];f=$.isFunction(f)?f.call(this):f;c=!d?f:f?d.call(this,f):e}return c!==e?c:this}})(jQuery);/**
 * jquery.slitslider.js v1.1.0
 * //www.codrops.com
 *
 * Licensed under the MIT license.
 * //www.opensource.org/licenses/mit-license.php
 * 
 * Copyright 2012, Codrops
 * //www.codrops.com
 */

;( function( $, window, undefined ) {
	
	'use strict';

	/*
	* debouncedresize: special jQuery event that happens once after a window resize
	*
	* latest version and complete README available on Github:
	* https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js
	*
	* Copyright 2011 @louis_remi
	* Licensed under the MIT license.
	*/
	var $event = $.event,
	$special,
	resizeTimeout;

	$special = $event.special.debouncedresize = {
		setup: function() {
			$( this ).on( "resize", $special.handler );
		},
		teardown: function() {
			$( this ).off( "resize", $special.handler );
		},
		handler: function( event, execAsap ) {
			// Save the context
			var context = this,
				args = arguments,
				dispatch = function() {
					// set correct event type
					event.type = "debouncedresize";
					$event.dispatch.apply( context, args );
				};

			if ( resizeTimeout ) {
				clearTimeout( resizeTimeout );
			}

			execAsap ?
				dispatch() :
				resizeTimeout = setTimeout( dispatch, $special.threshold );
		},
		threshold: 20
	};

	// global
	var $window = $( window ),
		$document = $( document ),
		Modernizr = window.Modernizr;

	$.Slitslider = function( options, element ) {
		
		this.$elWrapper = $( element );
		this._init( options );
		
	};

	$.Slitslider.defaults = {
		// transitions speed
		speed : 800,
		// if true the item's slices will also animate the opacity value
		optOpacity : false,
		// amount (%) to translate both slices - adjust as necessary
		translateFactor : 230,
		// maximum possible angle
		maxAngle : 25,
		// maximum possible scale
		maxScale : 2,
		// slideshow on / off
		autoplay : false,
		// keyboard navigation
		keyboard : true,
		// time between transitions
		interval : 4000,
		// callbacks
		onBeforeChange : function( slide, idx ) { return false; },
		onAfterChange : function( slide, idx ) { return false; }
	};

	$.Slitslider.prototype = {

		_init : function( options ) {
			
			// options
			this.options = $.extend( true, {}, $.Slitslider.defaults, options );

			// https://github.com/twitter/bootstrap/issues/2870
			this.transEndEventNames = {
				'WebkitTransition' : 'webkitTransitionEnd',
				'MozTransition' : 'transitionend',
				'OTransition' : 'oTransitionEnd',
				'msTransition' : 'MSTransitionEnd',
				'transition' : 'transitionend'
			};
			this.transEndEventName = this.transEndEventNames[ Modernizr.prefixed( 'transition' ) ];
			// suport for css 3d transforms and css transitions
			this.support = Modernizr.csstransitions && Modernizr.csstransforms3d;
			// the slider
			this.$el = this.$elWrapper.children( '.sl-slider' );
			// the slides
			this.$slides = this.$el.children( '.sl-slide' ).hide();
			// total slides
			this.slidesCount = this.$slides.length;
			// current slide
			this.current = 0;
			// control if it's animating
			this.isAnimating = false;
			// get container size
			this._getSize();
			// layout
			this._layout();
			// load some events
			this._loadEvents();
			// slideshow
			if( this.options.autoplay ) {
			
				this._startSlideshow();
			
			}

		},
		// gets the current container width & height
		_getSize : function() {

			this.size = {
				width : this.$elWrapper.outerWidth( true ),
				height : this.$elWrapper.outerHeight( true )
			};

		},
		_layout : function() {
			
			this.$slideWrapper = $( '<div class="sl-slides-wrapper" />' );
			
			// wrap the slides
			this.$slides.wrapAll( this.$slideWrapper ).each( function( i ) {
				
				var $slide = $( this ),
					// vertical || horizontal
					orientation = $slide.data( 'orientation' );
					
				$slide.addClass( 'sl-slide-' + orientation )
					  .children()
					  .wrapAll( '<div class="sl-content-wrapper" />' )
					  .wrapAll( '<div class="sl-content" />' );
			
			} );
			
			// set the right size of the slider/slides for the current window size
			this._setSize();
			// show first slide
			this.$slides.eq( this.current ).show();
			
		},
		_navigate : function( dir, pos ) {
			
			if( this.isAnimating || this.slidesCount < 2 ) {
			
				return false;
			
			}

			this.isAnimating = true;

			var self = this,
				$currentSlide = this.$slides.eq( this.current );

			// if position is passed
			if( pos !== undefined ) {

				this.current = pos;

			}
			// if not check the boundaries
			else if( dir === 'next' ) {

				this.current = this.current < this.slidesCount - 1 ? ++this.current : 0;

			}
			else if( dir === 'prev' ) {

				this.current = this.current > 0 ? --this.current : this.slidesCount - 1;

			}

			this.options.onBeforeChange( $currentSlide, this.current );
			
			// next slide to be shown
			var $nextSlide = this.$slides.eq( this.current ),
				// the slide we want to cut and animate
				$movingSlide = ( dir === 'next' ) ? $currentSlide : $nextSlide,
				
				// the following are the data attrs set for each slide
				configData = $movingSlide.data(),
				config = {};
			
			config.orientation = configData.orientation || 'horizontal',
			config.slice1angle = configData.slice1Rotation || 0,
			config.slice1scale = configData.slice1Scale || 1,
			config.slice2angle = configData.slice2Rotation || 0,
			config.slice2scale = configData.slice2Scale || 1;
				
			this._validateValues( config );
			
			var cssStyle = config.orientation === 'horizontal' ? {
					marginTop : -this.size.height / 2
				} : {
					marginLeft : -this.size.width / 2
				},
				// default slide's slices style
				resetStyle = {
					'transform' : 'translate(0%,0%) rotate(0deg) scale(1)',
					opacity : 1 
				},
				// slice1 style
				slice1Style	= config.orientation === 'horizontal' ? {
					'transform' : 'translateY(-' + this.options.translateFactor + '%) rotate(' + config.slice1angle + 'deg) scale(' + config.slice1scale + ')'
				} : {
					'transform' : 'translateX(-' + this.options.translateFactor + '%) rotate(' + config.slice1angle + 'deg) scale(' + config.slice1scale + ')'
				},
				// slice2 style
				slice2Style	= config.orientation === 'horizontal' ? {
					'transform' : 'translateY(' + this.options.translateFactor + '%) rotate(' + config.slice2angle + 'deg) scale(' + config.slice2scale + ')'
				} : {
					'transform' : 'translateX(' + this.options.translateFactor + '%) rotate(' + config.slice2angle + 'deg) scale(' + config.slice2scale + ')'
				};
			
			if( this.options.optOpacity ) {
			
				slice1Style.opacity = 0;
				slice2Style.opacity = 0;
			
			}
			
			// we are adding the classes sl-trans-elems and sl-trans-back-elems to the slide that is either coming "next"
			// or going "prev" according to the direction.
			// the idea is to make it more interesting by giving some animations to the respective slide's elements
			//( dir === 'next' ) ? $nextSlide.addClass( 'sl-trans-elems' ) : $currentSlide.addClass( 'sl-trans-back-elems' );
			
			$currentSlide.removeClass( 'sl-trans-elems' );

			var transitionProp = {
				'transition' : 'all ' + this.options.speed + 'ms ease-in-out'
			};

			// add the 2 slices and animate them
			$movingSlide.css( 'z-index', this.slidesCount )
						.find( 'div.sl-content-wrapper' )
						.wrap( $( '<div class="sl-content-slice" />' ).css( transitionProp ) )
						.parent()
						.cond(
							dir === 'prev', 
							function() {
							
								var slice = this;
								this.css( slice1Style );
								setTimeout( function() {
									
									slice.css( resetStyle );

								}, 50 );
										 
							}, 
							function() {
								
								var slice = this;
								setTimeout( function() {
									
									slice.css( slice1Style );

								}, 50 );
						
							}
						)
						.clone()
						.appendTo( $movingSlide )
						.cond(
							dir === 'prev', 
							function() {
								
								var slice = this;
								this.css( slice2Style );
								setTimeout( function() {

									$currentSlide.addClass( 'sl-trans-back-elems' );

									if( self.support ) {

										slice.css( resetStyle ).on( self.transEndEventName, function() {

											self._onEndNavigate( slice, $currentSlide, dir );

										} );

									}
									else {

										self._onEndNavigate( slice, $currentSlide, dir );

									}

								}, 50 );
						
							},
							function() {
								
								var slice = this;
								setTimeout( function() {

									$nextSlide.addClass( 'sl-trans-elems' );
									
									if( self.support ) {

										slice.css( slice2Style ).on( self.transEndEventName, function() {

											self._onEndNavigate( slice, $currentSlide, dir );

										} );

									}
									else {

										self._onEndNavigate( slice, $currentSlide, dir );

									}

								}, 50 );
								
							}
						)
						.find( 'div.sl-content-wrapper' )
						.css( cssStyle );
			
			$nextSlide.show();
			
		},
		_validateValues : function( config ) {
			
			// OK, so we are restricting the angles and scale values here.
			// This is to avoid the slices wrong sides to be shown.
			// you can adjust these values as you wish but make sure you also ajust the
			// paddings of the slides and also the options.translateFactor value and scale data attrs
			if( config.slice1angle > this.options.maxAngle || config.slice1angle < -this.options.maxAngle ) {
				
				config.slice1angle = this.options.maxAngle;
			
			}
			if( config.slice2angle > this.options.maxAngle  || config.slice2angle < -this.options.maxAngle ) {
				
				config.slice2angle = this.options.maxAngle;
			
			}
			if( config.slice1scale > this.options.maxScale || config.slice1scale <= 0 ) {
			
				config.slice1scale = this.options.maxScale;
			
			}
			if( config.slice2scale > this.options.maxScale || config.slice2scale <= 0 ) {
				
				config.slice2scale = this.options.maxScale;
			
			}
			if( config.orientation !== 'vertical' && config.orientation !== 'horizontal' ) {
			
				config.orientation = 'horizontal'
			
			}
			
		},
		_onEndNavigate : function( $slice, $oldSlide, dir ) {
			
			// reset previous slide's style after next slide is shown
			var $slide = $slice.parent(),
				removeClasses = 'sl-trans-elems sl-trans-back-elems';
			
			// remove second slide's slice
			$slice.remove();
			// unwrap..
			$slide.css( 'z-index', 1 )
				  .find( 'div.sl-content-wrapper' )
				  .unwrap();
			
			// hide previous current slide
			$oldSlide.hide().removeClass( removeClasses );
			$slide.removeClass( removeClasses );
			// now we can navigate again..
			this.isAnimating = false;
			this.options.onAfterChange( $slide, this.current );
			
		},
		_setSize : function() {
		
			// the slider and content wrappers will have the window's width and height
			var cssStyle = {
				width : this.size.width,
				height : this.size.height
			};
			
			this.$el.css( cssStyle ).find( 'div.sl-content-wrapper' ).css( cssStyle );
		
		},
		_loadEvents : function() {
			
			var self = this;
			
			$window.on( 'debouncedresize.slitslider', function( event ) {
				
				// update size values
				self._getSize();
				// set the sizes again
				self._setSize();
				
			} );

			if ( this.options.keyboard ) {
				
				$document.on( 'keydown.slitslider', function(e) {

					var keyCode = e.keyCode || e.which,
						arrow = {
							left: 37,
							up: 38,
							right: 39,
							down: 40
						};

					switch (keyCode) {
						
						case arrow.left :

							self._stopSlideshow();
							self._navigate( 'prev' );
							break;
						
						case arrow.right :
							
							self._stopSlideshow();
							self._navigate( 'next' );
							break;

					}

				} );

			}
		
		},
		_startSlideshow: function() {

			var self = this;

			this.slideshow = setTimeout( function() {

				self._navigate( 'next' );

				if ( self.options.autoplay ) {

					self._startSlideshow();

				}

			}, this.options.interval );

		},
		_stopSlideshow: function() {

			if ( this.options.autoplay ) {

				clearTimeout( this.slideshow );
				this.isPlaying = false;
				this.options.autoplay = false;

			}

		},
		_destroy : function( callback ) {
			
			this.$el.off( '.slitslider' ).removeData( 'slitslider' );
			$window.off( '.slitslider' );
			$document.off( '.slitslider' );
			this.$slides.each( function( i ) {

				var $slide = $( this ),
					$content = $slide.find( 'div.sl-content' ).children();

				$content.appendTo( $slide );
				$slide.children( 'div.sl-content-wrapper' ).remove();

			} );
			this.$slides.unwrap( this.$slideWrapper ).hide();
			this.$slides.eq( 0 ).show();
			if( callback ) {

				callback.call();

			}

		},
		// public methos: adds more slides to the slider
		add : function( $slides, callback ) {

			this.$slides = this.$slides.add( $slides );

			var self = this;
			
			
			$slides.each( function( i ) {

				var $slide = $( this ),
					// vertical || horizontal
					orientation = $slide.data( 'orientation' );

				$slide.hide().addClass( 'sl-slide-' + orientation )
					  .children()
					  .wrapAll( '<div class="sl-content-wrapper" />' )
					  .wrapAll( '<div class="sl-content" />' )
					  .end()
					  .appendTo( self.$el.find( 'div.sl-slides-wrapper' ) );

			} );

			this._setSize();

			this.slidesCount = this.$slides.length;
			
			if ( callback ) {

				callback.call( $items );

			}

		},
		// public method: shows next slide
		next : function() {

			this._stopSlideshow();
			this._navigate( 'next' );

		},
		// public method: shows previous slide
		previous : function() {

			this._stopSlideshow();
			this._navigate( 'prev' );

		},
		// public method: goes to a specific slide
		jump : function( pos ) {

			pos -= 1;

			if( pos === this.current || pos >= this.slidesCount || pos < 0 ) {

				return false;

			}

			this._stopSlideshow();
			this._navigate( pos > this.current ? 'next' : 'prev', pos );

		},
		// public method: starts the slideshow
		// any call to next(), previous() or jump() will stop the slideshow
		play : function() {

			if( !this.isPlaying ) {

				this.isPlaying = true;

				this._navigate( 'next' );
				this.options.autoplay = true;
				this._startSlideshow();

			}

		},
		// public method: pauses the slideshow
		pause : function() {

			if( this.isPlaying ) {

				this._stopSlideshow();

			}

		},
		// public method: check if isAnimating is true
		isActive : function() {

			return this.isAnimating;

		},
		// publicc methos: destroys the slicebox instance
		destroy : function( callback ) {

			this._destroy( callback );
		
		}

	};
	
	var logError = function( message ) {

		if ( window.console ) {

			window.console.error( message );
		
		}

	};
	
	$.fn.slitslider = function( options ) {

		var self = $.data( this, 'slitslider' );
		
		if ( typeof options === 'string' ) {
			
			var args = Array.prototype.slice.call( arguments, 1 );
			
			this.each(function() {
			
				if ( !self ) {

					logError( "cannot call methods on slitslider prior to initialization; " +
					"attempted to call method '" + options + "'" );
					return;
				
				}
				
				if ( !$.isFunction( self[options] ) || options.charAt(0) === "_" ) {

					logError( "no such method '" + options + "' for slitslider self" );
					return;
				
				}
				
				self[ options ].apply( self, args );
			
			});
		
		} 
		else {
		
			this.each(function() {
				
				if ( self ) {

					self._init();
				
				}
				else {

					self = $.data( this, 'slitslider', new $.Slitslider( options, this ) );
				
				}

			});
		
		}
		
		return self;
		
	};
	
} )( jQuery, window );jQuery(document).ready(function($) {

							
	//animate effect	
	$(".e_flash").hover(
		function () {
		$(this).addClass("animated flash");
		},
		function () {
		$(this).removeClass("animated flash");
		}
	);
	$(".e_bounce").hover(
		function () {
		$(this).addClass("animated bounce");
		},
		function () {
		$(this).removeClass("animated bounce");
		}
	);
	
	$(".e_shake").hover(
		function () {
		$(this).addClass("animated shake");
		},
		function () {
		$(this).removeClass("animated shake");
		}
	);
	$(".e_tada").hover(
		function () {
		$(this).addClass("animated tada");
		},
		function () {
		$(this).removeClass("animated tada");
		}
	);
	$(".e_swing").hover(
		function () {
		$(this).addClass("animated swing");
		},
		function () {
		$(this).removeClass("animated swing");
		}
	);
	$(".e_wobble").hover(
		function () {
		$(this).addClass("animated wobble");
		},
		function () {
		$(this).removeClass("animated wobble");
		}
	);
	$(".e_wiggle").hover(
		function () {
		$(this).addClass("animated wiggle");
		},
		function () {
		$(this).removeClass("animated wiggle");
		}
	);
	$(".e_pulse").hover(
		function () {
		$(this).addClass("animated pulse");
		},
		function () {
		$(this).removeClass("animated pulse");
		}
	);
	
	
	$(".e_flip").hover(
		function () {
		$(this).addClass("animated flip");
		},
		function () {
		$(this).removeClass("animated flip");
		}
	);
	$(".e_flipInX").hover(
		function () {
		$(this).addClass("animated flipInX");
		},
		function () {
		$(this).removeClass("animated flipInX");
		}
	);
	$(".e_flipOutX").hover(
		function () {
		$(this).addClass("animated flipOutX");
		},
		function () {
		$(this).removeClass("animated flipOutX");
		}
	);
	$(".e_flipInY").hover(
		function () {
		$(this).addClass("animated flipInY");
		},
		function () {
		$(this).removeClass("animated flipInY");
		}
	);
	$(".e_flipOutY").hover(
		function () {
		$(this).addClass("animated flipOutY");
		},
		function () {
		$(this).removeClass("animated flipOutY");
		}
	);	
	
	//Fading entrances
	$(".e_fadeIn").hover(
		function () {
		$(this).addClass("animated fadeIn");
		},
		function () {
		$(this).removeClass("animated fadeIn");
		}
	);		
	$(".e_fadeInUp").hover(
		function () {
		$(this).addClass("animated fadeInUp");
		},
		function () {
		$(this).removeClass("animated fadeInUp");
		}
	);	
	$(".e_fadeInDown").hover(
		function () {
		$(this).addClass("animated fadeInDown");
		},
		function () {
		$(this).removeClass("animated fadeInDown");
		}
	);
	$(".e_fadeInLeft").hover(
		function () {
		$(this).addClass("animated fadeInLeft");
		},
		function () {
		$(this).removeClass("animated fadeInLeft");
		}
	);
	$(".e_fadeInRight").hover(
		function () {
		$(this).addClass("animated fadeInRight");
		},
		function () {
		$(this).removeClass("animated fadeInRight");
		}
	);	
	$(".e_fadeInUpBig").hover(
		function () {
		$(this).addClass("animated fadeInUpBig");
		},
		function () {
		$(this).removeClass("animated fadeInUpBig");
		}
	);		
	$(".e_fadeInUpBig").hover(
		function () {
		$(this).addClass("animated fadeInUpBig");
		},
		function () {
		$(this).removeClass("animated fadeInUpBig");
		}
	);		
	$(".e_fadeInDownBig").hover(
		function () {
		$(this).addClass("animated fadeInDownBig");
		},
		function () {
		$(this).removeClass("animated fadeInDownBig");
		}
	);	
	$(".e_fadeInLeftBig").hover(
		function () {
		$(this).addClass("animated fadeInLeftBig");
		},
		function () {
		$(this).removeClass("animated fadeInLeftBig");
		}
	);	
	$(".e_fadeInRightBig").hover(
		function () {
		$(this).addClass("animated fadeInRightBig");
		},
		function () {
		$(this).removeClass("animated fadeInRightBig");
		}
	);	
	
	
	//Fading exits
	$(".e_fadeOut").hover(
		function () {
		$(this).addClass("animated fadeOut");
		},
		function () {
		$(this).removeClass("animated fadeOut");
		}
	);	
	$(".e_fadeOutUp").hover(
		function () {
		$(this).addClass("animated fadeOutUp");
		},
		function () {
		$(this).removeClass("animated fadeOutUp");
		}
	);	
	$(".e_fadeOutDown").hover(
		function () {
		$(this).addClass("animated fadeOutDown");
		},
		function () {
		$(this).removeClass("animated fadeOutDown");
		}
	);		
	$(".e_fadeOutLeft").hover(
		function () {
		$(this).addClass("animated fadeOutLeft");
		},
		function () {
		$(this).removeClass("animated fadeOutLeft");
		}
	);		
	$(".e_fadeOutRight").hover(
		function () {
		$(this).addClass("animated fadeOutRight");
		},
		function () {
		$(this).removeClass("animated fadeOutRight");
		}
	);	
	$(".e_fadeOutUpBig").hover(
		function () {
		$(this).addClass("animated fadeOutUpBig");
		},
		function () {
		$(this).removeClass("animated fadeOutUpBig");
		}
	);	
	$(".e_fadeOutDownBig").hover(
		function () {
		$(this).addClass("animated fadeOutDownBig");
		},
		function () {
		$(this).removeClass("animated fadeOutDownBig");
		}
	);	
	$(".e_fadeOutLeftBig").hover(
		function () {
		$(this).addClass("animated fadeOutLeftBig");
		},
		function () {
		$(this).removeClass("animated fadeOutLeftBig");
		}
	);	
	$(".e_fadeOutRightBig").hover(
		function () {
		$(this).addClass("animated fadeOutRightBig");
		},
		function () {
		$(this).removeClass("animated fadeOutRightBig");
		}
	);	
	
	
	//Bouncing entrances
	$(".e_bounceIn").hover(
		function () {
		$(this).addClass("animated bounceIn");
		},
		function () {
		$(this).removeClass("animated bounceIn");
		}
	);
	$(".e_bounceInDown").hover(
		function () {
		$(this).addClass("animated bounceInDown");
		},
		function () {
		$(this).removeClass("animated bounceInDown");
		}
	);
	$(".e_bounceInUp").hover(
		function () {
		$(this).addClass("animated bounceInUp");
		},
		function () {
		$(this).removeClass("animated bounceInUp");
		}
	);	
	$(".e_bounceInLeft").hover(
		function () {
		$(this).addClass("animated bounceInLeft");
		},
		function () {
		$(this).removeClass("animated bounceInLeft");
		}
	);
	$(".e_bounceInRight").hover(
		function () {
		$(this).addClass("animated bounceInRight");
		},
		function () {
		$(this).removeClass("animated bounceInRight");
		}
	);
	
	
	//Bouncing exits
	$(".e_bounceOut").hover(
		function () {
		$(this).addClass("animated bounceOut");
		},
		function () {
		$(this).removeClass("animated bounceOut");
		}
	);
	$(".e_bounceOutDown").hover(
		function () {
		$(this).addClass("animated bounceOutDown");
		},
		function () {
		$(this).removeClass("animated bounceOutDown");
		}
	);
	$(".e_bounceOutUp").hover(
		function () {
		$(this).addClass("animated bounceOutUp");
		},
		function () {
		$(this).removeClass("animated bounceOutUp");
		}
	);	
	$(".e_bounceOutLeft").hover(
		function () {
		$(this).addClass("animated bounceOutLeft");
		},
		function () {
		$(this).removeClass("animated bounceOutLeft");
		}
	);
	$(".e_bounceOutRight").hover(
		function () {
		$(this).addClass("animated bounceOutRight");
		},
		function () {
		$(this).removeClass("animated bounceOutRight");
		}
	);
	
	
	//Rotating entrances	
	$(".e_rotateIn").hover(
		function () {
		$(this).addClass("animated rotateIn");
		},
		function () {
		$(this).removeClass("animated rotateIn");
		}
	);
	$(".e_rotateInDownLeft").hover(
		function () {
		$(this).addClass("animated rotateInDownLeft");
		},
		function () {
		$(this).removeClass("animated rotateInDownLeft");
		}
	);
	$(".e_rotateInDownRight").hover(
		function () {
		$(this).addClass("animated rotateInDownRight");
		},
		function () {
		$(this).removeClass("animated rotateInDownRight");
		}
	);
	$(".e_rotateInUpRight").hover(
		function () {
		$(this).addClass("animated rotateInUpRight");
		},
		function () {
		$(this).removeClass("animated rotateInUpRight");
		}
	);
	$(".e_rotateInUpLeft").hover(
		function () {
		$(this).addClass("animated rotateInUpLeft");
		},
		function () {
		$(this).removeClass("animated rotateInUpLeft");
		}
	);
	
	
	//Rotating exits
	$(".e_rotateOut").hover(
		function () {
		$(this).addClass("animated rotateOut");
		},
		function () {
		$(this).removeClass("animated rotateOut");
		}
	);
	$(".e_rotateOutDownLeft").hover(
		function () {
		$(this).addClass("animated rotateOutDownLeft");
		},
		function () {
		$(this).removeClass("animated rotateOutDownLeft");
		}
	);
	$(".e_rotateOutDownRight").hover(
		function () {
		$(this).addClass("animated rotateOutDownRight");
		},
		function () {
		$(this).removeClass("animated rotateOutDownRight");
		}
	);	
	$(".e_rotateOutUpLeft").hover(
		function () {
		$(this).addClass("animated rotateOutUpLeft");
		},
		function () {
		$(this).removeClass("animated rotateOutUpLeft");
		}
	);
	$(".e_rotateOutUpRight").hover(
		function () {
		$(this).addClass("animated rotateOutUpRight");
		},
		function () {
		$(this).removeClass("animated rotateOutUpRight");
		}
	);
	
	
	//Lightspeed
	$(".e_lightSpeedIn").hover(
		function () {
		$(this).addClass("animated lightSpeedIn");
		},
		function () {
		$(this).removeClass("animated lightSpeedIn");
		}
	);
	$(".e_lightSpeedOut").hover(
		function () {
		$(this).addClass("animated lightSpeedOut");
		},
		function () {
		$(this).removeClass("animated lightSpeedOut");
		}
	);
	
	//specials
	$(".e_hinge").hover(
		function () {
		$(this).addClass("animated hinge");
		},
		function () {
		$(this).removeClass("animated hinge");
		}
	);
	$(".e_rollIn").hover(
		function () {
		$(this).addClass("animated rollIn");
		},
		function () {
		$(this).removeClass("animated rollIn");
		}
	);	
	$(".e_rollOut").hover(
		function () {
		$(this).addClass("animated rollOut");
		},
		function () {
		$(this).removeClass("animated rollOut");
		}
	);



});/*global jQuery:false */
jQuery(document).ready(function($) {
"use strict";


	(function() {

		var $menu = $('.navigation nav'),
			optionsList = '<option value="" selected>Go to..</option>';

		$menu.find('li').each(function() {
			var $this   = $(this),
				$anchor = $this.children('a'),
				depth   = $this.parents('ul').length - 1,
				indent  = '';

			if( depth ) {
				while( depth > 0 ) {
					indent += ' - ';
					depth--;
				}

			}
			$(".nav li").parent().addClass("bold");

			optionsList += '<option value="' + $anchor.attr('href') + '">' + indent + ' ' + $anchor.text() + '</option>';
		}).end()
		.after('<select class="selectmenu">' + optionsList + '</select>');
		
		$('select.selectmenu').on('change', function() {
			window.location = $(this).val();
		});
		
	})();

	
		  $('.toggle-link').each(function() {
			$(this).click(function() {
			  var state = 'open'; //assume target is closed & needs opening
			  var target = $(this).attr('data-target');
			  var targetState = $(this).attr('data-target-state');
			  
			  //allows trigger link to say target is open & should be closed
			  if (typeof targetState !== 'undefined' && targetState !== false) {
				state = targetState;
			  }
			  
			  if (state == 'undefined') {
				state = 'open';
			  }
			  
			  $(target).toggleClass('toggle-link-'+ state);
			  $(this).toggleClass(state);      
			});
		  });
	
		//add some elements with animate effect

		$(".big-cta").hover(
			function () {
			$('.cta a').addClass("animated shake");
			},
			function () {
			$('.cta a').removeClass("animated shake");
			}
		);
		$(".box").hover(
			function () {
			$(this).find('.icon').addClass("animated pulse");
			$(this).find('.text').addClass("animated fadeInUp");
			$(this).find('.image').addClass("animated fadeInDown");
			},
			function () {
			$(this).find('.icon').removeClass("animated pulse");
			$(this).find('.text').removeClass("animated fadeInUp");
			$(this).find('.image').removeClass("animated fadeInDown");
			}
		);
		
		
		$('.accordion').on('show', function (e) {
		
			$(e.target).prev('.accordion-heading').find('.accordion-toggle').addClass('active');
			$(e.target).prev('.accordion-heading').find('.accordion-toggle i').removeClass('icon-plus');
			$(e.target).prev('.accordion-heading').find('.accordion-toggle i').addClass('icon-minus');
		});
		
		$('.accordion').on('hide', function (e) {
			$(this).find('.accordion-toggle').not($(e.target)).removeClass('active');
			$(this).find('.accordion-toggle i').not($(e.target)).removeClass('icon-minus');
			$(this).find('.accordion-toggle i').not($(e.target)).addClass('icon-plus');
		});	


		
		//Navi hover
		$('ul.nav li.dropdown').hover(function () {
			$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn();
		}, function () {
			$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut();
		});
		
		// tooltip
		$('.social-network li a, .options_box .color a').tooltip();

		// fancybox
		$(".fancybox").fancybox({				
				padding : 0,
				autoResize: true,
				beforeShow: function () {
					this.title = $(this.element).attr('title');
					this.title = '<h4>' + this.title + '</h4>' + '<p>' + $(this.element).parent().find('img').attr('alt') + '</p>';
				},
				helpers : {
					title : { type: 'inside' },
				}
			});

		
		//scroll to top
		$(window).scroll(function(){
			if ($(this).scrollTop() > 100) {
				$('.scrollup').fadeIn();
				} else {
				$('.scrollup').fadeOut();
			}
		});
		$('.scrollup').click(function(){
			$("html, body").animate({ scrollTop: 0 }, 1000);
				return false;
		});
	
		//nivo slider
		$('.nivo-slider').nivoSlider({
			effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
			slices: 15, // For slice animations
			boxCols: 8, // For box animations
			boxRows: 4, // For box animations
			animSpeed: 500, // Slide transition speed
			pauseTime: 5000, // How long each slide will show
			startSlide: 0, // Set starting Slide (0 index)
			directionNav: true, // Next & Prev navigation
			controlNav: false, // 1,2,3... navigation
			controlNavThumbs: false, // Use thumbnails for Control Nav
			pauseOnHover: true, // Stop animation while hovering
			manualAdvance: false, // Force manual transitions
			prevText: '', // Prev directionNav text
			nextText: '', // Next directionNav text
			randomStart: false, // Start on a random slide
			beforeChange: function(){}, // Triggers before a slide transition
			afterChange: function(){}, // Triggers after a slide transition
			slideshowEnd: function(){}, // Triggers after all slides have been shown
			lastSlide: function(){}, // Triggers when last slide is shown
			afterLoad: function(){} // Triggers when slider has loaded
		});
				
		//slitslider				
		var Page = (function() {

			var $nav = $( '#nav-dots > span' ),
				slitslider = $( '#slider' ).slitslider( {
				onBeforeChange : function( slide, pos ) {
				$nav.removeClass( 'nav-dot-current' );
				$nav.eq( pos ).addClass( 'nav-dot-current' );
				}
			} ),

			init = function() {
				initEvents();
			},
			initEvents = function() {
				$nav.each( function( i ) {
					$( this ).on( 'click', function() {
					var $dot = $( this );
			
					if( !slitslider.isActive() ) {
						$nav.removeClass( 'nav-dot-current' );
						$dot.addClass( 'nav-dot-current' );
					}
										
					slitslider.jump( i + 1 );
					return false;
									
					} );
									
				} );

			};

			return { init : init };
		})();

		Page.init();
  
  $(".about-person").fancybox({
      maxWidth	  : 800,
      maxHeight	  : 600,
      fitToView	  : false,
      width		  : '70%',
      height	  : '70%',
      autoSize	  : false,
      closeClick  : false,
      openEffect  : 'none',
      closeEffect : 'none'
  }); 

});$(function(){
  $('ul.dropdown-menu').find('a:contains("Catering")').first().hide();
});document.addEventListener("DOMContentLoaded", () => {
	console.log("PAGE LOADED - EVENT LISTENeR -  TEST");
    SquareHook.FormSubmission.Initialize();console.log("POST CALLED INITIALIZE - TEST");
})(function(a,l,n,k){"use strict";var c="photosetGrid",g={width:"100%",gutter:"0px",highresLinks:false,lowresWidth:500,rel:"",onInit:function(){},onComplete:function(){}};function i(b,d){this.element=b;this.options=a.extend({},g,d);this._defaults=g;this._name=c;this.init()}i.prototype={init:function(){this.options.onInit();this._setupRows(this.element,this.options);this._setupColumns(this.element,this.options)},_callback:function(){this.options.onComplete()},_setupRows:function(b,e){if(e.layout)this.layout=e.layout;else if(a(b).attr("data-layout"))this.layout=a(b).attr("data-layout");else{for(var c="",h=1,f=0;f<a(b).find("img").length;f++)c=c+h.toString();this.layout=c}this.rows=this.layout.split("");for(var g in this.rows)this.rows[g]=parseInt(this.rows[g],10);var i=a(b).find("img"),d=0;a.each(this.rows,function(e,b){var c=d,a=d+b;i.slice(c,a).wrapAll('<div class="photoset-row cols-'+b+'"></div>');d=a});a(b).find(".photoset-row:not(:last-child)").css({"margin-bottom":e.gutter})},_setupColumns:function(b,c){var e=this,d=function(){var g=a(b).find(".photoset-row"),d=a(b).find("img");if(c.highresLinks){d.each(function(){var b;if(a(this).attr("data-highres"))b=a(this).attr("data-highres");else b=a(this).attr("src");a(this).wrapAll('<a href="'+b+'" class="photoset-cell highres-link" />')});c.rel&&d.parent().attr("rel",c.rel)}else d.each(function(){a(this).wrapAll('<div class="photoset-cell" />')});var h=a(b).find(".photoset-cell"),i=a(b).find(".cols-1 .photoset-cell"),j=a(b).find(".cols-2 .photoset-cell"),k=a(b).find(".cols-3 .photoset-cell"),m=a(b).find(".cols-4 .photoset-cell"),n=a(b).find(".cols-5 .photoset-cell");a(b).css({width:c.width});g.css({clear:"left",display:"block",overflow:"hidden"});h.css({"float":"left",display:"block","line-height":"0","-webkit-box-sizing":"border-box","-moz-box-sizing":"border-box","box-sizing":"border-box"});d.css({width:"100%",height:"auto"});i.css({width:"100%"});j.css({width:"50%"});k.css({width:"33.3%"});m.css({width:"25%"});n.css({width:"20%"});var f=parseInt(c.gutter,10);a(b).find(".photoset-cell:not(:last-child)").css({"padding-right":f/2+"px"});a(b).find(".photoset-cell:not(:first-child)").css({"padding-left":f/2+"px"});function e(){var d=a(b).width().toString();if(d!==a(b).attr("data-width")){g.each(function(){var b=a(this).find("img:eq(0)");a(this).find("img").each(function(){var d=a(this);if(d.height()<b.height())b=a(this);d.width()>c.lowresWidth&&d.attr("data-highres")&&d.attr("src",d.attr("data-highres"))});var d=b.height(),e=Math.floor(d*.025);a(this).height(d-e);a(this).find("img").each(function(){var b=(d-a(this).height())*.5+"px";a(this).css({"margin-top":b})})});a(b).attr("data-width",d)}}e();a(l).on("resize",function(){e()})};a(b).imagesLoaded(function(){d();e._callback()})}};a.fn[c]=function(b){return this.each(function(){!a.data(this,"plugin_"+c)&&a.data(this,"plugin_"+c,new i(this,b))})};
/*!
     * jQuery imagesLoaded plugin v2.1.1
     * http://github.com/desandro/imagesloaded
     *
     * MIT License. by Paul Irish et al.
     */
var j="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";a.fn.imagesLoaded=function(d){var e=this,b=a.isFunction(a.Deferred)?a.Deferred():0,n=a.isFunction(b.notify),c=e.find("img").add(e.filter("img")),h=[],i=[],f=[];a.isPlainObject(d)&&a.each(d,function(c,a){if(c==="callback")d=a;else b&&b[c](a)});function m(){var h=a(i),g=a(f);if(b)if(f.length)b.reject(c,h,g);else b.resolve(c);a.isFunction(d)&&d.call(e,c,h,g)}function l(a){g(a.target,a.type==="error")}function g(d,e){if(d.src===j||a.inArray(d,h)!==-1)return;h.push(d);if(e)f.push(d);else i.push(d);a.data(d,"imagesLoaded",{isBroken:e,src:d.src});n&&b.notifyWith(a(d),[e,c,a(i),a(f)]);if(c.length===h.length){setTimeout(m);c.unbind(".imagesLoaded",l)}}if(!c.length)m();else c.bind("load.imagesLoaded error.imagesLoaded",l).each(function(e,b){var d=b.src,c=a.data(b,"imagesLoaded");if(c&&c.src===d){g(b,c.isBroken);return}if(b.complete&&b.naturalWidth!==k){g(b,b.naturalWidth===0||b.naturalHeight===0);return}if(b.readyState||b.complete){b.src=j;b.src=d}});return b?b.promise(e):e};var h=a.event,d,m={_:0},b=0,f,e;d=h.special.throttledresize={setup:function(){a(this).on("resize",d.handler)},teardown:function(){a(this).off("resize",d.handler)},handler:function(i,c){var g=this,j=arguments;f=true;if(!e){setInterval(function(){b++;if(b>d.threshold&&f||c){i.type="throttledresize";h.dispatch.apply(g,j);f=false;b=0}if(b>9){a(m).stop();e=false;b=0}},30);e=true}},threshold:0}})(jQuery,window,document);
/*! FormSubmission.js
* Script to submit form on preview and published pages.
* 
*/
var SquareHook=SquareHook||{};SquareHook.FormSubmission=function(b){var a={};a.BaseUrl="/Forms/Form/";a.FieldType={Text:"Text",Name:"Name",Email:"Email",Message:"Message",Address:"Address",Hidden:"Hidden",Dropdown:"Dropdown",Checkbox:"Checkbox",Radio:"Radio",Captcha:"Captcha"};a.Initialize=function(){b(document).off("click","#formSubmit");b(document).on("click","#formSubmit",a.formSubmit)};a.formSubmit=function(h){h.preventDefault();var c=b(this).closest(".sh-form");if(c==null||c.length<=0){c=b(this).parent().parent();console.log("Failed to Find Form.")}var g=b(c).attr("id"),e=a.validateFormFields(c),d;if(e){d=a.collectFormData(c);var f={formId:g,formSubmitData:d};b.ajax({url:a.BaseUrl+"SubmitForm",type:"POST",dataType:"json",contentType:"application/json",async:false,data:JSON.stringify(f),success:function(a){if(a.Ok){b(c).parent().addClass("form-success");b(c).parent().append("<span>"+a.Results+"</span>");b(c).remove()}else{b(c).find("[class='span12 errorField']").remove();var d="<div class='span12 errorField'>"+a.Errors+"</div>";b(c).find("img").parent().parent().prepend(d)}}})}};a.collectFormData=function(d){var c=[],e;b.each(d.find(".control-label"),function(h,d){var b=a.getFieldTypeOfElement(d),g=a.getFieldNameOfElement(d,b,false),f=a.getFieldValueOfElement(d,b),e={Type:b,Name:g,Value:f};c.push(e)});b.each(d.find("[type='hidden']"),function(d,a){c.push({Type:"Hidden",Name:b(a).attr("name"),Value:b(a).val()})});return c};a.getFieldTypeOfElement=function(c){var g=b(c).parent().find("select");if(g.length>0)return a.FieldType.Dropdown;var f=b(c).parent().find(".checkbox");if(f.length>0)return a.FieldType.Checkbox;var i=b(c).parent().find(".radio");if(i.length>0)return a.FieldType.Radio;var h=b(c).parent().find("img");if(h.length>0)return a.FieldType.Captcha;var e,d=b(c).parent().find("input");if(d.length!==0){b.each(d,function(f,d){var c=a.getSubFieldType(b(d).attr("name"));e=a.getFieldType(c)});return e}else{var j=b(c).parent().find("textarea");if(b(j).length>0)return a.FieldType.Message}return""};a.getFieldNameOfElement=function(d,f,e){var c;if(f==a.FieldType.Checkbox)if(!e)c=a.getCheckboxFieldName(d);else c=b(d).html().trim();else if(f==a.FieldType.Radio)if(!e)c=a.getRadioFieldName(d);else c=b(d).html().trim();else if(f==a.FieldType.Captcha)c=a.getCaptchaFieldName(d);else c=b(d).html().trim();if(!e)if(a.getRequiredStatus(c))c=c.substring(0,c.length-1);return c};a.getCaptchaFieldName=function(d){var a=b(d).parent().find("input[type='text']");return b(a).length>0?b(a).attr("name"):"Undefined"};a.getCheckboxFieldName=function(d){var a=b(d).parent().find("input[type='checkbox']");return b(a).length>0?b(a).attr("name"):"Undefined"};a.getRadioFieldName=function(d){var a=b(d).parent().find("input[type='radio']");return b(a).length>0?b(a).attr("name"):"Undefined"};a.getFieldValueOfElement=function(d,c){var b;if(c==a.FieldType.Dropdown)b=a.getDropdownFieldValue(d);else if(c==a.FieldType.Text)b=a.getFieldValues(d);else if(c==a.FieldType.Message)b=a.getMessageFieldValue(d);else if(c==a.FieldType.Name)b=a.getFieldValues(d);else if(c==a.FieldType.Address)b=a.getFieldValues(d);else if(c==a.FieldType.Email)b=a.getFieldValues(d);else if(c==a.FieldType.Checkbox)b=a.getCheckboxFieldValue(d);else if(c==a.FieldType.Radio)return b=a.getRadioFieldValue(d);else if(c==a.FieldType.Captcha)return b=a.getFieldValues(d);return b};a.getDropdownFieldValue=function(e){var c=b(e).parent().find("select"),a=b(c).children(":selected");if(b(a).length>0){var d=b(c).children(":selected").index();return d==0?"":b(a).html().trim()}};a.getFieldValues=function(e){var a,c=[],d=b(e).parent().find("input");b.each(d,function(e,d){a=b(d).val();c.push(a)});return c};a.getMessageFieldValue=function(e){var a,c=[],d=b(e).parent().find("textarea");b.each(d,function(e,d){a=b(d).val();c.push(a)});return c};a.getCheckboxFieldValue=function(e){var a,c=[],d=b(e).parent().find("input[type='checkbox']");b.each(d,function(e,d){a=b(d).is(":checked")?b(d).val():null;a!=null&&c.push(a)});return c};a.getRadioFieldValue=function(e){var a,c=[],d=b(e).parent().find("input[type='radio']");b.each(d,function(e,d){a=b(d).is(":checked")?b(d).val():null;a!=null&&c.push(a)});return c};a.validateFormFields=function(d){var c=true;b.each(d.find(".control-label"),function(i,d){b(d).parent().find("[class='span12 errorField']").remove();var g=a.getFieldTypeOfElement(d),f=a.getFieldNameOfElement(d,g,true),e;if(g==a.FieldType.Captcha)e=true;else e=a.getRequiredStatus(f);var h=true;if(f!==null)if(g==a.FieldType.Dropdown)h=a.setDropdownValidationStyle(d,f,e);else if(g==a.FieldType.Radio)h=a.setRadioValidationStyle(d,f,e);else if(g==a.FieldType.Checkbox)h=a.setCheckboxValidationStyle(d,f,e);else if(g==a.FieldType.Message)h=a.setMessageValidationStyle(d,f,e);else if(g==a.FieldType.Captcha)h=a.setCaptchaValidationStyle(d,f,e);else h=a.setValidationStyle(d,f,e);c=h&&c});return c};a.setRadioValidationStyle=function(g,d,f){var e=true;if(f){var a=b(g).parent().find("input[type='radio']");b(a).parent().parent().find("[class='errorField']").remove();var c=false;b.each(a,function(d,a){selectdValue=b(a).is(":checked")?true:null;if(selectdValue!=null)c=true});if(!c){b(a).parent().parent().prepend("<div class='errorField'>"+d.substring(0,d.length-1)+" is required.</div>");e=false}}return e};a.setCheckboxValidationStyle=function(g,d,f){var e=true;if(f){var a=b(g).parent().find("input[type='checkbox']");b(a).parent().parent().find("[class='errorField']").remove();var c=false;b.each(a,function(d,a){selectdValue=b(a).is(":checked")?true:null;if(selectdValue!=null)c=true});if(!c){b(a).parent().parent().prepend("<div class='errorField'>"+d.substring(0,d.length-1)+" is required.</div>");e=false}}return e};a.setDropdownValidationStyle=function(g,c,f){var d=true,a=b(g).parent().find("select"),e=b(a).children(":selected").index();if(f)if(e==0){d=false;b(a).parent().find("[class='span12 errorField']").remove();b(a).parent().prepend("<div class='span12 errorField'>"+c.substring(0,c.length-1)+" is required.</div>")}return d};a.setValidationStyle=function(d,c,g){var f=true,e=b(d).parent().find("input");e.length!==0&&b.each(e,function(j,e){b(e).removeAttr("style");var h=a.getSubFieldType(b(e).attr("name")),i=a.checkFieldValidity(h,b(e).val(),g);if(!i){f=false;b(d).parent().find("[class='span12 errorField']").remove();if(h.toLowerCase()=="email"&&b(e).val()!=="")b(d).parent().prepend("<div  class='span12 errorField'>"+c.substring(0,c.length-1)+" is invalid.</div>");else b(d).parent().prepend("<div  class='span12 errorField'>"+c.substring(0,c.length-1)+" is required.</div>")}});return f};a.setCaptchaValidationStyle=function(c,f,e){var a=false,d=b(c).parent().find("input");if(e)if(d.length!==0)if(b(d).val().trim()==""){a=false;b(c).parent().find("[class='span12 errorField']").remove();b(c).parent().prepend("<div class='span12 errorField'>This field is required.</div>")}else a=true;return a};a.setMessageValidationStyle=function(d,e,j){var f=true,c=b(d).parent().find("textarea"),g=b(c).attr("name");if(g!=null){b(c).removeAttr("style");var i=a.getSubFieldType(g),h=a.checkFieldValidity(i,b(c).val(),j);if(!h){f=false;b(d).parent().find("[class='span12 errorField']").remove();b(d).parent().prepend("<div class='span12 errorField'>"+e.substring(0,e.length-1)+" is required.</div>")}}return f};a.getFieldType=function(b){return b.toLowerCase().indexOf("firstname")>=0?a.FieldType.Name:b.toLowerCase().indexOf("lastname")>=0?a.FieldType.Name:b.toLowerCase().indexOf("address")>=0?a.FieldType.Address:b.toLowerCase().indexOf("city")>=0?a.FieldType.Address:b.toLowerCase().indexOf("country")>=0?a.FieldType.Address:b.toLowerCase().indexOf("text")>=0?a.FieldType.Text:b.toLowerCase().indexOf("message")>=0?a.FieldType.Message:b.toLowerCase().indexOf("email")>=0?a.FieldType.Email:void 0};a.getSubFieldType=function(a){return a==null?"message":a.toLowerCase().indexOf("firstname")>=0?"firstname":a.toLowerCase().indexOf("lastname")>=0?"lastname":a.toLowerCase().indexOf("address")>=0?"address":a.toLowerCase().indexOf("city")>=0?"city":a.toLowerCase().indexOf("country")>=0?"country":a.toLowerCase().indexOf("text")>=0?"text":a.toLowerCase().indexOf("message")>=0?"message":a.toLowerCase().indexOf("email")>=0?"email":void 0};a.checkFieldValidity=function(d,c,e){var b=true;if(e)if(d.toLowerCase()=="firstname")b=c.trim()!==""?true:false;else if(d.toLowerCase()=="lastname")b=c.trim()!==""?true:false;else if(d.toLowerCase()=="address")b=c.trim()!==""?true:false;else if(d.toLowerCase()=="city")b=c.trim()!==""?true:false;else if(d.toLowerCase()=="text")b=c.trim()!==""?true:false;else if(d.toLowerCase()=="message")b=c.trim()!==""?true:false;else if(d.toLowerCase()=="email")b=c.trim()!==""?true:false;else b=true;if(d.toLowerCase()=="email")if(c.trim()!=="")if(!a.isValidEmailAddress(c.trim()))b=false;return b};a.isValidEmailAddress=function(a){var b=new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);return b.test(a)};a.getRequiredStatus=function(b){var a=true;try{var c=b.charAt(b.length-1);a=c=="*"?true:false;return a}catch(d){return false}};return a}(jQuery);$(document).ready(function(){SquareHook.FormSubmission.Initialize()});
/*! Carousel.js
* Script to submit Carousel on preview and published pages.
* 
*/
$(document).ready(function(){$("#carouselDiv").each(function(){$(this).carousel({interval:5e3})});$(".carousel-caption").each(function(){!($(this).find("p").text()!==""||$(this).find("h4").text()!=="")&&$(this).hide()});$(document).off("click",".carousel-indicators li");$(document).on("click",".carousel-indicators li",function(){var a=parseInt($(this).attr("data-slide-to"));$(this).parent().parent().carousel(a)});$(document).off("slid","#carouselDiv");$(document).on("slid","#carouselDiv",function(){var a=$(this).find(".item.active img").attr("alt");$(this).find(".carousel-indicators li").removeClass("active");$(this).find(".carousel-indicators [data-slide-to="+a+"]").addClass("active")});$(".carousel-inner").on("click","a",function(b){var a=$(this).attr("href");if(a==="#"){$(this).closest(".carousel").carousel("next");b.preventDefault()}});$(document).off("mouseover","#carouselDiv");$(document).on("mouseover","#carouselDiv",function(){$(this).carousel("pause")});$(document).off("mouseleave","#carouselDiv");$(document).on("mouseleave","#carouselDiv",function(){$(this).carousel({interval:5e3})})});
/*! LoadMap.js
* Script to redraw map on preview and published pages.
* Includes Google map API v3 methods to plot the map.
* 
*/
$(document).ready(function(){var a=0;$.each($(this).find(".map"),function(i,h){var c=$(this).next().val(),g=$(this).next().next().val(),b=$(this).next().next().next().val(),f=parseInt($(this).next().next().next().next().val()),e=$(this).next().next().next().next().next().val();++a;var d=$(this)[0];$(d).attr("id","map_canvas"+a);c!=null&&b!=null&&drawMap(c,b,g,f,h,e)})});drawMap=function(e,l,q,o,s,j){var b=l.split("#@#"),u=b[1]!==""?b[1]:b[2],k=e.indexOf(","),d=parseFloat(e.substring(1,k)),c=parseFloat(e.substring(k+1,e.length)),f,a,h,g;if(j=="initial")f=new google.maps.LatLng(d,c);else{a=j.split(",");if(a.length==2){h=a[0].replace("(","");g=a[1].replace(")","")}else{h=d;g=c}f=new google.maps.LatLng(h,g)}var m=b.filter(function(a){return a!==""}),p="https://maps.google.com/maps?ll="+d+","+c+"&q="+m.join(",")+"&z=10&t=m&hl=en",r=new google.maps.LatLng(d,c),n={zoom:o,center:f,mapTypeId:google.maps.MapTypeId.ROADMAP,scrollwheel:true},t=$(s).attr("id"),i;i=new google.maps.Map(document.getElementById(t),n);google.maps.event.addListenerOnce(i,"tilesloaded",function(){var a=new google.maps.Marker({position:r,map:i,title:q});google.maps.event.addListener(a,"click",function(){window.open(p)})})};
/*! BlogDisplay.js
* Script to render blog specific data
* 
*/
var SquareHook=SquareHook||{};SquareHook.BlogDisplay=function(b){var a={};a.BaseUrl="/API/Blog/";a.Initialize=function(){b(".photoset-grid-custom").photosetGrid({highresLinks:true,gutter:"10px",lowresWidth:200})};a.RecentPosts=function(d,c){b.post(a.BaseUrl+"GetRecent",{id:d},function(a){a.success&&c(a)})};a.PopularPosts=function(d,c){b.post(a.BaseUrl+"GetPopular",{id:d},function(a){a.success&&c(a)})};return a}(jQuery);$(document).ready(function(){SquareHook.BlogDisplay.Initialize()});
/*! SearchSite.js
* Script to search in site for contents.
* 
*/
var SquareHook=SquareHook||{};SquareHook.SearchSite=function(b){var a={};a.SearchForm=null;a.Initialize=function(){a.SearchForm=b("form#search");var d=a.SearchForm.attr("action");d!="/search"&&a.SearchForm.attr("action","/search");a.SearchForm.attr("method","get");var c=b("<input>").attr({type:"hidden",id:"page",name:"page",value:"1"});a.SearchForm.append(c)};return a}(jQuery);$(document).ready(function(){SquareHook.SearchSite.Initialize()});
/*! Create.js
* Script for create
*
*/
var SquareHook=SquareHook||{};SquareHook.Create=function(b){var a={};a.Button="<span class='sh-create'><a href='https://www.squarehook.com/'><img src='http://leulymedia.s3.amazonaws.com/www/2013/11/635192686877319756/squarehook-logo100.png' /><span>Create your Free Site!</span><div>Use SquareHook to create your free, mobile friendly website today.</div></a></span>";a.Initialize=function(){b("body").prepend(a.Button);b(".sh-create a").mouseover(function(){b(this).find("div").show()}).mouseout(function(){b(this).find("div").hide()})};return a}(jQuery);shMajick=false;$(document).ready(function(){shMajick&&SquareHook.Create.Initialize()});if(typeof JSON!=="object")JSON={};(function(){"use strict";function c(a){return a<10?"0"+a:a}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+c(this.getUTCMonth()+1)+"-"+c(this.getUTCDate())+"T"+c(this.getUTCHours())+":"+c(this.getUTCMinutes())+":"+c(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var h=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,f=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a,d,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},b;function g(a){f.lastIndex=0;return f.test(a)?'"'+a.replace(f,function(a){var b=i[a];return typeof b==="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function e(m,n){var h,j,i,k,l=a,f,c=n[m];if(c&&typeof c==="object"&&typeof c.toJSON==="function")c=c.toJSON(m);if(typeof b==="function")c=b.call(n,m,c);switch(typeof c){case"string":return g(c);case"number":return isFinite(c)?String(c):"null";case"boolean":case"null":return String(c);case"object":if(!c)return"null";a+=d;f=[];if(Object.prototype.toString.apply(c)==="[object Array]"){k=c.length;for(h=0;h<k;h+=1)f[h]=e(h,c)||"null";i=f.length===0?"[]":a?"[\n"+a+f.join(",\n"+a)+"\n"+l+"]":"["+f.join(",")+"]";a=l;return i}if(b&&typeof b==="object"){k=b.length;for(h=0;h<k;h+=1)if(typeof b[h]==="string"){j=b[h];i=e(j,c);i&&f.push(g(j)+(a?": ":":")+i)}}else for(j in c)if(Object.prototype.hasOwnProperty.call(c,j)){i=e(j,c);i&&f.push(g(j)+(a?": ":":")+i)}i=f.length===0?"{}":a?"{\n"+a+f.join(",\n"+a)+"\n"+l+"}":"{"+f.join(",")+"}";a=l;return i}}if(typeof JSON.stringify!=="function")JSON.stringify=function(h,c,f){var g;a="";d="";if(typeof f==="number")for(g=0;g<f;g+=1)d+=" ";else if(typeof f==="string")d=f;b=c;if(c&&typeof c!=="function"&&(typeof c!=="object"||typeof c.length!=="number"))throw new Error("JSON.stringify");return e("",{"":h})};if(typeof JSON.parse!=="function")JSON.parse=function(a,c){var b;function d(f,g){var b,e,a=f[g];if(a&&typeof a==="object")for(b in a)if(Object.prototype.hasOwnProperty.call(a,b)){e=d(a,b);if(e!==undefined)a[b]=e;else delete a[b]}return c.call(f,g,a)}a=String(a);h.lastIndex=0;if(h.test(a))a=a.replace(h,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){b=eval("("+a+")");return typeof c==="function"?d({"":b},""):b}throw new SyntaxError("JSON.parse");}})()/*! FormSubmission.js
* Script to submit form on preview and published pages.
* 
*/
var SquareHook = SquareHook || {};

SquareHook.FormSubmission = (function ($) {
    var my = {};

    my.BaseUrl = "/Forms/Form/";

    my.FieldType = {
        Text: 'Text',
        Name: 'Name',
        Email: 'Email',
        Message: 'Message',
        Address: 'Address',
        Hidden: 'Hidden',
        Dropdown: 'Dropdown',
        Checkbox: 'Checkbox',
        Radio: 'Radio',
        Captcha: 'Captcha'
    };


    my.Initialize = function (event) {
        //form submit
        $(document).off('click', "#formSubmit");
        $(document).on('click', '#formSubmit', my.formSubmit);
    };

    //Form Submit Method.
    my.formSubmit = function (e) {
        e.preventDefault(); // this will prevent from submitting the form.
        //get formid
        var parentForm = $(this).closest(".sh-form");
        if (parentForm == null || parentForm.length <= 0) { parentForm = $(this).parent().parent(); console.log("Failed to Find Form."); }

        var formId = $(parentForm).attr("id");
        //console.log("ID: " + formId);

        //validate
        var formValidFlag = my.validateFormFields(parentForm);
        var formSubmitData;
        if (formValidFlag) {
            //get field data
            formSubmitData = my.collectFormData(parentForm);
            //Save Result
            var formIDJson = { formId: formId, formSubmitData: formSubmitData };
            $.ajax({
                url: my.BaseUrl + 'SubmitForm',
                type: 'POST',
                dataType: 'json',
                contentType: 'application/json',
                async: false,
                data: JSON.stringify(formIDJson),
                success: function (result) {
                    if (result.Ok) {
                        //Display Submit Message 
                        //hide/remove form
                        $(parentForm).parent().addClass("form-success");
                        $(parentForm).parent().append("<span>" + result.Results + "</span>");
                        $(parentForm).remove();
                    }
                    else {
                        //Display error message in form for captcha
                        $(parentForm).find("[class='span12 errorField']").remove(); //clear previous error
                        var errorDisplay = "<div class='span12 errorField'>" + result.Errors + "</div>";
                        $(parentForm).find('img').parent().parent().prepend(errorDisplay);
                    }
                }
            });
        }
    };

    my.collectFormData = function (formElement) {
        /// <summary>
        /// get form data from the page.
        /// </summary>
        /// <param name="formElement">The form elements in DOM</param>

        var fieldInfo = [];
        var fieldResult;
        //iterate overfields to get field data.
        $.each(formElement.find('.control-label'), function (index, element) {

            var elementType = my.getFieldTypeOfElement(element); //field type
            var fieldName = my.getFieldNameOfElement(element, elementType, false); //fieldname
            var fieldValue = my.getFieldValueOfElement(element, elementType); //fieldvalue

            var fieldInfoEntry = { Type: elementType, Name: fieldName, Value: fieldValue };
            fieldInfo.push(fieldInfoEntry);

        });


        //Hidden field values collect separately as it's not included in .control label
        $.each(formElement.find("[type='hidden']"), function (index, element) {
            fieldInfo.push({ Type: "Hidden", Name: $(element).attr('name'), Value: $(element).val() });
        });

        return fieldInfo;

    };

    my.getFieldTypeOfElement = function (element) {
        /// <summary>
        /// get element field type
        /// </summary>
        /// <param name="element">The field element in form</param> 

        //Drop down
        var dropdownElement = $(element).parent().find('select');
        if (dropdownElement.length > 0) { return my.FieldType.Dropdown; }

        //Checkbox
        var checkBoxElement = $(element).parent().find(".checkbox");
        if (checkBoxElement.length > 0) { return my.FieldType.Checkbox; }

        //Radio
        var radioElement = $(element).parent().find(".radio");
        if (radioElement.length > 0) { return my.FieldType.Radio; }


        //Captcha
        var captchaElement = $(element).parent().find("img");
        if (captchaElement.length > 0) { return my.FieldType.Captcha; }

        //else check for other types
        var fieldType;
        var inputField = $(element).parent().find("input");
        if (inputField.length !== 0)  //Name , Email ,Text ,Address
        {
            //iterate to get subfields
            $.each(inputField, function (index, inputItems) {
                var subFieldtype = my.getSubFieldType($(inputItems).attr("name"));
                fieldType = my.getFieldType(subFieldtype);
            });
            return fieldType;
        }
        else //message field
        {
            var textArea = $(element).parent().find("textarea");
            if ($(textArea).length > 0) { return my.FieldType.Message; }
        }


        return "";
    };

    my.getFieldNameOfElement = function (element, fieldType, validationPurpose) {
        /// <summary>
        /// get field name
        /// </summary>
        /// <param name="element">The field element in form</param> 
        /// <param name="fieldType">The field type</param> 
        /// <param name="validationPurpose">The flag for validationUsage</param> 

        var fieldName;
        if (fieldType == my.FieldType.Checkbox) //field name for checkbox
        {
            if (!validationPurpose) {
                fieldName = my.getCheckboxFieldName(element);
            }
            else {
                fieldName = $(element).html().trim();
            }
        }
        else if (fieldType == my.FieldType.Radio) //field name for radio
        {
            if (!validationPurpose) {
                fieldName = my.getRadioFieldName(element);
            }
            else {
                fieldName = $(element).html().trim();
            }
        }
        else if (fieldType == my.FieldType.Captcha) //field name for captcha
        {
            fieldName = my.getCaptchaFieldName(element);
        }
        else {
            fieldName = $(element).html().trim();
        }

        //field anme
        if (!validationPurpose) {
            if (my.getRequiredStatus(fieldName)) {
                //remove last character from label (exclude *)
                fieldName = fieldName.substring(0, fieldName.length - 1); // get the last char of the original string
            }
        }
        return fieldName;
    };

    my.getCaptchaFieldName = function (element) {
        /// <summary>
        /// Captcha field name
        /// </summary>
        /// <param name="element">The field element in form</param> 

        //iterate to get subfields
        var inputField = $(element).parent().find("input[type='text']");
        if ($(inputField).length > 0) {
            var fieldName = $(inputField).attr('name');
            return fieldName;
        }
        return "Undefined";
    };

    my.getCheckboxFieldName = function (element) {
        /// <summary>
        /// Checkbox field name
        /// </summary>
        /// <param name="element">The field element in form</param> 

        //iterate to get subfields
        var inputField = $(element).parent().find("input[type='checkbox']");
        if ($(inputField).length > 0) {
            var fieldName = $(inputField).attr('name');
            return fieldName;
        }
        return "Undefined";
    };

    my.getRadioFieldName = function (element) {
        /// <summary>
        /// Radio field name
        /// </summary>
        /// <param name="element">The field element in form</param> 

        //iterate to get subfields
        var inputField = $(element).parent().find("input[type='radio']");
        if ($(inputField).length > 0) {
            var fieldName = $(inputField).attr('name');
            return fieldName;
        }
        return "Undefined";
    };

    my.getFieldValueOfElement = function (element, fieldType) {
        /// <summary>
        /// field values submitted
        /// </summary>
        /// <param name="element">The field element in form</param> 
        /// <param name="fieldType">The field type</param> 

        var fieldValue;
        if (fieldType == my.FieldType.Dropdown) //drop down selected value
        {
            fieldValue = my.getDropdownFieldValue(element);
        }
        else if (fieldType == my.FieldType.Text) {
            fieldValue = my.getFieldValues(element);
        }
        else if (fieldType == my.FieldType.Message) {
            fieldValue = my.getMessageFieldValue(element);
        }
        else if (fieldType == my.FieldType.Name) {
            fieldValue = my.getFieldValues(element);
        }
        else if (fieldType == my.FieldType.Address) {
            fieldValue = my.getFieldValues(element);
        }
        else if (fieldType == my.FieldType.Email) {
            fieldValue = my.getFieldValues(element);
        }
        else if (fieldType == my.FieldType.Checkbox) {
            fieldValue = my.getCheckboxFieldValue(element);
        }
        else if (fieldType == my.FieldType.Radio) {
            return fieldValue = my.getRadioFieldValue(element);
        }
        else if (fieldType == my.FieldType.Captcha) {
            return fieldValue = my.getFieldValues(element);
        }

        return fieldValue;
    };

    my.getDropdownFieldValue = function (element) {
        /// <summary>
        /// Dropdown selected value
        /// </summary>
        /// <param name="element">The field element in form</param> 

        var optionElement = $(element).parent().find('select');
        var selectedElement = $(optionElement).children(':selected');
        if ($(selectedElement).length > 0) {

            var selectedIndex = $(optionElement).children(':selected').index();
            if (selectedIndex == 0)
            { return ""; }
            else {
                return $(selectedElement).html().trim();
            }
        }

    };

    my.getFieldValues = function (element) {
        /// <summary>
        /// Text,Name,Address,Email field value
        /// </summary>
        /// <param name="element">The field element in form</param> 

        //iterate to get subfields
        var fieldResult;
        var fieldData = [];
        var inputField = $(element).parent().find("input");
        $.each(inputField, function (index, inputItems) {
            fieldResult = $(inputItems).val();
            fieldData.push(fieldResult);
        });
        return fieldData;
    };

    my.getMessageFieldValue = function (element) {
        /// <summary>
        /// Message field value
        /// </summary>
        /// <param name="element">The field element in form</param> 

        //iterate to get subfields
        var fieldResult;
        var fieldData = [];
        var inputField = $(element).parent().find("textarea");
        $.each(inputField, function (index, inputItems) {
            fieldResult = $(inputItems).val();
            fieldData.push(fieldResult);
        });
        return fieldData;
    };

    my.getCheckboxFieldValue = function (element) {
        /// <summary>
        /// Checkbox field value
        /// </summary>
        /// <param name="element">The field element in form</param> 

        var selectdValue;
        var fieldData = [];

        var checkElements = $(element).parent().find("input[type='checkbox']");
        $.each(checkElements, function (index, inputItems) {
            selectdValue = $(inputItems).is(":checked") ? $(inputItems).val() : null;
            if (selectdValue != null)
            { fieldData.push(selectdValue); }

        });

        return fieldData;
    };

    my.getRadioFieldValue = function (element) {
        /// <summary>
        /// Radio field value
        /// </summary>
        /// <param name="element">The field element in form</param> 

        var selectdValue;
        var fieldData = [];

        var radioElements = $(element).parent().find("input[type='radio']");
        $.each(radioElements, function (index, inputItems) {
            selectdValue = $(inputItems).is(":checked") ? $(inputItems).val() : null;
            if (selectdValue != null)
            { fieldData.push(selectdValue); }

        });

        return fieldData;
    };

    my.validateFormFields = function (formElement) {
        /// <summary>
        /// Validate form fields 
        /// </summary>
        /// <param name="formElement">The form element in page</param> 

        var formValidity = true;

        //iterate overfields to get field data.
        $.each(formElement.find('.control-label'), function (index, element) {

            //clear/remove validation messages if any
            $(element).parent().find("[class='span12 errorField']").remove();


            var elementType = my.getFieldTypeOfElement(element); //field type
            var fieldName = my.getFieldNameOfElement(element, elementType, true); //fieldname
            var requiredStatus;
            if (elementType == my.FieldType.Captcha)
            { requiredStatus = true; }
            else { requiredStatus = my.getRequiredStatus(fieldName); }

            var formValid = true;

            if (fieldName !== null) {
                if (elementType == my.FieldType.Dropdown) {
                    formValid = my.setDropdownValidationStyle(element, fieldName, requiredStatus);
                }
                else if (elementType == my.FieldType.Radio) {
                    formValid = my.setRadioValidationStyle(element, fieldName, requiredStatus);
                }
                else if (elementType == my.FieldType.Checkbox) {
                    formValid = my.setCheckboxValidationStyle(element, fieldName, requiredStatus);
                }
                else if (elementType == my.FieldType.Message) {
                    formValid = my.setMessageValidationStyle(element, fieldName, requiredStatus);
                }
                else if (elementType == my.FieldType.Captcha) {
                    formValid = my.setCaptchaValidationStyle(element, fieldName, requiredStatus);
                }
                else {
                    formValid = my.setValidationStyle(element, fieldName, requiredStatus);
                }
            }


            formValidity = formValid && formValidity; //form valid flag

        });

        return formValidity;

    };

    my.setRadioValidationStyle = function (element, fieldName, required) {
        /// <summary>
        /// Validation error style for radio field
        /// </summary>
        /// <param name="element">The element in form</param> 
        /// <param name="fieldName">The element name</param> 
        /// <param name="required">The element required status</param> 

        var formValid = true;

        if (required) {
            var radioElements = $(element).parent().find("input[type='radio']");
            //remove prevoius errors if any
            $(radioElements).parent().parent().find("[class='errorField']").remove();
            var hasSelected = false;
            $.each(radioElements, function (index, inputItems) {
                selectdValue = $(inputItems).is(":checked") ? true : null;
                if (selectdValue != null) {
                    hasSelected = true;
                }
            });
            if (!hasSelected) {
                //add error field
                $(radioElements).parent().parent().prepend("<div class='errorField'>" + fieldName.substring(0, fieldName.length - 1) + " is required.</div>");
                formValid = false;
            }
        }
        return formValid;
    };


    my.setCheckboxValidationStyle = function (element, fieldName, required) {
        /// <summary>
        /// Validation error style for checkbox field
        /// </summary>
        /// <param name="element">The element in form</param> 
        /// <param name="fieldName">The element name</param> 
        /// <param name="required">The element required status</param> 

        var formValid = true;
        if (required) {

            var checkElements = $(element).parent().find("input[type='checkbox']");
            //remove prevoius errors if any
            $(checkElements).parent().parent().find("[class='errorField']").remove();
            var hasSelected = false;
            $.each(checkElements, function (index, inputItems) {
                selectdValue = $(inputItems).is(":checked") ? true : null;
                if (selectdValue != null) {
                    hasSelected = true;
                }
            });

            if (!hasSelected) {
                //add error field
                $(checkElements).parent().parent().prepend("<div class='errorField'>" + fieldName.substring(0, fieldName.length - 1) + " is required.</div>");
                formValid = false;
            }
        }
        return formValid;

    };

    my.setDropdownValidationStyle = function (element, fieldName, required) {
        /// <summary>
        /// Validation error style for dropdown field
        /// </summary>
        /// <param name="element">The element in form</param> 
        /// <param name="fieldName">The element name</param> 
        /// <param name="required">The element required status</param> 

        var formValid = true;
        var optionElement = $(element).parent().find('select');
        var selectedIndex = $(optionElement).children(':selected').index();
        if (required) {
            if (selectedIndex == 0) {
                formValid = false;

                //remove prevoius errors if any
                $(optionElement).parent().find("[class='span12 errorField']").remove();
                //add error field
                $(optionElement).parent().prepend("<div class='span12 errorField'>" + fieldName.substring(0, fieldName.length - 1) + " is required.</div>");

            }
        }
        return formValid;

    };

    my.setValidationStyle = function (element, fieldName, required) {
        /// <summary>
        /// Validation error style for input fields (Text,Message,Name,Email)
        /// </summary>
        /// <param name="element">The element in form</param> 
        /// <param name="fieldName">The element name</param> 
        /// <param name="required">The element required status</param> 

        var formValid = true;
        //get input
        var inputField = $(element).parent().find("input");
        if (inputField.length !== 0) {

            //iterate to get subfields
            $.each(inputField, function (index, inputItems) {
                //remove validation styles for input field
                $(inputItems).removeAttr("style");

                //check validity
                var subFieldtype = my.getSubFieldType($(inputItems).attr("name"));
                var fieldValidStatus = my.checkFieldValidity(subFieldtype, $(inputItems).val(), required);

                //invalid 
                if (!fieldValidStatus) {
                    formValid = false;
                    //remove prevoius errors if any
                    $(element).parent().find("[class='span12 errorField']").remove();

                    if (subFieldtype.toLowerCase() == "email" && $(inputItems).val() !== "") {
                        //email should be invalid
                        $(element).parent().prepend("<div  class='span12 errorField'>" + fieldName.substring(0, fieldName.length - 1) + " is invalid.</div>");
                    }
                    else {
                        //add error field
                        $(element).parent().prepend("<div  class='span12 errorField'>" + fieldName.substring(0, fieldName.length - 1) + " is required.</div>");
                    }

                }

            });
        }

        return formValid;
    };

    my.setCaptchaValidationStyle = function (element, fieldName, required) {
        /// <summary>
        /// Validation error style for captcha
        /// </summary>
        /// <param name="element">The element in form</param> 
        /// <param name="fieldName">The element name</param> 
        /// <param name="required">The element required status</param> 

        var formValid = false;
        var captchaElementInput = $(element).parent().find('input');
        if (required) {
            if (captchaElementInput.length !== 0) {
                if ($(captchaElementInput).val().trim() == "") {
                    formValid = false;
                    //remove prevoius errors if any
                    $(element).parent().find("[class='span12 errorField']").remove();
                    //add error field
                    $(element).parent().prepend("<div class='span12 errorField'>" + "This field" + " is required.</div>");
                }
                else
                { formValid = true; }
            }
        }
        return formValid;
    };

    my.setMessageValidationStyle = function (element, fieldName, required) {
        /// <summary>
        /// Validation error style for Message fields.
        /// </summary>
        /// <param name="element">The element in form</param> 
        /// <param name="fieldName">The element name</param> 
        /// <param name="required">The element required status</param> 

        var formValid = true;
        var textArea = $(element).parent().find("textarea");
        var id = $(textArea).attr("name");

        if (id != null) {
            //remove validation styles
            $(textArea).removeAttr("style");
            //check validity
            var subFieldtype = my.getSubFieldType(id);
            var fieldValidStatus = my.checkFieldValidity(subFieldtype, $(textArea).val(), required);
            if (!fieldValidStatus) {
                formValid = false;
                //remove prevoius errors if any
                $(element).parent().find("[class='span12 errorField']").remove();
                //add error field
                $(element).parent().prepend("<div class='span12 errorField'>" + fieldName.substring(0, fieldName.length - 1) + " is required.</div>");
            }
        }
        return formValid;
    };

    my.getFieldType = function (subfieldName) {
        /// <summary>
        /// get field name from subfield.
        /// </summary>
        /// <param name="subfieldName">The subfieldname inside element.</param> 

        //first name
        if (subfieldName.toLowerCase().indexOf("firstname") >= 0) {
            return my.FieldType.Name;
        }
        //last name
        else if (subfieldName.toLowerCase().indexOf("lastname") >= 0) {
            return my.FieldType.Name;
        }
        //Address
        else if (subfieldName.toLowerCase().indexOf("address") >= 0) {
            return my.FieldType.Address;
        }
        //city 
        else if (subfieldName.toLowerCase().indexOf("city") >= 0) {
            return my.FieldType.Address;
        }
        //country
        else if (subfieldName.toLowerCase().indexOf("country") >= 0) {
            return my.FieldType.Address;
        }
        //text 
        else if (subfieldName.toLowerCase().indexOf("text") >= 0) {
            return my.FieldType.Text;
        }
        //message 
        else if (subfieldName.toLowerCase().indexOf("message") >= 0) {
            return my.FieldType.Message;
        }
        //email 
        else if (subfieldName.toLowerCase().indexOf("email") >= 0) {
            return my.FieldType.Email;
        }
    };

    my.getSubFieldType = function (subfieldName) {
        /// <summary>
        /// get subfield type from field name.
        /// </summary>
        /// <param name="subfieldName">The subfieldname inside element.</param> 

        if (subfieldName == null) {
            return "message";
        }
        //first name
        if (subfieldName.toLowerCase().indexOf("firstname") >= 0) {
            return "firstname";
        }
        //last name
        else if (subfieldName.toLowerCase().indexOf("lastname") >= 0) {
            return "lastname";
        }
        //Address
        else if (subfieldName.toLowerCase().indexOf("address") >= 0) {
            return "address";
        }
        //city 
        else if (subfieldName.toLowerCase().indexOf("city") >= 0) {
            return "city";
        }
        //country
        else if (subfieldName.toLowerCase().indexOf("country") >= 0) {
            return "country";
        }
        //text 
        else if (subfieldName.toLowerCase().indexOf("text") >= 0) {
            return "text";
        }
        //message 
        else if (subfieldName.toLowerCase().indexOf("message") >= 0) {
            return "message";
        }
        //email 
        else if (subfieldName.toLowerCase().indexOf("email") >= 0) {
            return "email";
        }

    };

    my.checkFieldValidity = function (fieldName, fieldValue, requiredStatus) {
        /// <summary>
        /// get required status for field.
        /// </summary>
        /// <param name="fieldName">The fieldname</param> 
        /// <param name="fieldValue">The fieldvalue</param> 
        /// <param name="requiredStatus">The required field status</param> 

        var validFlag = true;
        if (requiredStatus) //required fields
        {
            //First name field validation
            if (fieldName.toLowerCase() == "firstname") {
                validFlag = (fieldValue.trim() !== "") ? true : false;
            }
            //Last name field validation
            else if (fieldName.toLowerCase() == "lastname") {
                validFlag = (fieldValue.trim() !== "") ? true : false;
            }
            //Address
            else if (fieldName.toLowerCase() == "address") {
                validFlag = (fieldValue.trim() !== "") ? true : false;
            }

            //city 
            else if (fieldName.toLowerCase() == "city") {
                validFlag = (fieldValue.trim() !== "") ? true : false;
            }
            //text 
            else if (fieldName.toLowerCase() == "text") {
                validFlag = (fieldValue.trim() !== "") ? true : false;
            }
            //message
            else if (fieldName.toLowerCase() == "message") {
                validFlag = (fieldValue.trim() !== "") ? true : false;
            }
            //email
            else if (fieldName.toLowerCase() == "email") {
                validFlag = (fieldValue.trim() !== "") ? true : false;
            }
            else {
                validFlag = true;
            }

        }


        //check for email validity
        if (fieldName.toLowerCase() == "email") {
            //email 
            if (fieldValue.trim() !== "") {
                if (!my.isValidEmailAddress(fieldValue.trim())) {
                    validFlag = false;
                }
            }
        }


        return validFlag;

    };

    my.isValidEmailAddress = function (emailAddress) {
        /// <summary>
        /// email validation
        /// </summary>
        /// <param name="emailAddress">The emailaddress entered</param> 

        var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
        return pattern.test(emailAddress);
    };

    my.getRequiredStatus = function (fieldLabel) {
        /// <summary>
        /// get required status for field
        /// </summary>
        /// <param name="fieldLabel">The fieldlabel </param>

        var requiredStatus = true;
        try {
            var lastCharacter = fieldLabel.charAt(fieldLabel.length - 1);
            requiredStatus = (lastCharacter == "*") ? true : false;
            return requiredStatus;
        }
        catch (Error) {
            return false;
        }
    };

    return my;
} (jQuery));

$(document).ready(function () {
    SquareHook.FormSubmission.Initialize();
});