/* Author:

*/
jQuery(document).ready(function(){

	/* ==== * Jquery Test * ==== */
	jQuery('#jquery-test').hide();
	
	
	
	/* ==== * Toggle * ==== */
	$(".toggle_container").hide();
	$(".trigger.active").next().show();
	$(".trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle("fast");
	});
	
	
	/* ==== * FlexSlider * ==== */
	jQuery('.flexslider').flexslider({
		animation: "slide",              //String: Select your animation type, "fade" or "slide"
		slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
		slideshow: true,                //Boolean: Animate slider automatically
		slideshowSpeed: 7000,           //Integer: Set the speed of the slideshow cycling, in milliseconds
		animationDuration: 600,         //Integer: Set the speed of animations, in milliseconds
		directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
		controlNav: false,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
		keyboardNav: true,              //Boolean: Allow slider navigating via keyboard left/right keys
		mousewheel: false,              //Boolean: Allow slider navigating via mousewheel
		prevText: "<",           //String: Set the text for the "previous" directionNav item
		nextText: ">",               //String: Set the text for the "next" directionNav item
		pausePlay: false,               //Boolean: Create pause/play dynamic element
		pauseText: 'Pause',             //String: Set the text for the "pause" pausePlay item
		playText: 'Play',               //String: Set the text for the "play" pausePlay item
		randomize: false,               //Boolean: Randomize slide order
		slideToStart: 0,                //Integer: The slide that the slider should start on. Array notation (0 = first slide)
		animationLoop: true,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
		pauseOnAction: true,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
		pauseOnHover: false,            //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
		controlsContainer: "",          //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken.
		manualControls: "",             //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
		start: function(){
		jQuery("#slides").after(jQuery("#flex-nav"));
		},            //Callback: function(slider) - Fires when the slider loads the first slide
		before: function(){},           //Callback: function(slider) - Fires asynchronously with each slider animation
		after: function(slider){
			jQuery(slider.currentSlide).text('boyaaa');
		},            //Callback: function(slider) - Fires after each slider animation completes
		end: function(){
		}               //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
	});
	
	jQuery('#slides').find('a').parent('li').addClass('up-up');
	
	$('#services').slides({
		preload: false,
		autoHeight: true,
		effect: 'fade',
		generatePagination: false,
		play: 5000,
		pause: 5000
	});


	/* ==== * Hide element after X time * ==== */
	setTimeout(function(){
		jQuery(".fade").fadeOut("slow", function () {
			jQuery(".fade").hide();
		});
	}, 4000);

	
});

/*---------------------------*/
/*	Modal Window - On Load
/*---------------------------*/
$(document).ready(function(){
	
	//Settings
	var $js_display_modal = true;
	var $js_display_overlay = 'true';//display overlay true/false
	var $js_modal_overlay_click = 'false';//Close modal on overlay click
	var $js_modal_fade = 500;//fadein speed in miliseconds

	//Elements
	var $js_modal = $('.modal');//Define the modal inner div id/class/selector
	var $js_modal_close = $('.modal .close');//Define the close id/class
	var $js_modal_overlay = $('.overlay');//Define the modal overlay id/class

	//if $js_display_modal = true, display modal window
	
//display modal to ie 8 and below
if ( jQuery.browser.msie <= '8.0' ) {
	if ($js_display_modal === true) {
	
		if ($.cookie('js_modal') === 'closed') {
		    $js_modal.hide();
		    $js_modal_overlay.hide();
		} else {
			$js_modal.fadeIn($js_modal_fade);
			if ($js_display_overlay === 'true') {
				$js_modal_overlay.fadeIn($js_modal_fade);
			}
			$js_modal.css({'margin-top' : -$js_modal.outerHeight()/2, 'margin-left' : -$js_modal.outerWidth()/2});//Center div according to height of the content
		}
		
		//Close modal on close click	
		$js_modal_close.click( function () {
			$js_modal.fadeOut($js_modal_fade, function () {
				$js_modal.hide();
			});
			$js_modal_overlay.fadeOut($js_modal_fade, function () {
				$js_modal_overlay.hide();
			});
			$.cookie('js_modal', 'closed', { path: '/'});
			return false;
		});
		
		if ($js_display_overlay === 'false') $
	
	}
}
			
});
