<!--
/*!
 **************************************************
 * Copyright 2010 - Danny Carmical
 * http://luckykind.com
 **************************************************/

jQuery.expr[':'].regex = function(elem, index, match) {
    var matchParams = match[3].split(','),
        validLabels = /^(data|css):/,
        attr = {
            method: matchParams[0].match(validLabels) ? 
                        matchParams[0].split(':')[0] : 'attr',
            property: matchParams.shift().replace(validLabels,'')
        },
        regexFlags = 'ig',
        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
    return regex.test(jQuery(elem)[attr.method](attr.property));
}

var $j = jQuery.noConflict();


$j(document).ready(function() {
	
	var lightBoxImages = $j('a.lightbox');
	var lightBoxVideos = $j('a.lightbox-video');
	
	$j.each(lightBoxImages,function(){
		$j(this).hover(
			function(){
				$j(this).children().stop().animate({
					opacity:0.2
				},500);
			},
			function(){
				$j(this).children().stop().animate({
					opacity:1
				},500);				
			}
		);
	});

	lightBoxImages.colorbox({
		maxWidth: '95%',
		maxHeight:'95%'
	});
	
	var first_video = '';
	
	$j.each(lightBoxVideos,function(){

		$j(this).hover(
			function(){
				$j(this).children().stop().animate({
					opacity:0.2
				},500);
			},
			function(){
				$j(this).children().stop().animate({
					opacity:1
				},500);				
			}
		);

		
		var videoID = '#' + $j(this).attr('id').substr(5);
		if(first_video.length==0) {
			first_video = $j(videoID);
		} 
		
		var cb_rel = 'post-videos';
		
		if($j(this).attr('rel')!=cb_rel) {
			cb_rel = $j(this).attr('rel');
		}
		
		$j(this).colorbox({
			inline:true,
			href: videoID,
			maxWidth: '95%',
			maxHeight:'95%',
			current: "Video {current} of {total}",
			rel: cb_rel
		});

	});
	
	var first_video_link = $j('#post-video-1');
	if(first_video_link.length) {
		first_video_link.bind('click',function(){
			$j("a[rel='post-videos']").eq(0).click();
			return false;
		});
	}
	
	var content_video_link = $j('a:regex(class,videolink*)');
	var cvl_num = 0;
	if(content_video_link.length) {
		content_video_link.each(function(){
			$j(this).bind('click',function(){
				cvl_num = $j(this).attr('class').substr(9) - 1;
				$j("a[rel='post-videos']").eq(cvl_num).click();
				return false;
			});
			
		});
	}
	
	
	
	
	$j('.post-img-large').prepend('<div class="overlay-large"></div>');	
});
-->	
