$(document).ready(function() {
	


	$('.dep1').toggle(
      function () {
	  	var elIndex = $('.dep1').index(this);
	  	var elDom  = $('.dep2').get(elIndex);
    	$(elDom).show('slow');
	  },
	  function () {
	  	var elIndex = $('.dep1').index(this);
	  	var elDom  = $('.dep2').get(elIndex);
	  	$(elDom).hide('slow');
      }
    );
	
	
	
	$(".faq-question").toggle(function(){
	  $(this).next().show('slow');
	},function(){
	  $(this).next().hide('slow');
	});
	
	if(document.location.hash.indexOf('pytanie-')==1)
	{
		question = parseInt(document.location.hash.replace(/#pytanie-/,''))-1;
		$(".faq-answer").eq(question).css('display','block');
	}
})


function getCities(districtId,city)
{
	if (city)
	{
		document.location='/gdzie_szukac_pomocy.html?id=' + districtId + '&city=' + city;
	}
	else
	{
		document.location='/gdzie_szukac_pomocy.html?id=' + districtId;
	}
}


function changeProfile ()
{
	$('#rejestracja').submit();
}

function openPopup(popupUrl,width,height,top,left)
{

	if (!top)
	{
		var top = 100;
	}
	
	if (!left)
	{
		var left = 200;
	}
	
	window.open(popupUrl,'popup','width='+width+',height='+height+',top='+top+',left='+left);
}
function idklink(state)
{
	
	id = document.getElementById('idk');
	k  = document.getElementById('konsult');
	if(state==1)
	{
		id.style.color='#AB0000';
		k.style.color='#000000';
	}
	if(state==0)
	{
		id.style.color='#2f2f2f';
		k.style.color='#2f2f2f';
	}
}

function wyslijNewsletter2(){
	if( document.getElementById('wojewodztwo').value > 0 ){
		document.newsletter2.submit();
	} else {
		alert('Wybierz województwo');
	}
}

function wyslijNewsletter1(){
	var email = document.newsletter1.email.value;
	var pattern = new RegExp('^[a-z0-9]+[a-z0-9._]*@[a-z0-9]+[a-z0-9._]*[a-z0-9]+$');
	if( pattern.test(email) ){
		document.newsletter1.submit();
	} else {
		alert('Ares E-mail jest niepoprawny');
	}
}
