//formValidationz


//uyrukFix
var isUyrukFixUsed = false;
function uyrukFix()
{
	$("select#ctl00_ContentPlaceHolder1_uyruk").change(function()
	{
		$(this)
			.blur(function()
				{
					$(this).valid();
				})
			.change(function()
				{
					$(this).valid();
				});
				
		if($(this).val()=="Diger")
		{
			//ie
			if(isIe)
			{
				$('.uyruk_diger').css('display','block');
			}
			else
			{
				$('.uyruk_diger').css('display','table-row');
			}
			isUyrukFixUsed = true;
		}
		else
		{
			if(isUyrukFixUsed)
			{
				$('.uyruk_diger').css('display','none');
				isUyrukFixUsed = false;
			}
		}
	});
}


//genderFix
var isGenderFixUsed = false;
function genderFix()
{


	$("select#ctl00_ContentPlaceHolder1_cinsiyetiniz").change(function()
	{
		$(this)
			.blur(function()
				{
					$(this).valid();
				})
			.change(function()
				{
					$(this).valid();
				});
		
	    
		if($(this).val()=="Erkek")
		{
			isGenderFixUsed = true;
			if(isIe) {
			    $('#askerlikTercih').css('display','block');
			    $('#askerlikTarih').css('display','block');
			} else {
			    $('#askerlikTercih').css('display','table-row');
			    $('#askerlikTarih').css('display','table-row');
			}
	        $("#ctl00_ContentPlaceHolder1_askerlik").change(function()
	        {
        	    if($(this).val()=="Muaf" || $(this).val()=="Yapti")
		        {
		            $('#askerlikTarih').css('display','none');
		            addValidationz('remove','#ctl00_ContentPlaceHolder1_terhis_tarihi',false,true,"");
		        }
		        else
		        {
 			        if(isIe) {
			            $('#askerlikTarih').css('display','block');
			        } else {
			            $('#askerlikTarih').css('display','table-row');
			        }
    		        addValidationz('add','#ctl00_ContentPlaceHolder1_terhis_tarihi',false,true,"Lütfen terhis/tecil tarihinizi girin");
		        }
	        }
	        )
			/*$('.askerlik').each(function()
			{
				alert(this)
				if(isIe) {
					$(this).css('display','block');
				} else {
					$(this).css('display','table-row');
				}
			});*/
			addValidationz('add','#ctl00_ContentPlaceHolder1_askerlik',false,false,"Lütfen askerlik türünü girin")
			addValidationz('add','#ctl00_ContentPlaceHolder1_terhis_tarihi',false,true,"Lütfen terhis/tecil tarihinizi girin");
		}
		else
		{
			if(isGenderFixUsed)
			{
				isGenderFixUsed = false;
				/*$('.askerlik').each(function()
				{
					$(this).css('display','none');
				});*/
			    $('#askerlikTercih').css('display','none');
			    $('#askerlikTarih').css('display','none');
					
				addValidationz('remove','#ctl00_ContentPlaceHolder1_askerlik',false,false,"")
				addValidationz('remove','#ctl00_ContentPlaceHolder1_terhis_tarihi',false,true,"");
			}
		}
	});
}

//IK form
function basvuruValidation()
{
var ceptel;
var gsm;

	$.validator.addMethod("gsmTel", function()
	{
		$('.requiredGsm').each(function()
		{
			if($(this).attr('id')=='ctl00_ContentPlaceHolder1_cep_tel')
			{
				ceptel = $(this).val().length;
			}
			else if($(this).attr('id')=='ctl00_ContentPlaceHolder1_gsm')
			{
				gsm = $(this).val().length;
			}	
		});
		return gsm==3 && ceptel==7;
	},"Lütfen cep telefonu numaranızı girin.");
	
	$.validator.addClassRules
	({
		requiredGsm: {required:true, digits:true, gsmTel:true}
	});
	
	$.extend($.validator.messages,
	{
		required: "Lütfen cep telefonu numaranızı girin.",
		requiredGsm: "Lütfen cep telefonu numaranızı girin."
	});
		
	$("#aspnetForm").validate
	({
	 	groups:
		{
			gsmTel: "ctl00$ContentPlaceHolder1$cep_tel ctl00$ContentPlaceHolder1$gsm"
		},
		rules:
		{
			ctl00$ContentPlaceHolder1$adiniz:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$soyadiniz:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$cinsiyetiniz:
			{
				required: true
			},
			ctl00$ContentPlaceHolder1$uyruk:
			{
				required: true
			},
			ctl00$ContentPlaceHolder1$dogum_tarihi:
			{
				required: true,
				date: true
			},
			/*ctl00$ContentPlaceHolder1$terhis_tarihi:
			{
				required: true,
				date: true
			},*/
			ctl00$ContentPlaceHolder1$ev_adresiniz:
			{
				required: true,
				minlength: 10
			},
			ctl00$ContentPlaceHolder1$ilce:
			{
				required: true
			},
			ctl00$ContentPlaceHolder1$sehir:
			{
				required: true
			},
			ctl00$ContentPlaceHolder1$ev_tel:
			{
				required: true,
				minlength: 10,
				maxlength: 10
			},
			/*ctl00$ContentPlaceHolder1$gsm:
			{
				required: true,
				requiredGsm: true
			},
			ctl00$ContentPlaceHolder1$cep_tel:
			{
				requiredGsm: true
			},*/
			ctl00$ContentPlaceHolder1$emailiniz:
			{
				email: true,
				required: true,
				minlength: 5
			}
		},
		messages: 
		{
			ctl00$ContentPlaceHolder1$adiniz:		"Lütfen adınızı girin",
			ctl00$ContentPlaceHolder1$soyadiniz:	"Lütfen soyadınızı girin",
			ctl00$ContentPlaceHolder1$cinsiyetiniz:	"Lütfen cinsiyetinizi seçin",
			ctl00$ContentPlaceHolder1$uyruk:		"Lütfen uyruğunuzu seçin",
			ctl00$ContentPlaceHolder1$dogum_tarihi:	"Lütfen doğum tarihinizi girin",
			//ctl00$ContentPlaceHolder1$terhis_tarihi:"",
			ctl00$ContentPlaceHolder1$ev_adresiniz:	"Lütfen ev adresinizi girin",
			ctl00$ContentPlaceHolder1$ilce:			"Lütfen ilçenizi girin",
			ctl00$ContentPlaceHolder1$sehir:		"Lütfen şehrinizi girin",
			ctl00$ContentPlaceHolder1$ev_tel:		"Lütfen ev telefonunuzu girin",
			ctl00$ContentPlaceHolder1$emailiniz:	"Lütfen e-posta adresinizi kontrol edin"
			//ctl00$ContentPlaceHolder1$gsm_2:		"Lütfen gms kodunuzu giriniz",
			//ctl00$ContentPlaceHolder1$cep_tel:		"Lütfen cep telefonu numaranızı girin."
		}
	});
	
	genderFix();
	uyrukFix();
}

//shareForm
function shareValidation()
{
	$("#aspnetForm").validate
	({
		rules: 
		{
			ctl00$ContentPlaceHolder1$txtadiniz: 
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$txtt_eposta:
			{
				required: true,
				email: true,
				minlength: 5
			}
		},
		messages: 
		{
			ctl00$ContentPlaceHolder1$txtadiniz: 	"Lütfen adınızı ve soyadınızı girin",
			ctl00$ContentPlaceHolder1$txtt_eposta: 	"Lütfen arkadaşınızın e-posta adresini girin"
		}
	});
}

function contactValidationSizi() {
    $("#aspnetForm").validate
	({
	    rules:
		{
		    ctl00$ContentPlaceHolder1$txtad:
			{
			    required: true,
			    minlength: 2
			},
		    ctl00$ContentPlaceHolder1$txtsoyad:
			{
			    required: true,
			    minlength: 2
			},

		    ctl00$ContentPlaceHolder1$txttel:
			{
			    required: true,
			    minlength: 10
			},
		    ctl00$ContentPlaceHolder1$txtemail:
			{
			    required: true,
			    email: true,
			    minlength: 5
			}
		},
	    messages:
		{
		    ctl00$ContentPlaceHolder1$txtad: "Lütfen adınızı girin",
		    ctl00$ContentPlaceHolder1$txtsoyad: "Lütfen soyadınızı girin",
		    ctl00$ContentPlaceHolder1$txttel: "Lütfen telefonunuzu girin",
		    ctl00$ContentPlaceHolder1$txtemail: "Lütfen e-posta adresinizi girin"
		}
	});
}

//contactForm
function contactValidation()
{
	$("#aspnetForm").validate
	({
		rules: 
		{
			ctl00$ContentPlaceHolder1$txtAd:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$txtSoyad:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$txtEposta:
			{
				required: true,
				email: true,
				minlength: 5
			},
			ctl00$ContentPlaceHolder1$txtKonu:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$txtSoru:
			{
				required: true,
				minlength: 10
			}
		},
		messages: 
		{
			ctl00$ContentPlaceHolder1$txtAd: 		"Lütfen adınızı girin",
			ctl00$ContentPlaceHolder1$txtSoyad: 	"Lütfen soyadınızı girin",
			ctl00$ContentPlaceHolder1$txtEposta: 	"Lütfen e-posta adresinizi girin",
			ctl00$ContentPlaceHolder1$txtKonu: 		"Lütfen konu girin",
			ctl00$ContentPlaceHolder1$txtSoru: 		"Lütfen mesajınızı girin"
		}
	});
}

//contactForm
function referenceValidation()
{
	$("#aspnetForm").validate
	({
		rules: 
		{
			ctl00$ContentPlaceHolder1$txtAd:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$txtSoyad:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$txtEposta:
			{
				required: true,
				email: true,
				minlength: 5
			},
			ctl00$ContentPlaceHolder1$txtTelefon:
			{
				required: true,
				digits: true,
				minlength: 11,
				maxlength: 11
			},
			ctl00$ContentPlaceHolder1$txtSoru:
			{
				required: true,
				minlength: 10
			}
		},
		messages: 
		{
			ctl00$ContentPlaceHolder1$txtAd: 		"Lütfen adınızı girin",
			ctl00$ContentPlaceHolder1$txtSoyad: 	"Lütfen soyadınızı girin",
			ctl00$ContentPlaceHolder1$txtEposta: 	"Lütfen e-posta adresinizi girin",
			ctl00$ContentPlaceHolder1$txtTelefon: 	"Lütfen telefon numaranızı girin (Örn: 05321234567)",
			ctl00$ContentPlaceHolder1$txtSoru: 		"Lütfen sorunuzu girin"
		}
	});
}

//calcValidation
function calcValidation()
{
	$("#aspnetForm").validate
	({
		rules: 
		{
			ctl00$ContentPlaceHolder1$txtAd:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$txtSoyad:
			{
				required: true,
				minlength: 2
			},
			ctl00$ContentPlaceHolder1$txtEposta:
			{
				required: true,
				email: true,
				minlength: 5
			},
			ctl00$ContentPlaceHolder1$txtTelefon:
			{
				required: true,
				digits: true,
				minlength: 10,
				maxlength: 10
			},
			ctl00$ContentPlaceHolder1$txtSoru:
			{
				required: true,
				minlength: 10
			}
		},
		messages: 
		{
			ctl00$ContentPlaceHolder1$txtAd: 		"Lütfen adınızı girin",
			ctl00$ContentPlaceHolder1$txtSoyad: 	"Lütfen soyadınızı girin",
			ctl00$ContentPlaceHolder1$txtEposta: 	"Lütfen e-posta adresinizi girin",
			ctl00$ContentPlaceHolder1$txtTelefon: 	"Lütfen telefon numaranızı girin (Örn: 5321234567)",
			ctl00$ContentPlaceHolder1$txtSoru: 		"Lütfen sorunuzu girin"
		}
	});
}

$(document).ready(function()
{
	$('#ctl00_ContentPlaceHolder1_askerlik')
		.blur(function()
		{
			$(this).valid()
		})
		.change(function()
		{
			$(this).valid()
		});
		
	$('#ctl00_ContentPlaceHolder1_terhis_tarihi')
		.blur(function()
		{
			$(this).valid()
		});
		
	$.validator
		.addMethod("askerlikRequired", function()
		{
			if(isGenderFixUsed)
			{
				return $('#ctl00_ContentPlaceHolder1_askerlik').val()!='';
			}
			else
			return true;
		}, "Lütfen askerlik durumunuzu girin.")
		
	$.validator
		.addMethod("tecilRequired", function()
		{
			if(isGenderFixUsed)
			{
				return $('#ctl00_ContentPlaceHolder1_terhis_tarihi').val()!='';
			}
			else
			return true;
		}, "Lütfen tecil durumunuzu girin.");
	
});