// JavaScript Document

// Footer Blind
$(document).ready(function() {
	$("#footerlink").click(function(){
	$(this).toggleClass('active');
	$("#slide_hidden").slideToggle("slow");
	});
});

document.documentElement.className = 'js';
// SOCIAL icon popup
      $(document).ready(function(){ 
      $("#nav_facebook a").hover(function() { 
      $(this).next("em").stop(true, true).animate({opacity: "show", top: "47"}, "slow"); 
      }, function() { 
      $(this).next("em").animate({opacity: "hide", top: "70"}, "fast"); 
      }); 
});  
document.documentElement.className = 'js';
// SOCIAL icon popup
      $(document).ready(function(){ 
      $("#nav_twitter a").hover(function() { 
      $(this).next("em").stop(true, true).animate({opacity: "show", top: "47"}, "slow"); 
      }, function() { 
      $(this).next("em").animate({opacity: "hide", top: "70"}, "fast"); 
      }); 
});  
document.documentElement.className = 'js';
// SOCIAL icon popup
      $(document).ready(function(){ 
      $("#nav_linkedin a").hover(function() { 
      $(this).next("em").stop(true, true).animate({opacity: "show", top: "47"}, "slow"); 
      }, function() { 
      $(this).next("em").animate({opacity: "hide", top: "70"}, "fast"); 
      }); 
});  
document.documentElement.className = 'js';
// SOCIAL icon popup
      $(document).ready(function(){ 
      $("#nav_rss a").hover(function() { 
      $(this).next("em").stop(true, true).animate({opacity: "show", top: "47"}, "slow"); 
      }, function() { 
      $(this).next("em").animate({opacity: "hide", top: "70"}, "fast"); 
      }); 
});  
document.documentElement.className = 'js';
// SOCIAL icon popup
      $(document).ready(function(){ 
      $("#nav_email a").hover(function() { 
      $(this).next("em").stop(true, true).animate({opacity: "show", top: "47"}, "slow"); 
      }, function() { 
      $(this).next("em").animate({opacity: "hide", top: "70"}, "fast"); 
      }); 
});  
// START NAV SCROLLING
	jQuery(function( $ ){
		// Scroll the x and y axis
		$.localScroll.defaults.axis = 'xy';
		
		// Scroll if there's a hash (#something) in the url 
		$.localScroll.hash({
			target: '#content', // Could be a selector or a jQuery object too.
			queue:true,
			duration:1500
		});
		/**
		 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
		 * also affect the >> and << links. I want every link in the page to scroll.
		 */
		$.localScroll({
			target: '#content', // could be a selector or a jQuery object too.
			queue:true,
			duration:1000,
			hash:true,
			onBefore:function( e, anchor, $target ){
				// The 'this' is the settings object, can be modified
			},
			onAfter:function( anchor, settings ){
				// The 'this' contains the scrolled element (#content)
			}
		});
	});
// setting the selected menu item'class as active
$(function(){
        $('#nav a').click(function(){
                $('#nav a').removeClass('active');
                $(this).addClass('active');
				$('html, body').animate({scrollTop:0}, 'fast');
        });

// FANCYBOX FOR FEATURED CAROUSEL
			$("a.showcaseitem_link").fancybox({
				padding				:	10,
				imageScale			:	true,
				zoomOpacity			:	true,
				zoomSpeedIn			:	200,
				zoomSpeedOut		:	200,
				zoomSpeedChange		:	300,
				easingIn			:	'swing',
				easingOut			:	'swing',
				easingChange		:	'swing',
				frameWidth			:	600,
				frameHeight			:	500,
				overlayShow			:	true,
				overlayOpacity		:	0.3,
				hideOnContentClick	:	true,
				centerOnScroll		:	true,
				itemArray			:	[],
				callbackOnStart		:	null,
				callbackOnShow		:	null,
				callbackOnClose		:	null

			 });
			
//FIRST SCROLLER
	//INITIALIZE
    jQuery('#mycarousel-txtscroll-01').jcarousel({
        vertical: true,
        size: 0,
        initCallback: mycarousel_initCallback1
    });

function mycarousel_initCallback1(carousel, state)
{
    // Lock until all items are loaded. That prevents jCarousel from
    // setup correctly and we have to do that in the ajax callback
    // function with carousel.setup().
    // We're doing that because we don't know the exact height of each
    // items until they are added to the list.
    carousel.lock();

    jQuery.get(
        'wp/wp-content/themes/uxable/special_textscroller.php',
        {
            'feed': 'http://userexperiencenews.com/feed'
        },
        function(xml) {
            mycarousel_itemAddCallback1(carousel, xml);
        },
        'xml'
    );
};

function mycarousel_itemAddCallback1(carousel, xml)
{
    var $items = jQuery('item', xml);
    $items.each(function(i) {
        carousel.add(i + 1, mycarousel_txtscroll_01_getItemHTML(this));
    });
    carousel.size($items.size());
    // Unlock and setup.
    carousel.unlock();
    carousel.setup();
};

/* Item html creation helper */
function mycarousel_txtscroll_01_getItemHTML(item)
{
    return '<h3><a href="'+$('link', item).text()+'">'+$('title', item).text()+'</a></h3><p>'+mycarousel_truncate($('description', item).text(), 90)+'</p>';
};

/**
 * Utility function for truncating a string without breaking words.
 */
function mycarousel_truncate(str, length, suffix) {
    if (str.length <= length) {
        return str;
    }
    if (suffix == undefined) {
        suffix = '...';
    }
    return str.substr(0, length).replace(/\s+?(\S+)?$/g, '') + suffix;
};
    /**
     * We show a simple loading indicator
     * using the jQuery ajax events
     */
    jQuery().ajaxStart(function() {
        jQuery(".jcarousel-clip-vertical").addClass('loading');
    });
    jQuery().ajaxStop(function() {
        jQuery(".jcarousel-clip-vertical").removeClass('loading');
    });
		
//SECOND SCROLLER
	//INITIALIZE
    jQuery('#mycarousel-txtscroll-02').jcarousel({
        vertical: true,
        size: 0,
		scroll: 1,
        initCallback: mycarousel_initCallback2
    });

function mycarousel_initCallback2(carousel, state)
{
    // Lock until all items are loaded. That prevents jCarousel from
    // setup correctly and we have to do that in the ajax callback
    // function with carousel.setup().
    // We're doing that because we don't know the exact height of each
    // items until they are added to the list.
    carousel.lock();

    jQuery.get(
        'wp/wp-content/themes/uxable/special_textscroller.php',
        {
            'feed': 'http://twitter.com/statuses/user_timeline/28488553.rss'
        },
        function(xml) {
            mycarousel_itemAddCallback2(carousel, xml);
        },
        'xml'
    );
};

function mycarousel_itemAddCallback2(carousel, xml)
{
    var $items = jQuery('item', xml);
    $items.each(function(i) {
        carousel.add(i + 1, mycarousel_txtscroll_02_getItemHTML(this));
    });
    carousel.size($items.size());
    // Unlock and setup.
    carousel.unlock();
    carousel.setup();
};

/* Item html creation helper */
function mycarousel_txtscroll_02_getItemHTML(item)
{
    return '<h3><a href="'+$('link', item).text()+'">'+$('title', item).text()+'</a></h3><p>'+mycarousel_truncate($('description', item).text(), 90)+'</p>';
};

/**
 * Utility function for truncating a string without breaking words.
 */
function mycarousel_truncate(str, length, suffix) {
    if (str.length <= length) {
        return str;
    }
    if (suffix == undefined) {
        suffix = '...';
    }
    return str.substr(0, length).replace(/\s+?(\S+)?$/g, '') + suffix;
};
    /**
     * We show a simple loading indicator
     * using the jQuery ajax events
     */
    jQuery().ajaxStart(function() {
        jQuery(".jcarousel-clip-vertical").addClass('loading');
    });

    jQuery().ajaxStop(function() {
        jQuery(".jcarousel-clip-vertical").removeClass('loading');
    });

// ABOUT - SLIDESHOW SCRIPT
$(function() {
$('#aboutslides').crossSlide({
  fade: 2,
  shuffle:true
}, [
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_32.jpg',
    href: '#',
    from: '0% 100% 1x',
    to:   '20% 0% .7x',
    time: 5
  }, {
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_31.jpg',
    href: '#',
    from: '100% 100% .6x',
    to:   '0% 50% 1x',
    time: 5
  }, {
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_24.jpg',
    href: '#',
    from: '50% 50% .6x',
    to:   '50% 0% 1x',
    time: 5
  },
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_27.jpg',
    href: '#',
    from: 'bottom center .6x',
    to:   'top center 1x',
    time: 5
  },{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_01.jpg',
    href: '#',
    from: 'center center 0.7x',
    to:   'top center 1x',
    time: 5
  }, 
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_06.jpg',
    href: '#',
    from: '100% 50% 1x',
    to:   '20% 0% 1x',
    time: 5
  },
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_08.jpg',
    href: '#',
    from: '100% 50% .7x',
    to:   '0% 0% 1x',
    time: 5
  },
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_17.jpg',
    href: '#',
    from: '100% 100% 1.2x',
    to:   '0% 50% .8x',
    time: 5
  },
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_19.jpg',
    href: '#',
    from: '50% 20% .7x',
    to:   '100% 0% 1x',
    time: 5
  },
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_20.jpg',
    href: '#',
    from: 'bottom right .7x',
    to:   'top left 1x',
    time: 5
  },
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_22.jpg',
    href: '#',
    from: '50% 0% 1x',
    to:   '100% 100% .6x',
    time: 5
  },
{
    src:  'wp/wp-content/themes/uxable/images/about_slideshow_23.jpg',
    href: '#',
    from: '0% 120% .8x',
    to:   '30% 0% 1.3x',
    time: 5
  }
  ]);
});

// PORTFOLIO SCRIPT
				//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
				
				$('.boxgrid.captionfull').hover(function(){
					$(".cover", this).stop().animate({top:'110px'},{queue:false,duration:160});
				}, function() {
					$(".cover", this).stop().animate({top:'170px'},{queue:false,duration:160});
				});
// SHOWCASE SLIDE SCRIPT
				//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
				
				$('.showcaseitem.captionfull').hover(function(){
					$(".cover", this).stop().animate({top:'222px'},{queue:false,duration:160});
				}, function() {
					$(".cover", this).stop().animate({top:'290px'},{queue:false,duration:160});
				});

// FANCYBOX SCRIPT FOR PORTFOLIO
			$("a.boxgridlink").fancybox({
				padding				:	10,
				imageScale			:	true,
				zoomOpacity			:	true,
				zoomSpeedIn			:	200,
				zoomSpeedOut		:	200,
				zoomSpeedChange		:	300,
				easingIn			:	'swing',
				easingOut			:	'swing',
				easingChange		:	'swing',
				frameWidth			:	600,
				frameHeight			:	500,
				overlayShow			:	true,
				overlayOpacity		:	0.3,
				hideOnContentClick	:	true,
				centerOnScroll		:	true,
				itemArray			:	[],
				callbackOnStart		:	null,
				callbackOnShow		:	null,
				callbackOnClose		:	null
			 });
// VALIDATION FOR CONTACT FORM
$(document).ready(function(){
	$("#contactform").validate();
});

// JQUERY ERROR CONSOLE SCRIPT
$(document).ajaxError(function(){
    if (window.console && window.console.error) {
        console.error(arguments);
    }
});


//START jQuery Tooltip Plugin
$('li.icon_folio_ux, li.icon_folio_identity, li.icon_folio_design, li.icon_folio_dev, li.icon_folio_seo, li.icon_folio_social').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " - ", 
    fade: 250 
});
$('div#box_apps li').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " - ", 
    fade: 250 
});
$('.footer_block li a').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " - ", 
    fade: 250 
});

// SERVICES PAGE - EXPAND CONTENT
	$(".toggle_container").hide();

	$("h5.expand_heading").toggle(function(){
		$(this).addClass("active");
		}, function () {
		$(this).removeClass("active");
	});

	$("h5.expand_heading").click(function(){
		$(this).next(".toggle_container").slideToggle("slow,");
	});
	$(".expand_all").toggle(function(){
		$(this).addClass("expanded");
		}, function () {
		$(this).removeClass("expanded");
	});
	$(".expand_all").click(function(){
		$(".toggle_container").slideToggle("slow,");
	});

// CLOSE ALL
});


