﻿// JScript File

var	ie=navigator.appName=="Microsoft Internet Explorer";
var	nn=navigator.appName=="Netscape";

function onbtnMouseOver(btn)
{
	if(btn.getElementsByTagName("IMG")[0].src.indexOf("Disabled") > -1)
		return;
		
	btn.className = "buttonItemHot";
}
function onbtnMouseOut(btn)
{
	btn.className = "buttonItem"; 
}

function gonder(uzanti)
{
	if (uzanti == "") return;
	window.open("Upload.aspx" + uzanti,"_blank","resizable=no,width=340,height=15")
}

function tesisResimGoster(uzanti)
{
	if (uzanti == "") return;
	window.open("ResimGoster.aspx?url=" + uzanti,"_blank","resizable=no,width=620,height=425")
}

function popUpAc(pUrl,pWidth,pHeight)
{
	window.open(pUrl,"_blank","resizable=no,scrollbars=yes,width=" + pWidth + ",height=" + pHeight + ",top=" + (screen.availHeight - pHeight) / 2 + ",left=" + (screen.availWidth - pWidth) / 2)
}

function eklemeAciklamasi() {

	var curdate = new Date()
		
	if (document.all('fvRezervasyon$ACIKLAMATextBox').value=='') {
		document.all('fvRezervasyon$ACIKLAMATextBox').value = curdate.toLocaleString() + " - " + document.all('txtSonKullaniciAdi').value + ' - ' + document.all('txtEklemeTempAciklama').value;
	}else{
		document.all('fvRezervasyon$ACIKLAMATextBox').value =document.all('fvRezervasyon$ACIKLAMATextBox').value + '\n' + curdate.toLocaleString() + " - " + document.all('txtSonKullaniciAdi').value + ' - ' + document.all('txtEklemeTempAciklama').value;
	}
	
}

function degistirmeAciklamasi() {

	var curdate = new Date()
	
	if (document.all('fvRezervasyon$ACIKLAMATextBox').value=='') {
		document.all('fvRezervasyon$ACIKLAMATextBox').value = curdate.toLocaleString() + " - " + document.all('txtSonKullaniciAdi').value + ' - ' + document.all('txtDegistirmeTempAciklama').value;
	}else{
		document.all('fvRezervasyon$ACIKLAMATextBox').value =document.all('fvRezervasyon$ACIKLAMATextBox').value + '\n' + curdate.toLocaleString() + " - " + document.all('txtSonKullaniciAdi').value + ' - ' + document.all('txtDegistirmeTempAciklama').value;
	}
			
}

function turSehirleri() {

	if (document.all(document.all('txtUniqueId').value + '$txtSehirler').value=='') {
		document.all(document.all('txtUniqueId').value + '$txtSehirler').value = document.all(document.all('txtUniqueId').value + '$ddlSehir').value + ' (' + document.all(document.all('txtUniqueId').value + '$ddlGun').value + ')'
	}else{
		document.all(document.all('txtUniqueId').value + '$txtSehirler').value += " - " + document.all(document.all('txtUniqueId').value + '$ddlSehir').value + ' (' + document.all(document.all('txtUniqueId').value + '$ddlGun').value + ')'
	}
			
}

function turSehirleriniSil() {

	document.all(document.all('txtUniqueId').value + '$txtSehirler').value = ''
			
}


function turTarihSec() {

    if (document.all('fvTurRezervasyon$txtTurId')!=null){
        if (document.all('fvTurRezervasyon$txtTurId').value=='') {
		    Alert('Bir Tur Seçiniz...');
	    }else{
		    window.open('TurTarih.aspx?mod=secme&TurAdi=' + document.all('fvTurRezervasyon_lblTurAdi').innerText + '&TurId=' + document.all('fvTurRezervasyon$txtTurId').value ,"_blank","resizable=no,width=800,height=600,scrollbars=yes");
	    }
    }
}

function turToplamHesapla() {

var x,y
	
	if (document.all('fvTurRezervasyon_txtFiyat') == null) return;
	
	x = document.all('fvTurRezervasyon_txtFiyat').value;

	y = document.all('fvTurRezervasyon_txtIndirim').value;
	
	//x = x.replace(/\./g,'');
	//x = x.replace(/\,/g,'.');
	
	//y = y.replace(/\./g,'');
	//y = y.replace(/\,/g,'.');

	if (parseFloat(x) < parseFloat(y)){
		
			alert('İndirim fiyattan büyük olamaz.');
			document.all('fvTurRezervasyon_lblToplam').innerText=document.all('fvTurRezervasyon_txtFiyat').value;
			document.all('fvTurRezervasyon_txtIndirim').value=0
		
	}else{
		document.all('fvTurRezervasyon_lblToplam').innerText = parseFloat(x) - parseFloat(y)
	}

}

function turYeniToplamHesapla() {

var x,y
	
	if (document.all('fvTurRezervasyon_txtFiyat') == null) return;
	
	x = document.all('fvTurRezervasyon_txtYeniFiyat').value;

	y = document.all('fvTurRezervasyon_txtYeniIndirim').value;

	//x = x.replace(/\./g,'');
	//x = x.replace(/\,/g,'.');
	
	//y = y.replace(/\./g,'');
	//y = y.replace(/\,/g,'.');

	if (parseFloat(x) < parseFloat(y)){
		
			alert('İndirim fiyattan büyük olamaz.');
			document.all('fvTurRezervasyon_lblYeniToplam').innerText=document.all('fvTurRezervasyon_txtYeniFiyat').value;
			document.all('fvTurRezervasyon_txtYeniIndirim').value=0
		
	}else{
		document.all('fvTurRezervasyon_lblYeniToplam').innerText = parseFloat(x) - parseFloat(y)
	}

}

function tesisToplamHesapla() {

	var x,y,toplam
	
	if (document.all('fvTesisRezervasyon_txtFiyat') == null) return;
	document.all('lblHata').innerText=''
	x = document.all('fvTesisRezervasyon_txtFiyat').value;
		
	y = document.all('fvTesisRezervasyon_txtIndirim').value;

	//x = x.replace(/\./g,'');
	//x = x.replace(/\,/g,'.');
	
	//y = y.replace(/\./g,'');
	//y = y.replace(/\,/g,'.');

	
	if (parseFloat(x) < parseFloat(y)){
		
			document.all('lblHata').innerText='İndirim fiyattan büyük olamaz.';
			document.all('fvTesisRezervasyon_lblToplam').innerText=parseFloat(document.all('fvTesisRezervasyon_txtFiyat').value) + parseFloat(document.all('fvTesisRezervasyon_txtULASIM_TUTARI').value) - parseFloat(document.all('fvTesisRezervasyon_txtULASIM_INDIRIM_TUTARI').value) - parseFloat(document.all('fvTesisRezervasyon_txtOZEL_INDIRIM').value);
			document.all('fvTesisRezervasyon_txtIndirim').value=0;
			document.all('fvTesisRezervasyon_txtIndirim').innerText='0';
			alert('İndirim fiyattan büyük olamaz.');
		
	}else{
	    toplam = parseFloat(x) - parseFloat(y) + parseFloat(document.all('fvTesisRezervasyon_txtULASIM_TUTARI').value) - parseFloat(document.all('fvTesisRezervasyon_txtULASIM_INDIRIM_TUTARI').value) - parseFloat(document.all('fvTesisRezervasyon_txtOZEL_INDIRIM').value);
	    document.all('fvTesisRezervasyon_lblToplam').value = toplam;
	    document.all('fvTesisRezervasyon_lblToplam').innerText = toplam;
		
	}
}

function tesisYeniToplamHesapla() {

	var x,y
	
	if (document.all('fvTesisRezervasyon_txtFiyat') == null) return;
	
	x = document.all('fvTesisRezervasyon_txtYeniFiyat').value;
	
	y = document.all('fvTesisRezervasyon_txtYeniIndirim').value;
	
	//x = x.replace(/\./g,'');
	//x = x.replace(/\,/g,'.');
	
	//y = y.replace(/\./g,'');
	//y = y.replace(/\,/g,'.');

	if (parseFloat(x) < parseFloat(y)){
		
			alert('İndirim fiyattan büyük olamaz.');
			document.all('fvTesisRezervasyon_lblYeniToplam').innerText=parseFloat(document.all('fvTesisRezervasyon_txtYeniFiyat').value) + parseFloat(document.all('fvTesisRezervasyon_txtULASIM_TUTARI').value) - parseFloat(document.all('fvTesisRezervasyon_txtULASIM_INDIRIM_TUTARI').value) - parseFloat(document.all('fvTesisRezervasyon_txtOZEL_INDIRIM').value);
			document.all('fvTesisRezervasyon_txtYeniIndirim').value=0
		
	}else{
		document.all('fvTesisRezervasyon_lblYeniToplam').innerText = parseFloat(x) - parseFloat(y) + parseFloat(document.all('fvTesisRezervasyon_txtULASIM_TUTARI').value) - parseFloat(document.all('fvTesisRezervasyon_txtULASIM_INDIRIM_TUTARI').value) - parseFloat(document.all('fvTesisRezervasyon_txtOZEL_INDIRIM').value);
	}
}



function VisibilityDegistir(kontrol) {
    if (document.all(kontrol)!=null){
	    if (document.all(kontrol).style.display=='none'){
	        document.all(kontrol).style.display='';
	    }else if (document.all(kontrol).style.display!='none'){
	        document.all(kontrol).style.display='none';
	    }

        if (document.all(kontrol + "Visibility")!=null){
            
            if (document.all(kontrol).style.display=='none'){
                document.all(kontrol + "Visibility").value='none'
            }else{
                document.all(kontrol + "Visibility").value='visible'
            }
            
        }
    }
	
}

function SanalPosKontrol(ddlPos)
{
    var posvalue = "";
    var bRezervasyonSatisMusteriOdeme = true;
    var oObj = document.getElementById("fvMusteriOdeme_txtKartNo1");
    
    if (oObj == null) bRezervasyonSatisMusteriOdeme = false;
    
    if (ddlPos == null) return;
    
    for(i=0;i < ddlPos.options.length; i++)
    {
        var txt = ddlPos.options[i].text;
        if (txt.indexOf("Sanal Pos") != -1 && ddlPos.selectedIndex == i)
        {
            posvalue =  ddlPos.options[i].value;
            break;
        }
    }
      
    if (ddlPos.value == posvalue)
    {
        document.getElementById("fvMusteriOdeme_txtKartNo1").style.display="";
        document.getElementById("fvMusteriOdeme_txtKartNo2").style.display="";
        document.getElementById("fvMusteriOdeme_txtKartNo3").style.display="";
        document.getElementById("trKrediKarti").style.display="";
    }
    else {
        document.getElementById("fvMusteriOdeme_txtKartNo1").style.display="none";
        document.getElementById("fvMusteriOdeme_txtKartNo2").style.display="none";
        document.getElementById("fvMusteriOdeme_txtKartNo3").style.display="none";
        document.getElementById("trKrediKarti").style.display="none";
    }
    if (document.getElementById("fvMusteriOdeme_ddlOdemeSekli").selectedIndex <=1){
        document.getElementById("trKrediKarti").style.display="none";
        document.getElementById("tdKartNo").style.display="none";
        document.getElementById("tdKartNoText").style.display="none";
//	    document.getElementById("tdOnay").style.display="none";
//	    document.getElementById("tdOnayText").style.display="none";
    }
}

//AutoAdvance
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len,evt) {
	if (evt == null) return;
	if (evt.keyCode == null) return;	
	var o;
	if(input.value.length == 0 && evt.keyCode == 8)
	{
		o = input.form[(getIndex(input)-1)];
		o.focus();	
		o.select();
		return;
	} 
	if(input.value.length >= len && evt.keyCode != 8 && evt.keyCode != 46)
		input.form[(getIndex(input)+1)].focus();	

}

function getIndex(input) {
	var index = -1, i = 0;
	while (i < input.form.length && index == -1)
	if (input.form[i] == input)index = i;
	else i++;
	return index;
}
//AutoAdvance

//oda 
var Odalar = {}
Odalar.OdaGetir = function(odaid,OdaTipi,YetiskinSayisi,EkYatakSayisi,IndirimliCocuk,UcretsizCocuk)
{
	var oda = eval("Odalar.Oda" + odaid);
	if (oda == undefined)
	{
		var str = "Odalar.Oda" + odaid + ' = { "OdaTipi":'+ OdaTipi + ', "YetiskinSayisi":' + YetiskinSayisi + ', "EkYatakSayisi":' + EkYatakSayisi + ', "IndirimliCocuk":' + IndirimliCocuk + ', "UcretsizCocuk":'+ UcretsizCocuk + '}';
		//alert(str)
		oda = eval(str);
	}
	return oda;
}
function OdalariAyarla()
{
    var OdaTipi,YetiskinSayisi,EkYatakSayisi,IndirimliCocuk,UcretsizCocuk
    var OdaSayisi
    var pnlOda
    if (document.getElementById("fvTesisRezervasyon")!=null){
        OdaSayisi=document.getElementById("fvTesisRezervasyon_ddlOdaSayisi").value;
        pnlOda=document.getElementById("fvTesisRezervasyon_pnlOda");
        if (pnlOda.document.getElementById("fvTesisRezervasyon_ucOda1_ddlOdaTipi") == null)
        {
			alert("Oda bilgileri hatalıdır. Lütfen tekrar deneyiniz.");
			return;
		}
        for (var i=1;i<=OdaSayisi;i++){
            OdaTipi=pnlOda.document.getElementById("fvTesisRezervasyon_ucOda" + i + "_ddlOdaTipi").value;
            YetiskinSayisi=pnlOda.document.getElementById("fvTesisRezervasyon_ucOda" + i + "_txtYetiskinSayisi").value;
            EkYatakSayisi=pnlOda.document.getElementById("fvTesisRezervasyon_ucOda" + i + "_txtEkYatak").value;
            IndirimliCocuk=pnlOda.document.getElementById("fvTesisRezervasyon_ucOda" + i + "_txtIndirimliCocuk").value;
            UcretsizCocuk=pnlOda.document.getElementById("fvTesisRezervasyon_ucOda" + i + "_txtUcretsizCocuk").value;
            Odalar.OdaGetir(i,OdaTipi,YetiskinSayisi,EkYatakSayisi,IndirimliCocuk,UcretsizCocuk)

        }
    }else if(document.getElementById("fvTurRezervasyon")!=null){
        OdaSayisi=document.getElementById("fvTurRezervasyon_ddlOdaSayisi").value;
        pnlOda=document.getElementById("fvTurRezervasyon_pnlOda");
        if (pnlOda.document.getElementById("fvTurRezervasyon_ucOda1_ddlOdaTipi") == null)
        {
			alert("Oda bilgileri hatalıdır. Lütfen tekrar deneyiniz.");
			return;
		}        
        for (var i=1;i<=OdaSayisi;i++){
            OdaTipi=pnlOda.document.getElementById("fvTurRezervasyon_ucOda" + i + "_ddlOdaTipi").value;
            YetiskinSayisi=pnlOda.document.getElementById("fvTurRezervasyon_ucOda" + i + "_txtYetiskinSayisi").value;
            EkYatakSayisi=pnlOda.document.getElementById("fvTurRezervasyon_ucOda" + i + "_txtEkYatak").value;
            IndirimliCocuk=pnlOda.document.getElementById("fvTurRezervasyon_ucOda" + i + "_txtIndirimliCocuk").value;
            UcretsizCocuk=pnlOda.document.getElementById("fvTurRezervasyon_ucOda" + i + "_txtUcretsizCocuk").value;
            Odalar.OdaGetir(i,OdaTipi,YetiskinSayisi,EkYatakSayisi,IndirimliCocuk,UcretsizCocuk)
        }

    }
    
    var xml = JSerialize(Odalar, "Odalar")
    document.getElementById("hdnOdalar").value = xml;
    //alert(document.getElementById("hdnOdalar").value);
}
function OdaVisibilityDegistir(){
    var pnlOda
    var ucOda
    if (document.getElementById("fvTesisRezervasyon")!=null){
        OdaSayisi=document.getElementById("fvTesisRezervasyon_ddlOdaSayisi").value;
        pnlOda=document.getElementById("fvTesisRezervasyon_pnlOda");
        for (var i=1;i<=4;i++){
            if (i<=OdaSayisi){
                ucOda = pnlOda.document.getElementById("Oda"+ i)
                if (ucOda==null) return;
                ucOda.style.display=""
            }else{
                ucOda = pnlOda.document.getElementById("Oda"+ i)
                if (ucOda==null) return;
                ucOda.style.display="none"            
            }           
        }
    }else if(document.getElementById("fvTurRezervasyon")!=null){
        OdaSayisi=document.getElementById("fvTurRezervasyon_ddlOdaSayisi").value;
        pnlOda=document.getElementById("fvTurRezervasyon_pnlOda");
        for (var i=1;i<=4;i++){
            if (i<=OdaSayisi){
                ucOda = pnlOda.document.getElementById("Oda"+ i)
                if (ucOda==null) return;
                ucOda.style.display=""
            }else{
                ucOda = pnlOda.document.getElementById("Oda"+ i)
                if (ucOda==null) return;
                ucOda.style.display="none"            
            }           
        }
    }
}
//oda

function TextBoxlaraDegerGir(txtKaynak,txtHedef) {
    if (txtKaynak.value!=''){    
    	if (txtHedef.value=='') {
		    txtHedef.value = txtKaynak.value + ';'
	    }else{
		    txtHedef.value += txtKaynak.value + ';'
	    }
	}
	txtKaynak.value=''			
}

function CerezOku(name){
    var cookieValue = "";
    var search = name + "=";
    if(document.cookie.length > 0){
        offset = document.cookie.indexOf(search);
        if (offset != -1){
            offset += search.length;
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            cookieValue = unescape(document.cookie.substring(offset, end))
        }
    }
    return cookieValue;
}

var URL = location.href
function QueryString(Deger) {
  if(Deger!=null) {
    var regEx = new RegExp("(\\?|&)("+Deger+"=)(.*?)(&|$|#)","i")
    var exec = regEx.exec(URL)
    var Sonuc = RegExp.$3
  } else {
    var regEx = new RegExp("(\\?)(.*?)($)","i")
    var exec = regEx.exec(URL)
    var Sonuc = RegExp.$2
  }

  return(Sonuc)
}

function MusteriSifreVisibilityDegistir(){
    var trSifre=document.getElementById("trSifre")
    var sCooke=CerezOku("KullaniciId")
    var sQueryString=QueryString("No")
    if (trSifre==null) return;

    if (sQueryString==sCooke){
        trSifre.style.display=""
    }else{
        trSifre.style.display="none"
    }
}
function PasswordGenerate(){
	    var sPattern = "LLL9999UUU";
	    var nMin= 6;
	    var nMax =10
	    var sParola=document.getElementById("fvMusteri_txtGercekParola")
	    var pgen;
	    if (sParola==null) return;
	    pgen =  new PasswordGenerator(sPattern, nMin, nMax);
	    sParola.value=pgen.Password(0)
	    return;
    }

function dateChooser_OnTextChanged(oDateChooser, dummy, oEvent){
	if((oDateChooser.getText() == '') || (oDateChooser.getText() == ' '))
	{
		oDateChooser.setValue(null);
	}
}

function divKapat(divid){

document.getElementById(divid).style.display = "none";

}

function divAcKapa(divid){

var pnlDiv = document.getElementById(divid);

	if (pnlDiv.style.display == "none"){
		pnlDiv.style.display = "";
	}else {
		pnlDiv.style.display = "none";
	}
	

}

 function scrollTop()
{
    window.document.body.scrollTop = 0;
    window.document.documentElement.scrollTop = 0;
}
            
function addbookmark(){
var bookmarkurl= window.location;
var bookmarktitle= document.title;
window.external.AddFavorite(bookmarkurl,bookmarktitle);
}



//*******************************Karşılaştır için gerekli fonksiyonlar******************************************


//En fazla 4 checkbox ın işaretli olduğu durumlarda
// diğer tüm checkboxları kilitler
// 4 den az checkbox işaretli olduğu durumlarda kilitli olanları tekrar aktif eder
 function getgridcheckboxes(t)
  {
		var thetable;

			if (CompareType == "Tesis")
			{thetable = document.getElementById('ctl00_cphContent1_plOtelListe_gvOteller');}
			else if (CompareType == "Tur")
			{thetable = document.getElementById('ctl00_cphContent1_plTurListe_gvTurlar');}	
			else if  (CompareType == "Bolge")  
	   		{thetable = document.getElementById('ctl00_cphContent1_gvOteller2');}	
			else if (CompareType == "Yurtdisi")
			{thetable = document.getElementById('ctl00_cphContent1_gvOteller')}
		
		if (thetable != null)
		{
		var inputs = thetable.getElementsByTagName('input');
			for (var i=0; i<inputs.length; ++i)
			{ 
				if ('checkbox' == inputs[i].type.toLowerCase())
				{
					if (t != "clear")
					{
						if(inputs[i].checked==false)
						{
							inputs[i].disabled = 'disable';
							
						}
						
					}	
					else
					{
						if(inputs[i].checked==false)
						{
							inputs[i].disabled = '';
							
						}
					}
				} 
			}
		
		}
  }
   
   // Tüm Checkbox kutulularını seçili durumdan kaldırır
   function HepsiniTemizle()
   {
			var thetable;
			if (CompareType == "Tesis")
			{thetable = document.getElementById('ctl00_cphContent1_plOtelListe_gvOteller');}
			else if (CompareType == "Tur")
			{thetable = document.getElementById('ctl00_cphContent1_plTurListe_gvTurlar');}	
			else if  (CompareType == "Bolge")  
	   		{thetable = document.getElementById('ctl00_cphContent1_gvOteller2');}	
			else if (CompareType == "Yurtdisi")
			{thetable = document.getElementById('ctl00_cphContent1_gvOteller')}
			
			if (thetable != null)
			{
			var inputs = thetable.getElementsByTagName('input');
				for (var i=0; i<inputs.length; ++i)
				{ 
					if ('checkbox' == inputs[i].type.toLowerCase())
					{
						inputs[i].checked=false;
						inputs[i].disabled = '';
					}			
				}		
			}				
		 NavImg(); //Check işaretli olan gif leri temizler
		 Nav(0);
   }
   
   //Kaç tesis işaretli ise sayfa her yüklendiğinde 
   //kutucukların yanına "(1/4)" şeklide yazar
   function Nav(c)
   {
	var thetable;
	
			if (CompareType == "Tesis")
			{thetable = document.getElementById('ctl00_cphContent1_plOtelListe_gvOteller');}
			else if (CompareType == "Tur")
			{thetable = document.getElementById('ctl00_cphContent1_plTurListe_gvTurlar');}	
			else if  (CompareType == "Bolge")  
	   		{thetable = document.getElementById('ctl00_cphContent1_gvOteller2');}	
			else if (CompareType == "Yurtdisi")
			{thetable = document.getElementById('ctl00_cphContent1_gvOteller')}
	
	if (thetable != null)
	{
		var labels = thetable.getElementsByTagName('span');
			for (var i=0; i<labels.length; ++i)
			{ 
				if (labels[i].id.indexOf("lblCompareNav") > -1 )
				{
					if (c!=0) {labels[i].innerHTML = "( " + c.toString() + "/" + validCount.toString() +" )" ;}
					else{labels[i].innerHTML = "";}
				} 
			}

		}   
		
   }
   
   
   
  //Tüm check image ları temizler
function NavImg()
{
var thetable;
			if (CompareType == "Tesis")
			{thetable = document.getElementById('ctl00_cphContent1_plOtelListe_gvOteller');}
			else if (CompareType == "Tur")
			{thetable = document.getElementById('ctl00_cphContent1_plTurListe_gvTurlar');}	
			else if  (CompareType == "Bolge")  
	   		{thetable = document.getElementById('ctl00_cphContent1_gvOteller2');}	
			else if (CompareType == "Yurtdisi")
			{thetable = document.getElementById('ctl00_cphContent1_gvOteller')}
			
	if (thetable != null)
	{
		var imgs = thetable.getElementsByTagName('img');
			for (var i=0; i<imgs.length; ++i)
			{ 
				if (imgs[i].id.indexOf("imgCompare") > -1 )
					{
						imgs[i].src = "images/compare.gif";
					}
			} 
	}

}   
		

   var CompareType;
   var ArrTesisID = new Array();
   var c=0;
   var urllink = "";
   var rowindex=0;
   var validCount;
//   var isChk;	   
// CheckBox onClick olayının tetiklendiği fonksiyondur
// işaretli checkbox Tesis ait id gönderir 
// fonksiyon bunu array içine atar ve karşılaştırma için sorgu oluşturur
   function CheckClicked(chk,Tesisid,img){
	var s=0;
		if (CompareType == "Tesis"){s = document.getElementById('ctl00_cphContent1_plOtelListe_hdSelCheckBoxCount').value;}
		else if (CompareType == "Tur") {s = document.getElementById('ctl00_cphContent1_plTurListe_hdSelCheckBoxCount').value;}
		else if (CompareType == "Yurtdisi") {s = document.getElementById('ctl00_cphContent1_hdSelCheckBoxCount').value;}

		c = parseInt(s);
		if (isNaN(c)){ c=0;}
    if (document.getElementById(chk).checked == true)
	{
		if ( c < validCount)
		{
		
			if (CompareType == "Tesis")
			{ 
			document.getElementById('ctl00_cphContent1_plOtelListe_hdComparePath').value = document.getElementById('ctl00_cphContent1_plOtelListe_hdComparePath').value + "_" + Tesisid.toString();
			}
		    if (CompareType == "Tur") { document.getElementById('ctl00_cphContent1_plTurListe_hdComparePath').value = document.getElementById('ctl00_cphContent1_plTurListe_hdComparePath').value + "*" + Tesisid.toString();}
		    
			 if (CompareType == "Yurtdisi") { document.getElementById('ctl00_cphContent1_hdComparePath').value = document.getElementById('ctl00_cphContent1_hdComparePath').value + "_" + Tesisid.toString();}
    
			 ++c;
			 
			document.getElementById(img).src = "images/compare-check.gif" 
		

			 Nav(c);
				if (c==validCount){getgridcheckboxes(); }
		}
		else
		{
			document.getElementById(chk).checked = false;
			if (CompareType=="Tur")
			{alert("En fazla 3 tur için karşılaştırma yapabilirsiniz."); }
			else{alert("En fazla 4 hotel için karşılaştırma yapabilirsiniz.");}
			getgridcheckboxes('disable');
	    }
	}	
	else
	{
		if (c==0){ return false;}
		--c;
		if (CompareType == "Tesis")
		{ 
			ArrTesisID = document.getElementById('ctl00_cphContent1_plOtelListe_hdComparePath').value.split("_");
			for(var i =0;i<ArrTesisID.length ;++i)
			{
				if (ArrTesisID[i] == Tesisid)
				 { ArrTesisID.splice(i,1); }
			}
			document.getElementById('ctl00_cphContent1_plOtelListe_hdComparePath').value = ArrTesisID.join("_");
		}
		
		if (CompareType == "Yurtdisi")
		{ 
			ArrTesisID = document.getElementById('ctl00_cphContent1_hdComparePath').value.split("_");
			for(var i =0;i<ArrTesisID.length ;++i)
			{
				if (ArrTesisID[i] == Tesisid)
				 { ArrTesisID.splice(i,1); }
			}
			document.getElementById('ctl00_cphContent1_hdComparePath').value = ArrTesisID.join("_");
		}
		
		if (CompareType == "Tur")	
		{
			ArrTesisID = document.getElementById('ctl00_cphContent1_plTurListe_hdComparePath').value.split("*");
			for(var i =0;i<ArrTesisID.length ;++i)
			{
				if (ArrTesisID[i] == Tesisid)
				 { ArrTesisID.splice(i,1); }
			}
			document.getElementById('ctl00_cphContent1_plTurListe_hdComparePath').value = ArrTesisID.join("*");
		}
		document.getElementById(img).src = "images/compare.gif" 
		Nav(c);
		if (c < validCount){getgridcheckboxes('clear');}
	}
		if (CompareType == "Tesis"){document.getElementById('ctl00_cphContent1_plOtelListe_hdSelCheckBoxCount').value = c.toString();}
		else if (CompareType == "Tur"){document.getElementById('ctl00_cphContent1_plTurListe_hdSelCheckBoxCount').value = c.toString();}			
		else if (CompareType == "Yurtdisi"){document.getElementById('ctl00_cphContent1_hdSelCheckBoxCount').value = c.toString();}			

}

// Karşılaştır buttonun Click olayının tetiklendiği fonksiyondır
// Tüm Checkbox ları temizler
// Sayfayı TesisCompare.aspx e yönlendirir
function GoToCompareURL(EkLink)
	  {
			if (c >1)
			{
					if 	(CompareType == "Tesis")		
					{
						ArrTesisID = document.getElementById('ctl00_cphContent1_plOtelListe_hdComparePath').value.split("_");
						urllink="TesisCompare.aspx?TesisC=" + c.toString();
						for (rowindex = 1 ; rowindex < c+1;++rowindex)
						{				
							if(ArrTesisID[rowindex] != null)
							{
							urllink = urllink + "&Tesis" +(rowindex-1).toString() + "=" + 	ArrTesisID[rowindex].toString()
							 }
						}
					}	
					else if 	(CompareType == "Tur")		
					{
					   ArrTesisID = document.getElementById('ctl00_cphContent1_plTurListe_hdComparePath').value.split("*");
					   urllink="TurCompare.aspx?TurC=" + c.toString();
						for (rowindex = 1 ; rowindex < c+1;++rowindex)
						 {				
							if(ArrTesisID[rowindex] != null)
							{
							urllink = urllink + "&Tur" +(rowindex-1).toString() + "=" + ArrTesisID[rowindex].toString()
							 }
						}
					 }	
					 else if 	(CompareType == "Yurtdisi")
					{
						ArrTesisID = document.getElementById('ctl00_cphContent1_hdComparePath').value.split("_");
						urllink="HotelCompare.aspx?TesisC=" + c.toString();
						for (rowindex = 1 ; rowindex < c+1;++rowindex)
						{				
							if(ArrTesisID[rowindex] != null)
							{
							urllink = urllink + "&Tesis" +(rowindex-1).toString() + "=" + 	ArrTesisID[rowindex].toString()
							 }
						}
					}	
			
					SayacSifirla();
					document.location.href = urllink+EkLink;
			}
			else
			{
					switch (CompareType) {
					case "Tesis":	alert("Lütfen en az 2 otel seçiniz");	break;
					case "Tur"	  : alert("Lütfen en az 2 tur seçiniz");	break;
					case "Bolge" : alert("Lütfen en az 2 otel seçiniz");break;
					}
			}
			
        }
 

// Toplam kaç checkbox ın işaretli olduğu değişkeni ve saklandığı
// hiddenfield alanını sıfırlar        
function SayacSifirla()
{
var hdSelCheckBoxCount;
		if (CompareType == "Tesis")
		{
			if (document.getElementById('ctl00_cphContent1_plOtelListe_hdSelCheckBoxCount') != null)
				{document.getElementById('ctl00_cphContent1_plOtelListe_hdSelCheckBoxCount').value="0";}
			if (document.getElementById('ctl00_cphContent1_plOtelListe_hdComparePath') != null)
				{document.getElementById('ctl00_cphContent1_plOtelListe_hdComparePath').value="";}
		}
		else if (CompareType == "Tur")
		{
			if (document.getElementById('ctl00_cphContent1_plTurListe_hdSelCheckBoxCount')!=null)
			{document.getElementById('ctl00_cphContent1_plTurListe_hdSelCheckBoxCount').value="0";}
			if (document.getElementById('ctl00_cphContent1_plTurListe_hdComparePath') != null)
			{document.getElementById('ctl00_cphContent1_plTurListe_hdComparePath').value="";}

		}
		else if (CompareType == "Yurtdisi")
		{
			if (document.getElementById('ctl00_cphContent1_hdSelCheckBoxCount')!=null)
			{document.getElementById('ctl00_cphContent1_hdSelCheckBoxCount').value="0";}
			if (document.getElementById('ctl00_cphContent1_hdComparePath') != null)
			{document.getElementById('ctl00_cphContent1_hdComparePath').value="";}

		}
		
	c=0;
	HepsiniTemizle();
	
}
//*******************************Karşılaştır Fonksiyonları Sonu******************************************


//*******************************Günün Kampanyaları Kontrolüne ait Script*******************************
		function MrqSpeedDown()
		{
			ctl00_GununKampanyasi_mqList.direction="Down"
			ctl00_GununKampanyasi_mqList.scrollAmount=15
		}
		function MrqSlowDown()
		{
			ctl00_GununKampanyasi_mqList.direction="Up"
			ctl00_GununKampanyasi_mqList.scrollAmount=2
		}
		
		function MrqSpeedUp()
		{
			ctl00_GununKampanyasi_mqList.scrollAmount=15
		}
		
		function MrqSlowUp()
		{
			ctl00_GununKampanyasi_mqList.scrollAmount=2
		}
		function MrqStopit()
		{
			ctl00_GununKampanyasi_mqList.scrollAmount=0
		}
		function MrqScrollit()
		{
			ctl00_GununKampanyasi_mqList.scrollAmount=2
		}
//**************************************************************************************************************
		var BankaSayisi_0;
		function bankatrOver(index)
				{
					for (var i=0;i<=11;i++)
					{
						var tr = document.getElementById(index.toString() + i.toString()); 
						//tr.style.border = "solid 1px Navy";
						tr.style.color = "#FF0000";
						tr.style.fontWeight="bold";
					}
				}
		
		function bankatrOut(index)
		{
			for (var i=0;i<=11;i++)
			{
				var tr = document.getElementById(index.toString() + i.toString()); 
//				tr.style.border = "solid 1px WhiteSmoke";
					tr.style.color = "#000000";
					tr.style.fontWeight="";
			}
		}
		
			function trOver(index)
		{
			for (var i=1;i<=BankaSayisi_0;i++)
			{
				var tr = document.getElementById(i.toString() + index.toString()); 
//				tr.style.border = "solid 1px Navy";
				if (tr != null)
				{
				tr.style.color = "#FF0000";
				tr.style.fontWeight="bold"
				}
			}
		}
		
		function trOut(index)
		{
			for (var i=1;i<=BankaSayisi_0;i++)
			{
				var tr = document.getElementById(i.toString() + index.toString());
//				tr.style.border = "solid 1px Whitesmoke";
				if (tr != null)
				{
				tr.style.color = "#000000";
				tr.style.fontWeight="";
				}
			}
		}
		
	//*******************************************************************ToolTips************************************************************************************************
	
	
var tooltipObj="";
function toolTip(text,me,vis) {
 if (vis=='visible')
 {
	document.getElementById('toolTipBox').style.width="230px"
	document.getElementById('toolTipBox').style.height="125px"
 } 
  tooltipObj=me;
  document.getElementById('ToolTipTextArea').innerHTML=text;
  document.getElementById('toolTipBox').style.visibility= vis
  window.onscroll=PosBul;
  tooltipObj.onmousemove=PosBul;
  tooltipObj.onmouseover=PosBul;
}


function PosBul() {
 if (document.getElementById('toolTipBox').style.visibility == "visible")
 {
  var e = arguments[0]?arguments[0]:event;
  var x= e.clientX;
  var y= e.clientY;
  diffX=15;
  diffY=0;
  document.getElementById('toolTipBox').style.top  = y-2+diffY+document.body.scrollTop + "px";
  document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft + "px";
//  tooltipObj.onmouseout=Gizle;
 }
}
function Gizle() {
  document.getElementById('toolTipBox').style.display="none";
}
	//*****************************************************************************************************************************************************************************

    function OpenNewBrowser(sUrl,windowID){
        window.open(sUrl,windowID,'width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
        }
   function CloseAndGoToURL(sUrl)   
        {   
           window.opener.location.href = sUrl;
           window.close();
        } 
        
   function CloseAndRefresh() 
        {   
             window.close(); 
            //GetRadWindow().BrowserWindow.ReloadWindow(null);   
            window.opener.reload();
        }   

function DateAdd(interval,number,dateValue) {
	if (dateValue == "") return null;
	if (dateValue == null) return null;
	
	var millisecond=1;
	var second=millisecond*1000;
	var minute=second*60;
	var hour=minute*60;
	var day=hour*24;
	var year=day*365;

	var newDate;
	var dVal=dateValue.valueOf();
	switch(interval) {
		case "ms": newDate=new Date(dVal+millisecond*number); break;
		case "s": newDate=new Date(dVal+second*number); break;
		case "mi": newDate=new Date(dVal+minute*number); break;
		case "h": newDate=new Date(dVal+hour*number); break;
		case "d": newDate=new Date(dVal+day*number); break;
		case "y": newDate=new Date(dVal+year*number); break;
	}
	
	return newDate;
}

function CDate(dateString)
{
	//This function return a date object after accepting 
	//a date string
	if (dateString == '') return null;
	if (dateString == null) return null;
		
	var dateSeperator = ' ';
	if (dateString.indexOf('.') > 0) dateSeperator = '.';
	if (dateString.indexOf('/') > 0) dateSeperator = '/';
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDay,cMonth,cYear;

	//extract day portion
	curPos=dateString.indexOf(sepChar);
	cDay=dateString.substring(0,curPos);
	//extract month portion				
	endPos=dateString.indexOf(sepChar,curPos+1);			
	cMonth=dateString.substring(curPos+1,endPos);

	//extract year portion				
	curPos=endPos;
	endPos=curPos+5;			
	cYear=curValue.substring(curPos+1,endPos);
	
	//Create Date Object
	dtObject=new Date(cYear,cMonth-1,cDay);	
	return dtObject;
}	

var sDecimalSeparator = ",";
var sDigitSeparator = ".";
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
	if (isNaN(parseInt(bolCommas))) bolCommas = true;	
	if (num=="") return "0";
	if (isNaN(num)==true) num = UnFormatNumber(num);
	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	var iStart = tmpNumStr.indexOf(".");
	if (iStart > 0){
	    tmpNumStr = tmpNumStr.replace(".",sDecimalSeparator);
	}
	else
	{
	     tmpNumStr = tmpNumStr + Math.pow(10,decimalNum).toString().replace("1",".");
	     tmpNumStr = tmpNumStr.replace(".",sDecimalSeparator);
	  }
	
	if (bolCommas && (num >= 1000 || num <= -1000)) {	
		if (iStart < 0)
		{
			iStart = tmpNumStr.length;
		}
		
		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + sDigitSeparator + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}

function UnFormatNumber(num)
{
	var tmpNumStr = "";
	if (num=="") return "0";
	tmpNumStr = new String(num);
	tmpNumStr = tmpNumStr.replace(sDigitSeparator,"");
	tmpNumStr = tmpNumStr.replace(sDecimalSeparator,".");
}

var sDateSeperator = '.';

function FormatDateTime(datetime, FormatType)
/*
	 FomatType takes the following values
		1 - General Date = Friday, October 30, 1998
		2 - Typical Date = 10/30/98
		3 - Standard Time = 6:31 PM
		4 - Military Time = 18:31
*/
{
	if (datetime == "") return "";
	if (datetime == null) return "";
	
	var strDate = new String(datetime);
	if (strDate.toUpperCase() == "NOW") {
		var myDate = new Date();
		strDate = String(myDate);
	} else {
		var myDate = new Date(datetime);
		strDate = String(myDate);
	}


	// Get the date variable parts
	var Day = new String(strDate.substring(0,3));
	if (Day == "Sun") Day = "Sunday";
	if (Day == "Mon") Day = "Monday";
	if (Day == "Tue") Day = "Tuesday";
	if (Day == "Wed") Day = "Wednesday";
	if (Day == "Thu") Day = "Thursday";
	if (Day == "Fri") Day = "Friday";
	if (Day == "Sat") Day = "Saturday";	
	
	var Month = new String(strDate.substring(4,7)), MonthNumber = 0;
	if (Month == "Jan") { Month = "January"; MonthNumber = 1; }
	if (Month == "Feb") { Month = "February"; MonthNumber = 2; }
	if (Month == "Mar") { Month = "March"; MonthNumber = 3; }
	if (Month == "Apr") { Month = "April"; MonthNumber = 4; }
	if (Month == "May") { Month = "May"; MonthNumber = 5; }
	if (Month == "Jun") { Month = "June"; MonthNumber = 6; }
	if (Month == "Jul") { Month = "July"; MonthNumber = 7; }
	if (Month == "Aug") { Month = "August"; MonthNumber = 8; }
	if (Month == "Sep") { Month = "September"; MonthNumber = 9; }
	if (Month == "Oct") { Month = "October"; MonthNumber = 10; }
	if (Month == "Nov") { Month = "November"; MonthNumber = 11; }
	if (Month == "Dec") { Month = "December"; MonthNumber = 12; }
	
	var curPos = 11;
	var MonthDay = new String(strDate.substring(8,10));
	if (MonthDay.charAt(1) == " ") {
		MonthDay = "0" + MonthDay.charAt(0);
		curPos--;
	}	
	
	var MilitaryTime = new String(strDate.substring(curPos,curPos + 5));
	
	var Year = new String(strDate.substring(strDate.length - 4, strDate.length));	
	if (Year == "ime)" || navigator.appName == "Netscape" || navigator.appName == "Opera") Year = new String(strDate.substring(11,11+4));
	// Format Type decision time!
	if (FormatType == 1)
		strDate =  MonthDay + " " + Month + " " + Year + ", " + Day;
	else if (FormatType == 2) {
		Month = "0" + MonthNumber;
		Month = Right(Month,2);
		strDate = MonthDay + sDateSeperator + Month + sDateSeperator + Year;

	}
	else if (FormatType == 3) {
		var AMPM = MilitaryTime.substring(0,2) >= 12 && MilitaryTime.substring(0,2) != "24" ? " PM" : " AM";
		if (MilitaryTime.substring(0,2) > 12)
			strDate = (MilitaryTime.substring(0,2) - 12) + ":" + MilitaryTime.substring(3,MilitaryTime.length) + AMPM;
		else {
			if (MilitaryTime.substring(0,2) < 10)
				strDate = MilitaryTime.substring(1,MilitaryTime.length) + AMPM;
			else
				strDate = MilitaryTime + AMPM;
		}
	}	
	else if (FormatType == 4)
		strDate = MilitaryTime;

	else if (FormatType == 5)
		sDateSeperator = "/";
		Month = "0" + MonthNumber;
		Month = Right(Month,2);
		strDate = MonthDay + sDateSeperator + Month + sDateSeperator + Year;

	
	return strDate;
}

// ------------------------------------------------------------------
//Date Functions
// ------------------------------------------------------------------

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//	 0 if they are the same
//   1 if date1 is greater than date2
//   2 if date2 is greater than date1 
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2) {
		return 1;
		}
	else if (d1 < d2) {
		return 2;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
	format=format+"";
	if (format == null) format = "";
	if (format == "") format = "dd.MM.yyyy";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
	if (val == null) val = "";
	if (format == null) format = "";
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	if (format == "") format = "dd.MM.yyyy";
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:true;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
	}

// ------------------------------------------------------------------
//Date Functions
// ------------------------------------------------------------------

function MyParseFloat(n)
{
	if (n=="") n = 0; 
	if (n=="NaN") n = 0; 
	if (n==0) return 0;
	n = n.toString().replace(".","");
	n = n.toString().replace(",",".");
	return parseFloat(n);
}

        function Right(str, n)
        /***
                IN: str - the string we are RIGHTing
                    n - the number of characters we want to return

                RETVAL: n characters from the right side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                   return "";
                else if (n > String(str).length)   // Invalid bound, return
                   return str;                     // entire string
                else { // Valid bound, return appropriate substring
                   var iLen = String(str).length;
                   return String(str).substring(iLen, iLen - n);
                }
        }
        
        
//onKeyDown event ine eklenir
	function ValidateNumber(e)
	{	
		var keynum;
		if(window.event) // IE
		{
			keynum = event.keyCode;
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which;
		}
		if((keynum >= 48 && keynum <= 57)||(keynum >= 96 && keynum <= 105)||(keynum == 8 ) ||(keynum == 9) || (keynum == 12) || (keynum == 27) || (keynum == 37) || (keynum == 39) || (keynum == 46) || (keynum == 110) || (keynum == 188) )
			{return true;}else{return false;}
	}

	function ClearHtmlTags()
    {
		for(var i=0;i<document.forms[0].elements.length;i++)
		{
			if (document.forms[0].elements[i].type == "text" || document.forms[0].elements[i].type == "textarea")
			{
				  if (document.forms[0].elements[i].value.indexOf("<") >= 0)
				  {
						do
						{
							  document.forms[0][i].value = document.forms[0].elements[i].value.replace("<","&lt;")
						}
						while (document.forms[0].elements[i].value.indexOf("<") >= 0);
				  }
		          
				  if (document.forms[0].elements[i].value.indexOf(">") >= 0)
				  {      
						do
						{
							  document.forms[0][i].value = document.forms[0].elements[i].value.replace(">","&gt;")
						}
						while (document.forms[0].elements[i].value.indexOf(">") >= 0);
				  }
				  
				  if (document.forms[0].elements[i].value.indexOf("script") >= 0)
				  {      
						do
						{
							  document.forms[0][i].value = document.forms[0].elements[i].value.replace("script","scr ipt")
						}
						while (document.forms[0].elements[i].value.indexOf("script") >= 0);
				  }
				  if (document.forms[0].elements[i].value.indexOf("'") >= 0)
				  {      
						do
						{
							  document.forms[0][i].value = document.forms[0].elements[i].value.replace("'","`")
						}
						while (document.forms[0].elements[i].value.indexOf("'") >= 0);
				  }
				  if (document.forms[0].elements[i].value.indexOf("¶") >= 0)
				  {      
						do
						{
							  document.forms[0][i].value = document.forms[0].elements[i].value.replace("¶"," ")
						}
						while (document.forms[0].elements[i].value.indexOf("¶") >= 0);
				  }
			}
		}
    }
    
	function ProperCase(s)
	{
	  return s.toLowerCase().replace(/^(.)|\s(.)/g, 
			  function($1) { return $1.toUpperCase(); });
		  //   return this.charAt(0).toUpperCase() + this.substring(1,this.length).toLowerCase();
	 
	} 
	//onKeydown ve onKeyup özelliklerine setlenmelidir.
	function TextCounter(otxt,olblcounter,maxchar) {
		if (otxt.value.length > maxchar)
		otxt.value = otxt.value.substring(0, maxchar);
		else
		olblcounter.innerText = maxchar - otxt.value.length;
	}

	function ClearScriptInjection(otxt)
	{
		otxt.value = otxt.value.replace(/<.*?>/g,'');
		otxt.value = otxt.value.replace('<','');
		otxt.value = otxt.value.replace('>','');
	}

	function StringBuilder(value)
	{
		this.strings = new Array("");
		this.append(value);
	}

	// Appends the given value to the end of this instance.
	StringBuilder.prototype.append = function ()
	{
		for(argumentsCounter=0;argumentsCounter<arguments.length;argumentsCounter++)
		{
			this.strings.push(arguments[argumentsCounter]);
		}    
	}

	// Clears the string buffer
	StringBuilder.prototype.clear = function ()
	{
		this.strings.length = 1;
	}

	// Converts this instance to a String.
	StringBuilder.prototype.toString = function ()
	{
		return this.strings.join("");
	}

	function DoubleClickControl(objName)
	{
		var obj = document.getElementById(objName);
		obj.style.display="none";
		//setTimeout("DoubleClickReset('" + objName + "')", 5 * 1000);
	}
	function DoubleClickReset(objName)
	{
		var obj = document.getElementById(objName);
		obj.disabled = "";
		obj.style.display="";
	}

	/*********************************nifty player************************************/

	var FlashHelper =
	{
		movieIsLoaded : function (theMovie)
		{
			if (typeof(theMovie) != "undefined") return theMovie.PercentLoaded() == 100;
			else return false;
	  },

		getMovie : function (movieName)
		{
  		if (navigator.appName.indexOf ("Microsoft") !=-1) return window[movieName];
		  else return document[movieName];
		}
	};

	function niftyplayer(name)
	{
		this.obj = FlashHelper.getMovie(name);

		if (!FlashHelper.movieIsLoaded(this.obj)) return;

		this.play = function () {
			this.obj.TCallLabel('/','play');
		};

		this.stop = function () {
			this.obj.TCallLabel('/','stop');
		};

		this.pause = function () {
			this.obj.TCallLabel('/','pause');
		};

		this.playToggle = function () {
			this.obj.TCallLabel('/','playToggle');
		};

		this.reset = function () {
			this.obj.TCallLabel('/','reset');
		};

		this.load = function (url) {
			this.obj.SetVariable('currentSong', url);
			this.obj.TCallLabel('/','load');
		};

		this.loadAndPlay = function (url) {
			this.load(url);
			this.play();
		};

		this.getState = function () {
			var ps = this.obj.GetVariable('playingState');
			var ls = this.obj.GetVariable('loadingState');

			if (ps == 'playing')
				if (ls == 'loaded') return ps;
				else return ls;

			if (ps == 'stopped')
				if (ls == 'empty') return ls;
				if (ls == 'error') return ls;
				else return ps;

			return ps;

		};

		this.getPlayingState = function () {
			return this.obj.GetVariable('playingState');
		};

		this.getLoadingState = function () {
			return this.obj.GetVariable('loadingState');
		};

		this.registerEvent = function (eventName, action) {
			this.obj.SetVariable(eventName, action);
		};

		return this;
	}
	
	function LockBrowserButtons()
	{
		if (ie) {
			document.attachEvent("onkeydown", onkeydown_handler);
		}
		if(nn){
			document.addEventListener("onkeydown",onkeydown_handler,false);
		}
		
		document.oncontextmenu=new Function("return false");	
	}
	
	function onkeydown_handler() {
		switch (event.keyCode) {
			case 87 : // W Close
			case 73 : // I Favorites
			case 53 : // '5'
			case 82 : // R  Refresh
				if (event.ctrlKey) 		{  // Ctrl-R
					event.returnValue = false;
					event.keyCode = 0; // required to disable stubborn key strokes
				}
				break; 
			case 78 : // N New Page
				if (event.ctrlKey) 		{  // Ctrl-N
					event.returnValue = false;
					event.keyCode = 0; // required to disable stubborn key strokes
				}
				break;
			case 69 : // 'E'
				if (event.ctrlKey) 		{  // Ctrl-E
				}
				break;
			case 116 : // 'F5'
				event.returnValue = false;
				event.keyCode = 0; // required to disable stubborn key strokes
				break; 
			case 122 : // 'F11
			case 114 :
				event.returnValue = false;
				event.keyCode = 0; // required to disable stubborn key strokes
				break; 
		}
	}


/********************************************************************************/
function IsEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
		return true;	}   
    else{   return false;   } 
}

// ------------------------------------------------------------------
// telefon numarasını ülke koduna ve giriş formatına göre kontrol eder
// ------------------------------------------------------------------
function TelefonDogruMu(telUlke, tel1, tel2){	  
    
    var nUlke = telUlke.value.length;
    var nTel1 = tel1.value.length;
    var nTel2 = tel2.value.length;

    if(nUlke == 0 || nTel1 == 0 || nTel2 == 0 ){                      
        if(tel2.value != ''){
            return false;
        }
        else{                 
		    return true;
		}
    }        
    else if(telUlke.value == '90'){	    	    
        if((nTel1 != 3 || nTel2 != 7) == true){	            	            
		    return false;
        }
    }
    else{
        var isUlke = (nUlke < 1 || nUlke > 4);	
        var isTel1 = (nTel1 < 1 || nTel1 > 3);	
        var isTel2 = (nTel2 < 5 || nTel2 > 8);	
        
        if((isUlke == false) && (isTel1 == false) && (isTel2 == false)){
            return true;
        }
        else{
            return false;
        }                            
    }	    	
    return true;
}

function AcKapat(id)
{
    if (document.getElementById(id).style.display  == "none")
    {
        document.getElementById(id).style.display  ="";
    }
    else
    {
        document.getElementById(id).style.display  = "none";
    }
}
