function controlExists(field){
	if (field==""){
		return true;
	}
		return false;
}

function controlEmail(input) {
	var lgth=input.length;
	var i;
	for (i=0; i<lgth; i++){
		if (input.charAt(i)=="@" && i!=(lgth-1) && i!=0){
			return false;
		}
	}
	return true;
}

function controlEmailSpecialChars(input){
	var found=false;
	var lgth=input.length;
	var str=" öÖçÇıİşŞğĞüÜé!^+%&/()=?\\*}][{½$#£¨~´`,;:|<>\"'";
	var i, lastCH;
	for (var i=0; i<lgth; i++)
		for (var j=0; j<str.length; j++)
			if (input.charAt(i)==str.charAt(j)) 
				found=true;
	lastCH=input.charAt(input.length-1);
	if (lastCH==".")
		found=true;
	return found;
}
		
function changeInputStyle(forminput){
	if(forminput.className=='login_inputbox_warning'){
		forminput.className='login_inputbox';
		/*document.getElementById("login_warning").style.display="none";*/
	}
}

function changeDivStyle(div,commentId){
	var commentId=commentId;
	//self.document.getElementById(div).style.display="block";
	//alert(self.document.getElementById(div).style.display);
	if(self.document.getElementById(div).style.display=="none"){
		self.document.getElementById(div).style.display="block";
		if(commentId!=null){
			self.document.location.href="#lcomment"+commentId;
			self.document.getElementById('comment'+commentId).commentReply.focus();
		} else {
			self.document.location.href="#lcomment";
			self.document.comment.commentReply.focus();
		}
	} else {
		self.document.getElementById(div).style.display="none";
	}
}

function toggleDiv(div1,div2){
	self.document.getElementById(div1).style.display="block";
	self.document.getElementById(div2).style.display="none";
}

//Silinsin mi onayı...
function confirmDelete(){
	var agree=confirm("Silmek istediğinizden emin misiniz?");
	if (agree)
		return true ;
	else
		return false ;
}
		
//Comment Form
function commentFormSubmit(commentId){
	if(commentId!=null){
		var formName = self.document.getElementById('comment'+commentId);
		var commentReply = self.document.getElementById('comment'+commentId).commentReply.value;
	} else {
		var formName = self.document.comment;
		var commentReply = self.document.comment.commentReply.value;
	}
	if (controlExists(commentReply)){
		alert("Lütfen Yorum Alanını Boş Bırakmayınız!");
		formName.commentReply.className='form_textbox_warning';
		formName.commentReply.focus();
		return false;
	} else {
		formName.submit();
	}
}


// Profile Update Form
function profileUpdateFormSubmit(){
	var name = self.document.profile.name.value;
	var surname = self.document.profile.surname.value;
	/*var email = self.document.profile.email.value;*/
	var password = self.document.profile.password.value;
	var re_password = self.document.profile.re_password.value;
			
	if (controlExists(name)){
		alert("Lütfen Adınızı Giriniz!");
		self.document.profile.name.className='login_inputbox_warning';
		self.document.profile.name.focus();
		return false;
	} if (controlExists(surname)){
		alert("Lütfen Soyadınızı Giriniz!");
		self.document.profile.surname.className='login_inputbox_warning';
		self.document.profile.surname.focus();
		return false;
	/*} else if (controlExists(email)){
		document.getElementById("register_warning").style.display="block";
		document.getElementById("register_warning").innerHTML="Lütfen E-Posta Adresinizi Giriniz!";
		self.document.profile.email.className='login_inputbox_warning';
		self.document.profile.email.focus();
		return false;
	} else if (controlEmailSpecialChars(email)){
		document.getElementById("register_warning").style.display="block";
		document.getElementById("register_warning").innerHTML="E-posta Adresini Hatalı Girdiniz! E-posta Adresinde boşluk, Türkçe karakterler ve özel karakterler kullanmayınız. E-posta adresi sonunda nokta kullanmayınız.";
		self.document.profile.email.className='login_inputbox_warning';
		self.document.profile.email.focus();
		return false;
	} else if (controlEmail(email)){
		document.getElementById("register_warning").style.display="block";
		document.getElementById("register_warning").innerHTML="E-posta Adresini Yanlış Girdiniz. Lütfen Kontrol Ediniz.";
		self.document.profile.email.className='login_inputbox_warning';
		self.document.profile.email.focus();
		return false;*/
	/*} else if (controlExists(password)){
		document.getElementById("register_warning").style.display="block";
		document.getElementById("register_warning").innerHTML="Lütfen Şifrenizi Giriniz!";
		self.document.profile.password.className='login_inputbox_warning';
		self.document.profile.password.focus();
		return false;
	} else if (controlExists(re_password)){
		document.getElementById("register_warning").style.display="block";
		document.getElementById("register_warning").innerHTML="Lütfen Şifrenizi Tekrar Giriniz!";
		self.document.profile.re_password.className='login_inputbox_warning';
		self.document.profile.re_password.focus();
		return false;*/
	} else if (password!=re_password){
		alert("Girilen Şifreler Eşleşmemektedir! Lütfen Şifreleri Kontrol Ediniz.");
		self.document.profile.re_password.className='login_inputbox_warning';
		self.document.profile.re_password.focus();
		return false;
	} else {
		self.document.profile.submit();
	}
}