
// .leftalign for 2nd div in div.iho
jQuery(document).ready(function(){jQuery('div.iho').find('div:eq(1)').addClass('leftalign');});

jQuery(document).ready(function(){jQuery('a.cntbl').click(function(){jQuery.ajaxSetup({async: false}); jQuery.post("/x_click_logger", {target: this.id, href: this.href}); return true;});});
jQuery(document).ready(function(){jQuery('div.cntbl').click(function(){jQuery.ajaxSetup({async: false}); jQuery.post("/x_click_logger", {target: this.id, href: ''}); return true;});});




// div.iho > imgs. set div's width to img's
jQuery(document).ready(function(){
var imgs_quantity = jQuery('div.iho > img').length;
for (var i=0; i<imgs_quantity; i++)
	{
		if (!jQuery('div.iho > img')[i].complete)
			{
			jQuery('div.iho > img:eq('+i+')').bind('load', function (event){
			
				var divs_quantity = jQuery(event.target).parent().find('div').length;
				for (j=0;j<divs_quantity;j++)
				{
				jQuery(event.target).parent().find('div')[j].style.width = (event.target.width - 20) + 'px';
				}
				placeMagns();
			
			});
			}
		else
			{
				var divs_quantity = jQuery('div.iho > img:eq('+i+')').parent().find('div').length;
				for (j=0;j<divs_quantity;j++)
				{
				jQuery('div.iho > img:eq('+i+')').parent().find('div')[j].style.width = (jQuery('div.iho > img')[i].width - 20) + 'px';
				}
				
			}
	}
});

// div.iho > a > imgs. set div's width to img's ("copypast")
jQuery(document).ready(function(){
var imgs_quantity = jQuery('div.iho > a > img').length;
for (var i=0; i<imgs_quantity; i++)
	{
		if (!jQuery('div.iho > a > img')[i].complete)
			{
			jQuery('div.iho > a > img:eq('+i+')').bind('load', function (event){
				
				var divs_quantity = jQuery(event.target).parent().parent().find('div').length;
				for (j=0;j<divs_quantity;j++)
				{
				jQuery(event.target).parent().parent().find('div')[j].style.width = (jQuery(event.target).width() - 20) + 'px';
				}
				placeMagns();
			
			});
			}
		else
			{
				
				var divs_quantity = jQuery('div.iho > a > img:eq('+i+')').parent().parent().find('div').length;
				for (j=0;j<divs_quantity;j++)
				{
				jQuery('div.iho > a > img:eq('+i+')').parent().parent().find('div')[j].style.width = (jQuery('div.iho > a > img')[i].width - 20) + 'px';
				}
				
			}
	}
	
	placeMagns();
});


var placeMagns = function()
{
	var fixedPNG = false;
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {fixedPNG = true;}
	
	
jQuery('.magnHolder').addClass('hiddenClass');
var imgs_quantity = jQuery('div.iho > a > img').length;
for (var i=0; i<imgs_quantity; i++)
	{	

			// "лупа" на PNG c альфа, с MSIE-фиксом. увы, после фикса лупа некликабельна!
		
			var magnDiv = '<div class="magnHolder" style="position: absolute; left: ' + (jQuery('div.iho > a > img:eq('+i+')').offset().left + jQuery('div.iho > a > img:eq('+i+')').width() - 30) + 
			'px; top: ' + (jQuery('div.iho > a > img:eq('+i+')').offset().top - 15) + 'px; ';
			if (fixedPNG)
				{magnDiv = magnDiv + 'filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/images/design/magn.png\', sizingMethod=\'scale\'); width: 75px; height: 82px;';}
			magnDiv = magnDiv + '"><a rel="lightbox" href="' + jQuery('div.iho > a > img:eq('+i+')').parent().attr('href') + '">';
			if (fixedPNG)
				{
					magnDiv = magnDiv + '<img src="/images/misc/spacer.gif" alt="" border="0">';}
			else
				{magnDiv = magnDiv + '<img src="/images/design/magn.png" alt="" border="0">';}
			magnDiv = magnDiv + '</a></div>';
				
				
				jQuery('#main_magnHolder')[0].innerHTML =  jQuery('#main_magnHolder')[0].innerHTML + magnDiv;
	}
	
}

jQuery(window).resize(placeMagns);
//jQuery(window).scroll(placeMagns);



