﻿
function toggleLayer(whichLayer)
{
if (document.getElementById)
{
    
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{

var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{

var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}
function  LongControl()
{
var check = new Boolean(false);
    if(document.getElementById('txtPass').value.length>6 ||document.getElementById('txtPass').value.length<4)
    {
    alert('Şifre en az 4 en fazla 6 karakter olmalıdır');
    check=false;
    }
    else
    {
    check=true;
    }
    return check;
}
function OpenCalendar(obj,ctrltxt)
{
     displayCalendar(document.getElementById(ctrltxt),'dd.mm.yyyy',obj);
}


function Hesapla()
{
    document.getElementById('txtPeriyodTutar').value = document.getElementById('txtToplamBagis').value /  document.getElementById('drpSure').value;
    var tl =  document.getElementById('txtPeriyodTutar').value;
    document.getElementById('txtPeriyodTutar').value  =  formatla(tl,2,true,false,true)+" YTL";
   
}
function ControlOto()
{
    if(document.form1.chkOto.checked)
    {
        document.getElementById('oto').style.visibility='visible';
    }
    else
    {
        document.getElementById('oto').style.visibility='hidden';
    }
}

function aylar(ay)
{
    if (ay == 0)
        return 'Aralık';
    else if (ay == 1)
        return 'Ocak';
    else if (ay == 2)
        return 'Şubat';
    else if (ay == 3)
        return 'Mart';
    else if (ay == 4)
        return 'Nisan';
    else if (ay == 5)
        return 'Mayıs';
    else if (ay == 6)
        return 'Haziran';
    else if (ay == 7)
        return 'Temmuz';
    else if (ay == 8)
        return 'Ağustos';
    else if (ay == 9)
        return 'Eylül';
    else if (ay == 10)
        return 'Ekim';
    else if (ay == 11)
        return 'Kasım';
}

function CreatePayTable()
{
var tarih = new Date()
var deger=document.form1.txtBasTar.value;

var gun =  tarih.getDate(deger.substring(0,2));
var ay =  tarih.getMonth(deger.substring(3,5));
var yil=  tarih.getFullYear(deger.substring(6,10));



    if(document.form1.txtToplamBagis.value=='')
    {
        alert('ilk önce toplam tutarı giriniz');
        return false;
    }
    var table='<table align=center bgcolor=#dcdcdc ><tr><td style=width:200px>Bağış Tarihi</td><td style=width: 200px>Bağış Miktarı</td></tr>';
    for(i=0;i<document.form1.drpSure.value;i++)
    {
        tarih.setMonth(tarih.getMonth()+1);
        table+='<tr><td bgcolor=#fffff  >'+tarih.getDate()+'.'+aylar(tarih.getMonth())+'.'+tarih.getFullYear()+'</td><td bgcolor=#fffff >'+document.form1.txtPeriyodTutar.value+'</td></tr>';
    }
    table+='</table>';
    hesapTable.innerHTML = table;
    
    
}
function CinsiyetControl(sender,args)
{
    if(document.getElementById('drpGender').value==0)
    {
        alert('Lütfen cinsiyet seçiniz');
        args.isValid=false;
        return false;
    }
}
function ValidateCVV(sender,args)
{
    if(args.Value.length !=3)
    {
        args.IsValid=false;
        return;
    }
}
function ValidateCreditCard(sender,args)
{
    if (args.Value.length != 16)
    {
        
        args.IsValid = false;
        return;
    }
   

    var rakamlar = '0123456789';

    for (i=0; i<args.Value.length; i++) 
    {
        if (rakamlar.indexOf(args.Value.charAt(i),0) == -1) 
        {
            alert('Sadece rakam girilebilir.');
            args.IsValid=false;
            return;
        }
    }

    var toplam=0;
    for (i=0; i < args.Value.length; i++) 
    {
        var numara=args.Value.charAt(i);
        if (i % 2 == 0) 
            numara=numara * 2;
        if (numara > 9) numara=numara - 9;
            toplam = toplam + parseInt(numara);
    }
    if(toplam % 10!=0)
    {
        alert('Kredi kart no geçersiz.');
        args.IsValid=false;
        return;
    } 

}
function tcKimlikValidate(sender,args)
{
     if (args.Value.length != 11)
    {
        alert('T.C. Kimlik numarası 11 haneli olmalıdır.');
        args.IsValid = false;
        return;
    }

    var rakamlar = '0123456789';

    for (i=0; i<args.Value.length; i++) 
    {
        if (rakamlar.indexOf(args.Value.charAt(i),0) == -1) 
        {
            alert('T.C. kimlik no sadece rakam olmalıdır.');
            args.IsValid=false;
            return;
        }
    }
}
   
 function ControlHisse()
    {
        var control = new Boolean(false);
        if(document.form1.drpHisseSec.options[document.form1.drpHisseSec.selectedIndex].value>document.form1.drpHisse.options[document.form1.drpHisse.selectedIndex].value)
        {
            alert('Hisse sayısından fazla hissedar olamaz');
            control= false; 
        }
        else
        {
            control=true;
        }
      return control;

    }
function Calculate()
{
if(document.getElementById('txtTutar').value=='')
{
    alert('Tutar Giriniz!');
    return false;
}
else
{
//        var tl=( document.getElementById('DropDownList1').options[document.getElementById('DropDownList1').selectedIndex].value*document.getElementById('txtTutar').value);
          var tl=document.form1.DropDownList1.options[document.form1.DropDownList1.selectedIndex].value*document.form1.txtTutar.value;
//        alert(document.form1.DropDownList1.options[document.form1.DropDownList1.selectedIndex].value+' '+document.form1.DropDownList1.options[document.form1.DropDownList1.selectedIndex].value);
         document.form1.txtYTL.value=formatla(tl,2,true,false,true)+" YTL";
}
}
function CalculateKumanya()
{
 if(QueryControl()=='Kumanya')
  {
    var tutar = document.form1.txtKumanya.value * (50/document.form1.drpKumanyaKur.value);
    document.form1.txtTutar.value=formatla(tutar,2,true,false,true);
    document.form1.txtTutar.value = document.form1.txtTutar.value.replace(',','');
    var tl = document.form1.txtKumanya.value * 50;
    document.form1.txtYTL.value = formatla(tl,2,true,false,true)+" YTL";
    }
}
function CalculateIftariye()
{
 if(QueryControl()=='Iftariye')
  {
    var tutar = document.form1.txtIftariye.value * (4/document.form1.drpIftariyeKur.value);
    document.form1.txtTutar.value=formatla(tutar,2,true,false,true);
    document.form1.txtTutar.value = document.form1.txtTutar.value.replace(',','');
    var tl = document.form1.txtIftariye.value * 4;
    document.form1.txtYTL.value = formatla(tl,2,true,false,true)+" YTL";
    }
}
function CalculateFitre()
{
 if(QueryControl()=='Fitre')
  {
    var tutar = document.form1.txtFitre.value * (5/document.form1.drpIftariyeKur.value);
    document.form1.txtTutar.value=formatla(tutar,2,true,false,true);
    document.form1.txtTutar.value = document.form1.txtTutar.value.replace(',','');
    var tl = document.form1.txtFitre.value * 5;
    document.form1.txtYTL.value = formatla(tl,2,true,false,true)+" YTL";
    }
}
function Calculate2()
{

     if(QueryControl()=='YurticiKurban')
         {
//    var tl =(document.form1.txtTutar.value)* (document.form1.drpHisseKur.options[ document.form1.drpHisseKur.selectedIndex].value);
//var tl=275 * document.form1.drpHisse.options[document.form1.drpHisse.selectedIndex].value;
      var tl=260 * document.getElementById('drpHisse').options[document.getElementById('drpHisse').selectedIndex].value;
//    tl = document.form1.txtTutar.value * document.getElementById('drpHisse').value;
    //document.form1.txtYTL.value=formatla(tl,2,true,false,true)+" YTL";
      document.form1.txtYTL.value=formatla(tl,2,true,false,true)+" YTL";
     }
    else  if(QueryControl()=='YurtdisiKurban')
         {
//    var tl =(document.form1.txtTutar.value)* (document.form1.drpHisseKur.options[ document.form1.drpHisseKur.selectedIndex].value);
//var tl=275 * document.form1.drpHisse.options[document.form1.drpHisse.selectedIndex].value;
      var tl=175 * document.getElementById('drpHisse').options[document.getElementById('drpHisse').selectedIndex].value;
//    tl = document.form1.txtTutar.value * document.getElementById('drpHisse').value;
    //document.form1.txtYTL.value=formatla(tl,2,true,false,true)+" YTL";
      document.form1.txtYTL.value=formatla(tl,2,true,false,true)+" YTL";
     }
}
//function formatla(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
//{ 
//        if (isNaN(parseInt(num))) return "NaN";

//	var tmpNum = num;
//	var iSign = num < 0 ? -1 : 1;		
//	
//	
//	tmpNum *= Math.pow(10,decimalNum);
//	tmpNum = Math.round(Math.abs(tmpNum))
//	tmpNum /= Math.pow(10,decimalNum);
//	tmpNum *= iSign;					
//	

//	var tmpNumStr = new String(tmpNum);


//	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
//		if (num > 0)
//			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
//		else
//			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);

//	if (bolCommas && (num >= 1000 || num <= -1000)) {
//		var iStart = tmpNumStr.indexOf(".");
//		if (iStart < 0)
//			iStart = tmpNumStr.length;

//		iStart -= 3;
//		while (iStart >= 1) {
//			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
//			iStart -= 3;
//		}		
//	}

//	
//	if (bolParens && num < 0)
//		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

//	return tmpNumStr;	
//}
function formatla(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(num))) return "NaN";

	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
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + 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 RandomButton()
{
    btn1 = document.getElementById('Button1');
    btn2 = document.getElementById('Button2');
    btn3 = document.getElementById('Button3');
    btn4 = document.getElementById('Button4');
    btn5 = document.getElementById('Button5');
    btn6 = document.getElementById('Button6');
    btn7 = document.getElementById('Button7');
    btn8 = document.getElementById('Button8');
    btn9 = document.getElementById('Button9');
   
    var chars = new Array(8);
    chars[0]='1';
    chars[1]='2';
    chars[2]='3';
    chars[3]='4';
    chars[4]='5';
    chars[5]='6';
    chars[6]='7';
    chars[7]='8';
    chars[8]='9';
    chars[9] ='0';
    var ranNum= Math.round(Math.random()*chars.length);
    btn1.value=ranNum;
    chars.splice(btn1.value);
    ranNum=Math.round(Math.random()*chars.length);
    btn2.value=ranNum;
    chars.splice(btn2.value);
    ranNum=Math.round(Math.random()*chars.length);
    btn3.value=ranNum;
    chars.splice(btn3.value);
     ranNum=Math.round(Math.random()*chars.length);
    btn4.value=ranNum;
    chars.splice(btn4.value);
     ranNum=Math.round(Math.random()*chars.length);
    btn5.value=ranNum;
    chars.splice(btn6.value);
     ranNum=Math.round(Math.random()*chars.length);
    btn2.value=ranNum;
    chars.splice(btn6.value);
     ranNum=Math.round(Math.random()*chars.length);
    btn7.value=ranNum;
    chars.splice(btn7.value);
    
        
}

function SetText(ctrl,deger)
{
    var text=  document.getElementById(ctrl);
    if(text.value.length==16)
    {
        alert('Kredi kart numarası 16 hane olmalıdır');
        return false;
    }
    else
    {
    text.value +=deger;
    }
    
}

function RemoveTurksihChars(s)
{
        var str = s;
        str = str.replace('Ü', 'U');
        str = str.replace('ü', 'u');
        str = str.replace('Ö', 'O');
        str = str.replace('ö', 'o');
        str = str.replace('Ç', 'C');
        str = str.replace('ç', 'c');
        str = str.replace('Ğ', 'G');
        str = str.replace('ğ', 'g');
        str = str.replace('İ', 'I');
        str = str.replace('ı', 'i');
        str = str.replace('Ş', 'S');
        str = str.replace('ş', 's');
        return str;
}
function HisseHesapla()
{
 if(QueryControl()=='YurticiKurban')
  {
    var hisse = document.getElementById('drpHisse').value;
    var tl=hisse*tutar;
     document.getElementById('txtTutar').value= formatla( tl,2,true,false,true);
     document.getElementById('txtTutar').value = document.getElementById('txtTutar').value.replace(',','');
    }
   else  if(QueryControl()=='YurtdisiKurban')
  {
    var hisse = document.getElementById('drpHisse').value;
    var tl=hisse*tutar;
     document.getElementById('txtTutar').value= formatla( tl,2,true,false,true);
     document.getElementById('txtTutar').value = document.getElementById('txtTutar').value.replace(',','');
    }
}
var tutar=0;
function HisseMiktar()
{
//    if ( typeof( window['drpHisseKur']) != 'undefined' ) 
//    {
  if(QueryControl()=='YurticiKurban')
  {
        tutar =  (260 / document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].value) ;
        document.getElementById('hisseYTL').innerText='1 Hisse '+ formatla(tutar,2,true,false,true)+' '+ document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].text.substring(document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].text.indexOf('-'),50) ;
//      document.getElementById('hisseKur').innerText= document.getElementById('drpHisseKur').options[ document.getElementById('drpHisseKur').selectedIndex].text.substring( document.getElementById('drpHisseKur').options[ document.getElementById('drpHisseKur').selectedIndex].text.indexOf('-'),50) ;
  }
  else if(QueryControl()=='YurtdisiKurban')
  {
        tutar =  (175/ document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].value) ;
        document.getElementById('hisseYTL').innerText='1 Hisse '+ formatla(tutar,2,true,false,true)+' '+ document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].text.substring(document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].text.indexOf('-'),50) ;
//      document.getElementById('hisseKur').innerText= document.getElementById('drpHisseKur').options[ document.getElementById('drpHisseKur').selectedIndex].text.substring( document.getElementById('drpHisseKur').options[ document.getElementById('drpHisseKur').selectedIndex].text.indexOf('-'),50) ;
  }
//   }
/// tutar =  (275 / document.getElementById('drpHisseKur').options[document.form1.drpHisseKur.selectedIndex].value) ;
   /// document.getElementById('hisseYTL').innerText='1 Hisse '+ formatla(tutar,2,true,false,true)+' '+document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].text.substring(document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].text.indexOf('-'),50) ;
     ///   document.getElementById('hisseKur').innerText=document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].text.substring(document.form1.drpHisseKur.options[document.form1.drpHisseKur.selectedIndex].text.indexOf('-'),50) ;
   
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}

var URL = location.href

function QueryControl() {
	var regEx = new RegExp("(\\?|&)("+'Campaign'+"=)(.*?)(&|$)","i")
	var exec = regEx.exec(URL)
	var Sonuc = RegExp.$3
	return(Sonuc)
}


 function getElementLeft(Elem) {
	
		var elem;
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		xPos = elem.offsetLeft;
		tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
	  		tempEl = tempEl.offsetParent;
  		}
		return xPos;


	
}


function getElementTop(Elem) {
	 
		if(document.getElementById) {	
			var elem = document.getElementById(Elem);
		} else if (document.all) {
			var elem = document.all[Elem];
		}
		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
		return yPos;
	
}

function SetLabelText(msg)
{
if(document.all)
    {
    document.getElementById('lblUyari').innerText=msg;
    }
else
    {
     document.getElementById('lblUyari').textContent=msg;
    }
}

function onaylat()
{
 if(QueryControl()!='YurticiKurban')
 {
    if(QueryControl()!='YurtdisiKurban')
    {
        var check =new Boolean(false);
            if(document.getElementById('chkOto').checked)
            {
                      if (confirm('Kredi kartınızdan  '+document.getElementById('drpAy').value+' ay boyunca ,her ayın '+document.getElementById('drpGun').value+'. günü  '+document.getElementById('txtYTL').value+'  bağış alınacaktır. Onaylıyormusunuz? '))
                      {
                      check=true;
                      document.getElementById('Button11').disabled=true;
                        document.getElementById('Button11').value = 'Lütfen Bekleyiniz...';
                      }
                      else
                      {
                         check=false;
                      } 
             }
             else
             {
                 document.getElementById('Button11').disabled=true;
                document.getElementById('Button11').value = 'Lütfen Bekleyiniz...';
                check=true;
             }
            return check;
           
    }
    else
    {
       document.getElementById('Button11').disabled=true;
        document.getElementById('Button11').value = 'Lütfen Bekleyiniz...';
    }
    
 }

}
function DisableButton()
{
   document.getElementById('Button11').disabled=true;
         document.getElementById('Button11').value = 'Lütfen Bekleyiniz...';

}
//function LoginControl()
//{
//var ok = new Boolean(false);
//    if(!validateEmailv2(document.getElementById('UserName').value))
//    {
//    ok=false;
//    document.getElementById('dvAlert').style.left=getElementLeft('UserName')+135;
//    document.getElementById('dvAlert').style.top=getElementTop('UserName')-65;
//        document.getElementById('dvAlert').style.left=getElementLeft('UserName');
//    document.getElementById('dvAlert').style.top=getElementTop('UserName');
//        document.getElementById('dvAlert').style.display='block';
//       if(document.all)
//        {
//             document.getElementById('lblMsg').innerText='Email adresi geçersiz';
//        }
//        else
//        {
//            document.getElementById('lblMsg').textContent='Email adresi geçersiz';
//        }
//        
//    }
//    else
//    {
//    ok=true;
//         document.getElementById('dvAlert').style.display='none';
//        
//    }
//    return ok;
//}

function validateEmailv2(email)
{
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function ClearAllForm()
{
    document.getElementById('UserName').value='';
    document.getElementById('Password').value='';
    
}
function ChangeBgColor(obj,clsName)
{
    obj.className=clsName;
}
var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() 
{
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}


