/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *      @Filename:          None(Exists in tmcatalogtheme -> JS)
 *      @File path:         /smewebhome/PACKAGEID/Catalog/
 *      @Version:           1.0
 *      @Last change:       2010-09-09
 *      
 *      @Purpose:           Proportional product image fix.
 *    
 *      @Author:            Henrik Andersen
 *      
 *		@NOTE'S:			Dont use this code on new cusomers! This is only a emergency fix.
 *
 *		<script type="text/javascript" src="pub/JS/jquery-1.3.2.min.js"></script>
 *		<script type="text/javascript" src="Catalog/jsImageFix.js"></script>
 *							
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
var jsProductImageFix = 
{	
	init : function()
	{
		jsProductImageFix.checkRunPermission();
	},
	
	checkRunPermission : function()
	{
		var $elmStartPageContainer	= $('#Catalog_StartPage');
		var $elmProductListingPage	= $('#Catalog_ProductContainer');
		var $elmProductPage			= $('.Catalog_FileContainer');
		
		if($elmStartPageContainer.length == 1)
		{
			jsProductImageFix.replaceStartpageImages();
		}
		
		if($elmProductListingPage.length == 1)
		{
			jsProductImageFix.replaceProductListingPageImages();
		}
		
		if($elmProductPage.length == 1)
		{
			jsProductImageFix.replaceProductPageImage();
		}
	},	
	
	replaceStartpageImages : function()
	{
		$('#Catalog_StartPage img').each(function()
		{
			var strProductImageSrc 		= $(this).attr('src');
			var strNewProductImageSrc	= strProductImageSrc.replace('.thumbs/', '');
			
			$(this).css('max-height', '150px');
			$(this).css('max-width', '150px');
			$(this).css('height', 'auto');
			$(this).css('width', 'auto');
			$(this).attr('src', strNewProductImageSrc);
		});
	}, 
	
	replaceProductListingPageImages : function()
	{
		$('#Catalog_ProductContainer img').each(function()
		{
			var strProductImageSrc 		= $(this).attr('src');
			var strNewProductImageSrc	= strProductImageSrc.replace('.thumbs/', '');
			
			$(this).css('max-height', '110px');
			$(this).css('max-width', '110px');
			$(this).css('height', 'auto');
			$(this).css('width', 'auto');
			$(this).attr('src', strNewProductImageSrc);
		});
	}, 
	
	replaceProductPageImage : function()
	{
		$('.Catalog_PrimaryContainer img').each(function()
		{
			var strProductImageSrc 		= $(this).attr('src');
			var strNewProductImageSrc	= strProductImageSrc.replace('.thumbs/', '');
			
			$(this).css('max-height', '183px');
			$(this).css('max-width', '183px');
			$(this).css('height', 'auto');
			$(this).css('width', 'auto');
			$(this).attr('src', strNewProductImageSrc);
		});
	}
}

$(document).ready(function()
{  
	jsProductImageFix.init();
});
