function cursorset(a,b,c,d)
	{
	if ((a.value=="") & (b.value=="") & (c.value=="") & (d.value=="")) 
	{a.focus();}
	}
function cursorset(a,b)
	{
	if ((a.value=="") & (b.value=="")) 
	{a.focus();}
	}
function cursorset(a)
	{
	a.focus();
	}
function errorinit()
	{
	var error = "";
	return error;
	}
function errorexit(error,form)
	{
	if (error == "")
		{
		form.submit();
		}
	else 
	 alert(error);
	}
	
function emptycontrol(error,a,b)
	{
	if (error == "")
		{
		if (trim(a.value) == "")
			{ 
			error="Lütfen "+b+" giriniz.";
			a.focus();
			return error;
			}
			else
			{
			error="";
			return error;
			}
		
		}
		else
		{
		return error;
		}
	}
function emptycombo(error,a,b)
	{
	if (error == "")
		{
		if (a.selectedIndex == 0)
			{ 
			error="Lütfen "+b+" seçiniz.";
			a.focus();
			return error;
			}
			else
			{
			error="";
			return error;
			}
		
		}
		else
		{
		return error;
		}
	}
function emptyradio(error,a,b)
	{
	if (error == "")
		{
		if (a[0].checked == false && a[1].checked == false)
			{ 
			error="Lütfen "+b+" sorusuna cevap veriniz.";
			a[0].focus();
			return error;
			}
			else
			{
			error="";
			return error;
			}
		
		}
		else
		{
		return error;
		}
	}
function numeric(error,a)
	{
		if (error == "")
		{
			if (isNaN(a.value))
			{ 
			error="Lütfen nümerik değer giriniz.";
			a.focus();
			return error;
			}
			else
			{
			error="";
			return error;
			}
		}
		else
		{
		return error;
		}
	}
function equality(error,a,b,message)
	{
		if (error == "")
		{
			if ((a.value) != (b.value))
			{
			error = "Lütfen "+message+" aynı giriniz.";
			a.focus();
			return error;
			}
			else
			{
			error="";
			return error;
			}
		}
		else
		{
		return error;
		}
	}
	
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function control(db,kullanici)
	{
// First build your connection string
//var strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + db; 
var strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Vakif.mdb"; 

alert(strConn);
//var strConn = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(db);
 //var strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(db); 
       

// Now, create your connection object
var dbConn = new ActiveXObject("ADODB.Connection");

var rs = new ActiveXObject("ADODB.Recordset"); 

// Open the Connection
dbConn.Open(strConn);


sqlStr = "SELECT * FROM Kullanici where kullanici=" + kullanici.value;

dbConn.execute(sqlStr);
rs.Open (sqlStr,dbConn);  

alert(rs("kullanici"));  
//alert(strConn);
	}
	
function datecontrol(error,a)
{	
if (error != "")
	{
	return error;
	}
	var myDate = a.value;
	var month = parseInt(myDate.substring(3,5));
	var Nmonth = myDate.substring(3,5);
	if(Nmonth == "09")
    		month = 9
	else if(Nmonth == "08") 
    		month = 8 
	var day = parseInt(myDate.substring(0,2));
	var year = parseInt(myDate.substring(6,10));
	 
	var badChar = myDate.substring(0,2)+myDate.substring(3,5)+myDate.substring(6,10);
 
	if (myDate.length  != 10)
	     { 
	      error = "Lütfen tarihi doğru formatta giriniz.!\ngg/aa/yyyy";
	      a.focus();
	      return error;
             }
	    else if(isNaN(badChar))
	     { 
	     error = "Nümerik değer giriniz.";
	      a.focus();
	      return error;
	     }
	     else if (month  > 12)    
	    { 
	    error = "Lütfen ay için 01 - 12 arası giriniz.";
	      a.focus();
	      return error;
	    }
	    else if (day > 31) 
	    {
	    error = "Lütfen gün için 01 - 31 arası giriniz.";
	      a.focus();
	      return error;
	    }
	    else if (year < 1900 ) 
	    { 
	    error = "Yıl 1900'den büyük olmalı.";
	      a.focus();
	      return error;
            }
	   else { 
     		if(month == 4 || month == 6 || month == 9 || month == 11)
      		{ 
		        if( day > 30) 
		        { 
		         error = "Gün alanına 30'dan büyük girmeyiniz!";
	      		 a.focus();
	         	 return error;
		        }
		        else
			{
			return error;
			}
		}
		    else if(month == 2)
		    {
		       if (day == 29)
		       {
		       	var artik = (year%4)
		       	if (artik > 0)
		       	{
		       		error = "Girilen senede Şubat ayı 28 gündür!";
	      	        	a.focus();
	                	return error;	
		       	}
		       	else
		       	{
		       		return error;
		       	}
		       }	
		       if( day > 29)
		       {
		        error = "Şubat ayı en fazla 29 gündür!";
	      	        a.focus();
	                return error;
		        }
		        else
			{
			return error;
			}
		    } 
		    else
		    {
		     return error;
		    }
		     
      	        }
          
}
function emptycheck(error,a,b,c)
{
if (error == "")
	{
		j=0;
		for (i=0;i<b;i++)
		{
		d = eval(a + i);
		if (d.checked == true)
		j=j+1;
		}
		if (j==0)
		{
		error=c;
		d.focus();
		return error;
		}
		else
		{
		return error;
		}
	}
	else
	{
	return error;
	}
	
}

function childcontrol(error,a,b)
{
if (error == "")
	{
	for (i=1;i<21;i++)
	{	
		d = eval(a + i);
		if (i<=b)
		{
		if (d.selectedIndex == 0)
			{error="ilk "+b+" çocuk için öğrenim giriniz";
			d.focus();
			return error;
			 //break;
			 }
			 
		}
		else
		{
		if (d.selectedIndex != 0)
			{error="Fazla seçim yaptınız";
			d.focus();
			return error;
			//break;
			}
			
		}
	}
	return error;
	}
	else
	{
	return error;
	}
	
}

function agecontrol(error,dateString) {
if (error != "")
	{
	return error;
	}

    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());

    var yearNow = now.getYear();
    var monthNow = now.getMonth();
    var dateNow = now.getDate();

    var dt=dateString.value;	   
    var yearDob = parseInt(dt.substring(6,10));
    var monthDob = parseInt(dt.substring(3,5));
    var dateDob = parseInt(dt.substring(0,2));
    
    yearAge = yearNow - yearDob;
    
    if (monthNow >= monthDob)
        var monthAge = monthNow - monthDob;
    else {
        yearAge--;
        var monthAge = 12 + monthNow -monthDob;
    }

    if (dateNow >= dateDob)
        var dateAge = dateNow - dateDob;
    else {
        monthAge--;
        var dateAge = 31 + dateNow - dateDob;

        if (monthAge < 0) {
            monthAge = 11;
            yearAge--; 
        }
    }
    if (yearDob > yearNow)
    {
    	error="Sistem yılından büyük girmeyiniz.";
        dateString.focus();
    	return error;
    }
    else if (yearAge < 18)
    {
      error="18 yaşından küçükler başvuru yapamaz.";
      dateString.focus();
      return error;
    }
    else
    {
    	return error;
    }
    
}
function decimalcontrol(error,a)
	{
		if (error == "")
		{
			var msg = a.value;
  			var newmsg = "";
  			var j=0;
  			
  			for(var i=msg.length; i >= 0; i--) {
  				if (msg.substring(i,i-1) == ",")
  				{j=j+1;} 
  				if ((msg.substring(i,i-1) != ",") && isNaN(msg.substring(i,i-1)))
  				{
  					error="Yanlış değer girdiniz.";
					a.focus();
					return error;
  				}
  			}
  			if (j > 1)
  			{
  				error="Yanlış değer girdiniz.";
				a.focus();
				return error;
  			}
    			return error;

		}
		else
		{
		return error;
		}
	}
function emailcontrol(error,a)
{
if (error == "")
	{
	var str=a.value
	var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   error="Yanlış e-posta adresi girdiniz."
		   a.focus()
		   return error
		}
		else
		 {
	        	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	        	{
			error="Yanlış e-posta adresi girdiniz."
		        a.focus()
		        return error
		        }
		        else
		        {
		        	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		        	{
		    		error="Yanlış e-posta adresi girdiniz."
		    		a.focus()
		    		return error
				}
				else
				{
					if (str.indexOf(at,(lat+1))!=-1)
					{
		    			error="Yanlış e-posta adresi girdiniz."
		    			a.focus()
		    			return error
		 			}
		 			else
		 			{
		 				if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 				{
		    				error="Yanlış e-posta adresi girdiniz."
		    				a.focus()
		    				return error
		 				}
		 				else
		 				{
		 					if (str.indexOf(dot,(lat+2))==-1)
		 					{
		    					error="Yanlış e-posta adresi girdiniz."
		    					a.focus()
		    					return error
		 					}
		 					else
		 					{
		 						return error
		 					}
		 				}
		 			}
				}
		        }
		}

	}
	else
	{
	return error
	}
}

