/**
 * Created by JetBrains PhpStorm.
 * User: Treynolds
 * Date: 3/21/11
 * Time: 11:22 AM
 * To change this template use File | Settings | File Templates.
 */
$j(document).ready(function(){
    var landing = $j('.landing-top a, .vision-meetvid a');
    $j(landing).each(function(index){
        var link = landing[index];
        $j(link).fancybox(
            {
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		    : 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}}
            );
    });
    var videos = $j('ul.vision-video-gallery a, a.youtube');

    videos.each(function(index){

        var link = videos[index];
        var matches = link.href.match(/^.*((v\/)|(embed\/)|(watch\?))\??v?=?([^\&\?]*).*/);
        var id = link.href.replace(/^.*\//,'');
        if(matches!=null && matches.length>=5){
            id = matches[5];
        }
        link.innerHTML = "";
        var imageSource = "http://img.youtube.com/vi/" + id + "/0.jpg";
        $j(link).append("<img src='"+imageSource+"' />");
        $j(link).fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}});
        $j(link).bind('click',function(){
            
        });
    });
});
