function $(id) {
     return document.getElementById(id);
}
function mail(user, domain, subject){window.location = 'mailto:'+user+'@'+domain+'?subject='+subject;}
function checkForm() {
  if ( $('changecat').value == "" ) {
		$('changecat').style.backgroundColor = "#FFCCCC";
		$('changecat').style.color = "#FF0000";
		return false;
	} else {
			$('changecat').style.backgroundColor = "#FFFFFF";
     $('changecat').style.color = "#000000";
	return true; }
}

function URLDecodespacja( $tekst )
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef";
   var encoded = $tekst;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
       if (ch == "+") {
           plaintext += " ";
           i++;
       } else {
           plaintext += ch;
           i++;
        }
    } // while
   return plaintext;
};

function wstawajax (adresurl) {
 advAJAX.get({
    url: adresurl,
       onSuccess : function(obj) { gEBI('zawartosc').innerHTML = URLDecodespacja(unescape(obj.responseText)); },
    onError : function(obj) { alert("Error: " + obj.status); }
    });
    }

function sFocus(){
	 obj = document.getElementById('query');
   if(obj){
      if(obj.value==tekst)obj.value='';
			obj.style.color='#000000';
   }
}
function sBlur(){
	obj = document.getElementById('query');
   if(obj){
      if(obj.value=='')obj.value=tekst;
			if(obj.value==tekst) { obj.style.color='#959595'; };
   }
}
function check_email(email) {
   invalid = " /:,;";
   if(email == "") { return false }
   for(i=0; i < invalid.length; i++) {
      bad = invalid.charAt(i);
      if (email.indexOf (bad, 0) != -1) { return false }
   }
   at = email.indexOf("@", 0);
   if( (at == -1) || (at == 0) ) { return false }
   if(email.indexOf("@", at+1) != -1) { return false }
   period = email.indexOf(".", at);
   if( (period == -1) || (period == at+1) ) { return false }
   if(period+3 > email.length == -1) { return false }
   return true;
}
