			var forumID =				0;
			var currentContainerID =	"content_formular";
						
			
			function returnObjById( id )
			{
				if (document.getElementById)
					var returnVar = document.getElementById(id);
				else if (document.all)
					var returnVar = document.all[id];
				else if (document.layers)
					var returnVar = document.layers[id];
				return returnVar;
			}
			
			function ProductForum_InitForum() {
				//formBackup = returnObjById('forumForm').innerHTML;
				//returnObjById('forumForm').innerHTML = null;
			}
			
			function ProductForum_ShowForm(controlID,forumItemID) {
			    showCaptcha();
				var control =	returnObjById(controlID);
				var current =   returnObjById(currentContainerID);
				forumID = forumItemID;
				if (controlID!=currentContainerID) {
					control.innerHTML = current.innerHTML;
					current.innerHTML = "";
				}
				currentContainerID = controlID;
			}
			
			function ProductForum_HideForm() {
				//upraveno kvuli x-store v puvodni verzi byl pouzit nasledujici radek
				//window.location.reload();
				document.location = SuccesSubmitAdress;
			}
			
			function ProductForum_SendForm() {
				var name =		returnObjById('comment_jmeno').value;
				var subject =	returnObjById('comment_subject').value;
				var txt =		returnObjById('comment_txt').value;
				var email =		returnObjById('comment_email').value;
				var forID =		forumID;
				var controlToHide = returnObjById('control'+forumID);
				var code =		returnObjById('code').value;
				
				if (ProductForum_ValidateAndSubmit()) {
					var valid = AjaxCAPTCHA(code);
					//alert(valid);
					if (valid == '1') {
						ProductForum_AjaxCall(controlToHide,urlBase,name,subject,txt,email,forID);
					} else {
						alert("Spatne vyplneny kontrolni kod");
					}
				}
				
			}
			
			function ProductForum_ClearNewForm() {
				returnObjById('newjmeno').value =	"";
				returnObjById('newsubject').value = "";
				returnObjById('newtxt').value =		"";
				returnObjById('newemail').value =	"";
			}
			
			function AjaxCallScore(id,score,message) {
				var url = urlBase+'?id='+id+'&score='+score;
				var xmlHttp = GetHTTPObject();
				
				if (xmlHttp) {
					xmlHttp.abort();
					xmlHttp.open("GET", url, false);
					xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					xmlHttp.send(null);
					HideScoreBox(id,message);
				}				
			}
			
			function HideScoreBox(id,message) {
				var scoreBox = returnObjById('scoreBox'+id);
				if (scoreBox) {
					scoreBox.innerHTML = "("+message+")";
				}
			}
			
			function GetHTTPObject() {
				var xmlHttp = null;
				if(typeof XMLHttpRequest != "undefined"){
					xmlHttp = new XMLHttpRequest();
				}
				else if(typeof window.ActiveXObject != "undefined") {
					try {
						xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
					}
					catch(e) {
						try {
							xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
						}
						catch(e){
							try {
								xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
							}
							catch(e){
								xmlHttp = null;
							}
						}
					}
				}
				return xmlHttp;			
			}
			
			function ProductForum_AjaxCall(controlToHide,url,name,subject,txt,email,forID) {
				var DELIMITER = "*+*|_~_|-**";
				var productID =	returnObjById('productID').value;
				var xmlHttp = GetHTTPObject();
				
				if (xmlHttp) {
					//xmlHttp.onreadystatechange = function (){};
					xmlHttp.abort();
					xmlHttp.open("POST", url, false);
					xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					xmlHttp.send(name+DELIMITER+productID+DELIMITER+forID+DELIMITER+email+DELIMITER+subject+DELIMITER+txt);
					//xmlHttp.onreadystatechange = this.getResults;
					alert(xmlHttp.responseText);
					
					if (controlToHide) controlToHide.innerHTML = null;
					ProductForum_HideForm();
				}
			}
			
			
// ***************************** CAPTCHA **************************************

			function AjaxCAPTCHA(code) {
				var xmlHttp = GetHTTPObject();
				var url = captchaBase + '?code='+code;
				if (xmlHttp) {
					xmlHttp.abort();
					xmlHttp.open("GET", url, false);
					xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
					xmlHttp.send(null);
					//xmlHttp.onreadystatechange = this.getResults;
					//alert(xmlHttp.responseText);
					return xmlHttp.responseText.replace(/^\s+|\s+$/g, '');
				}
			}	
			
			function refreshCAPTCHA() {
				var obj =	returnObjById("obrazekCAPTCHA");
				obj.src =	obj.src+"0";			
			}
			
			function setTableColor(tdID) {
				var obj =	returnObjById(tdID);
				var obj1 = returnObjById("td1");var obj2 = returnObjById("td2");var obj3 = returnObjById("td3");var obj4 = returnObjById("td4");
				obj1.style.backgroundColor = "#eeeeee";obj2.style.backgroundColor = "#eeeeee";obj3.style.backgroundColor = "#eeeeee";obj4.style.backgroundColor = "#eeeeee";
				obj.style.backgroundColor = "#FFCC99";
			}
			
			
// ***************************** VALIDATION ***********************************		

function ProductForum_ValidateAndSubmit() {	
	if (
			validateRequiredAJAX(returnObjById('comment_jmeno')) &&
			validateRequiredAJAX(returnObjById('comment_email')) &&
			validateRequiredAJAX(returnObjById('comment_subject')) &&
			validateRequiredAJAX(returnObjById('comment_txt')) &&
			ValidateEmail(returnObjById('comment_email').value)
	   )
	{
		return true;
	} else {
		alert("Vsechny polozky musite vyplnit, email musi mit pozadovany format.");
		return false;
	}
}

function validateRequiredAJAX(field) {
    var bValid = true;
    if (field.type == 'text' ||
        field.type == 'textarea' ||
        field.type == 'select-one' ||
        field.type == 'radio' ||
        field.type == 'password') {
        var value;
		// get field's value
		if (field.type == "select-one") {
			var si = field.selectedIndex;
			value = field.options[si].value;
		} else {
			value = field.value;
		}
        
        if (value == '') {
			bValid = false;
        }
    }
    return bValid;
}

function ValidateEmail(str) {
if(str.length == 0){ return true;}
//validate email acording RFC2822 specification
var rx_local_strict = /^[a-zA-Z0-9\!\#\$\%\*\/\?\|\^\{\}\`\~\&\'\+\-\=\_\.]{1,64}@[^\@]+$/;
var rx_local_quotes = /^\".{1,62}\"@[^\@]+$/;
var rx_domain_named = /@[a-zA-Z0-9\-\.]{1,255}$/;
var rx_domain_addr = /@\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\]$/;
var rx_wrong1 = /(\.\.)|(^\.)|(\.@)|(@\.)/;
var rx_wrong2 = /^[^\"].*@+.*[^\"]@[^\@]*$/;
if ((rx_local_strict.test(str) || rx_local_quotes.test(str)) &&
(rx_domain_named.test(str) || rx_domain_addr.test(str)) &&
!rx_wrong1.test(str) &&
!rx_wrong2.test(str)) {
return true;
}
else {
return false;
}
}