jQuery = jQuery.noConflict();
jQuery(document).ready(function() {
	
	MagicIsNew();
	MagicHitSales();
	Treemenu();
	//initFilterblock();

});


function reloadCaptcha(path)
{
	jQuery("#captImage").attr('src','/kcaptcha/index.php?chk='+Math.random(150000));
}

function MagicIsNew()
{
   jQuery(".IsNew").each( function(i,e)
   {
	
	var _divIsNew = document.createElement("div");
	
	var _position = jQuery(e).position();
	var _newImage = new Image();
	_divIsNew.appendChild(_newImage);
	_divIsNew.className="bord0";
	_newImage.src = "/images/new-offer.png";
	_newImage.onload = function()
	{
		var _positions  = jQuery(e).position();
		var _width  = jQuery(e).width();
		var _height = jQuery(e).height();
		//_divIsNew.width = this.width;
		//_divIsNew.height = this.height;

		jQuery(_divIsNew).css({
						 width:this.width,height:this.height,position:"absolute",top:_positions.top+_height,left:_position.left+_width,'z-index':this.style.zIndex+5});
		jQuery(_divIsNew).insertBefore($(e));
		
	}
	
	});
}

function MagicHitSales()
{
   jQuery(".hit_sales").each( function(i,e)
   {
	
	var _divIsNew = document.createElement("div");
	
	var _position = jQuery(e).position();
	var _newImage = new Image();
	_divIsNew.appendChild(_newImage);
	_divIsNew.className="bord0";
	_newImage.src = "/images/hit.png";
	_newImage.onload = function()
	{
		var _positions  = jQuery(e).position();
		var _width  = jQuery(e).width();
		var _height = jQuery(e).height();
		//_divIsNew.width = this.width;
		//_divIsNew.height = this.height;

		jQuery(_divIsNew).css({
						 width:this.width,height:this.height,position:"absolute",top:_positions.top+_height,left:_position.left+_width-this.width,'z-index':this.style.zIndex+5});
		jQuery(_divIsNew).insertBefore($(e));
		
	}
	
	});
}

function Treemenu()
{
	
	jQuery('.opener').click( 
	function()
	{
			_sub = jQuery(this).attr('rel');
			jQuery(this).toggleClass('this_opened');
			jQuery(_sub).slideToggle();
			//jQuery(_sub).children("li").children("ul").slideToggle();
			if(jQuery(this).hasClass('this_opened'))
			{
				this.src='/img/minus.gif';
			}else
			{
				this.src='/img/plus.gif';
			}

			
	});
	
	jQuery('._alink_').click(function()
	{ 
			
			_sub = jQuery(this).attr('id');
			_sub = _sub.replace('_alink_','#');
			//alert(this);
			jQuery(_sub).trigger('click');
			
			
			return false;
			
	})
	
	jQuery('.opener').filter('.current').trigger('click');
}
function initFilterblock()
{
	jQuery('.filterblock').click( function() { _toogleFilter() } );
	
	
}
function _toogleFilter()
{
	
	
	jQuery('.filter_fieldset').slideToggle();
	
	jQuery('.filterblock').toggleClass('filterblockopened');
}
