function checkForm(formName){

	var go = new Array();
	var submit;
	
	Form.getElements(formName).each(function(n){
	
		if(n.getStyle("display") != "none"){
			
			var ID = n.identify();
			

			switch(ID){
				
				case formName+"-title":			go.push(checkFields(ID,"select"));
												break;
			
				case formName+"-firstName":		go.push(checkFields(ID,"text"));
												break;											
				
				case formName+"-lastName":		go.push(checkFields(ID,"text"));
												break;
												
				case formName+"-phone":			go.push(checkFields(ID,"phone"));
												break;
												
				case formName+"-eMail":			go.push(checkFields(ID,"email"));
												break;
												
				case formName+"-topic":			go.push(checkFields(ID,"select"));
												break;
				
				case formName+"-message":		go.push(checkFields(ID,"text"));
												break;
														
			}
			
		}
	});
	
	
	var error = go.detect(function(n) { return n == true; });

	(error == true)? submit = false : submit = true;

	
	return submit;
	
}

function checkNLForm(formName){

	var submit;	
	
	var error = checkFields(formName+"-eMail","email");

	(error == true)? submit = false : submit = true;

	return submit;
}


function checkFields(n,type){

	$(n).ancestors()[0].siblings()[1].remove();

	function setInfo(infoType){
	
		$(n).ancestors()[0].addClassName(infoType);
		
		$(n).ancestors()[0].insert({
			
			after: "<img src='/_files/images/layout/"+infoType+".png' width='40' height='34' alt='İPUCU.de - "+infoType+"' id='"+ $(n).identify()+"-"+infoType+"' />"
		});
		
		var error;
		
		
		(infoType == "warning")? error = true : error = false;
		
		return error;	
	}

	
	Try.these(function(){$(n+"-warning").remove()});
	Try.these(function(){$(n+"-confirm").remove()});
	Try.these(function(){$(n).ancestors()[0].removeClassName("warning")});
	Try.these(function(){$(n).ancestors()[0].removeClassName("confirm")});

	var error;


	switch(type){
	
		case "text":		($F(n).length < 2)? error = setInfo("warning") : error = setInfo("confirm");
							break;
						
		case "select":		($F(n) == "0") ? error = setInfo("warning") : error = setInfo("confirm");
							break;
							
		case "email":		var regExp = /^([a-zA-Z0-9\-\.\_]+)(\@)([a-zA-Z0-9\-\.]+)(\.)([a-zA-Z]{2,4})$/;
							var eMail = $F(n);
							var match = regExp.match(eMail);
							(match) ? error = setInfo("confirm") : error = setInfo("warning");
							break;
							
		case "phone":		var regExp = /^([0-9\-\.\_]{3,})$/;
							var phone = $F(n);
							var match = regExp.match(phone);
							(match) ? error = setInfo("confirm") : error = setInfo("warning");
							break;
	}
	
	return error;

}

function changeValue(el,value){

	if(value == ""){
		if($F(el) == "e-Posta"){
			el.setValue("");	
		}
	}
	if(value == "e-Posta"){
		if($F(el) == ""){
			el.setValue("e-Posta");	
		}
	}
	
	if(value == ""){
		if($F(el) == "Ara..."){
			el.setValue("");	
		}
	}
	if(value == "Ara..."){
		if($F(el) == ""){
			el.setValue("Ara...");	
		}
	}
}
