﻿var $j = jQuery.noConflict();

$j(document).ready(function()
{
	// Init Function
	function __construct()
	{
		$j('select').uniform();
		
		$j(document).pngFix({ blankgif: '/common/images/blank.gif' });
		
		if ($j('#popup').length > 0)
		{
			$j.colorbox({ opacity: .4, width: "600px", inline: true, href: "#popup" });
		}
		
		/*
		$j('input[type="text"]').each(function()
		{
		    $j(this).CreateAutoSelect();
		}); 
		*/
		
		
		
		
		$j(".sort-item-link").each(function()
		{
			$j('img', this).hover(function()
			{
				//alert($j('img', this).width());
				
				$j(".sort-item-link").each(function()
				{
					$j('img', this).stop().animate({ opacity: '.5' });
				});
				
				$j(this).stop().animate({ opacity: '1' });
				
			}, function()
			{
				$j(".sort-item-link").each(function()
				{
					$j('img', this).stop().animate({ opacity: '1' });
				});
			});
		});
		
	//  Setup the sortable gallery
		if ($j('.sortable').length > 0)
		{
			$j('.sortable').each(function()
			{
				$j(this).EnableSorting({ sortTypes: filterTags, container: $j('.worklist', this) });
			});
		}
		
		
		$j('.slider').each(function()
		{
			//  Smart Phone Fix
			//  The images would not resize with the height: auto; This is a workaround
				var ratio = 1.31;
				var h = Math.floor($j(this).find('img').width() / ratio);		
				$j('.slideItem', this).css({ 'height': h + 'px' });
				$j('.slideItemImg img', this).css({ 'height': h + 'px' });
			
			$j(this).CustomSlider({ controlType: 2, animationType: 'fade' });
		});
		//$j('.slider').CustomSlider({ controlType: 2, animationType: 'custom', animationTime: 500, customParameters: { customAnimation: 'blocks', cols: 3, rows: 3 } });
	};
	
	__construct();
});
