// JavaScript Document


function getItem(id)
    {
        var itm = false;
        if(document.getElementById)
            itm = document.getElementById(id);
        else if(document.all)
            itm = document.all[id];
        else if(document.layers)
            itm = document.layers[id];

        return itm;
    }

 function CBoxShowHide(tiklanan,acilan){
	if(tiklanan){
	 	if (tiklanan.checked){
			itm = getItem(acilan);
			itm.style.display ='';
		}
		else{
			itm = getItem(acilan);
			itm.style.display ='none';
			
		}
	 }
			
			
			

 }




function radiocheck(radioname){
	
	if(!radioname.length){  //only one radio button
		 if(radioname.checked){
			 return  radioname.value;
		 }
		 else
		 {
		 return null;
		 }
	}
	
	for (i=0;i<radioname.length;i++){
		if (radioname[i].checked){
			return radioname[i].value;
		}
	}
	return null;
}


	function isEmail(string) {
		if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
			return true;
		}
		else{
			return false;
		}
	}


function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

	function SelectUnSelect(obj){
		if(!obj.checked)
		obj.checked=true;
	}

//ac kapa
/*
for(i=0;i<DiziUrun.length;i++){
	
		if (eval("document.SiparisFormu.U"+DiziUrun[i]+".checked")){
						
			
				
				
				itm = getItem("Urun" & DiziUrun[i]); 
				if(itm){
				    			
				itm.style.display ="";
				}
			
		}
	}*/
	
		
		
		function limitText(limitField, limitCount, limitNum) {
			if (limitField.value.length > limitNum) {
				limitField.value = limitField.value.substring(0, limitNum);
			} else {
				limitCount.value = limitNum - limitField.value.length;
			}
		}
		
		
		
		function sil_onay(url,Data){
			var agree=confirm("Bu "+ Data+" silmek istedi?inizden eminmisiniz.  OK?")
			if (agree){
				var agree=confirm("Sildiğiniz " + Data +" geri alamıyacaksınız.  Eminmisiniz?")
				if (agree){
					window.location.href=url
				}else{alert("Silme işlemi iptal edildi")}


			}else{
				alert("Silme işlemi iptal edildi")
			}
		}
		
		
		function checkbox_checker(obj)
		{

	

			var checkbox_choices = 0;

			for (counter = 0; counter < obj.length; counter++)
			{


				if (obj[counter].checked)
				{ checkbox_choices = checkbox_choices + 1; }

			}
			return checkbox_choices 
		}

	
	
	
	
	
	function chkBoxDegerAra(obj,deger)
		{

	

			

			for (counter = 0; counter < obj.length; counter++)
			{


				if (obj[counter].checked)
				{ 
					if(obj[counter].value==deger){
						return true;
					}
				
				
				}

			}
			return false 
		}
		
		
		function AyrintiGoster(Bolum) {
			itm = getItem(Bolum);	
			
			if (itm.style.display =='none'){
				itm.style.display ='';
			}
			else{
				itm.style.display ='none';
			}
		}

	function popup_destek(a,w,h){
		url = a;
		pencere=window.open(url, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width='+w+', height='+h+', left = 40, top = 40');
		pencere.focus();
	}
	

	
	
	function blocktoggle(Block,i) {
			  if (document.getElementById) {
				shown[i] = (shown[i]) ? false : true;
    		    currentdisplay = (shown[i]) ? '' : 'none';
               	document.getElementById(Block+i).style.display = currentdisplay;
		      }
			}

			function blockdisplay(Block,i) {
			  if (document.getElementById){
			    if (document.getElementById(Block+i)) {
			      for ( j = 1; j < 1000; j++ ) {
			        if (document.getElementById(Block + j)) {document.getElementById(Block + j).style.display = 'none';}
				    else {j = 1000;}
			      }
			      if (i) {document.getElementById(Block+i).style.display = '';}
			    }
			  }
			}
        
		function SayiOlsun(degisen){
var sayi=parseInt(degisen.value);
 
  if(isNaN(sayi))  degisen.value = 1;
  if(sayi<1)  degisen.value= 1;
  }
  
  
  function limitText(limitField, limitCount, limitNum) {
			if (limitField.value.length > limitNum) {
				limitField.value = limitField.value.substring(0, limitNum);
			} else {
				limitCount.value = limitNum - limitField.value.length;
			}
		}
	
function isURL(argvalue) {

  if (argvalue.indexOf(" ") != -1)
    return false;
  else if (argvalue.indexOf("http://") == -1)
    return false;
  else if (argvalue == "http://")
    return false;
  else if (argvalue.indexOf("http://") > 0)
    return false;

  argvalue = argvalue.substring(7, argvalue.length);
  if (argvalue.indexOf(".") == -1)
    return false;
  else if (argvalue.indexOf(".") == 0)
    return false;
  else if (argvalue.charAt(argvalue.length - 1) == ".")
    return false;

  if (argvalue.indexOf("/") != -1) {
    argvalue = argvalue.substring(0, argvalue.indexOf("/"));
    if (argvalue.charAt(argvalue.length - 1) == ".")
      return false;
  }

  if (argvalue.indexOf(":") != -1) {
    if (argvalue.indexOf(":") == (argvalue.length - 1))
      return false;
    else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
      return false;
    argvalue = argvalue.substring(0, argvalue.indexOf(":"));
    if (argvalue.charAt(argvalue.length - 1) == ".")
      return false;
  }

  return true;

}

function checkExt(filename){
    
     var filelength = parseInt(filename.length) - 3;
     var fileext = filename.substring(filelength,filelength + 3);

      // Check file extenstion
          if (fileext != "gif" && fileext != "jpg" && fileext != "jpeg" && fileext != "png"){
     
                return false;
           } 
           return true;
}

function fncIlanGirisi(obj,mode){
	var VResimK=obj.ResimK.value;
	var VIBaslik=obj.IBaslik.value;
	var VIAyrinti =obj.IAyrinti.value;
	var VResimK=obj.ResimK.value;
	
	
	var hata=false;
	var hatamsg=""
	
	if (VIBaslik.length<3){
		hata=true;
		hatamsg=hatamsg+"<li>Lütfen ilan ba?ly?yny giriniz</li>";
	}
	if (VIAyrinti.length<3){
		hata=true;
		hatamsg=hatamsg+"<li>Lütfen ilan içeri?ini giriniz</li>";
	}
	



	if (mode!="update"){
		if(VResimK){
			if (!checkExt(VResimK)){
			hata=true;
			hatamsg=hatamsg +"<li>İlan resimleri *.jpg, *.jpeg, *.gif, *.png olabilir.</li>";
			}	

		
		}
	}
	if (checkbox_checker(obj.Iletisim)==0){
			hata=true;
			hatamsg=hatamsg+"<li>Lütfen en az bir iletişim aracyny seçiniz.</li>";
			
	}
	
	if(hata){
		document.getElementById("hata").innerHTML="<ul>" + hatamsg + "</ul>";
		return false;
	}
	else{
		return true;

	}
	
}

function fncUrlDegistir(url){
window.location.href=url;
}


function fncUyelikKayit(obj){
	var VUAdi=obj.UAdi.value;
	var VUSoyadi=obj.USoyadi.value;
	var VUTelefon =obj.UTelefon.value;
	var VUAdres=obj.UAdres.value;
	var VUEmail=obj.UEmail.value;
	var VUPassword=obj.UPassword.value;
	var VUPasswordT=obj.UPasswordT.value;
	var VUGSM=obj.UGSM.value;
	var VUDogumTarihi=obj.Gun.value + "/" +  obj.Ay.value + "/" + obj.Yil.value 
	var VUTcKimlikNo=obj.UTcKimlikNo.value;	
	var VUSehirID=obj.USehirID.options[obj.USehirID.selectedIndex].value;
	var hata=false;
	var hatamsg="";
	
	if (VUAdi.length<3){
		hata=true;
		hatamsg=hatamsg+"<li>Lütfen adınızı giriniz</li>";
	}
	if (VUSoyadi.length<3){
		hata=true;
		hatamsg=hatamsg+"<li>Lütfen soyadınızı giriniz</li>";
	}
	if (!isEmail(VUEmail)){
		hata=true;
		hatamsg=hatamsg + "<li>E-mailinizi eksik veya hatalı girdiniz</li>";
	}
	
	if (VUTelefon.length!=11){
		hata=true;
		hatamsg=hatamsg+"<li>Telefon numaranızı hatalı girdiniz. Telefon numaranızı alan kodu ile belirtiniz.  </li>";
	}
	if (VUGSM.length!=11){
		hata=true;
		hatamsg=hatamsg+"<li>GSM numaranızı hatalı girdiniz. GSM numaranızı alan kodu ile belirtiniz</li>";
	}

	if (VUTelefon.length!=11){
		hata=true;
		hatamsg=hatamsg+"<li>T.C. Kimlik numaranızı eksik veya hatalı girdiniz. </li>";
	}

	if (VUAdres.length<5){
		hata=true;
		hatamsg=hatamsg+"<li>Adres bilginizi eksik veya hatala belirttiniz </li>";
	}
	
	if (VUSehirID=="0"){
		hata=true;
		hatamsg=hatamsg+"<li>Lütfen şehir bilginizi belirtiniz.</li>";
	}	
	if (!validate(VUDogumTarihi)){
		hata=true;
		hatamsg=hatamsg+"<li>Doğum tarihinizi yanlış ve eksik girdiniz.</li>";
	}	


	
	if (VUPassword.length<4 || VUPassword.length>10){
		hata=true;
		hatamsg=hatamsg+"<li>?ifreniz en az 4 en fazla 10 karakter olmalıdır.</li>";
	}
	else if(VUPassword!=VUPasswordT){
		hata=true;
		hatamsg=hatamsg+"<li>Şifre doğrulaması hatası. İki Şifre aynı olmalıdır.</li>";	
	
	}
	



	
	if(hata){
		document.getElementById("hata").innerHTML="<ul>" + hatamsg + "</ul>";
		return false;
	}
	else{
		return true;
	}
	
}




	

	
	function blocktoggle(Block,i) {
			  if (document.getElementById) {
				shown[i] = (shown[i]) ? false : true;
    		    currentdisplay = (shown[i]) ? '' : 'none';
               	document.getElementById(Block+i).style.display = currentdisplay;
		      }
			}

			function blockdisplay(Block,i) {
			  if (document.getElementById){
			    if (document.getElementById(Block+i)) {
			      for ( j = 1; j < 1000; j++ ) {
			        if (document.getElementById(Block + j)) {document.getElementById(Block + j).style.display = 'none';}
				    else {j = 1000;}


			      }
			      if (i) {document.getElementById(Block+i).style.display = '';}
			    }
			  }
			}
        
		
		function isitFutureDate(dateString)
		{
			
			if (dateString.length != 7)
				{ alert("Enter Date format as: dd/mm/yyyy"); return false; }
				var now = new Date();
				var curMonth = now.getMonth();
				var curYear = now.getYear();
				var testMonth = dateString.substring(0,2);
				var testYear = dateString.substring(3,7);

				if (testYear >= curYear)
					{
						if (testMonth > curMonth) return true;
						else return false;
					}
					else return false;

			}
			
	
			

			
		
	function KapaYenile(){
		window.close();
		opener.window.location.reload(true);
		
	}


function submitonce(theform){

	if (document.all||document.getElementById){

		for (i=0;i<theform.length;i++){
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
			tempobj.disabled=true;
		}
	}
}





	function validate(dateValue) {

 	if (!/^\d\d?\/\d\d?\/\d{4}$/.test(dateValue)) {
 		 return false;
 	}
 	var aD = (dateValue).split("/");
 	var nD = new Date(aD[2], aD[1]-1, aD[0]);
	 if((aD[2]!=nD.getFullYear() || aD[1]!=nD.getMonth()+1 || aD[0]!=nD.getDate()) ){
		 return false
 	}
 		return true;

}

function Linkler(i,obj,Linkler) {

			  if (document.getElementById){
			    if (document.getElementById(obj+i)) {
			      for ( j = 0; j <= 1000; j++ ) {
			        if (document.getElementById(obj + j)) {
					
					document.getElementById(obj + j).style.display = 'none';
					document.getElementById(Linkler + j).className='aramaalt';
					
					}
					else {j = 1000;}
			      }
			       if (document.getElementById(obj+i))  {
				  document.getElementById(obj+i).style.display = '';
				  document.getElementById(Linkler+i).className='vka';
				  
				  }
			    }
			  }
			}
			
			
			function AdresDegistir(url,ID){

				window.location.href=url + ID

			}
			
			function AcilanPencereAdresDegistir(url){
						
				opener.window.location.href=url
				
				
			}
			
			
			
			function GetPage(today, id){
 			  new Ajax.Updater("calendars", " ajax.asp",
     			{asynchronous: true,
      			onCreate: function(){ showBusy },
      			onComplete: function(){ hideBusy },
      				method: "get",
      				parameters: "Email=" + today +"&hotel_id=" + "<?=$_SESSION[hotel_id]?>"
     			 });
			}

			function EmailEkle(LaodingID){
			
 			  new Ajax.Updater("EklemeSonucu", " ajax.asp",
     			{asynchronous: true,
      			onLoading : function(){ showBusy(LaodingID) },
      			onComplete: function(){ hideBusy(LaodingID) },
      			method:'post',
				parameters:Form.serialize('AddList')
     			});
			}





function showBusy(LaodingID){
	Element.show(LaodingID);
}

function hideBusy(LaodingID){
   Element.hide(LaodingID);
}




			function ajaxDivLoading(url,id){
			
 			  new Ajax.Updater(id, url,
     			{asynchronous: true,
      			onLoading : function(){ showBusyL(id) }

     			});
			}
			
			function showBusyL(id){
							
							itm=getItem(id);
							itm.innerHTML='<img src="/ajax/loading.gif" width="16" height="16"><br>Yükleniyor...';
			}


        function KategoriGetir(KategoriID,id,DV){
			itm=getItem(id);
			itm.style.display = '';
			if (KategoriID!="0"){
				ajaxDivLoading('/ajax.asp?FormName=CmbKategoriGoster&KategoriID='+KategoriID+'&DV='+DV,id);
			}
			else
			{
				id.innerHTML='<select name="KategoriID"></select>';
			}
			
		}

function AjaxTab(url,id,Tabid,number){
	alert('Girdi')
		for(i=1;i<10;i++){
			if (document.getElementById(Tabid + i)){
				 document.getElementById(Tabid+i).className='';
			}
			else{
				i=10;
			}
			
		}
	
       if (document.getElementById(Tabid+number))  {
				  document.getElementById(Tabid+number).className='active';
				  
		}
		
		ajaxDivLoading(url,id);
		return false;
	
	
}


function Tabbing(id,Tabid,number){

		for(i=1;i<10;i++){
			if (document.getElementById(id + i)){
				 document.getElementById(id+i).className='';
				 document.getElementById(Tabid+i).style.display = 'none';
				 
			}
			else{
				i=10;
			}
			
		}
	
       if (document.getElementById(id+number))  {
				  document.getElementById(id+number).className='active';
				  document.getElementById(Tabid+number).style.display = '';
				  
		}
		

	
}
