function bekle()
{
	$('bekle').style.display='';
	$('simplemodal-container').position({
	relativeTo: document.body,	
    position: 'center',
    edge: 'center'
	});
	
	var ust = $('simplemodal-container').style.top.replace('px','')-60-posTop()+'px';
	$('simplemodal-container').style.top = ust;
}

function git(u)
{
	getRequest('/islem.php?ne=git&u='+escape(u),'','GET');
}

function tg(v)
{
	getRequest('/islem.php?ne=tg&v='+v,'','GET');
}

function email_adresi_kontrol(epostasi)
{
   if ( (epostasi.indexOf ('@',0) == -1) || (epostasi.indexOf('.',0) == -1) || (epostasi.indexOf(' ',0) != -1) || (epostasi.length<6) || epostasi.indexOf ('@',0) != epostasi.lastIndexOf ('@') ){
        return false;
      }
      else{
      	return true;
      }	
}

function HiddenSelects() {var selectbox = document.getElementsByTagName("SELECT")
for(i=0;i<selectbox.length;i++) { selectbox[i].style.visibility='hidden'
}
}

function VisibleSelects() {var selectbox = document.getElementsByTagName("SELECT");for(i=0;i<selectbox.length;i++){selectbox[i].style.visibility='visible';}}

function doBlink() {
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  if (document.all)
    setInterval("doBlink()",600)
}
startBlink();

function getRequest(file,values,m){
	new Request.HTML({
		url: file,
		method: m,
		evalScript: true
	}).send(values);
}

function getInner(container, file, values){
	new Request.HTML({
		url: file,
		method: 'get',
		onComplete: function(rt,re,rh){$(container).set('html',rh); animasyon();},
		evalScript: true
	}).send(values);	
}

function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 
function posRight() {return posLeft()+pageWidth();} 
function posBottom() {return posTop()+pageHeight();}

function animasyon()
{
	iMyWidth = pageWidth()
		
	$('pop_ucus_detayi').style.top = '-430px';
	$('pop_ucus_detayi').style.left = (((iMyWidth-1000)/2)+85)+'px';
	
	var mover = new Fx.Move($('pop_ucus_detayi'), {
	relativeTo: document.body,	
    position: 'center',
    edge: 'center',
    offset: {x: 0, y: -posTop()}
});
	mover.start();
	addWindow();
}


function addWindow(){
     $$("#UI_window .close").hover(
        function(){
            $(this).addClass("hover");
        },
        function(){
            $(this).removeClass("hover");
        }
    );
    $$("#UI_window .close").addEvent('click',function(){
        removeWindow();
    });
}

function removeWindow(){
	var mover = new Fx.Move($('pop_ucus_detayi'), {
	relativeTo: document.body,	
    position: 'center',
    edge: 'center',
    offset: {x: 0, y: 690},
    onComplete: function(){$("UI_window").hide();}
});
	mover.start();
}


function light_window(p)
{
	getInner('inner_alpha',p,'');
}

window.addEvent('domready',function(){
	Element.implement({
		'hover': function(fn1,fn2) {
			this.addEvents({
				'mouseenter': function(e) {
					fn1.attempt(e,this);
				},
				'mouseleave': function(e) {
					fn2.attempt(e,this);
				}
			})
		},
		attr: function(property,value) {
		var type = $type(property);
		if(value == undefined && type != 'object') {
		return this.get(property);
		}
		else {
		var pvs = property;
		if(type != 'object') { pvs = {}; pvs[property] = value; }
		return this.set(pvs);
		}
		}

	});
	
	
	$$("#UI_results .price").hover(function(){
	    if(!$(this).hasClass('noprice'))
	    {
			$(this).getElements('span').addClass("over");
		}
		
		
	},function(){
		$(this).getElements('span').removeClass("over");
	});
	

	$$("#UI_area .offer").hover(
        function(){
           $(this).addClass("offer-over");
        },
        function(){
            $(this).removeClass("offer-over");
        }
    );

	
	
	$$("#UI_results .price").addEvent('click',function(){
	    if(!$(this).hasClass('noprice'))
	    {
	       var id = $(this).getElements('span').attr('alt');
	       light_window('/islem.php?ne=ucus_detayi&id='+id);
	       
		}
	});
	
	$$("#datepicker_jqui").hover(function(){
		alert(1);
	})
	
	/*
	$$('#UI .field_select_sexe input.custom, .field_select_phone input.custom').addEvent('click',function(){
		var field = $(this);
		$(this).getNext().style.display='';
		$(this).getNext().fade('in');
		
		$(this).getNext().getElements('dt').addEvent('click',function(){
		  field.value = $(this).get('text');
		  field.getNext().fade('out');
		});
		
		$$('#UI .field_select_sexe').addEvent("mouseleave",function(){
			field.getNext().fade('out');
		});
		
	});
	*/
});

function sondur()
{
	for (a=0;a<7;a++){$('k-'+a).removeClass("over");}
	for (b=0;b<9;b++){$('d-'+b).removeClass("over");}
}

function yak(k,d)
{
	sondur();
	
	$('k-'+k).addClass("over");
	$('d-'+d).addClass("over");
}

function tek_sondur()
{
	for (a=0;a<7;a++){$('k-'+a).removeClass("over");}
	//for (a=0;a<7;a++){$('c-'+a+'-0').removeClass("over");}
}

function tek_yak(k)
{
	//tek_sondur();
	//$('c-'+k+'-0').addClass("over");
	
	$('k-'+k).addClass("over");
}

function ucus_tab(t)
{
	$('ucus_detaylari').style.display='none';
	$('fiyatlar').style.display='none';
	$('havayolu_sirketi').style.display='none';
	$('bagaj').style.display='none';
	
	$('t_ucus_detaylari').removeClass('active');	
	$('t_fiyatlar').removeClass('active');	
	$('t_havayolu_sirketi').removeClass('active');	
	$('t_bagaj').removeClass('active');	
	
	$(t).style.display='';
	$('t_'+t).addClass('active');
}

function sehirleri_guncelle(sehir_id,type)
{
	if (type==2){o = $('ulke_id[]');} 
	else if (type==3){o = $('fatura_ulke_id');} 
	else {o = $('ulke_id');}
	getRequest('/islem.php?ne=sehirleri_guncelle&ulke_id='+o.value+'&sehir_id='+sehir_id+'&type='+type,'','GET');
}

function fatura_bilgi_doldur(tip)
{
if ($('yolcu_bilgileri').checked)
{
$('fatura_ad_soyad').value = $('adi').value+' '+$('soyadi').value;
$('fatura_adres').value = $('adresi').value;
$('fatura_posta_kodu').value = $('posta_kodu').value;
$('fatura_semt').value = $('semt').value;

if (tip == 1){
for(var i=0; i<$('fatura_ulke_id').options.length; i++) {
	if($('fatura_ulke_id').options[i].value == $('ulke_id').value) {
		$('fatura_ulke_id').options[i].selected=true;
		break;
	}
}

sehirleri_guncelle($('sehir_id').value,3);
}
}
else
{
$('fatura_ad_soyad').value = '';
$('fatura_adres').value = '';
$('fatura_posta_kodu').value = '';
$('fatura_semt').value = '';
$('fatura_ulke_id').options[0].selected=true;
$('fatura_sehir_id').options[0].selected=true;
}

if ($('yolcu_bilgileri').checked){$('table_fatura_bilgileri').style.display='none';}
else{$('table_fatura_bilgileri').style.display='';}
}

function cep_guncelle(o)
{
	if (o.value != 90)
	{
		$('div_diger_sehir_kodu').style.display='';
		$('div_diger_ulke_kodu').style.display='';
		
		$('cep_telefonu1_text').name = 'cep_telefonu1';
		$('cep_telefonu1_select').name = 'temp1';
		
		$('cep_telefonu2_text').name = 'cep_telefonu2';
		$('cep_telefonu2_select').name = 'temp2';
		
		$('cep_telefonu2_select').disabled = true;			
		$('cep_telefonu2_select').options[0].selected = true;			
	}
	else
	{
		$('div_diger_sehir_kodu').style.display='none';
		$('div_diger_ulke_kodu').style.display='none';
		
		$('cep_telefonu1_text').name = 'temp1';
		$('cep_telefonu1_select').name = 'cep_telefonu1';
		
		$('cep_telefonu2_text').name = 'temp2';
		$('cep_telefonu2_select').name = 'cep_telefonu2';
		
		$('cep_telefonu2_select').disabled = false;		
	}
}

function getAge(Y,M,D){
var now=new Date(),m=now.getMonth()+1,d=now.getDate();
return now.getFullYear()-Y+(M>m?-1:M==m&&D>d?-1:0);
}

function isNumberKey(evt)
{
 var charCode = (evt.which) ? evt.which : evt.keyCode
 if (charCode > 31 && (charCode < 48 || charCode > 57))
    return false;

 return true;
}


function taksit_guncelle(sid)
{
	getRequest('/islem.php?ne=taksit_guncelle&id='+$('kart_id').value+'&tutar='+$('tutar_temp').value+'&sid='+sid,'','GET');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function kampanya_hesapla()
{
	if ($('kampanya_kodu').value == ''){alert('Lütfen kampanya kodunu yazınız');$('kampanya_kodu').focus();}
	else {document.location.href = document.location+'&kampanya_kodu='+$('kampanya_kodu').value;}
}

function ucus_tablosu()
{
	$('ucus_tablosu_ana').style.display='';
}

function ucus_tablosu_kapat()
{
	$('ucus_tablosu_ana').style.display='none';
}

function arkadasina_oner_kapat()
{
	mySlide_arkadas.slideOut();
	$('arkadasina_oner_div').style.display='none';
}


function arkadasina_oner(){
	$('arkadasina_oner_table').style.display='';
	$('arkadasina_oner_sonuc').style.display='none';
	$('alici_email_adresi').value='';
	$('gonderen_email_adresi').value='';
	$('arkadasina_oner_div').style.display='';
	$('gonderen_email_adresi').removeClass('error');
	$('alici_email_adresi').removeClass('error');
	$('hatalar_arkadas').innerHTML = '';
}


function buyult(evt,o)
{
 	var val = o.value;
    evt = evt || window.event;

    var charCode = typeof evt.which == "number" ? evt.which : evt.keyCode;
    if(evt.ctrlKey==true)return;
    
    if (charCode && charCode != 13 && charCode != 32) {
        
		if(charCode==287)charCode=71; //ğ
		else if(charCode==286)charCode=71;
		else if(charCode==220)charCode=85; //ü
		else if(charCode==252)charCode=85;
		else if(charCode==350)charCode=83; //Ş
		else if(charCode==351)charCode=83;
		else if(charCode==304)charCode=73; // ı
		else if(charCode==305)charCode=73;
		else if(charCode==214)charCode=79; //Ö
		else if(charCode==246)charCode=79;
		else if(charCode==199)charCode=67;
		else if(charCode==231)charCode=67;
		else if( charCode>=97 && charCode<=122)charCode = 65 + charCode-97;
        
		if (charCode == 8){return true;}
		
		var keyChar = String.fromCharCode(charCode);

        var mappedChar = keyChar;

        var start, end;
        if (typeof o.selectionStart == "number" && typeof o.selectionEnd == "number") {
            start = o.selectionStart;
            end = o.selectionEnd;
            o.value = val.slice(0, start) + mappedChar + val.slice(end);

            o.selectionStart = o.selectionEnd = start + 1;
        } else if (document.selection && document.selection.createRange) {
            var selectionRange = document.selection.createRange();
            var textInputRange = o.createTextRange();
            var precedingRange = o.createTextRange();
            var bookmark = selectionRange.getBookmark();
            textInputRange.moveToBookmark(bookmark);
            precedingRange.setEndPoint("EndToStart", textInputRange);
            start = precedingRange.text.length;
            end = start + selectionRange.text.length;

            o.value = val.slice(0, start) + mappedChar + val.slice(end);
            start++;

            textInputRange = o.createTextRange();
            textInputRange.collapse(true);
            textInputRange.move("character", start - (o.value.slice(0, start).split("\r\n").length - 1));
            textInputRange.select();
        }

        return false;
    }
}

function shareWindow(siteName,id){

	var sharedPage = window.location;
	
	if (siteName == "facebook"){
			
			t=document.title;
			window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(sharedPage)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
			
	}else if (siteName == "twitter"){
	
		window.open('http://twitter.com/?status='+encodeURIComponent(sharedPage),'sharer','toolbar=1,status=1');
	
	}else if (siteName == "friendfeed"){
			window.open('http://friendfeed.com/?url='+encodeURIComponent(sharedPage),'sharer','toolbar=1,status=1');
	}
	else if (siteName == "email"){
			light_window('/islem.php?ne=arkadasina_oner&otel_id='+id);
	}	
}

function at_kontrol()
{
	if ($('email_adresi1').value.substr($('email_adresi1').value.length-1,1) == '@'){$('email_adresi2').focus();$('email_adresi1').value = $('email_adresi1').value.substr(0,$('email_adresi1').value.length-1);}
}

function taksit_tablosu_goster(id,fiyat)
{
	if ($('tablo'+id).style.display=='none')
	{	
		getRequest('/islem.php?ne=taksit_tablosu_goster&id='+id+'&fiyat='+fiyat,'','GET');
	}
	else
	{
		$('tablo'+id).style.display = 'none';
	}
}
