$(document).ready(

function(){
			
	 var domain = "http://"+window.location.host+"/";
	
			$("a[rel=_blank]").live( 'click', function(){ window.open(""+$(this).attr("href")+"",'_blank'); return false;  });
	
			
			
			//-----------------------------------------menu------------------------------------------------------------------------------------------------------------------------------------
			//allMenuHide //.naviLeft
			$("div.naviLeft ul li.aOpen ul").hide();
			$("li.aOpen").removeClass("aOpen").addClass("aClosed");
			
			//$("div.naviLeft>ul>li").hover( function(){ $(this).addClass("lightThis"); }, function(){ $(this).removeClass("lightThis"); } );
			
			//open/close ul lev.2
			$("div.naviLeft>ul>li>a").click( function(){ 
									
									
									//v1 - open all
//									if( $(this).parent().hasClass("aOpened") == true )
//									{ 
//										$(this).parent().removeClass("aOpened").addClass("aClosed");
//									}
//									else
//									{ 
//										$(this).parent().removeClass("aClosed").addClass("aOpened");
//									}
//									$(this).next("ul").slideToggle();
				
				 	
									//v2 - open only selected									
									$("div.naviLeft>ul>li>ul").slideUp(  function(){ $("div.naviLeft>ul>li").removeClass("aOpened").addClass("aClosed");} );
									$(this).next("ul").slideToggle( function(){ $(this).parent().removeClass("aClosed").addClass("aOpened"); } );
				
									return false;
								});
			
			//$(".naviLeft ul li ul li a").click( function(){ window.open( ""+$(this).attr("href")+"",'_self'); } );
		

					$(".ocm").click( function()
					{  
						$("div.naviLeft>ul>li.aClosed>ul").slideToggle( function(){ $("li.aClosed").removeClass("aClosed").addClass("aOpened"); } );
						return false;
					} );
					
					
			// -------------------------------------------product bookmarks
			// show bookmarks
			$(".prodBookmarks").show();
			// hide all contents & open first
			$(".containerProd").hide(); $(".containerProd:first").show();
			
			$(".prodBookmarks>div").click( function()
											{ 
												//switch bookmarks
												$(".prodBookmarks div").addClass("bookmarkClosed"); 
												$(this).removeClass("bookmarkClosed").addClass("bookmarkOpened");
												
												//toggle content
												$(".containerProd").hide(); 
												$("#"+$(this).attr("id")+"-content").show();
											} );
			
			// ----------- search
			$("#keywordSearch").click( function(){ $(this).attr("value", ""); } );
			
			
			
			// --------------------------------------- social
			var social = '<div class="topic">Podziel się: </div>';
				social+= '<a href="http://www.facebook.com/sharer.php?u='+window.location+'" rel="_blank" title="Dodaj do Facebooka" ><img src="'+domain+'social/facebook.jpg" alt="facebook" /></a>';
				social+= '<a href="http://twitter.com/home?status='+window.location+'" rel="_blank" title="Dodaj do Twittera"><img src="'+domain+'social/twitter.jpg" alt="twitter" /></a>';
				social+= '<a href="http://blip.pl/dashboard?body='+window.location+'" rel="_blank" title="Dodaj na Blipie" ><img src="'+domain+'social/blip.jpg" alt="blip" /></a>';
				social+= '<a href="http://flaker.pl/add2flaker.php?url='+window.location+'" rel="_blank" title="Wrzuć na Flakera"><img src="'+domain+'social/flaker.jpg" alt="flaker" /></a>';
				social+= '<a href="http://nasza-klasa.pl/sledzik?shout='+window.location+'" rel="_blank" title="Dodaj do Naszej-Klasy"><img src="'+domain+'social/nk.jpg" alt="nk" /></a>';
			
			$(".social").html( social );
			$(".social").fadeIn(1000);
			
			
			//-- social [facebook - like it]
			var org = new Array( ':', '/', '&', '=', '\\?', '#', '~' );
			var rep = new Array( '%3A', '%2F', '%26', '%3D', '%3F', '%23', '%7E' );
	
			var myLink = ''+window.location+'';
			
			for ( var i = 0; i < org.length; i++ ) 
			{
				myLink = myLink.replace( new RegExp(org[i],"g"), rep[i] );
			}
			
			likeIt = '<iframe src="http://www.facebook.com/plugins/like.php?href='+myLink+'&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=recommend&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>';
			
			$(".likeIt").html( likeIt );
			

			
			// - menu control
			//$(".containerMiddleLeft a, .containerTopMainNavi a, .productItemDesc a").hover( 
					//function(){ 
								//$(this).css('opacity','0.25').animate({
								//    opacity: 1
							//	  }, 500, function() {
								   // // Animation complete.
							//	  });

					//	}, 
				//	function(){ 
							//	$(this).css('opacity','1');
						//		});

			
			
			
//			$('.containerMiddleLeft>h1').after('<div class="mainRotationContent"></div>');
//			$('.mainRotationContent').html( $('.oferPos') ); //-> przenies
//			$('.mainRotationContent .oferPos:first').before('<div class="miniBlocks"></div>');
//			$('.oferPos').css('position','absolute');
			
			//showMore();
			
			// -------------------------------- -> navigation
			$('.naviMain li').each( function()
								{ 
										//alert($(this).index());
										$(this).children().next('ul').hide( 1, function(){ 
																			$(this).prev().children().parent('.container').prepend('<a class="more">&nbsp;&nbsp;</a>'); 
																						}); 
										
										$(this).children().children('a.bnLight').parent().next('ul').show( 1, function(){ 
																			$(this).prev().children('a.more').toggleClass('moreNo'); 
														});
										
										
								} );
			
			$('.naviMain li a.more').live( "click", function(){ 
				
																$(this).parent().next().toggle();
																$(this).toggleClass('moreNo');
																
																
															});
			
			
			//-> fast navi
			var fastNavi = new Array();
			fastNavi['pl'] = new Array();
			fastNavi['en'] = new Array();
			
			fastNavi['pl'][0] = '<a href="">Systemy informatyczne</a><br/><ul><li><a href=""><b>TSI 2011&reg;</b><br/>system informatyczny dla komunikacji miejskiej i samochodowegej</a></li><li><a href=""><b>SOR Software&reg;</b><br/>system informatyczny dla Ratownictwa</a></li><li><a href=""><b>DPK Railways&reg;</b><br/>system informatyczny dla kolejnictwa</a></li><li><a href=""><b>nowa Nazwa</b><br/>system informatyczny dla górnictwa i przemysłu</a></li></ul>';
			fastNavi['pl'][1] = '<a href="">Automatyzacja dla transportu</a><br/><ul><li><a href=""><b>TachoAnalizer&reg;</b><br/>program do analizy danych z tachografów cyfrowych i kart kierowców</a></li><li><a href=""><b>TachoAnalizer COMBO&reg;</b><br/>czytnik tachografów i kart kierowców</a></li><li><a href=""><b>DPK Tacho System</b><br/>system pobierania danych z tachografów i kart kierowców</a></li></ul>';
			fastNavi['pl'][2] = '<a href="">Elektroniczne systemy zabezpieczeń</a><br/><ul><li><a href="https://www.jablotron.pl/">Systemy alarmowe JABLOTRON ALARMS</a><ul><li><a href="https://www.jablotron.pl/index.php?mod=dzial&nr=10">Sprzedaż hurtowa i detaliczna</a></li><li><a href="https://www.jablotron.pl/index.php?mod=dzial&nr=115">Pomoc techniczna</a></li><li><a href="https://www.jablotron.pl/index.php?mod=dzial&nr=115">Ogólnopolski serwis JABLOTRON ALARMS</a></li><li><a href="https://www.jablotron.pl/index.php?mod=dzial&nr=1">Szkolenia dla instalatorów</a></li></ul></li><li><a href="'+domain+'oferta/elektroniczne-systemy-zabezpieczen/cctv">Telewizja przemysłowa</a></li><li><a href="'+domain+'oferta/elektroniczne-systemy-zabezpieczen/czytniki-biometryczne">Czytniki biometryczne</a></li></ul>';
			
			fastNavi['en'][0] = 'en1';
			fastNavi['en'][1] = 'en2';
			fastNavi['en'][2] = 'en3';
			
			
			$('.short').mousemove( 	function(){
												
				
				var lang = $('meta[http-equiv="content-language"]').attr('content');
				var shortIndex = $(this).index();
				
				
											$('.shortNaviBlock').hide();
			
											var offset = $(this).offset();
											var content = fastNavi[lang][shortIndex];
											$('body').prepend('<div class="shortNaviBlock"><div class="top"></div><div class="center">'+content+'</div><div class="bottom"></div>');
											$('.shortNaviBlock').animate({
											    opacity: 0.90
											  }, 0).offset({ top: offset.top+137, left: offset.left+13 });
										} );
			
			
			$('.shortNaviBlock').live("hover", function(e){
				if( e.type == "mouseover" ){}
				else{ $('.shortNaviBlock').detach();  }
				});
			
			$('.containerTopLeft, .containerTopRight, .containerMiddleRight').mouseover(function(){ $('.shortNaviBlock').detach(); });
			
			
});

//-> new functions
function showMore(){
	
	
	$('.oferPosContainerLinks').hide();
	$('.aShowDisable').addClass('aShowEnable');
	
	$('.oferPos').mouseover( function(){   } );
	
	$('.oferPos').hover( function(){ 
									
									timer( $(this), 500 );
								}, 
						function(){ 
									
									$(this).children('ul').slideUp(400).prev('.aShowDisable').toggleClass('aShowEnable');
									clearTimeout(idTimer);
								});
}

function showPos(obj)
{
	$(obj).children('ul').slideDown(500).prev('.aShowDisable').toggleClass('aShowEnable');
}


function timer( obj, time )
{ 
	return idTimer = setTimeout( function(){ showPos(obj); }, time);
}


function setCookie(cookieName,cookieValue,nDays){
	 var today = new Date();
	 var expire = new Date();
	 if (nDays==null || nDays==0) nDays=1;
	 expire.setTime(today.getTime() + 3600000*24*nDays);
	 document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString();
	}

function Set_Cookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}


function del_cookie(name) {
	document.cookie = name +
	'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
	} 

function Get_Cookie( name ) {

	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
	}


function readCookie(cookieName) {
	 var theCookie=""+document.cookie;
	 var ind=theCookie.indexOf(cookieName);
	 if (ind==-1 || cookieName=="") return ""; 
	 var ind1=theCookie.indexOf(';',ind);
	 if (ind1==-1) ind1=theCookie.length; 
	 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
	}
