function displayWindow(url, width,height) {
        var Win = window.open(url,"displayWindow", 'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no' );
}

var obj='0';
var timer='';
var ilosc=250;

function iloscZnakow(o){
   if (o) obj=o;
   var div=document.getElementById('iloscZnakow');
   div.style.fontWeight='normal';
   var iloscWpisanych = obj.value.length;
   div.innerHTML='Limit znaków '+iloscWpisanych+'/<em>'+ilosc+'</em>';
   timer=setTimeout('iloscZnakow()', 100);
}

function skoncz(){
   clearTimeout(timer);
   var div=document.getElementById('iloscZnakow');
   div.style.fontWeight='normal';
}

function licz(pole,max){
	if (pole.value.length > max){
	   pole.value = pole.value.substr(0,max);
	}
}

function zmien1 (name)
{
	myDiv = document.getElementById(name);
	myDiv.style.backgroundColor="#FFCFCF";
}
function zmien2 (name)
{
	myDiv = document.getElementById(name);
	myDiv.style.backgroundColor="#EFEFEF";
}
function zmien3 (name)
{
	myDiv = document.getElementById(name);
	myDiv.style.backgroundColor="#DFDFDF";
}

function print_email(user, site) {
  document.write('<a class="news" href=\"mailto:' + user + '@' + site + '\">');
  document.write(user+'@'+site+'</a>');
}


function zaznaczElementy(Od,Do){
	if(Do >= 0)
	{
		for(Od; Od <= Do; Od++)
		{
			zaznaczPole = "check_"+Od;
			
				document.getElementById(zaznaczPole).checked = true;
		}
	}
}
    var done = false;
 function dodajZdarzenie(odnosnik, zdarzenie, funkcja)
 {
 if (odnosnik.addEventListener)
 {
 odnosnik.addEventListener(zdarzenie, funkcja, false);
 }
 else
 {
 odnosnik.attachEvent("on"+zdarzenie, funkcja);
 }
 }
 function Laduj()
 {
 var box = document.getElementById('all2');
 dodajZdarzenie(box, "click", Zaznacz);
 }

 function Zaznacz()
 {
 var elements = document.forms['formularz'].elements;

 for (var i = 0;i<elements.length ;i++ )
 {
 if (elements[i].type == "checkbox" && elements[i].id != "all2")
 {
 if (!done)
 {
 elements[i].checked = "true";
 }
 else
 {
 elements[i].checked = "";
 }
 }
 }
 if (!done)
 {
 done = true;
 }
 else
 {
 done = false;
 }
 }

 dodajZdarzenie(window, "load", Laduj);

function odznaczElementy(Od,Do){
	if(Do >= 0)
	{
		for(Od; Od <= Do; Od++)
		{
			zaznaczPole = "check_"+Od;
			document.getElementById(zaznaczPole).checked = false;
		}
	}
}

function sprawdz(adres) {
	if (adres != "") {
		var re = new RegExp("[^@]{1,}[@]{1}[^@.]{1,}[.]{1}[^@]{1,}","gi");
		var wynik = re.test(adres);
		if (wynik == true) {
			return true;
		}
		if (wynik == false) {
			alert("Podaj prawidłowy adres e-mail");
			return false;
		}
	}
}
function show(id){
	if (id==1)
	{
		document.getElementById('div_1').style.display="block";
		document.getElementById('div_2').style.display="none";
		document.getElementById('div_3').style.display="none";
		document.getElementById('nav_1').setAttribute('class','active');
		document.getElementById('nav_2').setAttribute('class','noactive');
		document.getElementById('nav_3').setAttribute('class','noactive');
	} else if (id==2)
	{
		document.getElementById('div_2').style.display="block";
		document.getElementById('div_1').style.display="none";
		document.getElementById('div_3').style.display="none";
		document.getElementById('nav_2').setAttribute('class','active');
		document.getElementById('nav_1').setAttribute('class','noactive');
		document.getElementById('nav_3').setAttribute('class','noactive');
	} else if (id==3)
	{
		document.getElementById('div_3').style.display="block";
		document.getElementById('div_2').style.display="none";
		document.getElementById('div_1').style.display="none";
		document.getElementById('nav_3').setAttribute('class','active');
		document.getElementById('nav_1').setAttribute('class','noactive');
		document.getElementById('nav_2').setAttribute('class','noactive');
	}
}

function SendRequest(file,div) {
	var req = mint.Request();
	req.Send('aja/'+file+'.php', div);
	//req.onLoading=document.getElementById(div).innerHTML='<img src="js/loading.gif" style="margin:5px 0 0 30px" />'; 
	mint.fx.Fade(div, 100, 20, 0);
}
function FadeOut(div) {
	mint.fx.Fade(div+'1', 0, 20, 500, null, function () {SendRequest(div+'1',div)});
}
function FadeIn(div) {
	mint.fx.Fade(div, 0, 20, 500, null, function () {SendRequest(div,div)});
}
function SendForm(pole,div) {
	var req = mint.Request();
	req.AddParam(pole, $1(pole).value);
	req.Send('aja/'+div+'1.php', div);
	mint.fx.Fade(div, 100, 20, 0);
}
function FadeOutSave(pole,div) {
	mint.fx.Fade(div+'1', 0, 20, 500, null, function () {SendForm(pole,div)});
}
function FadeOutSaveForm(form,div) {
	mint.fx.Fade(div+'1', 0, 20, 500, null, function () {SendAllForm(form,div)});
}
function SendAllForm(formID,div) {
    var req = mint.Request();
               
    req.OnSuccess = function() {
        $1(div).innerHTML = this.responseText;
    }
               
    req.SendForm(formID,'aja/'+div+'1.php');
} 

function SendForm2(pole1,pole2,div) {
	var req = mint.Request();
	req.AddParam(pole1, $1(pole1).value);
	req.AddParam(pole2, $1(pole2).value);
	req.Send('aja/'+div+'1.php', div);
}
function FadeOutSave2(pole1,pole2,div) {
	mint.fx.Fade(div+'1', 0, 20, 500, null, function () {SendForm2(pole1,pole2,div)});
}

function FadeInZnajomy(div,adres) {
	mint.fx.Fade(div, 0, 20, 500, null, function () {SendRequestZnajomy(adres,div)});
}
function SendRequestZnajomy(id,div) {
	var req = mint.Request();
	req.Send('aja/znajomy.php?id='+id, div);
	//req.onLoading=document.getElementById(div).innerHTML='<img src="js/loading.gif" style="margin:5px 0 0 30px" />'; 
	mint.fx.Fade(div, 100, 20, 0);
}

function FadeInOcenaShow(id) {
	mint.fx.Fade('oceny', 0, 20, 500, null, function () {SendRequestOcenaShow(id)});
}
function SendRequestOcenaShow(id) {
  mint.Request('aja/ocena.php?id='+id, "oceny");
	mint.fx.Fade('oceny', 100, 20, 0);
}  

function FadeInOcena1(ocena,kat,id) {
	mint.fx.Fade('oceny', 0, 20, 500, null, function () {SendRequestOcena1(ocena,kat,id)});
}
function SendRequestOcena1(ocena,kat,id) {
	var req = mint.Request();
	req.Send('aja/ocena1.php?id='+id+'&ocena='+ocena+'&kat='+kat, 'oceny');
	mint.fx.Fade('oceny', 100, 20, 0);
}
function FadeInOcena2(ocena,kat,id) {
	mint.fx.Fade('oceny', 0, 20, 500, null, function () {SendRequestOcena2(ocena,kat,id)});
}
function SendRequestOcena2(ocena,kat,id) {
	var req = mint.Request();
	req.Send('aja/ocena2.php?id='+id+'&ocena='+ocena+'&kat='+kat, 'oceny');
	mint.fx.Fade('oceny', 100, 20, 0);
}

function temat (sub)
{
	document.getElementById('temat').value=sub;
}

function load_faq() {
    var accordion = mint.gui.CreateAccordionWidget();
   
    accordion.openClass = "open";
    accordion.hoverClass = "hover";
   
	 for (i=1;i<=100;i++)
		accordion.AddItem("header"+i, "target"+i);

} 

function ukryj(div) {
	mint.fx.Fade(div, 0, 20, 500, null);
}

function validSpec(id)
{
	var zaz = 0;
	var elements = document.forms[id].elements;
	for (var i = 0;i<elements.length ;i++ )
	{
		if (elements[i].type == "checkbox" && elements[i].name=='spec[]')
		{
			if (elements[i].checked == true)
			{
				zaz++;
			} else
			{
				elements[i].disabled=false;
			}
		}
	}
	if (zaz>=2)
	{
		for (var i = 0;i<elements.length ;i++ )
		{
			if (elements[i].type == "checkbox" && elements[i].name=='spec[]')
			{
				if (elements[i].checked == false)
				{
					elements[i].disabled=true;
				}
			}
		}
	}
}


var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
