function NumberOnly(id) {

	var elm = document.getElementById(id)
	var val = document.getElementById(id).value
	var match = /^(\d|\s)+$/.test(val)
	if (val=="")
	match=1
	if (!match) {
	//	alert ("Alan sadece rakamlardan oluşabilir.")
		elm.style.backgroundColor = "#eeeeee"
		elm.focus()
		return false
	}
	return true
}

function ValidEmail(id) {
	var elm = document.getElementById(id)
	var val = document.getElementById(id).value
	var match = /^\S+\@\w+(\.\w+$)|(\.\w+\.\w+$)/.test(val)
	if (!match)  {
		//alert ("Geçerli email adresi giriniz.")
		elm.style.backgroundColor = "#eeeeee"
		elm.focus()
		return false	}
		return true
}

function NotEmpty(id) {
	var elm = document.getElementById(id)
	var val = document.getElementById(id).value
	if (val=="") {
		//alert ("Lütfen gerekli alanları doldurunuz.")
		elm.style.backgroundColor = "#eeeeee"
		elm.focus()
		return false	}
		return true
}

function StringOnly(id) {
	var elm = document.getElementById(id)
	var val = document.getElementById(id).value
	var match = /^\w+$/.test(val)
	if (val=="")
	match=1
	if (!match) {
		//alert ("Alan sadece harflerden oluşabilir.")
		elm.style.backgroundColor = "#eeeeee"
		elm.focus()
		return false		}
		return true
}

function FormValidate(id) {

	var id
	switch (id)
	{
		case "bayilik" :
		if(!NotEmpty("namesurname") || !NotEmpty("address") || !NotEmpty("city") || !NotEmpty("phone1") || !NotEmpty("email") || !ValidEmail("email") || !NotEmpty("position"))
		return false
		break

		case "contact" :
		if(!NotEmpty("namesurname")|| !NotEmpty("phone1") || !NotEmpty("email") || !ValidEmail("email"))
		return false
		break

		case "order" :
		if(!NotEmpty("namesurname") || !NotEmpty("address") || !NotEmpty("company") || !NotEmpty("phone1") || !NotEmpty("email") || !ValidEmail("email"))
		return false
		break
				
	} //end switch

	return true

} // end function

