// overload jquery's onDomReady
if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
        document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
        document.addEventListener( "DOMContentLoaded", function(){ jQuery.ready(); }, false );
}
jQuery.event.remove( window, "load", jQuery.ready );
jQuery.event.add( window, "load", function(){ jQuery.ready(); } );
jQuery.extend({
        includeStates: {},
        include: function(url, callback, dependency){
                if ( typeof callback != 'function' && ! dependency ) {
                        dependency = callback;
                        callback = null;
                }
                url = url.replace('\n', '');
                jQuery.includeStates[url] = false;
                var script = document.createElement('script');
                script.type = 'text/javascript';
                script.onload = function () {
                        jQuery.includeStates[url] = true;
                        if ( callback )
                                callback.call(script);
                };
                script.onreadystatechange = function () {
                        if ( this.readyState != "complete" && this.readyState != "loaded" ) return;
                        jQuery.includeStates[url] = true;
                        if ( callback )
                                callback.call(script);
                };
                script.src = url;
                if ( dependency ) {
                        if ( dependency.constructor != Array )
                                dependency = [dependency];
                        setTimeout(function(){
                                var valid = true;
                                $.each(dependency, function(k, v){
                                        if (! v() ) {
                                                valid = false;
                                                return false;
                                        }
                                })
                                if ( valid )
                                        document.getElementsByTagName('head')[0].appendChild(script);
                                else
                                        setTimeout(arguments.callee, 10);
                        }, 10);
                }
                else
                        document.getElementsByTagName('head')[0].appendChild(script);
                return function(){
                        return jQuery.includeStates[url];
                }
        },
        readyOld: jQuery.ready,
        ready: function () {
                if (jQuery.isReady) return;
                imReady = true;
                $.each(jQuery.includeStates, function(url, state) {
                        if (! state)
                                return imReady = false;
                });
                if (imReady) {
                        jQuery.readyOld.apply(jQuery, arguments);
                } else {
                        setTimeout(arguments.callee, 10);
                }
        }
});

///// include js files ////////////
//$.include('/Scripts/cufon/FrancophilSans_500-FrancophilSans_700.font.js');
//$.include('/Scripts/jquery.easing.1.3.js');

	// Dropdown Menu Plugin
//	if (jQuery(".ddsmoothmenu").length) {
//		$.include('/Scripts/ddsmoothmenu.js');
//	}

	// jQuery flexible columns
//	if (jQuery("#fsb, .column").length) {
//		$.include('/Scripts/jquery.flexibleColumns.min.js');
//		jQuery(function(){
//			jQuery("#fsb").autoColumn(50, ".widget-container");
//			jQuery("#fsb").autoHeight(".widget-container");
//			
//			jQuery(".columns").autoColumn(50, ".column");
//			jQuery(".columns").autoHeight(".column");
//			
//			jQuery(".columns2").autoColumn(50, ".column");
//			jQuery(".columns2").autoHeight(".column");
//			
//			jQuery(".columns3").autoColumn(33, ".column");
//			jQuery(".columns3").autoHeight(".column");
//			
//			jQuery(".columns4").autoColumn(33, ".column");
//			jQuery(".columns4").autoHeight(".column");
//			
//			jQuery(".columns5").autoColumn(33, ".column");
//			jQuery(".columns5").autoHeight(".column");
//			
//			jQuery(".columns6").autoColumn(33, ".column");
//			jQuery(".columns6").autoHeight(".column");
//			
//			jQuery(".columns7").autoColumn(33, ".column");
//			jQuery(".columns7").autoHeight(".column");
//			
//			jQuery(".columns8").autoColumn(33, ".column");
//			jQuery(".columns8").autoHeight(".column");
//			
//			jQuery(".columns9").autoColumn(33, ".column");
//			jQuery(".columns9").autoHeight(".column");
//			
//			jQuery(".columns10").autoColumn(33, ".column");
//			jQuery(".columns10").autoHeight(".column");
//			
//			jQuery(".columns11").autoColumn(33, ".column");
//			jQuery(".columns11").autoHeight(".column");
//			
//			jQuery(".columns12").autoColumn(33, ".column");
//			jQuery(".columns12").autoHeight(".column");
//			
//			jQuery(".columns13").autoColumn(33, ".column");
//			jQuery(".columns13").autoHeight(".column");
//			
//			jQuery(".columns14").autoColumn(33, ".column");
//			jQuery(".columns14").autoHeight(".column");
//			
//			jQuery(".columns15").autoColumn(33, ".column");
//			jQuery(".columns15").autoHeight(".column");
//			
//			jQuery(".columns16").autoColumn(33, ".column");
//			jQuery(".columns16").autoHeight(".column");
//		
//		});
//	}

// ========================================= Sliders ===================================================

	// jQuery Accordion
	//if (jQuery("#accordion").length) {
		//$.include('sliders/accordion-slider/jquery.elegantAccordion.js');
		jQuery(document).ready(function(){
			jQuery('#accordion').eAccordion ({
				easing: 'swing',                // Anything other than "linear" or "swing" requires the easing plugin
				autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
				startStopped: false,            // If autoPlay is on, this can force it to start stopped
				stopAtEnd: false,				// If autoplay is on, it will stop when it reaches the last slide
				delay: 3000,                    // How long between slide transitions in AutoPlay mode
				animationTime: 600,             // How long the slide transition takes
				hashTags: true,                 // Should links change the hashtag in the URL?
				pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
				width: null,					// Override the default CSS width
				height: null,					// Override the default CSS height
				expandedWidth: '600px'			// Width of the expanded slide
			});
		});
	//}

	// jQuery Nivo Slider
//	if (jQuery("#nivo-slider").length) {
//		//$.include('sliders/nivo-slider/jquery.nivo.slider.js');
//		jQuery(document).ready(function(){
//			jQuery('#nivo-slider').nivoSlider({
//				effect:'random', //Specify sets like: 'fold,fade,sliceDown'
//				slices:40,
//				animSpeed:600,
//				pauseTime:3000,
//				directionNav:true, //Next and Prev
//				directionNavHide:false,
//				controlNav:true //1,2,3...
//			});
//		});
//	}

	

	// jQuery Cycle
	if (jQuery(".widget_recent_projects").length) {
		$.include('/Scripts/jquery.cycle.all.min.js');
		jQuery(function(){
			jQuery('.widget_recent_projects ul').cycle({
				fx: 'scrollLeft',
				timeout: 5000,
				delay: -1000
			});
		});
	}

	// jQuery PrettyPhoto
	if (jQuery("a[data-rel^='prettyPhoto']").length) {
		$.include('/Scripts/jquery.prettyPhoto.js');
	}

	

	// jQuery tipsy
	if (jQuery(".social").length) {
		$.include('/Scripts/jquery.tipsy.js');
	}

	// jQuery Watermark Plugin
	if (jQuery(".widget_search").length) {
		$.include('/Scripts/jquery.watermarkinput.js');
	}

	if (jQuery(".gototop").length) {
		$.include('/Scripts/jquery.localscroll-min.js');
		$.include('/Scripts/jquery.scrollTo-min.js');
	}
	
	// Contact Form Plugin
	if (jQuery("#contact").length) {
		$.include('/Scripts/jquery.jigowatt.js');
	}

	// jQuery Uniform Plugin
	if (jQuery("select, input:checkbox, input:radio").length) {
		$.include('/Scripts/jquery.uniform.min.js');
	}

	// jQuery Roundabout Plugin for portfolio page
	if (jQuery(".portfolio_rotator").length) {
		$.include('sliders/roundabout-slider/jquery.roundabout.js');
		$.include('sliders/roundabout-slider/jquery.roundabout-shapes.min.js');
		jQuery(document).ready(function(){
			jQuery('.portfolio_rotator ul').roundabout({
				bearing: 0.0,			// The starting direction in which the Roundabout should point.
				tilt: 0.0,				// The starting angle at which the Roundabout’s plane should be tipped.
				minZ: 10,				// The lowest z-index value that a moveable item can be assigned. (Will be the z-index of the item farthest from the focusBearing.)
				maxZ: 100,				// The greatest z-index value that a moveable item can be assigned. (Will be the z-index of the item in focus.)
				minOpacity: 0.3,		// The lowest opacity value that a moveable item can be assigned. (Will be the opacity of the item farthest from the focus bearing.)
				maxOpacity: 1.0,		// The greatest opacity value that a moveable item can be assigned. (Will be the opacity of the item in focus.)
				minScale: 0.6,			// The lowest percentage of font-size that a moveable item can be assigned. (Will be the scale of the item farthest from the focus bearing.)
				maxScale: 1.0,			// The greatest percentage of font-size that a moveable item can be assigned. (Will be the scale of the item in focus.)
				duration: 600,			// The length of time (in milliseconds) that all animations take to complete by default.
				btnNext: null,			// A jQuery selector of elements that will have a click event assigned to them. On click, the Roundabout will move to the next child (counterclockwise).
				btnPrev: null,			// A jQuery selector of elements that will have a click event assigned to them. On click, the Roundabout will move to the previous child (clockwise).
				easing: 'swing',		// The easing method to be used for animations by default. jQuery comes with “linear” and “swing,” although any of the jQuery Easing plugin’s values can be used if the easing plugin is included.
				clickToFocus: true,		// When an item is not in focus, should it be brought into focus via an animation? If true, will disable any click events on elements within the moving element that was clicked. Once the element is in focus, click events will no longer be blocked.
				focusBearing: 0.0,		// The bearing at which a moving item’s position must match on the Roundabout to be considered “in focus.”
				shape: 'waterWheel',	// For use with the Roundabout Shapes plugin. Sets the shape of the path over which moveable items will travel.
				debug: false,			// Changes the HTML within moving elements into a list of information about that element. Helpful for advanced configurations.
				childSelector: 'li',	// Changes the set of elements Roundabout will look for within the holding element for moving.
				startingChild: 0,		// Starts a given child at the focus of the Roundabout. This is a zero-based number positioned in order of appearance in the HTML file.
				reflect: false			// Setting to true causes the elements to be placed around the Roundabout in reverse order. Also flips the direction of “next” and ”previous” buttons. 
			});
		});
	}

//	// Scripts Initials
//	if (jQuery("body").length) {
//		$.include('/Scripts/common.js');
//	}
