 function Forum_validatePostThreadForm(oForm) {

    oForm.author_email.value = String(oForm.author_email.value).replace(/^\s*|\s*$/g,'');

	var emailRegExp = /^[A-Za-z0-9._\-]+@[A-Za-z0-9]([A-Za-z0-9._\-]*\.)+[A-Za-z]+$/;

	if (emailRegExp.test(oForm.author_email.value) == false) {
	  window.alert('Podaj swój adres e-mail!');
	  return false;    
	}

    oForm.title.value = String(oForm.title.value).replace(/^\s*|\s*$/g,'');
    if('' == oForm.title.value) {
      window.alert('Podaj tytuł komentarza!');
      oForm.title.focus();
      return false;
    }
    oForm.content.value = String(oForm.content.value).replace(/^\s*|\s*$/g,'');
    if('' == oForm.content.value) {
      window.alert('Podaj treść komentarza!');
      oForm.content.focus();
      return false;
    }
    oForm.author_name.value = String(oForm.author_name.value).replace(/^\s*|\s*$/g,'');
    if('' == oForm.author_name.value) {
      window.alert('Podaj autora!');
      oForm.author_name.focus();
      return false;
    }    
	
    if(oForm.author_track.checked && !(oForm.author_email.value != '' && parseInt(oForm.author_id.value) > 0)) {
      window.alert('Funkcja powiadamiania o pierwszej odpowiedzi\njest dostępna tylko dla zalogowanych użytkowników,\nktórzy podali swój adres email.\n\nZarejestruj się na forum i podaj swój email!');
      oForm.author_name.focus();
      return false;
    }        
    return true;
  }

  function Forum_quoteSelected(oField) {  
    if(!oField) {
      return false;
    }   
    var sSelection = (document.selection) ? document.selection.createRange().text : window.getSelection();
    if('' == sSelection) {
      window.alert('Zaznacz najpierw fragment tekstu na stronie.');
      return false;
    }
    oField.value = oField.value + "[cytat]\n" + sSelection + "\n[/cytat]\n";
    oField.focus();
    return true;
  }
  
  function Forum_sendModeratorForm(oForm) {
    oForm.content.value = String(oForm.content.value).replace(/^\s*|\s*$/g,'');
    if('' == oForm.content.value) {
      window.alert('Podaj powód zgłoszenia komentarza do moderacji!');
      oForm.content.focus();
      return false;
    }
    oForm.author_id.value = parseInt(oForm.author_id.value);
    oForm.author_item.value = parseInt(oForm.author_item.value);
    oForm.post_id.value = parseInt(oForm.post_id.value);
    if(oForm.author_id.value > 0 && oForm.author_item.value > 0 && oForm.post_id.value > 0 && oForm.content.value) {
      var oImg = new Image();
      oImg.src = 'http://www.money.pl/d/forum/moderator/?author_id='+oForm.author_id.value+'&author_item='+oForm.author_item.value+'&post_id='+oForm.post_id.value+'&content='+encodeURIComponent(oForm.content.value);
      
      var oDiv = document.getElementById(sForumActiveDivId);
      oDiv.innerHTML = '<table class="add" style="background-color:#ffd9d9;">' + 
        '<tr><td class="bld ac">Dziękujemy za zgłoszenie nadużycia! <a href="#" onclick="window.location.reload();">Kliknij aby odświeżyć.</a></td></tr>' +
        '</table>';
    }
    return true;
  } 

	function Forum_showSpinner(src) {
		f = src.form;
		e = document.createElement('img');
		e.src="/i/spinner.gif";
		e.width="14";
		e.height="14";
		e.style.marginLeft='10px';
		src.parentNode.replaceChild(e,src);
	}

	function Forum_votePost(voteValue, postId) {

	    var oImg = new Image();

		if (voteValue == 1 || voteValue == -1) {

			makeRequest('http://www.money.pl/d/forum/votes/?thread_id=' + nThreadId + '&post_id=' + postId + '&vote_value=' + voteValue, 'vote_' + postId);

			return true;

		} else return false;

	}


	function makeRequest(url, id) {
        var httpRequest;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
                // See note below about this line
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        httpRequest.onreadystatechange = function() { getContents(httpRequest, id); };
        httpRequest.open('GET', url, true);
        httpRequest.send('');

    }

    function getContents(httpRequest, id) {

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {

				e=document.getElementById(id);
				e.innerHTML = httpRequest.responseText;

            } else {
                alert('There was a problem with the request.');
            }
        }

    }

  function Forum_showObj(nIdShow, nIdHide) {
    var oObj;
    oObj = document.getElementById(nIdShow);
    if(oObj) {
      oObj.style.display='block';
    }
    oObj = document.getElementById(nIdHide);
    if(oObj) {
      oObj.style.display='none';
    }
  }

