/*
function eposta_kontrol(emField){ //reference to email field passed as argument

eposta_uyari="Lütfen geçerli bir e-posta adresi yazmayı unutmayın!";

var fieldValue = emField.value // store field's entire value in variable

// Begin Valid Email Address Tests

//if field is not empty
if(fieldValue != ""){
var atSymbol = 0

//loop through field value string
for(var a = 0; a < fieldValue.length; a++){

//look for @ symbol and for each @ found, increment atSymbol variable by 1
if(fieldValue.charAt(a) == "@"){
atSymbol++
}

}

// if more than 1 @ symbol exists
if(atSymbol > 1){
// then cancel and don't submit form
alert(eposta_uyari)
return false
}

// if 1 @ symbol was found, and it is not the 1st character in string
if(atSymbol == 1 && fieldValue.charAt(0) != "@"){
//look for period at 2nd character after @ symbol
var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2)

// "." immediately following 1st "." ?
var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false

//if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
// then cancel and don't submit form
alert(eposta_uyari)
return false
}

}
// no @ symbol exists or it is in position 0 (the first character of the field)
else{
// then cancel and don't submit form
alert(eposta_uyari)
return false
}
}
// if field is empty
else{
// then cancel and don't submit form
alert(eposta_uyari)
return false
}

return true
}
*/

function form_kontrol(){

var theform = document.forms['onaylanacak']

for(i=0; i<theform.elements.length; i++){
		var field = theform.elements[i]
		//alert(theform.elements[i].type)
		var isReq = (uyarim[field.name]) ? true : false
		if(isReq){
		
			if((field.type=="text" || field.type=="textarea" || field.type=="password") && field.value==""){
			alert(uyarim[field.name]);
			setTimeout("document.forms['onaylanacak'].elements["+i+"].focus()", 10)
			return false
			}
			
			if(field.type=="select-one" && field.selectedIndex == 0){	
			alert(uyarim[field.name]);
			setTimeout("document.forms['onaylanacak'].elements["+i+"].focus()", 10)
			return false
			}
			
			if(field.type=="select-multiple"){	
			Sel=0
				for(o=0; o<field.options.length; o++){
					if(field.options[o].selected){
					Sel++
					break
					}
				}
				if(Sel == 0){
				alert(uyarim[field.name]);
				setTimeout("document.forms['onaylanacak'].elements["+i+"].focus()", 10)
				return false
				}			
			}
			
			if(field.type=="checkbox" || field.type=="radio"){
			var startingIndex = i	
			var Checked = 0
			var rLength=1
				while(field.type == theform.elements[i+1].type && field.name == theform.elements[i+1].name){
				rLength++
				i++ 
				}
				
				for(g = startingIndex; g < rLength+startingIndex; g++){
					if(theform.elements[g].checked){
					Checked++
					break
					}
				}		
				if(Checked == 0){
				i=startingIndex
				alert(uyarim[field.name]);				
				setTimeout("document.forms['onaylanacak'].elements["+i+"].focus()", 10)
				return false
				}
			}
			/*
			if(field.name=="eposta")
			  {
				  return eposta_kontrol("eposta")
					
				}
			*/
		}//isReq
	  
	}//for
	return true
}

