function checkDopytForm(form) {
	var error = false;
	var errorMessage = "";
	
	if(form.company.value == "") {
		error = true;
		errorMessage += "\n * " + CMS_CATALOG_DOPYT_COMPANY_ERROR;
		form.company.style.background = "yellow";
	}

	if(form.name.value == "") {
		error = true;
		errorMessage += "\n * " + CMS_CATALOG_DOPYT_NAME_ERROR;
		form.name.style.background = "yellow";
	}
	
	if(contactFormValidateEmail(form.email.value) == false) {
		error = true;
		errorMessage += "\n * " + CMS_CATALOG_DOPYT_MAIL_ERROR;
		form.email.style.background = "yellow";
	}

	if(form.phone.value == "") {
		error = true;
		errorMessage += "\n * " + CMS_CATALOG_DOPYT_PHONE_ERROR;
		form.phone.style.background = "yellow";
	}
	
	if(form.dopyt.value == "") {
		error = true;
		errorMessage += "\n * " + CMS_CATALOG_DOPYT_LABEL_ERROR;
		form.dopyt.style.background = "yellow";
	}
	
	//error = false;

	if(error == false) {
		return true;
	} else {
		alert(CMS_CATALOG_DOPYT_ERRORS + ":\n " + errorMessage);
		return false;
	}
}

function contactFormValidateEmail(elementValue) {
	return contactFormTestRegExp(elementValue, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
}

function contactFormTestRegExp(elementValue, re) {
	if(window.RegExp) {
		return new RegExp(re).test(elementValue);
	} else {
		return true;
	}
}

// pridavanie priloh
function addInputFile() {
	if (fields != 10) {
		var nodeHome = DOM.gI("inputFile");
		var input = document.createElement("input");
        input.name = "file[]";
        input.id = "fileID_"+(fields+1);
        input.className = "fileAttachment";
        input.type = "file";
        input.size = "28";        
        nodeHome.appendChild(input);

		var ahref = document.createElement("a");
        ahref.id = "fileA_"+(fields+1);
        ahref.innerHTML= CMS_CATALOG_DELETE_ATTACHMENT;
        ahref.className = "fileA";        
        ahref.href = "javascript: void(deleteInputFile("+ fields +"));";					
        nodeHome.appendChild(ahref);
		fields += 1;
	} else {
		DOM.gI("maxAttachmentError").style.display="block";		
		DOM.gI("maxAttachmentError").innerHTML = ' <span style="color:red;">' + CMS_CATALOG_INSERT_MAX_ATTACHMENT + '</span>';
		DOM.gI("add").style.display="none";
	}
}

// odstranovanie priloh
function deleteInputFile(fieldsNumber) {
	DOM.gI('inputFile').removeChild(DOM.gI('fileID_' + (fieldsNumber+1)));
	DOM.gI('inputFile').removeChild(DOM.gI('fileA_' +(fieldsNumber+1)));
	fields-=1;
	if(fields<10){
		DOM.gI("add").style.display="block";
		DOM.gI("maxAttachmentError").style.display="none";
	}
		
}
