// JavaScript Document
//łśćłżź

/* =================================================== */
/* =================================================== */
/* =================================================== */
/*   Code (XHTML/CSS) By: WEBZONES Krystian Lenik      */
/*   Contact:                                          */
/*           GG: 7369412                               */
/*          www: www.webzones.pl                       */
/*       e-mail: biuro@webzones.pl                     */
/*   Date: 08.04.2010                                  */
/* =================================================== */
/* =================================================== */
/* =================================================== */

var DebugQueryMode=true; //Show Alerts
//var IE=false;


var GlobIE8=false;
if(jQuery.browser.msie && jQuery.browser.version == 8){ GlobIE8=true; }


/* ================================================================================== */
/* =============================== jquery.ready [START] ============================= */
/* ================================================================================== */
/* =============================== .jMenuAnimation [START] ========================== */
function jMenuEventOverSingleA(event){
	try{ 
		$JQ(this).attr('class','active_single');
		$JQ(this).parent().find('div').css('display','block');
	}catch(err){ if(jDebugMode==true){ alert('jMenuEventOverSingleA: ' + err); }}
}

function jMenuEventOutSingleA(event){
	try{ 
		$JQ(this).attr('class','');
		$JQ(this).parent().find('div').css('display','none');
	}catch(err){ if(jDebugMode==true){ alert('jMenuEventOutSingleA: ' + err); }}
}

function jMenuEventOverA(event){
	try{ 
		var IDul=event.data.IDul;
		if(!IDul || IDul==''){ return false; }
		$JQ('#'+IDul).css('display','block');
		
		$JQ(this).stop(true,false);
		$JQ(this).attr('class','active');
		$JQ(this).parent().find('div').css('display','block');
		$JQ('#'+IDul).stop(true,false);
		if(GlobIE8==true){ $JQ('#'+IDul).find('*').animate({ opacity:1 },{easing:"easeInOutSine",duration:400, queue:false }); } //IE8 Path
		$JQ('#'+IDul).animate({ opacity:1 },{easing:"easeInOutSine",duration:400, queue:false, complete:function(){    }});
	}catch(err){ if(jDebugMode==true){ alert('jMenuEventOverA: ' + err); }}
}

function jMenuEventOutA(event){
	try{ 
		var IDul=event.data.IDul;
		if(!IDul || IDul==''){ return false; }
		$JQ('#'+IDul).stop(true,false);
		/*$JQ(this).attr('class','');
		$JQ(this).parent().find('div').css('display','none');*/
		if(GlobIE8==true){ $JQ('#'+IDul).find('*').animate({ opacity:0 },{easing:"easeInOutSine",duration:300, queue:false }); } //IE8 Path
		$JQ('#'+IDul).animate({ opacity:0 },{easing:"easeInOutSine",duration:300, queue:false, complete:function(){  $JQ('#'+IDul).css('display','none');   }});
		
		$JQ(this).stop(true,false);
		$JQ(this).animate({ opacity:1 },{easing:"easeInOutSine",duration:50, queue:false, complete:function(){ $JQ(this).attr('class',''); $JQ(this).parent().find('div').css('display','none');    }});
	}catch(err){ if(jDebugMode==true){ alert('jMenuEventOutA: ' + err); }}
}


function jMenuEventEnterUL(event){
	try{
		var IDa=event.data.IDa;
		var IDul=event.data.IDul;
		if(!IDa || IDa==''){ return false; }
		if(!IDul || IDul==''){ return false; }
		$JQ('#'+IDul).css('display','block');
		
		$JQ('#'+IDa).stop(true,false);
		$JQ('#'+IDa).attr('class','active');
		$JQ('#'+IDa).parent().find('div').css('display','block');
		$JQ('#'+IDul).stop(true,false);
		if(GlobIE8==true){ $JQ('#'+IDul).find('*').animate({ opacity:1 },{easing:"easeInOutSine",duration:400, queue:false }); } //IE8 Path
		$JQ('#'+IDul).animate({ opacity:1 },{easing:"easeInOutSine",duration:400, queue:false, complete:function(){    }});
	}catch(err){ if(jDebugMode==true){ alert('jMenuEventEnterUL: ' + err); }}
}

function jMenuEventLeaveUL(event){
	try{ 
		var IDa=event.data.IDa;
		var IDul=event.data.IDul;
		if(!IDa || IDa==''){ return false; }
		if(!IDul || IDul==''){ return false; }

		/*$JQ('#'+IDa).attr('class','');
		$JQ('#'+IDa).parent().find('div').css('display','none');*/
		$JQ('#'+IDul).stop(true,false);
		if(GlobIE8==true){ $JQ('#'+IDul).find('*').animate({ opacity:0 },{easing:"easeInOutSine",duration:300, queue:false }); } //IE8 Path
		$JQ('#'+IDul).animate({ opacity:0 },{easing:"easeInOutSine",duration:300, queue:false, complete:function(){  $JQ('#'+IDul).css('display','none');   }});
		
		
		$JQ('#'+IDa).stop(true,false);
		$JQ('#'+IDa).animate({ opacity:1 },{easing:"easeInOutSine",duration:50, queue:false, complete:function(){ $JQ(this).attr('class',''); $JQ(this).parent().find('div').css('display','none');    }});
		
	}catch(err){ if(jDebugMode==true){ alert('jMenuEventLeaveUL: ' + err); }}
}
	
function jMenuAnimation(ID){
	try{
		if(!ID || ID==''){ return false; }
		
		$JQ('#'+ID+' ul').each(function(index){
			if(index==0){ $JQ(this).attr('id',ID+'_mainul'); }
			if(index>0){
				$JQ(this).attr('id',ID+'_subul_'+index); 
				$JQ(this).bind("mouseenter", {IDa:ID+'_maina_'+index, IDul:ID+'_subul_'+index}, jMenuEventEnterUL);
				$JQ(this).bind("mouseleave", {IDa:ID+'_maina_'+index, IDul:ID+'_subul_'+index}, jMenuEventLeaveUL);
				$JQ(this).css('display','none');
				$JQ(this).css('opacity',0);
				$JQ(this).find('li:last').css('background','none');
			}
		});
		
		/*$JQ('#'+ID+' ul:last').css({'left':'auto','right':4});*/
		
		var counter=1;
		$JQ('#'+ID+' a').each(function(index){
			if($JQ(this).parent().parent().attr('id')==ID+'_mainul'){
				if($JQ(this).parent().find('ul').length>0){
					$JQ(this).attr('id',ID+'_maina_'+counter);
					$JQ(this).bind("mouseover", {IDa:ID+'_maina_'+counter, IDul:ID+'_subul_'+counter}, jMenuEventOverA);
					$JQ(this).bind("mouseout", {IDa:ID+'_maina_'+counter, IDul:ID+'_subul_'+counter}, jMenuEventOutA);
					$JQ(this).before('<div class="topul_lt"></div>');
					$JQ(this).before('<div class="topul_rt"></div>');
					counter++;
				}else{
					//$JQ(this).attr('id',ID+'_maina_'+counter);
					$JQ(this).bind("mouseover", {}, jMenuEventOverSingleA);
					$JQ(this).bind("mouseout", {}, jMenuEventOutSingleA);
					$JQ(this).before('<div class="topul_lt" style="height:30px;"></div>');
					$JQ(this).before('<div class="topul_rt" style="height:30px;"></div>');
				}
				
			}
		});
		
		//$JQ('#'+ID+' ul li:last').css({'left':'auto','right':4});
		
	}catch(err){ if(jDebugMode==true){ alert('jMenuAnimation: ' + err); }}
}


/* =============================== .jMenuAnimation [END] ============================ */
/* =============================== .jBranchAnimation [START] ======================== */
function jBranchEventClick(event){
	try{ 
		var ID=event.data.ID;
		if(!ID || ID==''){ return false; }
		$JQ('#'+ID).find('.branch_range').eq(0).trigger('mouseenter');
		return false;
	}catch(err){ if(jDebugMode==true){ alert('jBranchEventClick: ' + err); }}
}

function jBranchEventLeave(event){
	try{ 
		var ID=event.data.ID;
		var Duration=event.data.Duration;
		if(!ID || ID==''){ return false; }
		if(!Duration || Duration==''){ return false; }
		
		var c_range=$JQ('#'+ID).find('.branch_range').eq(0);
		$JQ(c_range).stop(true,false);
		if(GlobIE8==true){ $JQ(c_range).find('*').animate({ opacity:0 },{easing:"easeInOutSine",duration:Duration, queue:false }); } //IE8 Path
		$JQ(c_range).animate({ opacity:0 },{easing:"easeInOutSine",duration:Duration, queue:false, complete:function(){  $JQ(c_range).css('display','none');   }});
		
	}catch(err){ if(jDebugMode==true){ alert('jBranchEventLeave: ' + err); }}
}

function jBranchEventEnter(event){
	try{ 
		var ID=event.data.ID;
		var Duration=event.data.Duration;
		if(!ID || ID==''){ return false; }
		if(!Duration || Duration==''){ return false; }
		
		var c_range=$JQ('#'+ID).find('.branch_range').eq(0);
		$JQ(c_range).css('display','block');
		$JQ(c_range).stop(true,false);
		if(GlobIE8==true){ $JQ(c_range).find('*').animate({ opacity:1 },{easing:"easeInOutSine",duration:Duration, queue:false }); } //IE8 Path
		$JQ(c_range).animate({ opacity:1 },{easing:"easeInOutSine",duration:Duration, queue:false, complete:function(){   }});
		
	}catch(err){ if(jDebugMode==true){ alert('jBranchEventEnter: ' + err); }}
}

function jBranchAnimation(ID, Duration){
	try{ 
		if(!ID || ID==''){ return false; }
		if(!Duration || Duration==''){ Duration=300; }
		
		$JQ('#'+ID+' .branch_btn:eq(0)').each(function(index){
			$JQ(this).bind("click", {ID:ID, Duration:Duration}, jBranchEventClick);
			$JQ(this).bind("mouseleave", {ID:ID, Duration:Duration}, jBranchEventLeave);
		});
		
		$JQ('#'+ID+' .branch_range:eq(0)').each(function(index){
			$JQ(this).bind("mouseleave", {ID:ID, Duration:Duration}, jBranchEventLeave);
			$JQ(this).bind("mouseenter", {ID:ID, Duration:Duration}, jBranchEventEnter);
		});
		
	
		var c_range=$JQ('#'+ID).find('.branch_range').eq(0);
		$JQ(c_range).css({'opacity':0, 'display':'none'});
		if(GlobIE8==true){ $JQ(c_range).find('*').animate({ opacity:0 },{easing:"easeInOutSine",duration:Duration, queue:false }); } //IE8 Path
		
	}catch(err){ if(jDebugMode==true){ alert('jBranchAnimation: ' + err); }}
}
/* =============================== .jBranchAnimation [END] ========================== */
/* =============================== .jSLIDER [START] ================================= */
function jSLIDER_Activate(ID, IDnav){
	try{  
		if(!ID || ID==''){ return false; }
		if(!IDnav || IDnav==''){ return false; }
		var elements=$JQ('#'+ID+' li');
		var c_liwidth=parseInt($JQ(elements).eq(0).css('width'))*parseInt(elements.length);
		var c_ulwidth=parseInt($JQ('#'+ID).css('width'));
		if(c_ulwidth<c_liwidth){ $JQ('#'+ID).css('width',c_liwidth) }
		if(elements.length>0){
			$JQ('#'+IDnav).slider({
				value:1,
				min: 1,
				max: elements.length,
				step: 1,
				//slide: function(event, ui) { $JQ("#amount").html('$' + ui.value); },
				change: function(event, ui) { jSLIDER_Change(ID,$JQ(this).slider("value")); }
			});
		}
		return;
	}catch(err){ if(DebugMode==true){ alert('jSLIDER_Activate: ' + err); }}
}


var GlobalSlider_TimerPerm=false;
function jSlider_TimerSet(ID, IDnav, Duration){
	try{
		if(!ID || ID==''){ return false; }
		if(!IDnav || IDnav==''){ return false; }
		if(!Duration || Duration==''){ return false; }
		if(Duration<=0){ return false; }
	
		$JQ('#'+IDnav).bind("mouseover", {ID:ID, IDnav:IDnav, Duration:Duration}, jSlider_TimerOver);
		$JQ('#'+IDnav).bind("mouseout", {ID:ID, IDnav:IDnav, Duration:Duration}, jSlider_TimerOut);
		
		GlobalSlider_TimerPerm=true;
		jSlider_Timer(ID, IDnav, Duration, 'firstrun');
		return true;
	}catch(err){ if(jDebugMode==true){ alert('jSlider_TimerSet: ' + err); }}
}

function jSlider_TimerOver(event){
	try{
		GlobalSlider_TimerPerm=false;
	}catch(err){ if(jDebugMode==true){ alert('jSlider_TimerOver: ' + err); }}
}

function jSlider_TimerOut(event){
	try{
		GlobalSlider_TimerPerm=true;
	}catch(err){ if(jDebugMode==true){ alert('jSlider_TimerOut: ' + err); }}
}


function jSlider_Timer(ID, IDnav, Duration, Status){
	try{
		if(!ID || ID==''){ return false; }
		if(!IDnav || IDnav==''){ return false; }
		if(!Duration || Duration==''){ return false; }
		if(Duration<=0){ return false; }
		if(!Status || Status==''){ Status='right' }
		
		if(Status=='firstrun'){ Status='right'; self.setTimeout("jSlider_Timer('"+ID+"','"+IDnav+"',"+Duration+",'"+Status+"')",  Duration); return false; }
		
		if(GlobalSlider_TimerPerm==true){
			
			/*var c_value=parseInt($JQ('#'+IDnav).slider("value"))+1;
			var c_max=$JQ('#'+IDnav).slider('option', 'max');
			if(c_value>c_max){ c_value=$JQ('#'+IDnav).slider('option', 'min'); }
			$JQ('#'+IDnav).slider("value",c_value);
			self.setTimeout("jSlider_Timer('"+ID+"','"+IDnav+"',"+Duration+")",  Duration);*/
			//var c_value=parseInt($JQ('#'+IDnav).slider("value"))+1;
			
			//return false;
			
			//if(DebugConsoleMode==true){alert(c_value); }
			var c_value=-1;
			var c_actual=parseInt($JQ('#'+IDnav).slider("value"));
			var c_max=$JQ('#'+IDnav).slider('option', 'max');
			var c_min=$JQ('#'+IDnav).slider('option', 'min');
			
			if(Status=='right'){ 
				if(c_actual>=c_max){ Status='left'; jSlider_Timer(ID, IDnav, Duration, Status); return false; }
				else{ c_value=c_actual+1; }
			}
			if(Status=='left'){
				if(c_actual<=c_min){ Status='right'; jSlider_Timer(ID, IDnav, Duration, Status); return false;  }
				else{ c_value=c_actual-1; }
			}
			//if(DebugConsoleMode==true){ alert('Status:'+Status+' Value:'+c_value); }
			
			
			if((c_value>=c_min) && (c_value<=c_max)){ 	}
			else{ c_value=0;  /*error*/ }
			
			$JQ('#'+IDnav).slider("value",c_value);
			self.setTimeout("jSlider_Timer('"+ID+"','"+IDnav+"',"+Duration+",'"+Status+"')",  Duration);
			
			//if(c_value>c_max){ c_value=$JQ('#'+IDnav).slider('option', 'min'); }
			
			
			return;
		}else{ self.setTimeout("jSlider_Timer('"+ID+"','"+IDnav+"',"+Duration+",'"+Status+"')",  Duration); }
		//self.setTimeout("jSliderMVA_Timer('"+IDprev+"','"+IDnext+"',"+Duration+")", 3000);
		
	}catch(err){ if(jDebugMode==true){ alert('jSlider_Timer: ' + err); }}
}

function jSLIDER_Change(ID,Num){
	try{  
		if(!ID || ID==''){ return false; }
		if(!Num || Num=='' || Num<1){ return false; }
		
		GlobalSlider_TimerPerm=false;
		var elements=$JQ('#'+ID+' li');
		var c_liwidth=parseInt($JQ(elements).eq(0).css('width'));
		var c_position=c_liwidth*(Num-1)*(-1);
		//$JQ('#'+ID).animate({ left:c_position },{easing:"easeOutElastic",duration:1000, queue:false, complete:function(){ /**/ }});
		$JQ('#'+ID).animate({ left:c_position },{easing:"easeInOutExpo",duration:1000, queue:false, complete:function(){
			GlobalSlider_TimerPerm=true;																			  
		}});//animate
		//easeInOutExpo
	}catch(err){ if(DebugMode==true){ alert('jSLIDER_Change: ' + err); }}
}
/* =============================== .jSLIDER [END] =================================== */
/* =============================== .single [START] ================================== */
(function($JQ){
	var _sleeptimer;
	$JQ.sleep = function( time2sleep, callback )
	{
		$JQ.sleep._sleeptimer = time2sleep;
		$JQ.sleep._cback = callback;
		$JQ.sleep.timer = setInterval('$JQ.sleep.count()', 1000);
	}
	$JQ.extend ($JQ.sleep, {
		current_i : 1,
		_sleeptimer : 0,
		_cback : null,
		timer : null,
		count : function()
		{
			if ( $JQ.sleep.current_i === $JQ.sleep._sleeptimer )
			{
				clearInterval($JQ.sleep.timer);
				$JQ.sleep._cback.call(this);
			}
			$JQ.sleep.current_i++;
		}
	});
})(jQuery);

function jItemHoverAnimation(Name, Duration){
	try{ 
		if(!Name || Name=='' || Name.length<2){ return false; }
		if(!Duration || Duration==''){ Duration=300; }
		
		switch(Name.charAt(0)){
			case '.': break;
			case '#': break;
			default: Name='#'+Name;
		}
		
		$JQ(Name+' img').css('opacity',0);
		$JQ(Name+' img').css('visibility','visible');
		
		$JQ(Name).hover(function(){
			$JQ(this).find('img').eq(0).animate({ opacity:1 },{easing:"swing",duration:Duration, queue:false, complete:function(){    }});
		},function(){
			$JQ(this).find('img').eq(0).animate({ opacity:0 },{easing:"swing",duration:Duration, queue:false, complete:function(){    }});
		});
		
	}catch(err){ if(jDebugMode==true){ alert('jItemHoverAnimation: ' + err); }}
}




$JQ(document).ready(function(){
	//jTopAnimation();
	//jMenuAnimation('menul');
});
/* =============================== .single [END] ==================================== */
/* =============================== .Disabled [START] ================================ */
/*
function jAjaxClearboxCleaner(){
	try{
		var elements=$JQ('.jAjaxDone').find('a');
		for(i=0;i<elements.length;i++){
			c_rev=$JQ(elements).eq(i).attr('rev');
			if(c_rev.toLowerCase()=='clearbox'){
				$JQ(elements).eq(i).click(function () { return false; });
			}
		}
		
		setBlur();
		
	}catch(err){ if(DebugQueryMode==true){ alert('jAjaxClearboxCleaner: '+err); }}
}
*/
/* =============================== .Disabled [END] ================================== */
/* ================================================================================== */
/* =============================== jquery.ready [END] =============================== */
/* ================================================================================== */
