// Validator Functions
function trim(string) {
	var temp = "";
		string = '' + string;
		splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
		temp += splitstring[i];
return temp;
}

function isNull(str, desc) {
	if ( trim(str) == "") {
		isError++
		error = error +  desc + " alanını doldurmalısınız.	<BR>"
	}
}

function isNumeric(str, desc) {
	if (isNaN(trim(str))) {
		isError++
		error = error +  desc + " sadece rakamlardan oluşmalı.	<BR>"
	}
}

function isEn(str,desc) {
	var valid = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
    var temp;
	var problem = "no";
	for (var i=0; i<str.length; i++) {
		tempCHAR = "" + str.substring(i, i+1);
		temp = valid.indexOf(tempCHAR);
		if (temp == "-1") {
			    problem = "yes";
		}
	}
	if ( problem == "yes" ) {
		isError++
		error = error +  desc + " Türkçe ya da özel karakter içermemelidir.<BR>(Geçerli özel karakterler '_','-')<BR><BR>"
	}
}

function isValidNick(str,desc) {
	var valid = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-_$^`{|}®©";
    var temp;
	var problem = "no";
	for (var i=0; i<str.length; i++) {
		tempCHAR = "" + str.substring(i, i+1);
		temp = valid.indexOf(tempCHAR);
		if (temp == "-1") {
			    problem = "yes";
		}
	}
	if ( problem == "yes" ) {
		isError++
		error = error + desc + " geçersiz karakter içeriyor.<BR>Geçerli özel karakterler:<BR>- _ $ ^ ` { | } ® ©<BR><BR>"
	}
}

function isTr(str,desc) {
	var valid = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZöçşığüÖÇŞİĞÜ";
    var temp;
	var problem = "no";
	for (var i=0; i<str.length; i++) {
		tempCHAR = "" + str.substring(i, i+1);
		temp = valid.indexOf(tempCHAR);
		if (temp == "-1") {
			    problem = "yes";
		}
	}
	if ( problem == "yes" ) {
		isError++
		error = error +  desc + " rakam ya da özel karakterlerden oluşamaz.<BR>"
	}
}

function isInRangeString(str, desc, minStrLen, maxStrLen) {
	if (str != "") {
		str = trim(str)
		if ( str.length > maxStrLen && maxStrLen != 0 ) {
			isError++
			error = error +  desc + " en fazla " + maxStrLen + " karakterden oluşabilir.	<BR>"
		}
		if ( str.length < minStrLen && minStrLen != 0 ) {
			isError++
			error = error +  desc + " en az " + minStrLen + " karakterden oluşmalıdır.	<BR>"
		}
	}
}

function compareStr(str1, str2, desc) {
	if (str1 != str2) {
		isError++
		error = error + "Girdiğiniz " + desc + " birbirleriyle aynı değil. Lütfen yeniden giriniz.	<BR>"
	}
}

function isEmail(str, desc){
	if (str != "") {
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str))){
			isError++
			error = error +  desc + " geçersiz. Lütfen kontrol ediniz.	<BR>"
		}
	}
}

// Baloon INFO
	function on_focus(inputID,InfoID,inputTop, inputLeft, TimeOut){
		if (inputID!=="disable"){
			inputID.style.background = "#FFFFFF";
			inputID.style.color = "#FF0000";
		}
		if (InfoID!=="disable"){
			var my_array = new Array();
			my_array[1] = "<B>Bir rumuz (nickname) belirleyin.</B><BR>Belirleyeceğiniz rumuz aynı zamanda kullanıcı adınız olacaktır.<BR>15 karakteri geçmemeli ve Türkçe karakter içermemelidir.<BR><BR><B>Örnek:</B>&nbsp;&nbsp;burak81, red_rose, tatli-cadi"
			my_array[2] = "<B>En az 6 karakterden oluşan bir şifre belirleyin.</B><BR>Şifreniz rakamlardan (0-9), büyük ve küçük harflerden<BR>(A-Z, a-z) oluşabilir.<BR>Güvenlik açısından şifre seçiminiz önemlidir.<BR>Başkaları tarafından kolay tahmin edilemeyecek bir şifre belirlemelisiniz."
			my_array[3] = "<B>Geçerli E-Posta adresinizi girin.</B><BR><BR><FONT COLOR=#FF0000>Gireceğiniz mail adresine kontrol amaçlı bir mail gönderilecektir.</FONT> Üyelik işlemlerine devam edebilmeniz için bu adresin kesinlikle geçerli ve takip ettiğiniz bir mail adresi<BR>olması gerekmektedir."
			my_array[4] = "<B>Cinsiyetinizi doğru işaretlediğinizden emin olun.</B><BR>Üyelik işlemi sonrası cinsiyet seçeneği değiştirilmeyecektir."
			my_array[5] = "Bulunduğunuz ülkeyi seçin."
			my_array[6] = "Bulunduğunuz ili doğru seçmeniz önemlidir.<BR><BR>Bir sonraki adımda belirtmiş olduğunuz şehire ait semtler listelenecek ve yaşadığınız semti seçmeniz istenecektir."
			document.all.spanInfo.innerHTML = my_array[InfoID];
			document.all.divInfo.style.top = inputTop + 15;
			document.all.divInfo.style.left = inputLeft + 10;
			document.all.divInfo.style.display = "block";
			if (TimeOut > 0){
			setTimeout('document.all.divInfo.style.display = "none";',TimeOut)
			}
		}
	}
	function on_blur(inputID){
		document.all.divInfo.style.display = "none";
		if (inputID!=="disable"){
			inputID.style.background = "transparent";
			inputID.style.color = "#000000";
		}
	}
// Baloon INFO #END

document.write("<DIV id='divInfo' style='z-index:999;position:absolute; display:none; width:313; height:77;'>");
document.write("<table border='0' cellpadding='0' cellspacing='0' style='filter:progid:DXImageTransform.Microsoft.Shadow(color=#B4B4B4, Direction=135, Strength=5)'>");
document.write("	<tr>");
document.write("		<td colspan='3'>");
document.write("		<img border='0' src='images/h-table_ust.gif' width='313' height='27'></td>");
document.write("	</tr>");
document.write("	<tr>");
document.write("		<td width='1' bgcolor='#000000'>");
document.write("		<img border='0' src='images/_spacer.gif' width='1' height='1'></td>");
document.write("		<td width='296' bgcolor='#FFFFE1' style='padding-left: 15; padding-top: 3;'>");
document.write("		<table border='0' cellpadding='0' cellspacing='0'>");
document.write("			<tr>");
document.write("				<td colspan='2' class='ta11' style='color:black;' width='296'>");
document.write("				<img border='0' src='images/_spacer.gif' width='3' height='3'><br>");
document.write("				<span id='spanInfo'></span></td>");
document.write("			</tr>");
document.write("		</table>");
document.write("		</td>");
document.write("		<td width='1' bgcolor='#000000'>");
document.write("		<img border='0' src='images/_spacer.gif' width='1' height='1'></td>");
document.write("	</tr>");
document.write("	<tr>");
document.write("		<td colspan='3'>");
document.write("		<img border='0' src='images/h-table_alt.gif' width='313' height='13'></td>");
document.write("	</tr>");
document.write("</table>");
document.write("</DIV>");


function disableSubmit(exp){
	var submitButton = document.getElementById("submit_button")
	if(submitButton)
	submitButton.disabled = exp;
}

//FOR POPUP PAGES
function show_error(){
		document.getElementById("spanAlertTitle").innerHTML = "Dikkat"
		document.getElementById("spanAlert").innerHTML = error
		document.getElementById("divAlert").style.display = "block";
		document.getElementById("div_alert_bottom").style.display = "block";
		document.getElementById("div_main").style.display = "none";
		document.getElementById("div_bottom").style.display = "none";
		disableSubmit(false);
}

function hide_error(){
		document.getElementById("divAlert").style.display = "none";
		document.getElementById("div_alert_bottom").style.display = "none";
		document.getElementById("div_main").style.display = "block";
		document.getElementById("div_bottom").style.display = "block";
}

function showMessage(msgTitle,msgText){
		document.getElementById("spanAlertTitle").innerHTML = msgTitle
		document.getElementById("spanAlert").innerHTML = msgText
		document.getElementById("divAlert").style.display = "block";
		document.getElementById("div_alert_bottom").style.display = "block";
		document.getElementById("div_main").style.display = "none";
		document.getElementById("div_bottom").style.display = "none";
		setTimeout('hide_error();disableSubmit(false);',1500)
}

//FOR MAIN WINDOWS
function show_error2(){
		document.getElementById("spanAlertTitle").innerHTML = "Dikkat"
		document.getElementById("spanAlert").innerHTML = error
		document.getElementById("divAlert").style.display = "block";
		disableSubmit(false);
}

function hide_error2(){
		document.getElementById("divAlert").style.display = "none";
}

function showMessage2(msgTitle,msgText){
		document.getElementById("spanAlertTitle").innerHTML = msgTitle
		document.getElementById("spanAlert").innerHTML = msgText
		document.getElementById("divAlert").style.display = "block";
		setTimeout('hide_error2();disableSubmit(false);',1500)
}


