function changeSearchButton(mode) {
	if(mode==1) {
		document.getElementById('searchButton').src='./images/searchButton2.jpg';
	} else {
		document.getElementById('searchButton').src='./images/searchButton1.jpg';
	}
}

function maskSearchInput(mode) {
	if(mode==1) {
		if(document.getElementById('searchInput').value=='...') {
			document.getElementById('searchInput').value='';
		}
	} else {
		if(document.getElementById('searchInput').value=='') {
			document.getElementById('searchInput').value='...';
		}		
	}
}

$(document).ready(function() {		

  $(".appearing-image img").css("opacity",0).fadeTo(500, 0);
	$(".appearing-image img").mouseover(function () {
      $(this).fadeTo(300, 1);
    });
	$(".appearing-image img").mouseout(function () {
      $(this).fadeTo(300, 0);
    });
		
});

$(function() {
        $('#gallery a').lightBox();
});

function encodeLoginForm(name){

login='document.'+name+'.formLogin.value';
password='document.'+name+'.formPassword.value';

if( eval(login+'.length')<4 || eval(password+'.length')<4 )
	{
	alert('Login i hasło muszą mieć długość powyżej 3 znaków.');
	}
	else
	{
	
		newLogin = hex_md5(eval(login));
		newPassword = hex_md5(eval(password));
		
		newLogin = hex_md5(newLogin);
		newPassword = hex_md5(newPassword);
	
		
		eval('document.'+name+'.formLogin.value=\'\';');
		eval('document.'+name+'.formPassword.value=\'\';');			
		eval('document.'+name+'.formLoginEnc.value=\''+newLogin+'\';');
		eval('document.'+name+'.formPasswordEnc.value=\''+newPassword+'\';');	
		//alert(eval('document.formLogin.submit();'));
		eval('document.'+name+'.submit();');
	}

}

function MyAddress(IP) {
	//
	document.cookie="localIP="+IP;
}

function go(address)
{
	document.location.href=address;
	return false;
}

function emailValidate(address,alerts)
{

	if(!alerts)
		{
		alert('Niepoprawne wywołanie funkcji walidacyjnej.');
		return false;	
		}
	
	if(!address)
		{ 
		if(alerts==1)
			alert('Wskazane pole nie istnieje.');
		return false;
		}
		
	if(address.value.length<8 || address.value.indexOf('@')<0 || address.value.indexOf('.')<0)
		{
		if(alerts==1)
			alert('Podano niepoprawny adres e-mail.');
		return false;
		}
	else
		{ return true; }
}

//ajax

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  

if(xmlhttp.overrideMimeType) {
xmlhttp.overrideMimeType('text/html');
}  
  
  return xmlhttp;
}


function printContent()
{
  if (stow.readyState == 4 || stow.readyState=="complete") {
			(stow.status == 200)
			{
			returnedData = stow.responseText;
			alert(returnedData);
			//document.getElementById('bodyMiddle').innerHTML=returnedData;	
			}
  }
}

function _res_printNewsletter()
{
  if (stow.readyState == 4 || stow.readyState=="complete") {
			(stow.status == 200)
			{
			returnedData = stow.responseText;
			var pieces=returnedData.split("˘˘˘"); 
			if(pieces[0]=='ALERT')
				alert(pieces[1]);
			else if(pieces[0]=='TEXT')
				document.getElementById('footerRightInputBox').innerHTML=pieces[1];	
			}
  }
}

function _send_NewslatterAddr(address)
{
			parameters="eMail=" + escape(encodeURI(address.value));
			
			stow.onreadystatechange = function() { _res_printNewsletter(); } //obsługa odpowiedzi ajax
			stow.open("POST", "./ajax.php?mode=_send_NewslatterAddr", true);  //tworzenie gniazda ajax
            stow.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            stow.setRequestHeader("Content-length", parameters.length);
            stow.setRequestHeader("Connection", "close");			
			stow.send(parameters);	
					
}

function showMenuImage(wartosc) {
	
	
	if(wartosc!="0") {
		document.getElementById('testowyObrazek').src="../images/topMenu/"+wartosc+"_0.jpg";
	}
	
}

function checkImager(wartosc) {
	if(wartosc=='1') {
		document.getElementById('menuImager').disabled=false;
		document.getElementById('menuImagerDiv').style.visibility='visible';
		
	} else {
		document.getElementById('menuImager').disabled=true;
		document.getElementById('menuImagerDiv').style.visibility='hidden';
	}
}

function sprawdzObrazekMenu() {

	if(document.frm.frmName.value=='') {
		alert('Musisz podać nazwę pozycji w menu!');
		return false;	
	} else if(document.frm.frmMenu.value=='1' && document.frm.frmMenuImage.value=='0') {
		alert('Wybrałeś główny element menu, musisz wybrać także obrazek, który będzie go reprezentował!');
		return false;
	} else {
		document.frm.submit();
	}
}

var stow = getHTTPObject(); // object


