$().ready(function(){	

$('#input-hidden').attr('value','1');


	Cufon.replace('#header h2, #home-recommended h3, #side-news h3, #side-categories h3, #side-stolarka h3, #side-kontakt h3, #side-sell-points h3, .headForm', { fontFamily: 'MyriadPro' });
	Cufon.replace('#side-login h3', { fontFamily: 'MyriadPro', textShadow: 'rgba(0, 0, 0, 0.2) 2px 2px'});
	Cufon.replace('#menubar li a span', { fontFamily: 'MyriadPro', textShadow: 'rgba(0, 0, 0, 0.38) 1px 1px'});
	$('#side-news p').hide();
	$('#side-news h4').addClass('hidden');
	$('#side-news li:first-child p').show();
	$('#side-news li:first-child h4').removeClass('hidden');
	$('#side-news h4').click(function()
	{
		if ($(this).hasClass('hidden'))
		{
			$('#side-news p').slideUp('fast', function() { $(this).parent().children('h4').addClass('hidden')});
			$('#side-news h4').addClass('hidden');
			$(this).parent().children('p').slideDown('fast');
			$(this).removeClass('hidden');
		} 
		else { 
			$(this).parent().children('p').slideUp('fast', function() { $(this).parent().children('h4').addClass('hidden')});
		}
	});	
});


function nowy_token() {
	var id = new Math.random(9999);
	document.getElementById("token").src = "captcha.jpg?id=" + id + "";
	document.getElementById("captcha").value = "";
}


function DodajDoZakladek(bookmarkurl,bookmarktitle){
	if (navigator.appName=='Netscape')
		window.sidebar.addPanel(bookmarktitle,bookmarkurl, '');
	else if (navigator.appName=='Microsoft Internet Explorer')
		window.external.AddFavorite(bookmarkurl,bookmarktitle);
} 


function show_confirm(url)
{
	var r=confirm("Czy na pewno usunąć?");
	if (r==true)
		{
		window.location=url;
		}
	else
		{
		
		}
}


function potwierdz(url,msg)
{
	var r=confirm(msg);
	if (r==true)
		{
		window.location=url;
		}
	else
		{
			
		}
}

function dodajDoKoszyka(url)
{
	var result=prompt('Podaj ilość sztuk:');
	var Wzor = /^[0-9]+$/;
	if (Wzor.test(result))
	{
		window.location=url+result;
	}
}

function gotoURL(url)
{
	window.location=url;
}

function checkForm()
{
  var brakuje_danych=false;
  var formularz=document.forms['kontakt'];
  var napis="";
  if (formularz.ImieNazwisko.value == ""){
    napis += "- imie i nazwisko<br />"
    brakuje_danych=true;
  }
	
  if (formularz.Telefon.value == ""){
    napis += "- telefon<br />"
    brakuje_danych=true;
  }
	
	var WzorMaila = /^[0-9a-zA-Z_.-]+@+[0-9a-zA-Z.-]+\.[a-zA-Z]{2,3}$/;
	if (WzorMaila.test(formularz.Email.value)){}else 
	{
    napis += "- e-mail (np. imienazwisko@nnn.pl)<br />"
    brakuje_danych=true;
  }
	
	if (formularz.Temat.value == ""){
    napis += "- temat<br />"
    brakuje_danych=true;
  }
	
	var WzorTresci = /^.{10,}$/;
	if (WzorTresci.test(formularz.Tresc.value)) {} else
	{
    napis += "- treść (min. 10 znaków)<br />"
    brakuje_danych=true;
  }
	
	if (!formularz.Preferowana.value){
    napis += "- wybrać preferowaną formę kontaktu<br />"
    brakuje_danych=true;
  }
	
  if (!brakuje_danych)
    { 
			return true; 
		}
  else
    { 
			Sexy.alert('<h1>W formularzu pojawiły się błędy.</h1><br/><p>Proszę poprawnie wypełnić następujące pola<br />' + napis);
			scroll(0,0);
			return false;
		}
}

function changeLang(parm)
{
	var new_language = "/"+parm+"/";
	var address = window.location.href;
	var current = new RegExp("/../","i");
	var new_address = address.replace(current, new_language);

	window.location.href = new_address;
}


function przelicz(flag) {
	
	var rabat = (100-document.getElementById('rabat').value)/100;
	var kwota = document.getElementById('all2').value
	
	if (flag==1)
	{
		document.getElementById('all').value=kwota * rabat;
		document.getElementById('RAZEM').value=kwota * rabat;
	}
	else if (flag==2)
	{
		document.getElementById('all').value=kwota;
		document.getElementById('RAZEM').value=kwota;
	}
	document.getElementById('link').href='realizacja_zamowienia.html?payment='+flag;
}

function expand(div)
{
	var Block = document.getElementById(div);
	if (Block.style.display=='none') {Block.style.display='block';}
	else {Block.style.display='none';}
}

function validateEmail(id)
{
	document.getElementById(id).className = 'kom-text';
	
	var Wzor1 = /^[0-9a-zA-Z_.-]+@+[0-9a-zA-Z.-]+\.[a-zA-Z]{2,3}$/;
	if (!Wzor1.test(document.getElementById(id).value)) 
	{
		document.getElementById(id).className += ' error-comm';
  }
}

function validateKomentarz(id)
{
	document.getElementById(id).className = 'kom-text';
	
	var Wzor1 = /^.{5,}/;
	if (!Wzor1.test(document.getElementById(id).value)) 
	{
		document.getElementById(id).className += ' error-comm';
  }
}

function validateNick(id)
{
	document.getElementById(id).className = 'kom-text';
	
	var Wzor1 = /^.+/;
	if (!Wzor1.test(document.getElementById(id).value)) 
	{
		document.getElementById(id).className += ' error-comm';
  }
}

function checkCommentForm()
{
	var brakuje_danych1 = false;
  var napis1 = "";
  
	document.getElementById('nick-comm').className = 'kom-text';
	document.getElementById('email-comm').className = 'kom-text';
	document.getElementById('komentarz-comm').className = 'kom-text';
	
	if (document.getElementById('nick-comm').value == "")
	{
    napis1 += "- nick\n";
    brakuje_danych1=true;
		document.getElementById('nick-comm').className += ' error-comm';
  }
	
	var Wzor1 = /^[0-9a-zA-Z_.-]+@+[0-9a-zA-Z.-]+\.[a-zA-Z]{2,3}$/;
	if (!Wzor1.test(document.getElementById('email-comm').value)) 
	{
    napis1 += "- e-mail (np. imienazwisko@nnn.pl)\n";
    brakuje_danych1=true;
		document.getElementById('email-comm').className += ' error-comm';
  }
	
	if ( document.getElementById('komentarz-comm').value.length < 5 )
	{
    napis1 += "- treść komentarza (min. 5 znaków)\n";
    brakuje_danych1=true;
		document.getElementById('komentarz-comm').className += ' error-comm';
  }
	
	if (brakuje_danych1)
	{ 
		var flag = 2;
	}
	else
	{
		var flag = 1;
	}
	
	DodajKomentarz(flag);
	return false;
	
}


function PopUP(url, width, height, scrollbars) {
	var Win=window.open(url,"ToDo",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=' + scrollbars + ',menubar=no' );

}


function showSeries(id,max)
{
	for(var i=1;i<=max;i++)
	{
		document.getElementById('seria'+i).style.display = 'none';
		document.getElementById('AGm'+i).className = '';
	}
	document.getElementById('seria'+id).style.display = 'block';
	document.getElementById('AGm'+id).className = 'active';
}
