function strpos(haystack, needle, offset) {
    var i = (haystack+'').indexOf(needle, (offset || 0));
    return i === -1 ? false : i;
}

function setChangeImage(main_class) {
	jQuery(main_class+' .orlyAd a img').each(function (){
		if (jQuery(this).attr('large') != '') {
			jQuery(this).mouseout(function () {
				current_crs = jQuery(this).attr('large');
				jQuery(this).attr('large', jQuery(this).attr('src'));
				jQuery(this).attr('src', current_crs);
				 jQuery(this).parent().next().attr('style','margin-top:5px');
				jQuery(this).attr('style', '');
			}).mouseover(function () {
				current_crs = jQuery(this).attr('src');	
				height = jQuery(this).css('height');
				if (!strpos(height,'px')) {
					height = jQuery(this).height(); 	
				} else {
					height = height.substr(height,  strpos(height,'px'));
				} 
				jQuery(this).attr('src', jQuery(this).attr('large'));
				jQuery(this).attr('large', current_crs);
				height_2 = jQuery(this).css('height');
				if (!strpos(height_2,'px')) {
					height_2 = jQuery(this).height(); 	
				} else {
					height_2 = height_2.substr(height_2,  strpos(height_2,'px'));
				}
				height = height_2 - height - 5;
				jQuery(this).attr('style','position:relative;  z-index:10;')
				 jQuery(this).parent().next().attr('style','margin-top:-'+height+'px');	
			});
		}
	});	
}



function setChangeImageV2(main_class) {
        jQuery(main_class+' .orlyAd a img').each(function (){
                if (jQuery(this).attr('large') != '') {
                        jQuery(this).mouseover(function () {
                        	current_crs = jQuery(this).attr('large');
				current_height = jQuery(this).height()*2+1;
				current_href = jQuery(this).parent().attr('href');
                                jQuery(this).parent().parent().append('<a href="'+current_href+'"><img src="'+current_crs+'" style="margin-top:-'+jQuery(this).parent().parent().height()+'px;"  class="addonImage"/></a>');
				jQuery(this).parent().parent().find('img.addonImage').mouseout( function () {
						jQuery(this).parent().remove();
					}
				);    
                        });
                }
        });
}
