// CSS Browser Selector   v0.2.5
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();
/*menu fonksiyonu*/
var acikaltmenu = 'anasayfa';
function menu(){
	var element = $$('#menu #anamenu a');
	for(a=0;a<element.length;a++){
		var l=element[a];
		if(l != undefined){
			element[a].addEvent('mouseenter',function(){return false});
		}
		element[a].addEvent('mouseenter',
																						function(){
																							var array = this.id.split('_');
																							array = this.id.replace('_'+array[array.length-1],'');
																							var element=$(array);
																							if(element != undefined){
																								$(acikaltmenu).style.display = 'none';
																								element.style.display = 'block';
																								acikaltmenu=element;
																							}
																						});
	}
}
//Şifremi unuttum kısmı ajax fonksiyonu.
function sunuttum(){
	if($('eposta').value!=''){
		var veri='eposta='+$('eposta').value+'&tip=sifre';
		$('sifremi_gonder').style.display='none';
		$('sonuc').style.display='block'
		var sorgu = new Ajax('index.php?sayfa=uye&islem=unuttum', {method: 'post',data: veri ,update:$('sonuc_icerik')}).request();
	}else{
		alert('E-posta adresiniz geçerli değil.');
	}
}
//şifrenin güvenirliğini ölçelim.
function testPassword(passwd)
{
		var intScore   = 0
		var strVerdict = 0
		var strLog     = ""
		
		// PASSWORD LENGTH
		if (passwd.length<5)                         // length 4 or less
		{
			intScore = (intScore+3)
			strLog   = strLog + "3 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>4 && passwd.length<8) // length between 5 and 7
		{
			intScore = (intScore+6)
			strLog   = strLog + "6 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>7 && passwd.length<16)// length between 8 and 15
		{
			intScore = (intScore+12)
			strLog   = strLog + "12 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>15)                    // length 16 or more
		{
			intScore = (intScore+18)
			strLog   = strLog + "18 point for length (" + passwd.length + ")\n"
		}
		
		
		// LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex)
		if (passwd.match(/[a-z]/))                              // [verified] at least one lower case letter
		{
			intScore = (intScore+1)
			strLog   = strLog + "1 point for at least one lower case char\n"
		}
		
		if (passwd.match(/[A-Z]/))                              // [verified] at least one upper case letter
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one upper case char\n"
		}
		
		// NUMBERS
		if (passwd.match(/\d+/))                                 // [verified] at least one number
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one number\n"
		}
		
		if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/))             // [verified] at least three numbers
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least three numbers\n"
		}
		
		
		// SPECIAL CHAR
		if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))            // [verified] at least one special character
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one special char\n"
		}
		
									 // [verified] at least two special characters
		if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least two special chars\n"
		}

		if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for upper and lower letters\n"
		}

		if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/))
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for letters and numbers\n"
		}
 
		if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for letters, numbers and special chars\n"
		}
	
	
		if(intScore < 16)
		{
		   strVerdict = 1
		}
		else if (intScore > 15 && intScore < 25)
		{
		   strVerdict = 2
		}
		else if (intScore > 24 && intScore < 35)
		{
		   strVerdict = 3
		}
		else if (intScore > 34 && intScore < 45)
		{
		   strVerdict = 4
		}
		else
		{
		   strVerdict = 5
		}
		return strVerdict;
}
//anket için gönderi fonksiyonu
function anket(){
	var element=$$('#anket input');
	for(a=0;a<element.length;a++){
		if(element[a].checked==true){
			var veri='anketoy='+element[a].value+'&snu='+element[a].name+'&anu='+$('anu').value;
			$('anket_oylama').style.display='none';
			$('anket_sonuc').innerHTML='İşlem devam ediyor.';
			$('anket_sonuc').style.display='block';
			var sorgu = new Ajax('index.php?sayfa=anket&islem=sonuc', {method: 'post',data: veri ,update:$('anket_sonuc')}).request();
		}
	}
}

function kkontrol(){
	var element=$('kullaniciadi');
	var veri = 'tip=kkontrol&kadi='+element.value;
	var sorgu = new Ajax('index.php?sayfa=uye&islem=kkontrol', {method: 'post',data: veri ,onComplete:
	function(){$('kullanici_adi_durum').innerHTML = (this.response.text == 1 ?'Kullanici Adi Uygun Degil':'Kullanici Adi Uygun')}
	}).request();
}

function pkontrol(){
	var element=$('eposta_adresi').value+'@'+$('eposta_adresi2').value;
	var veri = 'tip=pkontrol&eposta='+element;
	var sorgu = new Ajax('index.php?sayfa=uye&islem=kkontrol', {method: 'post',data: veri ,onComplete:
	function(){$('eposta_durum').innerHTML = (this.response.text == 1 ?'E-posta Kayitli':'E-posta Uygun')}
	}).request();
}

function show(){
effect2.start({
    'opacity': 0.1
}).chain(function(){
		effect2.start({'opacity': 1});
});
}

function loadimage(url){
		var as=new Asset.images([url], {
		    onComplete: function(){
						el2=as[0];
		        show();
		    }
		});
}

var htimer={};
var rurl = '';
function habergetir(id,url) {
	$clear(htimer);
	rurl = url;
	htimer = setTimeout('habergetir2("'+id+'","'+url+'")',800);
}
function habergetir2(id,url) {
	var veri = 'id='+id;
	var sorgu = new Ajax('index.php?sayfa=haber&islem=goster', {method: 'post',data: veri ,onComplete:
	function(){
		if(this.response.text != '')
			$('haber').innerHTML = this.response.text;
		loadimage(rurl);
		}
	}).request();
}

function anketgeri(){
			$('anket_sonuc').style.display='none';
			$('anket_oylama').style.display='block';
			$('anket_sonuc').innerHTML='';
}
var yaziid=0;
function oylama(){
		element=$$('#oy_ver a');
		var yaziid=element[0].id;
		for(a=0;a<element.length;a++){
				element[a].id=a;
				element[a].addEvent('mouseenter',function(){this.getParent().getParent().className='yildizp'+this.id});
				element[a].addEvent('click',function(){oykullan(this.id,yaziid)});
		}
}
var puan='';
function oykullan(oy,yaziid){
			veri='oy='+oy+'&tip=yazioy&yaziid='+yaziid;
			var puan = new Ajax('index.php?sayfa=genel&islem=puan', {method: 'post',data: veri ,update:$('anket_sonuc'),
																								onComplete:function(veri){
																										$('oy_ver').className=puan.response.text;
																								}}).request();		
}
function formolustur() {
		var veri=$$('#uyelik_formu input');
		for(a=0;a<veri.length;a++){
				if(veri[a].value == '')
					veri[a].className = 'hata';
				veri[a].addEvent('keyup', function(){formkontrol()});
		}
		var veri=$$('#uyelik_formu textarea');
		for(a=0;a<veri.length;a++){
				if(veri[a].value == '')
					veri[a].className = 'hata';
				veri[a].addEvent('keyup', function(){formkontrol()});
		}
}
function formkontrol() {
		var veri=$$('#uyelik_formu input');
		for(a=0;a<veri.length;a++){
				if(veri[a].id == 'eposta_adresi2'){
						var c = veri[a].value.split('.');
						if(c.length < 2)
							veri[a].className = 'hata';
						else
							veri[a].className = '';
				}
				else if(veri[a].id == 'sifre'){
						var c = veri[a].value;
						if(c.length>6 && c.length < 30){
							veri[a].className = '';
							var test=testPassword(veri[a].value);
							if(test >= 1 && test <= 2){
									$('derece').className = 'derece_zayif';
									$('derece').innerHTML = 'Zayif';
							}
							else if(test == 3){
									$('derece').className = 'derece_orta';
									$('derece').innerHTML = 'Orta';
							}
							else if(test > 3){
									$('derece').className = 'derece_guclu';
									$('derece').innerHTML = 'Güçlü';
							}							
						}else{
							veri[a].className = 'hata';
							$('derece').className = 'derece_zayif';
							$('derece').innerHTML = 'Zayif';
						}
				}
				else if(veri[a].value == '')
					veri[a].className = 'hata';
				else
					veri[a].className = '';
		}
		var veri=$$('#uyelik_formu textarea');
		for(a=0;a<veri.length;a++){
				if(veri[a].value == '')
					veri[a].className = 'hata';
				else
					veri[a].className = '';
		}
}

// resim değişimi için...
/*$(document).ready(function(){
	$("div#alt_etiketler").css("zIndex","999"); 
});*/
var effect2 = {};
var el2={};
var forms = {};
var arrays = new Array('turkce_isimli','yerlimali_yorumlar','secenler');
window.addEvent('domready', function() {
	/*menu*/
	menu();
	if($('foto'))
		effect2 = new Fx.Styles('foto', {duration: 1000, transition: Fx.Transitions.linear,onComplete:function(){$('foto').src=el2.src;}});
	//uyelik bilgileri kontrol
	
	if($('kullaniciadi_sorgula'))
		$('kullaniciadi_sorgula').addEvent('click',function(){kkontrol()});
	if($('eposta_sorgula'))
		$('eposta_sorgula').addEvent('click',function(){pkontrol()});
																																						
	// kutu kapatma butonlarının işlevselliği
	$$('.kutu_kapat').addEvent('click',function(){this.getParent().getParent().style.display='none'});
	

	
	//form gizle göster
	if($('ymform1')){
		forms.a = new formgoster('ymform1');
		forms.b = new formgoster('ymform2');
		
		$('ymbtn1').addEvent('click',function(){forms.a.gg();});
		$('ymbtn2').addEvent('click',function(){forms.b.gg();});
	}
	
	//anket kısmı için kodlar
	if($('anket_gonder'))
		$('anket_gonder').addEvent('click',function(){anket()});
	// Açıklama kısımlarının belirlenmesi.																																		
	var Aciklama1 = new Tips($$('.digerleri'),{className: 'aciklama'});
	var Aciklama2 = new Tips($$('.kirmizi'),{className: 'aciklama'});
	var Aciklama2 = new Tips($$('.rss'),{className: 'aciklama'});
	if($('nededi'))
		Plider.create('nededi');
	if($('kullanici_form_menu'))	
		panmen.olustur('kullanici_form_menu');
	//Üst giriş paneli yazı alanları kontorlü
	$('kullanici_adi').addEvent('click', function(){$('kullanici_adi').getPrevious().style.display='none'});
	$('kullanici_adi').addEvent('blur', function(){if($('kullanici_adi').value==''){$('kullanici_adi').getPrevious().style.display='block'}});
	
																																					$('kullanici_sifresi').addEvent('click', function(){$('kullanici_sifresi').getPrevious().style.display='none'});
	$('kullanici_sifresi').addEvent('blur', function(){if($('kullanici_sifresi').value==''){$('kullanici_sifresi').getPrevious().style.display='block'}});

	//Sifremi unuttum kısmı
	if($('sifremi_ver')){
		$('sifremi_unuttum').addEvent('click', function(){$('sifremi_gonder').style.display='block';$('sonuc').style.display='none'});
		$('sifremi_ver').addEvent('click',function(){sunuttum()});
	}
	//akordiyon efekti
	
	var accordion = new Accordion('li.baslangic', 'li.baslangic2', {
	opacity: false,
	duration:200,
	onActive: function(toggler, element){
		toggler.firstChild.className='aktif';
	},
 
	onBackground: function(toggler, element){
		toggler.firstChild.className='';
	}
	}, $('turkcevar'));
	
	if($('oy_ver'))
	oylama();
	//form kontrolleri
	if($('davetiye_numarasi_yoksa')){
		
			$('davetiye_numarasi_yoksa').addEvent('click', function(){$('davetiye_paneli').style.display = 'none';});
			formolustur();
			
	}
	});

	// plider
	function Plider(){
		this.ids=[];
		this.current=0;
		this.num;
		
		this.create = function(el){
			this.el=$$('#'+el+' .ic div');
			for(var a=0;a<this.el.length;a++){
				this.ids[a]=this.el[a].id;
			}
			this.num=this.ids.length-1;
			this.scroll = new Fx.Scroll(el,{wait: false,duration: 400,wheelStops:false,transition: Fx.Transitions.Cubic.easeOut});
			this.scroll.toElement('section0');
			$$('.devami').addEvent('click',function(){this.change(+1)}.bind(this));
		}
		
		this.change = function(t){
			if(t == 1){
				if(this.current == this.num){
					this.scroll.toElement('section'+0);
					this.current = 0;
				}else{
					this.scroll.toElement('section'+(this.current+1));
					this.current++;
				}
			}else if(t == -1){
				if(this.current == 0){
					this.scroll.toElement('section'+this.num);
					this.current=this.num;
				}else{
					this.scroll.toElement('section'+(this.current-1));
					this.current--;
				}
			}
		}
		
	}
		function formgoster(id){
		this.fx = new Fx.Styles(id, {duration: 500, transition: Fx.Transitions.linear,'onComplete':function(){}});
		this.goster = function(){
			this.fx.$events['onComplete'] = [];
			this.fx.element.setStyles({'display':'block'}) 
			this.fx.start({'opacity':1});
		}
		
		this.gizle = function(){
			
			this.fx.$events['onComplete'] = [function(){this.fx.element.setStyles({'display':'none'})}.bind(this)]; 
			this.fx.start({'opacity':0});
		}
		
		this.gg = function(){
			if(this.fx.element.getStyle('display') == 'none') {
				this.goster();
			}else{
				this.gizle();
			}
		}
	}
		function yeni_pencere(url,w,h){
		var url, w, h
		self.name="anasayfa";
		window.open(url, "Pencere","toolbar=no,width="+w+" ,statusbar=0, height="+h+" ,top=25, left=25, scrollbars=1");
		}	

  function UyariVer(url, uyari)
	{
 		if (confirm("Emin misiniz, "+uyari+"?")) location = url; 
	}

	function icerikal(el,up,tip,atip,id){
		$$('#cons .solicerikkutu').each(function(el){el.setStyles({'display':'none'})});
		$(up).setStyles({'display':'block'});
		var veri = 'tip='+tip+'&atip='+atip+'&id='+id;
		var sorgu = new Ajax('index.php?sayfa=yerlimali&islem=detayislem', {method: 'post',data: veri ,update:$(up)}).request();
		$$('.aktifsekme')[0].className='';
		el.className='aktifsekme'
	}	
	
	function icerikalogretim(el,up,tip,atip,id){
		$$('#cons .solicerikkutu').each(function(el){el.setStyles({'display':'none'})});
		$(up).setStyles({'display':'block'});
		var veri = 'tip='+tip+'&atip='+atip+'&id='+id;
		var sorgu = new Ajax('index.php?sayfa=turkceogretim&islem=detayislem', {method: 'post',data: veri ,update:$(up)}).request();
		$$('.aktifsekme')[0].className='';
		el.className='aktifsekme'
	}	
	
	function icerikaltabela(el,up,tip,atip,id){
		$$('#cons .solicerikkutu').each(function(el){el.setStyles({'display':'none'})});
		$(up).setStyles({'display':'block'});
		var veri = 'tip='+tip+'&atip='+atip+'&id='+id;
		var sorgu = new Ajax('index.php?sayfa=turkcetabela&islem=detayislem', {method: 'post',data: veri ,update:$(up)}).request();
		$$('.aktifsekme')[0].className='';
		el.className='aktifsekme'
	}
	
	
	function panelmenunavigasyonu(){
		this.olustur=function(id){
			var el=$$('#'+id+' ul li');
			this.acik=el[0].id.substr(0,el[0].id.length-1);
			for(a=0;a<el.length;a++){
				el[a].addEvent('click',function(){$(panmen.acik+'m').firstChild.className='';$(panmen.acik).style.display='none';panmen.acik=this.id.substr(0,this.id.length-1);$(this.id.substr(0,this.id.length-1)).style.display='block';this.firstChild.className='aktif_sekme';});
			}
		}
	}
	var Plider = new Plider();
	var panmen = new panelmenunavigasyonu();