// External JavaScript Klasörü

/* Üye Girişi Form Kontrolü */ 
/****************************/

function kontrol_g()
{
var form = document.getElementById("form_g");

var profile = {
			// filters change the field value and are applied before validation.
			trim: ["kullanici_adi"],
			
			// required input fields that are blank will be reported missing.
			required: ["kullanici_adi","sifre"],

			// Fields can be validated using any boolean valued function.  
			constraints: {
				sifre: function() 
				       {
				        if( form.sifre.value.length > 5 )
						  {
							  return true;
						  }
				       }
			}
		};
		
var results = dojo.validate.check(form, profile);
return results.isSuccessful();
}

/* İletişim Köşesi <textarea></textarea> Doluluk Durumu Çubuğu */
/****************************************************/

//dojo.addOnLoad(go);
//function go()
//{
//	//dojo.byId("gorus").value="";
//	progressValue = 0;
//	maxProgressValue = 500
//	dojo.event.connect(dojo.byId("gorus"), "onkeyup", keyUpHandler);
//}
//
//function keyUpHandler()
//{
//	dojo.widget.byId("durum_cubugu").setProgressValue(dojo.byId("gorus").value.length);
//
//}
//
//// Textarea içindeki karakter sayısı
//function textCounter(field, maxlimit) 
//{
//    if (field.value.length > maxlimit)
//	{
//        field.value = field.value.substring(0, maxlimit);
//	}
//}


/* İletişim Köşesi Form Kontrolü */ 
/*********************************/

function kontrol_i()
{
var form = document.getElementById("form_i");

var profile = {
			// filters change the field value and are applied before validation.
			trim: ["adi","soyadi","mail"],
		    ucfirst: ["adi","soyadi"],

			// required input fields that are blank will be reported missing.
			required: ["adi","soyadi","mail","gorus"],

			// Fields can be validated using any boolean valued function.  
			constraints: {
				mail: [dojo.validate.isEmailAddress, false]
			}
		};

var results = dojo.validate.check(form, profile);
return results.isSuccessful();
}


/* Şifre Hatırlatıcı Form Kontrolü */ 
/***********************************/

function kontrol_h()
{
var form = document.getElementById("form_h");

var profile = {
			// filters change the field value and are applied before validation.
			trim: ["email","dtarih"],

			// required input fields that are blank will be reported missing.
			required: ["email","dtarih"],

			// Fields can be validated using any boolean valued function.  
			constraints: {
				email: [dojo.validate.isEmailAddress, false],
				dtarih: [dojo.date.parse,{selector:"dateOnly",datePattern:"dd/MM/yyyy"}]
				
			}
		};

var results = dojo.validate.check(form, profile);
return results.isSuccessful();
}




/* Üyelik Form Kontrolü */ 
/*********************************/

function kontrol_u()
{
var form = document.getElementById("form_u");

var profile = {
			// filters change the field value and are applied before validation.
			trim: ["adi","soyadi","email","dtarih"],
		    ucfirst: ["adi","soyadi"],

			// required input fields that are blank will be reported missing.
			required: ["adi","soyadi","email","dtarih","sehir","kullanici_adi",
					   "sifre1","sifre2"],

			// Fields can be validated using any boolean valued function.  
			constraints: {
				email: [dojo.validate.isEmailAddress, false],
				dtarih: [dojo.date.parse,{selector:"dateOnly",datePattern:"dd/MM/yyyy"}],
				kullanici_adi: function() 
				          {
						    var result = false;
							var re = new RegExp("^[\\w]{3,}$");
							if(form.kullanici_adi.value.match(re))
							{
							   result = true;
							}

							return result;
							
						  },
				sifre1: function() 
				          {
						    var re = new RegExp("^[\\w\\W]{6,}$");

							if( form.sifre1.value.match(re) )
							  {
								  return true;
							  }
						   },
			    sifre2: function() 
				          {
						    var re = new RegExp("^[\\w\\W]{6,}$");

							if( form.sifre2.value.match(re) )
							  {
								  return true;
							  }
						   }
			},
			
			confirm: {
				/*email_confirm: "email",*/	
				sifre1: "sifre2"	
			}
		};

var results = dojo.validate.check(form, profile);
return results.isSuccessful();
}


/* PASSWORD CONFIRM INVALID MESSAGE 4 UYELIK  (UP) */
function passconfirm1() {
   var form = document.getElementById("form_u");
   var pass = form.sifre1.value;
   var pass_rpt = form.sifre2.value;
   var pass_warn = document.getElementById('sifre_uyari');
   if( pass !== pass_rpt)
   {
	   pass_warn.style.display = "";
   }else{
       pass_warn.style.display = "none";
   }
   
   var city = form.sehir.value;
   var city_warn = document.getElementById('sehir_uyari');
   if( city == "")
   {
	   city_warn.style.display = "";
   }else{
	   city_warn.style.display = "none";
   }
}




/* Şifre Hatırlatma Form Kontrolü */ 
/**********************************/

function kontrol_s_d()
{
var form = document.getElementById("form_s_d");

var profile = {

            // required input fields that are blank will be reported missing.
			required: ["sifre1","sifre2"],

			// Fields can be validated using any boolean valued function.  
			constraints: {
				
				sifre1: function() 
				          {
						    var re = new RegExp("^[\\w\\W]{6,}$");

							if( form.sifre1.value.match(re) )
							  {
								  return true;
							  }
						   },
			    sifre2: function() 
				          {
						    var re = new RegExp("^[\\w\\W]{6,}$");

							if( form.sifre2.value.match(re) )
							  {
								  return true;
							  }
						   }
			},
			
			confirm: {
				/*email_confirm: "email",*/	
				sifre1: "sifre2"	
			}
		};

var results = dojo.validate.check(form, profile);
return results.isSuccessful();
}


/* PASSWORD CONFIRM INVALID MESSAGE 4 SIFRE HATIRLATMA  (UP) */
function passconfirm(form_name) {
   var form = document.getElementById(form_name);
   var pass = form.sifre1.value;
   var pass_rpt = form.sifre2.value;
   var pass_warn = document.getElementById('sifre_uyari');
   if( pass !== pass_rpt)
   {
	   pass_warn.style.display = "";
   }else{
       pass_warn.style.display = "none";
   }
   
}



/* Yorum Form Kontrolü */ 
/**********************************/

function kontrol_yorum(formadi)
{

var form = document.getElementById(formadi);

var profile = {

            // required input fields that are blank will be reported missing.
			required: ["weblog","adi","mail"],

			// Fields can be validated using any boolean valued function.
			// filters change the field value and are applied before validation.
			trim: ["adi","mail","url"],
			
			constraints: {
				
				adi: function() 
				          {
						    var re = new RegExp("^[\\w\\W]{3,}$");

							if( form.adi.value.match(re) )
							  {
								  return true;
							  }
						   },
				
				mail: [dojo.validate.isEmailAddress, false],
				
				url: [dojo.validate.isUrl]
			}
        };
		
// Ekran Çözünürlüğü
   form.cozunur.value = screen.width + "*" + screen.height;
				
// Renk Derinliği 
   form.renk.value = screen.colorDepth;

//var a = "";
//for (i=0; i<form.elements.length; i++) {
//	a += form.elements[i].name +" = "+form.elements[i].value + "\n";
//	}
//alert(a);

var results = dojo.validate.check(form, profile);
return results.isSuccessful();
}
