var currentPart = 1;

$(document).ready(function() {

	$('a.delete').css('color','red').click(function(){
		if (confirm('Czy napewno usunąć ten element ?'))
		{
			return true;
		}
		
		return false;
	});
 	
	$("#systemMessageClose").click(function () {
      $("#systemMessage").slideUp(500, function () {
        $("#systemMessage").remove();
      });
    });
        	
});

function nextPart(obj){
	var parent = obj.parentNode;
	var next = parent.nextSibling;
	while(next != undefined && next.nodeType != 1){
		next = next.nextSibling;
	}
	$(parent).slideUp('slow');
	$(next).slideDown('slow');
}

function prevPart(obj){
	var parent = obj.parentNode;
	var prev = parent.previousSibling;
	while(prev != undefined && prev.nodeType != 1){
		prev = prev.previousSibling;
	}
	$(parent).slideUp('slow');
	$(prev).slideDown('slow');
}

function showPart(partNo){
	var i = 1;
	var obj = null;
	var toFadeIn = null;
	while( obj = document.getElementById('part_'+i) ){
		if( i == partNo ){
			toFadeIn = obj;
		} else {
			$(obj).css('display','none');
		}
		i++;
	}
	if( toFadeIn != null ){
		$(toFadeIn).fadeIn('slow');
		$(document).scrollTop(0);
		
		$('#page_'+currentPart).css('font-weight','normal');
		currentPart = partNo;
		$('#page_'+currentPart).css('font-weight','bold');
	}
}


function showMenu(partNo){
	$("#menu_"+partNo).slideDown('slow');	
}

function showSearch(partNo){
	var i = 1;
	var obj = null;
	var toFadeIn = null;
	while( obj = document.getElementById('item_'+i) ){
		if( i == partNo ){
			toFadeIn = obj;
		} else {
			$(obj).css('display','none');
		}
		i++;
	}
	if( toFadeIn != null ){
		$(toFadeIn).fadeIn('slow');
		//$(document).scrollTop(0);
		
		$('#itempos_'+currentPart).css('font-weight','normal');
		currentPart = partNo;
		$('#itempos_'+currentPart).css('font-weight','bold');
	}
}

function showFaq(partNo){
	var i = 1;
	var obj = null;
	var zaj = null;
	var toFadeIn = null;
	var toFadeZaj = null;
	while( obj = document.getElementById('element_'+i) ){
		zaj = document.getElementById('intro_'+i);
		if( i == partNo ){
			toFadeIn = obj;
			toFadeZaj = zaj;
		} else {
			$(obj).css('display','none');
			$(zaj).css('display','block');
		}
		i++;
	}
	if( toFadeIn != null ){
		$(toFadeZaj).css('display', 'none');
		$(toFadeIn).fadeIn('slow');
			
	}
}
function topSelector()
{
	var selector = 	document.getElementById('topSelector');
	$(selector).fadeIn('slow');
	
}
function topSelectorClose()
{
	var selector = 	document.getElementById('topSelector');
	$(selector).fadeOut('slow');
	
}
function topAssign(topId)
{
	var topField = document.getElementById('element9i');
	var selector = document.getElementById('topSelector');
	var topOld	 = document.getElementById('topPreview');
	var topNew	=	document.getElementById('top'+topId);
	topField.value=topId;
	topOld.src=topNew.src;
	$(selector).fadeOut('slow');
}
function executeSearch()
{
	
	var word = document.getElementById('searchWord').value;
	document.location.href='/wyszukiwarka.html?searchWord='+word;
	//alert(word);
}

