jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

(function($){
/*----------------------------------------------------------------------------------
Class: FloatObject
-------------------------------------------------------------------------------------*/
	function FloatObject(jqObj, params)
	{
		this.jqObj = jqObj;
		
		switch(params.speed)
		{
			case 'fast': this.steps = 5; break;
			case 'normal': this.steps = 10; break;
			case 'slow': this.steps = 20; break;
			default: this.steps = 10;
		};
		
		var offset = this.jqObj.offset();
		this.currentY = offset.top;
		this.width = this.jqObj.width();
		this.height = this.jqObj.height();
		this.alwaysVisible = params.alwaysVisible;
		this.alwaysTop = params.alwaysTop;
		
		
		this.origY = typeof(params.y) == "string" ?  this.currentY : params.y;
		
		this.scrollLength = typeof(params.scrollLength) == "string" ? this.scrollLength : params.scrollLength;
		
		//now we make sure the object is in absolute positions.
		this.jqObj.css({'position':'absolute' , 'top':this.currentY});
	}
	
	FloatObject.prototype.updateLocation = function()
	{
		
		
		if( this.alwaysTop == false ){
			if($(window).scrollTop() > this.origY){
				this.updatedY = $(window).scrollTop();
			}
			
			if( this.alwaysVisible ){
				if( this.origY + this.height > this.windowHeight() ) 
				{
					this.updatedY = $(window).scrollTop() + this.windowHeight() - this.height;
					if( this.updatedY < this.origY ) this.updatedY = this.origY;
				}				
			}
		}
		else
		{

			if( $(window).scrollTop() > this.origY )
			{
				this.updatedY = $(window).scrollTop() + 5;
			}
			else
			{
				this.updatedY = this.origY + 5;
			}
		}
		
		if(($(".sidebar").position().top + $(".sidebar").height()) > $(".main").position().top + $(".main").height()){			
			this.updatedY = this.origY + $(".main").height() - $(".sidebar").height();
		}
		
		if($(window).scrollTop() < this.origY){
			this.updatedY = this.origY;
		}
		
		if(this.updatedY < this.origY){
			this.updatedY = this.origY;
		}
		
		this.dy = Math.abs(this.updatedY - this.currentY );
		
		return this.dy;
	}
	
	FloatObject.prototype.windowHeight = function()
	{
		var de = document.documentElement;
		
		return self.innerHeight ||
			(de && de.clientHeight) ||
			document.body.clientHeight;
	}
	
	FloatObject.prototype.windowWidth = function()
	{
		var de = document.documentElement;
		
		return self.innerWidth ||
			(de && de.clientWidth) ||
			document.body.clientWidth;
	}
	
	
	FloatObject.prototype.move = function()
	{
		if( this.jqObj.css("position") != "absolute" ) return;
		var cy = 0;
		
		if( this.dy > 0 )
		{
			if( this.dy < this.steps / 2 )
				cy = (this.dy >= 1) ? 1 : 0;
			else
				cy = Math.round(this.dy/this.steps);
			
			if( this.currentY < this.updatedY )
				this.currentY += cy;
			else
				this.currentY -= cy;
		}
		
		this.jqObj.css({'top': this.currentY });			

	}

	
	
/*----------------------------------------------------------------------------------
Object: floatMgr
-------------------------------------------------------------------------------------*/		
	$.floatMgr = {
		
		FOArray: new Array() ,
		
		timer: null ,
		
		initializeFO: function(jqObj,params) 
		{
			var settings =  $.extend({
				x: 0 ,
				y: 0 ,
				speed: 'fast'	,
				alwaysVisible: false ,
				alwaysTop: false},params||{});
			var newFO = new FloatObject(jqObj,settings);
			
			$.floatMgr.FOArray.push(newFO);
			
			if( !$.floatMgr.timer ) $.floatMgr.adjustFO();
			
			//now making sure we are registered to all required window events
			if( !$.floatMgr.registeredEvents ) 
			{
					$(window).bind("resize", $.floatMgr.onChange);
					$(window).bind("scroll", $.floatMgr.onChange);
					$.floatMgr.registeredEvents = true;
			}		
		} , 
		
		adjustFO: function() 
		{
			$.floatMgr.timer = null;
			
			var moveFO = false;
			
			for( var i = 0 ; i < $.floatMgr.FOArray.length ; i++ )
			{
				 FO = $.floatMgr.FOArray[i];
				 if( FO.updateLocation() )  moveFO = true;
			}
			
			if( moveFO )
			{
				for( var i = 0 ; i < $.floatMgr.FOArray.length ; i++ )
				{
					FO = $.floatMgr.FOArray[i];
					FO.move();
				}
				
				if( !$.floatMgr.timer ) $.floatMgr.timer = setTimeout($.floatMgr.adjustFO,50);
			}
		}	,
		
		stopFloatChk: false ,
		
		onChange: function()
		{
			if( !$.floatMgr.timer && !$.floatMgr.stopFloatChk ) $.floatMgr.adjustFO();
		} 		
	};
	
/*----------------------------------------------------------------------------------
Function: makeFloat
-------------------------------------------------------------------------------------*/		
	$.fn.makeFloat = function(params) {
		var obj = this.eq(0); //we only operate on the first selected object;
		$.floatMgr.initializeFO(obj,params); 
		if( $.floatMgr.timer == null ) $.floatMgr.adjustFO();
		return obj;
	};
	$.fn.stopFloat = function(params) {
		$.floatMgr.stopFloatChk = true;
	};
	
	$.fn.restartFloat = function(params) {
		$.floatMgr.stopFloatChk = false;
	};
})(jQuery);

jQuery.noConflict();

var $j = jQuery.noConflict(); 
$j(document).ready(function(){

	winwa=$j("body").width();
	if(winwa % 2 !== 0) $j("body").width(winwa-1);
	window.menuInAnim=false;
	window.origColMainH=$j(".col-main").height()
	window.behuz=function(){
		clearTimeout(window.behuzT);
		if(window.opera){}else{if(window.origColMainH < $j(".sidebar").height()) $j(".col-main").css("height",$j(".sidebar").height());} 
		if(window.menuInAnim) window.behuzT=setTimeout("window.behuz()",10);
	}

	$j("#newsletter").focus(function(){
		$j(this).val("");
	});

	$j(".level0").each(function(){
		if($j(this).find("ul").size()>0){
			if(!$j(this).hasClass("level0-active") && !$j(this).hasClass("level0-parent")){
				$j(this).find("ul").hide();
				$j(this).find("span").first().append("<b class='sig'> <img src='/skin/frontend/default/default/images/gza/tree_close.png' /></b>");
			}else{
				$j(this).find("span").first().append("<b class='sig'> <img src='/skin/frontend/default/default/images/gza/tree_open.png' /></b>");
			}			
			$j(this).find(".product-count").first().html("");
			$j(this).find("a").first().removeAttr("href").css("cursor","pointer");			
			$j(this).find(".vertnav-cat").bind("click",function(){
				//alert($j(this).attr("class"));
				window.menuInAnim=true;
				window.behuzT=setTimeout("window.behuz()",10);				
				$j(this).parent().find("ul").first().slideToggle(function(){
					window.menuInAnim=false;
					//$j(".sidebar").makeFloat({x:"current",y:"current",speed:"fast",scrollLength: $j(".main").height()-80});
					if(!$j(this).is(":visible")) sig=" <img src='/skin/frontend/default/default/images/gza/tree_close.png' />";
					else sig=" <img src='/skin/frontend/default/default/images/gza/tree_open.png' />";
					$j(this).parent().find(".sig").html(sig);
					/*
					if(window.opera){}else{if($j(".sidebar").height() < window.origColMainH) {
						clearTimeout(window.behuzT); 
						$j(".main").css("height",$j(".sidebar").height()+(window.origColMainH-$j(".sidebar").height()));
					} } 
					*/
				});
			});
			
		}else{
			$j(this).click(function(){
				location.href=$j(this).find("a").attr("href");
			});
		}
	});
	
	$j(".level1 .vertnav-cat").each(function(){
		$j(this).bind("click",function(){
			location.href=$j(this).find("a").attr("href");
		});
	});
	
	if(window.opera){}else{ 
		if($j(".sidebar #vertnav").length){
			$j(".sidebar").makeFloat({x:"current",y:"current",speed:"fast",scrollLength: $j(".main").height()-80});
			if($j(".col-main").height() < $j(".sidebar").height()) $j(".col-main").css("height",$j(".sidebar").height());
		}
	}
	
	if( $j('.vertnav-container').length ) $j("#search").focus();


	if (navigator.appVersion.indexOf("Mac")!=-1 && !$j("body").hasClass("page-print")){
		//$j("body, .main-container").css("background-color","#3C3C3C");
		$j("#signa").attr("src","/skin/frontend/default/default/images/gza/signer2.png");
	}
	
	
	$j(".cat_form").each(function(){
		$j(this).find(".btn-cart").click(function(){
			$j(this).parent().submit();
		});
	});
	
	
	$j(document).keyup(function(e) {
		  if (e.keyCode == 27 && $j(".product-image.product-image-zoom").css("z-index")=="1000") { 
				product_zoom.toggleFull();
		  }
	});


	window.loginNyit=function(){
		clearTimeout(window.loginNyitT);
		$j(".belep").stop().animate({height: '98px'},{queue:false,duration:800,easing:"easeOutQuad"});
	}
	window.loginCsuk=function(){
		clearTimeout(window.loginCsukT);
		$j(".belep").stop().animate({height: '0px'},{queue:false,duration:500,easing:"easeOutQuad"});
	}

	$j("#notloggedin_butt").click(function(){
		clearTimeout(window.loginCsukT);
		if($j(".belep").height()==0){
			$j(".belep").stop().animate({height:98},{queue:false,duration:800,easing:"easeOutQuad"});
		}else{
			$j("#loginbox_close").trigger("click");
		}
		//window.loginNyitT=setTimeout("window.loginNyit()",1);	

	});
	$j("#notloggedin_butt, .belep").mouseout(function(){
		//window.loginCsukT=setTimeout("window.loginCsuk()",500);	
	});
	
	$j("#loginbox_close").click(function(){
		$j(".belep").stop().animate({height: '0px'},{queue:false,duration:500,easing:"easeOutQuad"});
	});

	
		
	
})





