var mooGlobal = {};
(function($) {
window.addEvent('domready',function() {


var validEmail = function(email) {
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   var address = $(email).value;
	   if(reg.test(address)) {
		   return true;
	   } else { 
		   return false;
		}
	};
	
	/* KURLAR */
	if($('kurlar')) {
		var kurReq = new Request({
							 url:'kur.php',
							 method:'get',
							 onComplete:function(req) {
								$('kurlar').set('html',req); 
							 },
							 onFailure:function() {
								$('kurlar').set('html','<p>Kurlar yüklenemedi!</p>'); 
							 }
							 
							 });
	kurReq.send();	
	}
/************************************************************************************************/	
	
	/* HAVA */
	if($('hava')) {
		var havaReq = new Request({
							 url:'hava/hava.php',
							 method:'get',
							 onComplete:function(req) {
								$('hava').set('html',req); 
							 },
							 onFailure:function() {
								$('hava').set('html','<p>Hava durumu yüklenemedi!</p>'); 
							 }
							 
							 });
	havaReq.send();	
	}
	
	
	
/************************************************************************************************/	
/* BANA OZEL LISTEM */
	if($$('#banaozel_listem li')) {
		
		$$('#banaozel_listem li').each(function(listeli) {
							listeli.addEvents({
											  'mouseenter':function() {
													listeli.getChildren("a.user-list-kaldir").setStyle("display","block");
													listeli.highlight('#FEF9BA','#FFFFFF');
											  },
											  'mouseleave':function() {
												  	listeli.getChildren("a.user-list-kaldir").setStyle("display","none"); 
											  }
							});				   
											   
		});
		
		
		
		
		
		
		$$('#banaozel_listem li a.user-list-kaldir').each(function(deletelink) {
								var silinecek = deletelink.getProperty('rel');
								deletelink.addEvent('click',function() {
												$('banaozel_listem_loading').setStyle('display','block');
												deletelink.getParent('li').highlight('#FF9900','#FFF'); 
												
												new Request({
													url : '_listeSil.php',
													method:'get',
													onComplete:function(silindi) {
														var deletefx = new Fx.Slide(deletelink.getParent('li'),{fps:90});
														deletefx.slideOut().chain(function() { 
														deletelink.getParent('li').destroy();
														$('banaozel_listem_loading').setStyle('display','none');
														});
													}
												}).send("id="+silinecek);
												
												
												 });
																   
								});
		
	}
	
	
/************************************************************************************************/	
/* EMLAK TÜRÜ */
	
	if($('arama_emlak1')) {
		$('arama_emlak1').addEvent('change',function(){
			$('arama_emlak2_cont').setStyle('display','block');
			new Request({
				url:'_emlakTur.php',
				method:'get',
				onSuccess:function(turlistesi) {
					$('arama_emlak2_cont').set('html',turlistesi);
				}
			}).send("id="+$('arama_emlak1').value);
		});
	}
	
	
/* EMLAK TÜRÜ - Haberci*/
	
	if($('harama_emlak1')) {
		$('harama_emlak1').addEvent('change',function(){
			$('harama_emlak2_cont').setStyle('display','block');
			new Request({
				url:'_emlakTur.php',
				method:'get',
				onSuccess:function(turlistesi) {
					$('harama_emlak2_cont').set('html',turlistesi);
				}
			}).send("id="+$('harama_emlak1').value);
		});
	}
	
/************************************************************************************************/	
/* İLÇELER */
		
		if($('arama_il')) {
			$('arama_il').addEvent('change',function(){
				$('arama_ilce_cont').setStyle('display','block');
				new Request({
					url:'_emlakIlce.php',
					method:'get',
					onSuccess:function(ilcelistesi) {
						$('arama_ilce_cont').set('html',ilcelistesi);
					}
				}).send("id="+$('arama_il').value);
			});
		}
		
/* İLÇELER - Haberci */
		
		if($('harama_il')) {
			$('harama_il').addEvent('change',function(){
				$('harama_ilce_cont').setStyle('display','block');
				new Request({
					url:'_emlakIlce.php',
					method:'get',
					onSuccess:function(ilcelistesi) {
						$('harama_ilce_cont').set('html',ilcelistesi);
					}
				}).send("id="+$('harama_il').value);
			});
		}

		
/*************************************************************************************************/

		
		
		if($('hform_arama')) {

			new FormCheck('hform_arama', {
				display : {
					errorsLocation : 1, // tip
					indicateErrors : 1, // sırayla
					flashTips:1
					//scrollToFirst:false
				}
			});
		}
		
		
		
		
		
		
		
		
		
		mooGlobal.updateList = function() {
			new Request({url:'_listeGoster.php',method:'get',onComplete:function(listeRes) { $('listem').set('html',listeRes); }}).send();
		};
		
		
});
})(document.id);

function updateListe() {
	mooGlobal.updateList();
}


var g = {};


/* jQuery */
$(document).ready(function(){
			if($("a[rel='detail']")) {
				$("a[rel='detail']").colorbox({width:"963", height:"498", maxHeight:"498",maxWidth:"963",iframe:true});
			}
			if($("a[class='haberbox']")) {
				$("a[class='haberbox']").colorbox({width:"360",maxWidth:"360",height:"40%",iframe:true});
			}
			
			if($("a[class='sektorelbox']")) {
				$("a[class='sektorelbox']").colorbox({width:"360",maxWidth:"360",height:"40%",iframe:true});
			}
			
			
			/* SEMT */
			if($('arama_semt')) {
				$("#arama_semt").autocomplete("_emlakSemt.php",{
					delay:10,
					minChars:1,
					matchSubset:1,
					autoFill:true,
					maxItemsToShow:10,
					width:168
				});
			}
			
			/* Fiyat */
			if($('#arama_fiyat1')) {
				$('#arama_fiyat1').setMask();
				$('#arama_fiyat2').setMask();
			}
			
			/* Fiyat 2 - Haberci */
			
			if($('#harama_fiyat1')) {
				$('#harama_fiyat1').setMask();
				$('#harama_fiyat2').setMask();
			}
			
			/* SEMT - Haberci*/
			if($('#harama_semt')) {
				$("#harama_semt").autocomplete("_emlakSemt.php",{
					delay:10,
					minChars:1,
					matchSubset:1,
					autoFill:true,
					maxItemsToShow:10,
					width:168
				});
			}
			
			
			g.updateSon = function() {
				$('#banaozel_son').load('_sonGezdiklerim.php');
			};
			
			if('#sektorellist') {
				$('#sektorellist').load('sektorel/sektorel.php');
			}
			
			if('#ul-kredi') {
				$('#ul-kredi').load('uygunkredi/uygunkredi.php');
			}
			
			
});

function updateSon2() {
	g.updateSon();
}

