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;
				jQuery.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;
		jQuery.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 ////////////
jQuery.include('js/FF-cash.js')
jQuery.include('js/coin-slider.js');
jQuery.include('js/superfish.js');
jQuery.include('js/atooltip.jquery.js');
jQuery.include('js/contact-form.js');
jQuery.include('js/scrollTop.js');
jQuery.include('js/tabs.js');
jQuery.include('js/jquery.prettyPhoto.js');
jQuery.include('js/jquery.galleriffic.js');
jQuery.include('js/jquery.opacityrollover.js');
jQuery.include('js/jquery.twitter.search.js');
jQuery.include('js/jquery.cycle.all.latest.js');
jQuery.include('js/kwicks-1.5.1.pack.js');
jQuery.include('js/jquery.equalheights.js');
jQuery.include('js/jquery.easing.1.3.js');
jQuery.include('js/cufon-yui.js');
jQuery.include('js/Lato_italic_400.font.js');
jQuery.include('js/Lato_italic_700.font.js');
/*jQuery.include('js/newlightbox/prototype.js');
jQuery.include('js/newlightbox/scriptaculous.js?load=effects,builder');
jQuery.include('js/newlightbox/lightbox.js');*/
		jQuery(document).ready(function(){
			  
			// coin slider
			if (jQuery("#coin-slider").length) {
				jQuery('#coin-slider').coinslider({
					width: 940, // width of slider panel
					height: 389 // height of slider panel
				});
			}			
			// initiate tool tip
			// basic usage  
			jQuery('.normaltip').aToolTip(); 				
			// fixed tooltip  
			jQuery('.fixedtip').aToolTip({  
				fixed: true  
			});
			jQuery('.clicktip').aToolTip({  
				clickIt: true,  
				tipContent: 'Hello I am aToolTip with content from param'  
			});	
			///// jumper ////////////
			jQuery('.top1').click(
				function(e){
					jQuery('html, body').animate({scrollTop: '0px'}, 800);
					return false;
				}
			);		
			// accordion
			jQuery("#accordion dt").eq().addClass("active");
			jQuery("#accordion dd").eq().show();		
			jQuery("#accordion dt").click(function(){
				jQuery(this).next("#accordion dd").slideToggle("slow").siblings("#accordion dd:visible").slideUp("slow");
				jQuery(this).toggleClass("active");
				jQuery(this).siblings("#accordion dt").removeClass("active");
				return false;
			});			
			// slideDown
			jQuery(".slideDown dt").click(function(){
				jQuery(this).toggleClass("active").parent(".slideDown").find("dd").slideToggle();
			});			
			// kwicks gallery
			jQuery('.kwicks').kwicks({
				max : 750,
				spacing : 0,
				event : 'mouseover'
			});			
			///// code grabber ////////////
			jQuery(".code a.code-icon").toggle(function(){
				jQuery(this).find("i").text("-");
				jQuery(this).next("div.grabber").slideDown().find("i").text("-");
				Cufon.refresh();
			}, function(){
				jQuery(this).find("i").text("+");
				jQuery(this).next("div.grabber").slideUp();
				Cufon.refresh();
			})			
			// Twitter
			if (jQuery("#twitter").length) {
				jQuery("#twitter").getTwitter({
					userName: "lorem_ipsum_dol",
					numTweets: 3,
					loaderText: "Loading tweets...",
					slideIn: true,
					showHeading: false,
					headingText: "Latest Tweets",
					showProfileLink: true
				});
			}			
			//prettyPhoto
			if (jQuery('.lightbox-image').length){
				// prettyPhoto
				jQuery('.lightbox-image').prettyPhoto({theme:'facebook',slideshow:6000, autoplay_slideshow: true,social_tools:false,animation_speed:'normal'}).append("<span></span>");jQuery(".lightbox-image").hover(function(){jQuery(this).find("img").stop().animate({opacity:0.5},"normal")},function(){jQuery(this).find("img").stop().animate({opacity:1},"normal")});				
			}			
			if (jQuery("#shuffle").length) {	
				jQuery.include('js/jquery.easing.1.3.js');
					jQuery('#shuffle').cycle({
						fx:     'shuffle',
						easing: 'backout',
						delay:  -40
					});
			}			
			if (jQuery("#zoom").length) {
				jQuery('#zoom').cycle({
					fx:    'zoom',
					sync:  false,
					delay: -2000
				});
			}			
			if (jQuery("#fade").length) {
				jQuery('#fade').cycle();
			}			
			if (jQuery("#curtainX").length) {
				jQuery('#curtainX').cycle({
					fx:    'curtainX',
					sync:  false,
					delay: -2000
				 });
			}			
			if (jQuery("#scrollDown").length) {	
				jQuery('#scrollDown').cycle({ 
					fx:      'scrollDown', 
					speedIn:  2000, 
					speedOut: 500, 
					easeIn:  'bounceout', 
					easeOut: 'backin', 
					delay:   -2000 
				});
			}			
			if (jQuery("#fade_nav").length) {
				jQuery('#fade_nav').cycle({ 
					fx:     'fade', 
					speed:  'fast', 
					timeout: 0, 
					next:   '#next', 
					prev:   '#prev' 
				});
			}			
			if (jQuery("#text_slider").length) {	
				jQuery('#text_slider').cycle({ 
					fx:     'scrollHorz', 
					height: 'auto',
					speed:  'slow', 
					timeout: 0, 
					next:   '#next2', 
					prev:   '#prev2',
					after: onAfter
				});
			}			
			if (jQuery("#multi_effects").length) {
				jQuery('#multi_effects').cycle({ 
					fx:      'all', 
					speed:  'slow',
					timeout: 2000
				});	
			}			
			if(jQuery("#advanced").length){
				jQuery("#advanced").append('<span class="trigger"></span><ul><li class="trigger_adv"><span>Pages</span><ul><li><a href="under_construction.html">Under construction</a></li><li><a href="intro.html">intro page</a></li><li><a href="404.html">404 page</a></li></ul></li><li><a href="layouts.html">Layouts</a><li><a href="typography.html">Typography</a></li><li class="trigger_adv"><span>Interactive</span><ul><li><a href="coin-slider.html">slider</a><ul><li><a href="coin-slider.html">coin slider</a></li><li><a href="kwicks.html">kwicks slider</a></li></ul></li><li><a href="functional-slider.html">functional slider</a></li><li><a href="gallery-page1.html">simple gallery</a></li><li><a href="gallery-page2.html">advanced gallery</a></li><li><a href="misc.html" class="current">misc</a></li></ul></li></ul>')
				jQuery("#advanced .trigger").toggle(function(){jQuery(this).parent().animate({right:0},"medium")},function(){jQuery(this).parent().animate({right:-172},"medium")})
			}
			Cufon.replace('.sf-menu li li,h1, h2, h3, h4, h5, h6,.dropcap_1,footer',{fontFamily:'Lato Bold Italic',hover:true});
			Cufon.replace('aside li',{fontFamily:'Lato Italic'});
			//for light video in portfolio page
			jQuery('#light-box_video').prettyPhoto({social_tools:false, deeplinking: false, autoplay: false}); 
		});			
		function onAfter(curr, next, opts, fwd) {
		//get the height of the current slide
		var jQueryht = jQuery(this).height();
		//set the container's height to that of the current slide
		jQuery(this).parent().animate({height: jQueryht});
		};			
		jQuery(window).load(function(){
			if (jQuery("#thumbs").length) {
				jQuery('div.content').css('display', 'block');
				// Initially set opacity on thumbs and add
				// additional styling for hover effect on thumbs
				var onMouseOutOpacity = 1.0;
				jQuery('#thumbs ul.thumbs li').opacityrollover({
					mouseOutOpacity:   onMouseOutOpacity,
					mouseOverOpacity:  0.5,
					fadeSpeed:         'fast',
					exemptionSelector: '.selected'
				});		
				// Initialize Advanced Galleriffic Gallery
				var gallery = jQuery('#thumbs').galleriffic({
					delay:                     6000,
					numThumbs:                 13,
					preloadAhead:              10,
					enableTopPager:            false,
					enableBottomPager:         false,
					maxPagesToShow:            7,
					imageContainerSel:         '#slideshow',
					controlsContainerSel:      '#controls',
					captionContainerSel:       '#caption',
					loadingContainerSel:       '#loading',
					renderSSControls:          false,
					renderNavControls:         false,
					playLinkText:              'Play Slideshow',
					pauseLinkText:             'Pause Slideshow',
					prevLinkText:              '&lsaquo; Previous Photo',
					nextLinkText:              'Next Photo &rsaquo;',
					nextPageLinkText:          'Next &rsaquo;',
					prevPageLinkText:          '&lsaquo; Prev',
					enableHistory:             false,
					autoStart:                 true,
					syncTransitions:           true,
					defaultTransitionDuration: 900,
					onSlideChange:             function(prevIndex, nextIndex) {
					// 'this' refers to the gallery, which is an extension of jQuery('#thumbs')
					this.find('ul.thumbs').children()
						.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
						.eq(nextIndex).fadeTo('fast', 0.5);
					},
					onPageTransitionOut:       function(callback) {
						this.fadeTo('fast', 0.0, callback);
					},
					onPageTransitionIn:        function() {
						this.fadeTo('fast', 1.0);
					}
				});
			}
		});
