﻿//@Buyomer | 2011


//Set Date
var nFullDate = new Date();
var day1 = nFullDate.getDate();
var month = nFullDate.getMonth();

var month=new Array(12);
  month[0]=31;
  month[1]=59;
  month[2]=90;
  month[3]=120;
  month[4]=151;
  month[5]=181;
  month[6]=212;
  month[7]=243;
  month[8]=273;
  month[9]=304;
  month[10]=334;
  month[11]=365;

month1 = month[nFullDate.getMonth()];
var year1 = nFullDate.getFullYear();
var date1= ((Number(year1) * 365)) + (Number(month1) + Number(day1));

//Set Cookie for CheckBox	

//Date Alert
function messageAlert(message) 
{
	$("#alert").hide();
    $("#alert").html(message);
	$("#alert").fadeIn();
}

function messageFadeOut()
{
	$("#alert").fadeOut();
	
}


//Pop-up Pages	
function temrsOfUsage()

{
	var url="termsofusage.html"
	
	var w=570;
	var h=500;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (url,'Kullanim Kosullari','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
	}
	
function privacy()

{
	var url="privacy.html"
	
	var w=570;
	var h=500;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (url,'Gizlilik','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
	}	
	
function showArrow(){
	setTimeout(function() { if (YR.newScroll == 0) $('.arrow').fadeIn(1000); }, 500);}
	
function hideArrow(){
	setTimeout(function() { if (YR.newScroll == 0) $('.arrow').hide(); }, 500);}	
	
//FormCheck
function check_form()
{	
			
	var e=0;
	var i=1;
	for (i=1;i<=8;i++)
	{
		if(document.getElementById('tb'+i).value=='')
		{
			e=1;
		}
	}
	if(e==1)
	{
		messageAlert("Lütfen tüm alanları doldurunuz.");
		
		
        //setTimeout (messageFadeOut, 3000,"");
		return false;
	}
	else
	{
			
			var box1=$("#tb1").val();
			var box2=$("#tb2").val();
			var box3=$("#tb3").val();
			var box4=$("#tb4").val();
			var box5=$("#tb5").val();
			var box6=$("#tb6").val();
			var box7=$("#tb7").val();
			var box8=$("#tb8").val();
			var year2=(box5+box6+box7+box8) * 365;
			var month2=(box3+box4);
			if (month2 == 00 && month2 > 12){
				
				messageAlert("Lütfen geçerli bir tarih giriniz.");
				return false;
			};
			if (month2 >= 13){
				
				messageAlert("Lütfen geçerli bir tarih giriniz.");
				return false;
			};
			if (month2 == 01){
			
			month2 = 31;	
			};
			if (month2 == 02){
			
			month2 = 59;
			};
			if (month2 == 03){
			
			month2 = 90;
			};
			if (month2 == 04){
			
			month2 = 120;	
			};
			if (month2 == 05){
			
			month2 = 151;	
			};
			if (month2 == 06){
			
			month2 = 181;	
			};
			if (month2 == 07){
			
			month2 = 212;	
			};
			if (month2 == 08){
			
			month2 = 243;	
			};
			if (month2 == 09){
			
			month2 = 273;	
			};
			if (month2 == 10){
			
			month2 = 304;	
			};
			if (month2 == 11){
			
			month2 = 334;	
			};
			if (month2 == 12){
			
			month2 = 365;	
			};
			
			
			var day2= box1 + box2;
			if (day2 >= 32){
				
				messageAlert("Lütfen geçerli bir tarih giriniz.");
				return false;
			};
			var date2 = (Number(year2)) + (Number(month2) + Number(day2));
			var yas= (date1 - date2) / 365;
			yas = parseInt(yas)
			
			
			
			if (yas < 24)
			{
				
			
				messageAlert(yas+" yaş siteye girmeniz için yeterli değildir.");
				//setTimeout (messageFadeOut, 3000,"");
				return false;
			}
			if (yas >= 24)
			{
			
			
			if ($('#checkBox').attr('checked'))
			{
				location.replace('http://www.bibuyukfest.com/buyuk/');
				setCookie("loginStatus", 0, 1);}
			else
			{
				location.replace('http://www.bibuyukfest.com/buyuk/');
				setCookie("loginStatus", 1, 1);};
				return false;
			}
			return true;
		}
	
	
}
$(document).ready(function()
{
	
	
	
	$("input").keydown(function(e)
	{
		code = e.keyCode ? e.keyCode : String.fromCharCode(e.charCode);
		if(code==8)//Silme
		{
			if($(this).val()=='')
			{
				var tbid = $(this).attr('id').substr(2, 1);
				if(tbid-1>0)
				{
					$('#tb'+(tbid-1)).focus();
				}
			}
			else
			{
				$(this).val('');
			}
		}
	});
	
	$("input").keyup(function(e)
	{
		code = e.keyCode ? e.keyCode : String.fromCharCode(e.charCode);
		if((code>=48 && code<=57) || (code>=96 && code<=105))//Rakam
		{
			var tbid = $(this).attr('id').substr(2, 1);
			if((tbid*1)+1<9)
			{
				if($(this).attr('id')=='tb1' && $(this).val()>3)
				{
					$(this).val('');
				}
				else if($(this).attr('id')=='tb3' && $(this).val()>1)
				{
					$(this).val('');
				}
				else if($(this).attr('id')=='tb5' && $(this).val()!=1)
				{
					$(this).val('');
				}
				else if($(this).attr('id')=='tb6' && $(this).val()!=9)
				{
					$(this).val('');
				}
				else
				{
					$('#tb'+((tbid*1)+1)).focus();
				}
			}
				
		}
		else
		{
			$(this).val('');
		}
	});
	
	
	
	//Cookie Check
	var checkLogin=getCookie("loginStatus");
	if (checkLogin==1)
	{}if (checkLogin==0)
		{
		location.replace('http://www.bibuyukfest.com/buyuk/');
		}
	
		else {
		setCookie("loginStatus",1,1);
		};
});


//Set Cookie
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

