jQuery.noConflict();

jQuery( function($) {
	if( $('#highlight .slideshow').length > 0 ) {
		$('#highlight .slideshow').cycle({
		    timeout: 0,
		    fx: 'scrollHorz',
			next: '#highlight .next',
			prev: '#highlight .prev'
		});
	}
	
	$('.fancybox-iframe').fancybox({
		'type'			: 'iframe',
		'width'			: 500,
		'height'		: 600
	});
	
	$('.solution .button').click( function() {
		if( $(this).parents('.solution').children('.popup').length > 0 ) {
			$.fancybox({
				'width'				: 500,
				'height'			: 680,
				'padding'			: 20,
				'autoScale' 		: false,
				'autoDimensions'	: false,
				'centerOnScroll'	: true,
				'content'			: $(this).parents('.solution').children('.popup').first().html()
			});
		}
		return false;
	});
	
	$("#video").click( function() {
		if( $(this).attr('href') == "#" ) {
			return false;
		}else if( this.href.indexOf('youtube') > -1 ) {
			thisHref = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/');
			thisWidth = 640;
			thisHeight = 385;
		}else if( this.href.indexOf('vimeo') > -1 ) {
			thisHref = this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1');
			thisWidth = 640;
			thisHeight = 360;
		}else {
			thisHref = this.href;
			thisWidth = 640;
			thisHeight = 385;
		}

		$.fancybox({
			'padding'	: 0,
			'title'		: this.title,
			'width'		: thisWidth,
			'height'	: thisHeight,
			'href'		: thisHref,
			'type'		: 'swf',
			'swf'		: {
				'allowfullscreen'	: 'true'
			}
		});
		return false;
	});
	
	$('#content #controller a').click( function() {
		if( !$(this).hasClass('selected') ) {
			$(this).addClass('selected').siblings().removeClass('selected');
			if( $(this).hasClass('brokers') ) {
				$('#content .solutions.brokers').slideDown().siblings('.solutions').slideUp();
			}else {
				$('#content .solutions.agents').slideDown().siblings('.solutions').slideUp();
			}
		}
		return false;
	});
});
