function setup_lightbox($object)
{
	$as = $object.find('a');
	
	$as.each( function()
	{
		$a = $(this);
		
		if ($a.length > 0)
		{
			ext = $a.attr('href');
			ext = ext.substring(ext.length-3, ext.length).toLowerCase();

			if (ext == 'jpg' || ext == 'gif' || ext == 'png')
			{
				$a.lightbox
				({
					id: 'single',
					path: config.images_dir,
					speed: 500,
					single: true
				});
			}
		}
	});
}

var displays =
{
	'small':
	{
		width: 180.0,
		height: 110.0,
		position: 0.375,
		index: 10.0,
		border_height: 2,
		shadow:
		{
			top: 0.0,
			left: -10.0,
			width: 200.0,
			height: 140.0	
		}
	},
	'medium':
	{
		width: 240.0,
		height: 150.0,
		position: 0.245,
		index: 20.0,
		border_height: 3,
		shadow:
		{
			top: -10.0,
			left: -30.0,
			width: 300.0,
			height: 200.0	
		}
	},
	'big':
	{
		width: 340.0,
		height: 215.0,
		position: 0.0,
		index: 30.0,
		border_height: 4,
		shadow:
		{
			top: 0.0,
			left: -40.0,
			width: 420.0,
			height: 265.0	
		}
	},
	'hidden':
	{
		width: 90.0,
		height: 33.0,
		position: 0.0,
		index: 5.0,
		border_height: 1,
		shadow:
		{
			top: 0.0,
			left: -10.0,
			width: 110.0,
			height: 70.0
		}
	}
};
	
var displays_alt =
{
	'small':
	{
		width: 180.0,
		height: 110.0,
		position: 0.205,
		index: 10.0,
		border_height: 2,
		shadow:
		{
			top: 0.0,
			left: -10.0,
			width: 200.0,
			height: 140.0	
		}
	},
	'medium':
	{
		width: 240.0,
		height: 150.0,
		position: 0.0,
		index: 20.0,
		border_height: 3,
		shadow:
		{
			top: -10.0,
			left: -30,
			width: 300.0,
			height: 200.0	
		}
	},
	'hidden':
	{
		width: 90.0,
		height: 33.0,
		position: 0.0,
		index: 5.0,
		border_height: 1,
		shadow:
		{
			top: 0.0,
			left: -10.0,
			width: 110.0,
			height: 70.0
		}
	}
};

function init_display(display, type, direction, config)
{
	if (typeof config == 'undefined')
	{
		var config = displays;
	}
		
	var width = display.parents('div.displays').width();
	var img = display.children('div.item').find('img');
	var item = display.children('div.item');
	var shadow = display.children('img.displays-shadow');
	var border = display.children('div.displays-border');
		
	display.find('div.desc').hide();
		
	border.css
	({
		'width': config[type].width,
		'height': config[type].border_height,
		'top': config[type].height,
		'position': 'absolute'
	});
		
	shadow.css
	({
		'top': config[type].shadow.top,
		'left': config[type].shadow.left,
		'width': config[type].shadow.width,
		'height': config[type].shadow.height,
		'position': 'absolute'
	});
		
	$.merge(item, img).css
	({
		'width': config[type].width,
		'height': config[type].height
	});
		
	display.css
	({
		'left': (typeof config[type].position != 'undefined' ? (width * config[type].position) * direction + width / 2 : config[type].left),
		'z': config[type].index,
		'margin-left': -config[type].width/2
	});
		
	display.removeClass('small').removeClass('medium').removeClass('big').removeClass('hidden');
	display.addClass(type);
	display.css('z-index', config[type].index);
		
	if (type == 'big')
	{
		display.find('div.desc').show();
	}
}

function animate_display(display, type, direction, config)
{
	if (typeof config == 'undefined')
	{
		var config = displays;
	}
	
	var width = display.parents('div.displays').width();
	var img = display.children('div.item').find('img');
	var item = display.children('div.item');
	var shadow = display.children('img.displays-shadow');
	var border = display.children('div.displays-border');
	
	display.find('div.desc').fadeOut(300);
	
	border.animate
	({
		'width': config[type].width,
		'height': config[type].border_height,
		'top': config[type].height
	},
	{
		duration: 500,
		step: function()
		{
			
		},
		complete: function()
		{
			
		}
	});
	
	shadow.animate
	({
		'top': config[type].shadow.top,
		'left': config[type].shadow.left,
		'width': config[type].shadow.width,
		'height': config[type].shadow.height
	},
	{
		duration: 500,
		step: function()
		{
			
		},
		complete: function()
		{
			
		}
	});
	
	$.merge(item, img).animate
	({
		'width': config[type].width,
		'height': config[type].height
	},
	{
		duration: 500,
		step: function()
		{
			
		},
		complete: function()
		{
			
		}
	});

	display.animate
	({
		'left': (width * config[type].position) * direction + width / 2,
		'z': config[type].index,
		'margin-left': -config[type].width/2, 
		'margin-top': -config[type].height/2
	},
	{
		duration: 500,
		step: function()
		{
			if ($(this).hasClass('small') && type == 'small' || $(this).hasClass('medium') && type == 'medium')
			{
				$(this).css('z-index', config['hidden'].index + 1);
			}
		},
		complete: function()
		{
			$(this).removeClass('small').removeClass('medium').removeClass('big').removeClass('hidden');
			$(this).css('z-index', config[type].index);
			$(this).addClass(type);
			
			$(this).find('div.desc').hide();
			
			if (type == 'big')
			{
				$(this).find('div.desc').fadeIn(300);
			}
		}
	});
}

function setup_displays(element)
{
	$display = element;
	var single = element.hasClass('single');

	var width = $display.width();
	$items = $display.children('ul.images').children('li');
	$shadow = $('<img />').attr('src', config.images_dir + 'bg/displays-shadow.png').addClass('displays-shadow');
	$border = $('<div />').html('<div class="center"><div class="left-cap"></div><div class="right-cap"></div></div>').addClass('displays-border');
	
	$items.prepend($shadow).append($border);
	
	if (single)
	{
		if ($display.hasClass('big'))
		{
			$items.each( function()
			{
				init_display($(this), 'big', 1, displays);
				
				$(this).css
				({
					'left': width / 2
				}).hide();
			});
		} else if ($display.hasClass('medium'))
		{
			$items.each( function()
			{
				init_display($(this), 'medium', 1, displays);
				
				$(this).css
				({
					'left': width / 2
				}).hide();
			});
		} else if ($display.hasClass('small'))
		{
			$items.each( function()
			{
				init_display($(this), 'small', 1, displays);
				
				$(this).css
				({
					'left': width / 2
				}).hide();
			});
		}
		$items.eq(0).show();
	} else
	{
		if ($display.hasClass('big'))
		{
			init_display($items.eq(0), 'small', -1, displays);
			init_display($items.eq(1), 'medium', -1, displays);
			init_display($items.eq(2), 'big', 1, displays);
			init_display($items.eq(3), 'medium', 1, displays);
			init_display($items.eq(4), 'small', 1, displays);
			
			$items.eq(4).nextAll('li').each( function()
			{
				init_display($(this), 'hidden', 1, displays);
			});
		} else if ($display.hasClass('medium'))
		{
			init_display($items.eq(0), 'medium', -1, displays);
			init_display($items.eq(1), 'big', 1, displays);
			init_display($items.eq(2), 'medium', 1, displays);
			
			$items.eq(2).nextAll('li').each( function()
			{
				init_display($(this), 'hidden', 1, displays);
			});
		} else if ($display.hasClass('small'))
		{
			init_display($items.eq(0), 'small', -1, displays_alt);
			init_display($items.eq(1), 'medium', 1, displays_alt);
			init_display($items.eq(2), 'small', 1, displays_alt);
			
			$items.eq(2).nextAll('li').each( function()
			{
				init_display($(this), 'hidden', 1, displays);
			});
		}
	}
}

function setup_background(element)
{
	element.slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.images',
		pagination: 'ul.slider-pagination',
		visible: 1,
		slide: 1,
		auto_width: false,
		width: 1280,
		auto_height_parent: true,
		on_show: setup_lightbox
	});
	
	element.children('ul.slider-pagination').hide();
	element.children('ul.slider-nav li').hide();
}

function setup_simple(element)
{
	width = element.children('ul.items').children('li').width();
	height = element.children('ul.items').children('li').height();
	
	element.children('ul.items').width(width).height(height);
	
	element.children('ul.items').children('li').hide().eq(0).show();
	
	element.children('div.featured-ribbon').css('top', height/2 - 60);
}

function setup_pure(element)
{
	width = element.parent().width();
	
	element.children('ul.images').children('li').width(width);
	
	element.slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.images',
		pagination: 'ul.slider-pagination',
		visible: 1,
		slide: 1,
		width: width,
		auto_width: false,
		auto_height_parent: true,
		on_show: setup_lightbox
	});	
}

function setup_video(element)
{
	element.slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.video-previews',
		pagination: 'ul.slider-pagination',
		visible: 2,
		slide: 1,
		auto_width: false,
		width: 340,
		auto_height_parent: false
	});
	
	element.find('.slider-wrapper').css('clear', 'right');
}

function setup_wide(element)
{
	element.slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.images',
		pagination: 'ul.slider-pagination',
		visible: 1,
		slide: 1,
		auto_width: false,
		width: 980,
		auto_height_parent: false,
		on_show: setup_lightbox
	});
}

$( function()
{
	// JS SUPPORT BEGIN

	$(config.js_support).addClass('js');
	
	// JS SUPPORT END
	
	// TOGGLE BEGIN
	
	$('a.toggle').each( function()
	{
		if ( ! $(this).hasClass('hide'))
		{
			$(this).next().hide();
		} else
		{
			$(this).next().show();
		}
	});
	
	$('a.toggle').click( function()
	{
		$(this).toggleClass('hide');
		
		if ($(this).hasClass('hide'))
		{
			$(this).next().show();
		} else
		{
			$(this).next().hide();
		}
		
		return false;
	});
	
	// TOGGLE END
	
	// TWITTER SLIDER BEGIN
	
	$('#main-heading > #twitter_div').css('padding-bottom', '50px').slider
	({
		nav: 'ul.slider-nav',
		items: 'ul#twitter_update_list',
		wrapper_class: 'twiter_wrapper',
		visible: 3,
		slide: 1,
		speed: 500,
		fade: true,
		auto_height_parent: true
	});

	/*$('#twitter_div').slider
	({
		nav: 'ul.slider-nav',
		items: 'ul#twitter_update_list',
		wrapper_class: 'twiter_wrapper',
		visible: 3,
		slide: 1,
		speed: 500,
		fade: true,
		width: 200,
		auto_width: false,
		horizontal: false
	});*/
	
	$('div.sidebar > #twitter_div').each( function()
	{
		$(this).data('index', 0);
		$tweets = $(this).children('ul#twitter_update_list').children('li');
		width = $(this).parent().width();
		
		if ($tweets.length > config.twitter_widget.visible)
		{
			height = 0;
			
			for (i = 0; i < config.twitter_widget.visible - 1; i++)
			{
				height += $tweets.eq(i).outerHeight();
			}
			
			$twitter_wrapper = $('<div />').addClass('twitter_wrapper').css
			({
				'position': 'relative',
				'overflow': 'hidden',
				'width': width,
				'height': height - 20
			});
		
			$(this).children('ul#twitter_update_list').wrap($twitter_wrapper).css
			({
				'top': 0,
				'position': 'absolute',
				'width': width,
				'height': 9999
			});
			
			$(this).children('ul.slider-nav').children('li.prev').click( function()
			{
				$tweets = $(this).parent().prev('.twitter_wrapper').children('ul#twitter_update_list');
				size = $tweets.children('li').length;
				current = $tweets.parents('#twitter_div').data('index');
				prev = current - 1;
				
				if (prev >= 0)
				{
					height = 0;
					
					for (i = 0; i < prev; i++)
					{
						if ($tweets.children('li').eq(i).length > 0)
						{
							height += $tweets.children('li').eq(i).outerHeight();
						}
					}

					$tweets.animate
					({
						'top': -(height + 20)
					}, config.twitter_widget.speed, function()
					{
						
					});
					
					height = 0;
					
					for (i = prev; i < prev + config.twitter_widget.visible; i++)
					{
						if ($tweets.children('li').eq(i).length > 0)
						{
							height += $tweets.children('li').eq(i).outerHeight();
						}
					}
					
					$tweets.parent('.twitter_wrapper').animate
					({
						'height': height
					}, config.twitter_widget.speed, function()
					{
						
					});
					
					$tweets.parents('#twitter_div').data('index', prev);
				}
				
				return false;
			});
			
			$(this).children('ul.slider-nav').children('li.next').click( function()
			{
				$tweets = $(this).parent().prev('.twitter_wrapper').children('ul#twitter_update_list');
				size = $tweets.children('li').length;
				current = $tweets.parents('#twitter_div').data('index');
				next = current + 1;
				
				if (next + config.twitter_widget.visible < size)
				{
					height = 0;
					
					for (i = 0; i < next; i++)
					{
						if ($tweets.children('li').eq(i).length > 0)
						{
							height += $tweets.children('li').eq(i).outerHeight();
						}
					}
					
					$tweets.animate
					({
						'top': -(height + 20)
					}, config.twitter_widget.speed, function()
					{
						
					});
					
					height = 0;
					
					for (i = next; i < next + config.twitter_widget.visible; i++)
					{
						if ($tweets.children('li').eq(i).length > 0)
						{
							height += $tweets.children('li').eq(i).outerHeight();
						}
					}
					
					$tweets.parent('.twitter_wrapper').animate
					({
						'height': height
					}, config.twitter_widget.speed, function()
					{
						
					});
					
					$tweets.parents('#twitter_div').data('index', next);
				}
				
				
				return false;
			});
		}
	});
	
	// TWITTER SLIDER END
	
	// DESCRIPTION FOR IMAGES FROM TITLE ATTRIBUTE BEGIN
	
	$('a.frame > img').each( function()
	{
		if ($(this).attr('title') != '' && $(this).parents('div.flickr-feed').length == 0)
		{
			title = $(this).attr('title');

			$(this).after
			(
				$('<span />').addClass('title-description').text(title)
			);
			
			if ($(this).hasClass('aligncenter') || $(this).parent('a.frame').hasClass('aligncenter'))
			{
				$(this).load( function()
				{
					$img = $(this);
					
					$(this).parent('a.frame').css
					({
						'width': $img.width(),
						'margin-left': 'auto',
						'margin-right': 'auto'
					});
				});
			}
		}
	});
	
	$('.frame > *').each( function()
	{
		if ($(this)[0].tagName.toLowerCase() != 'img' && $(this)[0].tagName.toLowerCase() != 'span')
		{
			$(this).parent('.frame').width($(this).width());
		}
	});
	
	$('.lightbox-icon').each( function()
	{
		width = $(this).parent().width();
		height = $(this).parent().height();
		
		$(this).css
		({
			'position': 'absolute',
			'top': 0,
			'left': 0,
			'width': width,
			'height': height
		});
	});
		
	// DESCRIPTION FOR IMAGES FROM TITLE ATTRIBUTE END
	
	// SCROLL TOP BEGIN
	
	$('a[href=#header],a.separator').click( function()
	{
		$('html,body').animate
		({
			'scrollTop': 0
		}, 300);
		
		return false;
	});
	
	// SCROLL TOP END
	
	// TOOLTIPS BEGIN

	$(config.tooltips_standalone).tooltip
	({
		tooltip: '.tooltip',
		x: 20,
		y: 25,
		standalone: true
	});
	
	$(config.tooltips).tooltip
	({
		tooltip: '.tooltip',
		x: 20,
		y: 25
	});
	
	// TOOLTIPS END
	
	// PRICING TABLE HOVER BEGIN
	
	$('table.pricing-1').each( function()
	{
		index = $(this).find('table').index($(this).find('table.current'));
		
		$(this).data('default-col', index);
	});
	
	$('table.pricing-1').hover( function()
	{

	}, function()
	{
		index = $(this).data('default-col');
		
		$(this).find('table').removeClass('current').eq(index).addClass('current');
	});
	
	$('table.pricing-1 td > table').hover( function()
	{
		$(this).parents('table.pricing-1').find('table').removeClass('current');
		$(this).addClass('current');
	}, function()
	{
		$(this).removeClass('current');
	});

	// PRICING TABLE HOVER END
	
	// TABLE TOOLTIPS BEGIN
	
	$('td').each( function()
	{
		if (typeof $(this).attr('custom-description') != 'undefined' && $(this).attr('custom-description') != '')
		{
			desc = $(this).attr('custom-description');
			$(this).append($('<span />').hide().addClass('tooltip').html('<span>' + desc + '</span>'));
		}
	});
	
	$('td').tooltip
	({
		tooltip: '.tooltip',
		x: 20,
		y: 25,
		offset: false
	});
	
	// TABLE TOOLTIPS END
	
	// MENU BEGIN
		
	$('ul.menu-1 li[class!=current] ul').hide();
	
	$('ul.menu-1 > li a').click( function()
	{
		$current = $(this);
		$not_current = $(this).parents('ul.menu-1').children('li').children('a').not(this);
		
		$current.parent('li').addClass('current');
		$current.next('ul').slideDown(500);
		
		if ($not_current.next('ul:visible').length > 0)
		{
			$not_current.next('ul:visible').slideUp(500, function()
			{
				$(this).parent('li').removeClass('current');
			});
		} else
		{
			$not_current.parent('li').removeClass('current');
		}
		
		$current.parent('li').addClass('current');
	
		if ($current.next('ul').length > 0)
		{
			return false;
		}
	});

	// MENU END
	
	// TABS BEGIN
	
	$('.tabs').tabs();
	
	// TABS END
	
	$background = $('div.background').clone();
	$('div.background').remove();
	$('div#container').prepend($background);

	// NAV BEGIN
	
	$(config.dropdown).dropdown();
	
	// NAV END
	
	// FORM VALIDATION BEGIN
	
	$(config.form_validate).blur( function()
	{
		val = $(this).val();

		$(this).removeClass('valid');
			
		if (val == '' || val == $(this).data('placeholder'))
		{
			$(this).addClass('error');
		} else
		{
			if ($(this).attr('name') == 'email' || $(this).attr('id') == 'email' || $(this).hasClass('email'))
			{
				if (/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(val))
				{
					$(this).removeClass('error').addClass('valid');
				} else
				{
					$(this).addClass('error');
				}
			} else
			{
				$(this).removeClass('error').addClass('valid');
			}
		}
	});
	
	$('form').submit( function()
	{
		if ($(this).find('input.error, textarea.error').length > 0)
		{
			return false;
		}
	});

	// FORM VALIDATION END
	
	// FORM PLACEHOLDERS BEGIN
	
	$(config.input_placeholder).placeholder(config.placeholder);
		
	// FORM PLACEHOLDERS END
	
	// PAGINATION POSITIONING BEGIN
	
	$pagination = $('ul.pagination');
	
	$pagination.each( function()
	{
		if ( ! $(this).hasClass('compact'))
		{			
			$(this).css('margin-left', $(this).parent().width() / 2 - $(this).outerWidth(true) / 2);
		}
	});

	// PAGINATION POSITIONING END
	
	// BORDER FIX BEGIN
	
	if ($.browser.msie || ($.browser.mozilla && $.browser.version < '1.9') || $.browser.opera)
	{
		$(config.border_shadow).addClass('border');
	}
	
	// BORDER FIX END
	
	// DROP CAP BEGIN
	
	$('p.first-letter').each( function()
	{
		html = $(this).html();
		
		for (var i = 0; i < html.length; i++)
		{
			if (i == 0 && /^[a-z]+$/.test(html.substring(0, 1).toLowerCase()))
			{
				$(this).html('<span class="dropcap">' + html.substring(0, 1) + '</span>' + html.substring(i + 2, html.length));
				break;
			} else
			{
				if (html.substring(i, 1) == '>' && /^[a-z]+$/.test(html.substring(i + 1, 1).toLowerCase()))
				{
					
					$(this).html(html.substring(0, i) + '<span class="dropcap">' + html.substring(i + 1, 1) + '</span>' + html.substring(i + 2, html.length));
					break;
				}
			}
		}
	});
	
	// DROP CAP END
	
	// ZOOMBOX ENLARGED BEGIN
	
	$('div.zoombox').each( function()
	{
		$enlarged = $(this).children('div.enlarged');

		if ($enlarged.children('img').length == 0)
		{
			$desc = $(this).children('ul.images').children('li').eq(0).children('div.desc').clone();
			$desc.show();
			var src = $(this).children('ul.images').children('li').eq(0).children('a').attr('href');
			
			$enlarged.append($('<img />').attr('src', src));
			$enlarged.append($desc);
		}
	});
	
	// ZOOMBOX ENLARGED END
	
	// DISPLAYS INITIALIZATION BEGIN

	$('div.displays').each( function()
	{
		setup_displays($(this));
	});
	
	// DISPLAYS INITIALIZATION END
	
	// FEATURED SLIDER BEGIN
	
	$('div.featured-1').each( function()
	{
		width = $(this).width();
		
		$(this).children('ul.items').children('li').css('width', width - (width * 0.2));
	});
	
	$('div.featured-1').slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.items',
		visible: 1,
		slide: 1,
		speed: 500,
		auto_height_parent: true
	});
	
	// FEATURED SLIDER END
});

$(window).load( function()
{
	// ZOOM BOX BEGIN

	$('div.zoombox').each( function()
	{
		var item_width = $(this).children('ul.images').children('li').width();
		
		$(this).children('ul.slider-nav').css
		({
			'bottom': item_width
		}).children('li').children('a').css
		({
			'width': item_width,
			'height': item_width
		});
		
		$enlarged = $(this).children('div.enlarged');
		$img = $(this).children('div.enlarged').children('img');
		
		$enlarged.css
		({
			'overflow': 'hidden',
			'position': 'relative',
			'height': $enlarged.height(),
			'width': $enlarged.width()
		});
		
		if ($(this).parent().width() < $enlarged.width())
		{
			$enlarged.width($(this).parent().width());
		}
		
		$img.css
		({
			'position': 'absolute',
			'top': $enlarged.height()/2 - $img.height()/2,
			'left': $enlarged.width()/2 - $img.width()/2
		});
		
		$(this).children('ul.images').css
		({
			'margin-left': item_width
		});
		
		$(this).slider
		({
			nav: 'ul.slider-nav',
			items: 'ul.images',
			visible: Math.round(($(this).width() / item_width)) - 2,
			slide: 2,
			speed: 600,
			auto_width: false,
			width: $enlarged.width() - item_width
		});
	});
	
	$('div.zoombox div.enlarged').mousemove( function(e)
	{
		$enlarged = $(this);
		$img = $enlarged.children('img');

		var x = $img.width()/2 - ((e.pageX - $enlarged.offset().left) / $enlarged.width() * $img.width());
		var y = $img.height()/2 - ((e.pageY - $enlarged.offset().top) / $enlarged.height() * $img.height());
		var offsetx = $enlarged.width()/2 - (e.pageX - $enlarged.offset().left);
		var offsety = $enlarged.height()/2 - (e.pageY - $enlarged.offset().top);

		$img.css
		({
			'top': $enlarged.height()/2 - $img.height() / 2 + y - offsety, 
			'left': $enlarged.width()/2 - $img.width() / 2 + x - offsetx 
		});
	});

	$('div.zoombox ul.images li').live('click', function()
	{
		$this = $(this);
		$desc = $(this).children('div.desc').clone();
		$zoombox = $(this).parents('div.zoombox');
		$enlarged = $zoombox.children('div.enlarged');
		
		$enlarged.children('div.desc').remove();
		$img = $enlarged.children('img');
		
		$img.imgload($this.children('a').attr('href')).load( function()
		{
			$(this).css
			({
				'top': $enlarged.height()/2 - $(this).height()/2,
				'left': $enlarged.width()/2 - $(this).width()/2
			});
		}, { path: config.images_dir });
		
		$zoombox.children('div.enlarged').append($desc);
		
		return false;
	});
	
	$('div.picture-in-picture ul.images li').live('click', function()
	{
		$zoombox = $(this).parents('div.picture-in-picture');
		
		$img = $zoombox.children('div.enlarged').children('img');
		$img.imgload($(this).children('a').attr('href'), { path: config.images_dir });
		
		return false;
	});
	
	
	// ZOOM BOX END
	
	// GALLERIES SLIDERS END
	
	// SLIDERS BEGIN

	$('div.flickr-feed').slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.items',
		visible: 2,
		slide: 2,
		speed: 500,
		on_show: setup_lightbox
	});
	
	$('#partners').slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.items',
		visible: 5,
		slide: config.partners.slide,
		speed: config.partners.speed,
		fade: config.partners.fade,
		easing: config.partners.easing
	});
	
	$('div.success-stories').slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.items',
		wrapper_class: 'success-stories-wrapper',
		visible: 1,
		slide: 1,
		speed: config.success_stories.speed,
		fade: config.success_stories.fade,
		easing: config.success_stories.easing,
		on_show: setup_lightbox
	});
	
	$('div.success-stories-wrapper').css
	({
		'padding-left': '1px',
		'padding-right': '1px'
	});
	
	$('div.testimonials').each( function()
	{
		width = $(this).width();
		
		$(this).children('ul.items').children('li').css('width', width - (width * 0.2));
	});
	
	$('div.testimonials').slider
	({
		nav: 'ul.slider-nav',
		items: 'ul.items',
		visible: 1,
		slide: 1,
		speed: config.testimonials.speed,
		fade: config.testimonials.fade,
		easing: config.testimonials.easing,
		auto_height_parent: true
	});
	
	
	// SLIDERS END

	$('div.displays ul.slider-nav li.prev').live('click', function()
	{
		var width = $(this).parents('div.displays').width() / 2;
		$displays = $(this).parents('div.displays').children('ul.images');
		var single = $(this).parents('div.displays').hasClass('single');
		
		$big = $displays.children('li.big');
		$medium = $displays.children('li.medium');
		$small = $displays.children('li.small');
		$hidden = $displays.children('li.hidden');
		
		if ($displays.children('li:animated').length == 0)
		{
			if ( ! single)
			{
				if ($big.not('animated'))
				{
					if ($big.length == 1 && $medium.length == 2 && $small.length == 2)
					{
						$small_left = ($small.first().position().left < width ? $small.first() : $small.last());
						$medium_left = ($medium.first().position().left < width ? $medium.first() : $medium.last());
						$medium_right = ($medium.first().position().left > width ? $medium.first() : $medium.last());
						$small_right = ($small.first().position().left > width ? $small.first() : $small.last());
						$hidden_left = $hidden.first();
						
						if ($hidden_left.length == 0)
						{
							animate_display($small_right, 'small', -1);
						} else
						{
							animate_display($hidden.last(), 'small', -1);
							animate_display($small_right, 'hidden', -1);
						}
						
						animate_display($small_left, 'medium', -1);
						animate_display($medium_left, 'big', -1)
						animate_display($big, 'medium', 1);
						animate_display($medium_right, 'small', 1);
					} else if ($big.length == 1 && $medium.length == 2 && $small.length == 0)
					{
						$medium_left = ($medium.first().position().left < width ? $medium.first() : $medium.last());
						$medium_right = ($medium.first().position().left > width ? $medium.first() : $medium.last());
						$hidden_left = $hidden.first();
						
						if ($hidden_left.length == 0)
						{
							animate_display($medium_right, 'medium', -1);
						} else
						{
							animate_display($hidden.last(), 'medium', -1);
							animate_display($medium_right, 'hidden', -1);
						}
						
						animate_display($medium_left, 'big', -1)
						animate_display($big, 'medium', 1);
					} else if ($big.length == 0 && $medium.length == 1 && $small.length == 2)
					{
						$small_left = ($small.first().position().left < width ? $small.first() : $small.last());
						$small_right = ($small.first().position().left > width ? $small.first() : $small.last());
						$hidden_left = $hidden.first();
						
						if ($hidden_left.length == 0)
						{
							animate_display($small_right, 'small', -1, displays_alt);
						} else
						{
							animate_display($hidden.last(), 'small', -1, displays_alt);
							animate_display($small_right, 'hidden', -1, displays_alt);
						}
						
						animate_display($small_left, 'medium', -1, displays_alt)
						animate_display($medium, 'small', 1, displays_alt);
					}
				}
			} else
			{
				$items = $displays.children('li');
				current = $items.index($displays.children('li:visible'));
				prev = current - 1
				
				if (prev < 0)
				{
					prev = $items.length - 1;
				}

				$items.eq(current).fadeOut();
				$items.eq(prev).fadeIn();
			}
		}
		
		return false;
	});
	
	$('div.displays ul.slider-nav li.next').live('click', function()
	{
		var width = $(this).parents('div.displays').width() / 2;
		$displays = $(this).parents('div.displays').children('ul.images');
		var single = $(this).parents('div.displays').hasClass('single');
		
		$big = $displays.children('li.big');
		$medium = $displays.children('li.medium');
		$small = $displays.children('li.small');
		$hidden = $displays.children('li.hidden');
		
		if ($displays.children('li:animated').length == 0)
		{
			if ( ! single)
			{
				if ($big.not('animated'))
				{
					if ($big.length == 1 && $medium.length == 2 && $small.length == 2)
					{
						$small_left = ($small.first().position().left < width ? $small.first() : $small.last());
						$medium_left = ($medium.first().position().left < width ? $medium.first() : $medium.last());
						$medium_right = ($medium.first().position().left > width ? $medium.first() : $medium.last());
						$small_right = ($small.first().position().left > width ? $small.first() : $small.last());
						$hidden_right = $hidden.last();
						
						if ($hidden_right.length == 0)
						{
							animate_display($small_left, 'small', 1);
						} else
						{
							animate_display($hidden.last(), 'small', 1);
							animate_display($small_left, 'hidden', 1);
						}
						
						animate_display($small_right, 'medium', 1);
						animate_display($medium_right, 'big', -1)
						animate_display($big, 'medium', -1);
						animate_display($medium_left, 'small', -1);
					} else if ($big.length == 1 && $medium.length == 2 && $small.length == 0)
					{
						$medium_left = ($medium.first().position().left < width ? $medium.first() : $medium.last());
						$medium_right = ($medium.first().position().left > width ? $medium.first() : $medium.last());
						$hidden_right = $hidden.last();
						
						if ($hidden_right.length == 0)
						{
							animate_display($medium_left, 'medium', 1);
						} else
						{
							animate_display($hidden.last(), 'medium', 1);
							animate_display($medium_left, 'hidden', 1);
						}
						
						animate_display($medium_right, 'big', -1)
						animate_display($big, 'medium', -1);
					} else if ($big.length == 0 && $medium.length == 1 && $small.length == 2)
					{
						$small_left = ($small.first().position().left < width ? $small.first() : $small.last());
						$small_right = ($small.first().position().left > width ? $small.first() : $small.last());
						$hidden_right = $hidden.last();
						
						if ($hidden_right.length == 0)
						{
							animate_display($small_left, 'small', 1, displays_alt);
						} else
						{
							animate_display($hidden.last(), 'small', 1, displays_alt);
							animate_display($small_left, 'hidden', 1, displays_alt);
						}
						
						animate_display($small_right, 'medium', -1, displays_alt)
						animate_display($medium, 'small', -1, displays_alt);
					}
				}
			} else
			{
				$items = $displays.children('li');
				current = $items.index($displays.children('li:visible'));
				next = current + 1

				if (next > $items.length - 1)
				{
					next = 0;
				}
				
				$items.eq(current).fadeOut();
				$items.eq(next).fadeIn();
			}
		}
		
		return false;
	});

	setup_background($('div.background'));
	
	$('div.background > div.slider-wrapper').live('mousemove', function(e)
	{
		width = $(this).width();
		height = $(this).height();

		if (e.pageY - $(this).offset().top > height - height / 8)
		{
			$(this).nextAll('ul.slider-pagination').show();
		} else
		{
			$(this).nextAll('ul.slider-pagination').hide();
		}
		
		if (e.pageX - $(this).offset().left < width / 6)
		{
			$(this).nextAll('ul.slider-nav').children('li.prev').show();
		} else
		{
			$(this).nextAll('ul.slider-nav').children('li.prev').hide();
		}
		
		if (e.pageX - $(this).offset().left > width - width / 6)
		{
			$(this).nextAll('ul.slider-nav').children('li.next').show();
		} else
		{
			$(this).nextAll('ul.slider-nav').children('li.next').hide();
		}
	});
	
	$('div.background ul.slider-pagination li').live('hover', function()
	{
		$(this).parent().show();
	}, function()
	{
	});
	
	$('div.background ul.slider-nav li').live('hover', function()
	{
		$(this).show();
		$(this).parents('div.background').children('ul.slider-pagination').show();
	}, function()
	{
		$(this).parents('div.background').children('ul.slider-pagination').hide();
	});
	
	$('div.background div.slider-wrapper').live('hover', function()
	{
		
	}, function()
	{
		$(this).nextAll('ul.slider-nav').children('li').hide();
		$(this).nextAll('ul.slider-pagination').hide();
	});
	
	$('div.simple').each( function()
	{
		setup_simple($(this));
	});
	
	$('div.simple ul.slider-pagination li').live('click', function()
	{
		if ( ! $(this).hasClass('current'))
		{
			index = $(this).parent().children('li').index(this);
			$(this).parent().children('li').removeClass('current').eq(index).addClass('current');
			
			$items = $(this).parents('div.simple').children('ul.items');

			$items.children('li:visible').fadeOut(500);
			$items.children('li').eq(index).fadeIn(500);
		}
		
		return false;
	});
	
	$('div.pure').each( function()
	{
		setup_pure($(this));
	});
	
	setup_video($('div.video'));

	setup_wide($('div.wide'));
	
	$('div.background ul.slider-pagination, div.wide ul.slider-pagination, div.pure ul.slider-pagination').addClass('bottom-middle');
	
	$('div.background ul.slider-nav li').live('click', function()
	{
		return false;
	});
	
	// DESCRIPTION FOR IMAGES FROM TITLE ATTRIBUTE BEGIN
	
	$('a.frame > img').each( function()
	{
		width = $(this).width();
			
		if ($(this).next('span.title-description').length > 0)
		{
			$(this).next('span.title-description').css('width', width);
		}
	});
		
	// DESCRIPTION FOR IMAGES FROM TITLE ATTRIBUTE END
	
	// LIGHTBOX BEGIN
	
	$('div.columns > div > a.frame, div.columns > div > p > a.frame, div.columns > div > ul.news > li > a.frame, div.columns > div > ul.news > li > p > a.frame, div.nivo-slider > a, #partners a, div.header > a.frame').each( function()
	{
		if ($(this).children('img').length > 0)
		{
			ext = $(this).attr('href');
			ext = ext.substring(ext.length-3, ext.length).toLowerCase();

			if (ext == 'jpg' || ext == 'gif' || ext == 'png')
			{
				$(this).lightbox
				({
					id: 'single',
					path: config.images_dir,
					speed: 500,
					single: true
				});
			}
		}
	});

	$('a[rel=lightbox]').lightbox
	({
		id: 'frame-images',
		path: config.images_dir,
		speed: 500,
		single:true
	});

	// LIGHTBOX END
});

