/*!
 * Copyright (c) 2010 Liberty Concepts
 * http://www.libertyconcepts.com
 * All right reserved *
 * @version 1.6
 */

jQuery.noConflict();
var $j = jQuery;

$j(document).ready(function(){

	// Main Navigation
	if ($j("ul.sf-menu").length) {
		$j("ul.sf-menu").supersubs({
				minWidth:15,
				maxWidth:30,
				extraWidth:1 
		}).superfish({delay:400,speed:200 }).find('ul').bgIframe({
				opacity:false
		});
	}

	// Text Resizer
	$j('#font_select').click(function(){
		$j('.content:not("h1,h2,h3,h4")').animate({'font-size':'100%','line-height':'160%'}, 500);
	});
	$j('#font_select_mid').click(function(){
		$j('.content:not("h1,h2,h3,h4")').animate({'font-size':'120%','line-height':'180%'}, 500);
	});
	$j('#font_select_large').click(function(){
		$j('.content:not("h1,h2,h3,h4")').animate({'font-size':'150%','line-height':'200%'}, 500);
	});

	// enable form placeholders for non-HTML5 browsers
	//$j('[placeholder]').placeholder();
	
	// Flickr Feed
	$j('ul#flickr').jflickrfeed({
		limit: 4,
		qstrings: {
			id: '37304598@N02'
		},
		itemTemplate:
		'<li>' +
			'<a rel="colorbox" href="{{image}}" title="{{title}}">' +
				'<img src="{{image_s}}" alt="{{title}}" />' +
			'</a>' +
		'</li>'
	}, function(data) {
		$j('ul#flickr li a').colorbox();
	});
	
	// video colorbox
	$j('a.cb').colorbox({iframe:true, innerWidth:560, innerHeight:421});
	
	//fade siblings on hover
	$j(".support ul li, #flickr li, .connect ul li, .videos li").live({
		mouseenter:
		 function() {
			$j(this).siblings().stop().animate({opacity: 0.5}, "200"); 
		 },
		mouseleave:
		 function() {
			$j(this).siblings().stop().animate({opacity: 1.0}, "200");   
		 }
		}
   );

	// slide show
	$j(".slides").cycle({
		fx: 'fade' ,
		timeout: 8000,
		cleartypeNoBg: true,
		pager:  '.controls' ,				
	 	pagerAnchorBuilder:function(idx,slide){
		 	return '<li><a href="#">'+ parseFloat(idx+1) +'</a></li>';
		}
	});

	// twitter feed
	if( $j('#twitter_update_list').length ){
		$j('#twitter_update_list').cycle({
			fx: 'scrollUp' ,
			timeout: 5000,		
			cleartypeNoBg: true		
		});
	}
	
	// css for ie
	$j('ul.sf-menu li ul li:last-child').css({'border-bottom':'none'});

	// external link dialog
	$j('a').each(function() {
		$j.expr[':'].external = function(obj){
			return !obj.href.match(/^mailto\:/)
			&& (obj.hostname != location.hostname)
			&& !obj.href.match(/^javascript\:/)
			&& !obj.href.match(/^http\:\/\/www.youtube.com\//)
		};
		$j('a:external').addClass('external').attr('target','_blank');
	});

	
});
