// INCLUDED IN EVERY PAGE
    var turkMonth=new Array("Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık");
    var turkMonth_eng=new Array("January","February","March","April","May","June","July","August","September","October","Novamber","December");
    var turkDays=new Array("Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi");

    function setDate(){
      var now=new Date();
      var year=now.getYear();
      var month=now.getMonth();
      var day=now.getDate();
      var dayOfWeek=now.getDay();
      document.dateForm.dateText.value=day+" "+turkMonth[month]+" "+year;
      document.dateForm.dayText.value=turkDays[dayOfWeek];
       setTheHours();      
    }

    function setTheHours(){
      var now=new Date();    
      var year=now.getYear();
      var month=now.getMonth();
      var day=now.getDate();
      var dayOfWeek=now.getDay();
      var hour=now.getHours();      
      var minute=now.getMinutes();
      var second=now.getSeconds();
      var h=getZeroNumber(hour);
      var m=getZeroNumber(minute);
      var s=getZeroNumber(second);            
      str = day+"."+(month+1)+"."+year+" "+h+":"+m+":"+s;
//      document.dateForm.dateText.value=day+" "+turkMonth[month]+" "+year;
//      document.dateForm.dayText.value=turkDays[dayOfWeek];

      document.dateForm.hourText.value=str;
      window.setTimeout("setTheHours()",1000);
    }
    function getZeroNumber(number){
      if(number<10){
        return "0"+number.toString();
      }else{
        return number.toString();
      }
    }

function Minutes(data) {
    for(var i=0;i<data.length;i++) if(data.substring(i,i+1)==":") break;
    return(data.substring(0,i)); }
function Seconds(data) {
    for(var i=0;i<data.length;i++) if(data.substring(i,i+1)==":") break;
    return(data.substring(i+1,data.length)); }
function Display(min,sec) {
    var disp;
    if(min<=9) disp=" 0"; 
    else disp=" ";
    disp+=min+":";
    if(sec<=9) disp+="0"+sec;
    else disp+=sec;
    return(disp); }
function Up() {
    cmin1=0;
    csec1=0;
    min1=0+Minutes(document.sw.beg1.value);
    sec1=0+Seconds(document.sw.beg1.value);
    UpRepeat(); }
function UpRepeat() {
    csec1++;
    if(csec1==60) { csec1=0; cmin1++; }
    window.status=Display(cmin1,csec1);
    if((cmin1==min1)&&(csec1==sec1)) parent.location.href='/logout.php';
    else up=setTimeout("UpRepeat()",1000); }
function Down() {
    cmin2=1*Minutes('20:00');
    csec2=0+Seconds('20:00');
    DownRepeat(); 
    }
function DownRepeat() {
    csec2--;
    if(csec2==-1) { csec2=59; cmin2--; }
    window.status=Display(cmin2,csec2);
    if((cmin2==0)&&(csec2==0)) parent.location.href='/logout.php';
    else down=setTimeout("DownRepeat()",1000);
}

function add2cart(marka, kod, ad, adet, birim, kur, dfiyat, tlfiyat, tarih){
	popup('add2cart.php?MARKA='+marka+'&KOD='+kod+'&AD='+ad+'&ADET='+adet+'&BIRIM='+birim+'&KUR='+kur+'&DFIYAT='+dfiyat+'&TLFIYAT='+tlfiyat+'&TARIH='+tarih,'ADD',300,120);
}

function popup_ac(popup_url, popup_name, winWidth, winHeight){
         winWidth = screen.width-8;
         winHeight = screen.height-20;
	scrL = 0;
	scrT = 0;
    yeni = window.open(popup_url, popup_name, "width="+winWidth+",height="+winHeight+",status=yes,resizable=yes,scrollbars=yes,top="+scrT+",left="+scrL);
    if(yeni)yeni.focus();
	}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function SASICOZ(gelen){
     popup('/vin/decode.php?VIN=' + gelen ,'',600,600);
}


function date_validate(d,m,y)
{
		   var chk    = 0;
		   var maxDay = 0;
		   var dd = d; // day
		   var mm = m; // month
		   var yyyy = y; // year
		
   if (d != "" && m != "" && y != ""){
		// calling function to get maximum day for this month
		maxDay = max_day(mm, yyyy);  
		
		if((dd <= 0) || (dd > maxDay))
		{ chk = 1;}
		else if((mm <= 0) || (mm > 12))
		{ chk = 1;}
		else if((yyyy <= 0))
		{ chk = 1;} 
		
		if(chk == 1){ 
			return true;
		}else{	
			return false;
		}
	}else{
			return false;
	}	
}

// function for calculating maximum day 
function max_day(mn, yr)
{
   var mDay;
if((mn == 4) || (mn == 6) || (mn == 9) || (mn == 11))
{ 
mDay = 30;
}
else if(mn == 2)
{
//calling leap year function 
mDay = isLeapYear(yr) ? 29 : 28;    
}
else
{
mDay = 31;
}
return mDay; 
}

    // function to check leap year
function isLeapYear(yr)
{
if (yr % 2 == 0) 
   return true;
   return false;
}

// function to restrict any non-numeric key pressing
function nn_Key()
{
if ((event.keyCode<48) || (event.keyCode>57))
event.keyCode = 0;
}


function number_format_old(n) {
        //var re;
        //re = /\./ig;
        //n = n.replace(re, "");
        //alert(n);
        a = n.toString();
        b = a.split(".");
        n = b[0];
        var arr=new Array('0'), i=0;
        while (n>0)
        {   arr[i]=''+n%1000; n=Math.floor(n/1000); i++;}
        arr=arr.reverse();

        for (var i in arr) if (i>0) //padding zeros
        while (arr[i].length<3) arr[i]='0'+arr[i];
        return arr.join();
}
function number_format(m)
{
 return m;
//m.value=_c
}
function number_clear(str) {
        var r;
		re = /,/ig;
        r = str.replace(re, "");
        return(r);
}

function formatla(m)
{
 return m;
//m.value=_c
}

var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
				}
			}
		}
	}
 function select_(gelen){
//       gelen.select();;
 }	
 function popup(popup_url, popup_name, winWidth, winHeight){
	if (winWidth == 0){		
		winWidth = (screen.width-30);	
        winHeight = (screen.height-200);	
		scrL = 10;
		scrT = 50;
	}else{
		scrL = (screen.width - winWidth) / 2;
		scrT = ((screen.height - winHeight) / 2);
	}	
  popup_name = window.open(popup_url, popup_name, "width="+winWidth+",height="+winHeight+",status=yes,resizable=yes,scrollbars=yes,top="+scrT+",left="+scrL);
  if(popup_name)popup_name.focus();
}

function popup_son(popup_url, popup_name, winWidth, winHeight,L,T){
  yeni = window.open(popup_url, popup_name, "width="+winWidth+",height="+winHeight+",status=yes,resizable=yes,scrollbars=yes,top="+T+",left="+L);
  if(yeni)yeni.focus();
}

function popup_src(popup_url, popup_name, winWidth, winHeight,to_item_name,str){
	scrL = (screen.width - winWidth) / 2;
	scrT = ((screen.height - winHeight) / 2);
	yeni = window.open(popup_url+'?'+to_item_name+'='+str, popup_name, "width="+winWidth+",height="+winHeight+",status=yes,resizable=yes,scrollbars=yes,top="+scrT+",left="+scrL);
    if(yeni)yeni.focus();
}


 function form_focus(from_item_name, chr, to_item_name){
	if (chr != ""){
		if (from_item_name.value.length == chr){
			if (to_item_name != ""){
				document.all(to_item_name).select();
				document.all(to_item_name).focus();
			}	
		}
	}else{
		  document.all(to_item_name).focus();
	}
 }

							     function arac_sorgula(gelen){
									if (!gelen){
										popup("http://sorgu.trafik.gov.tr/tbssorgular/aracsorgulama.aspx","ARAC_SORGULA",700,450);								 
									}else{
										popup("/blank.php","ARAC_SORGULA",700,450);								 
										document.frmPlakaSorgu.txtPlaka.value=gelen;
										document.frmPlakaSorgu.submit();
									}
									

								 }
							     function arac_kaza_sorgula(gelen){
								 if (!gelen){
								 	popup("http://sorgu.trafik.gov.tr/tbssorgular/puansorgulama.aspx","ARAC_SORGULA",700,450);								 
								 }else{
										popup("/blank.php","ARAC_SORGULA",700,450);								 
										document.Form1.txtaracPlaka.value=gelen;
										document.Form1.submit();
								 }
									
								 }
							     function kazazede_sorgula(){
									popup("http://www.trafik.gov.tr/IAS/IAS/wfKisiKazaSorgulama.aspx","ARAC_SORGULA",700,450);								 
								 }


function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function daysElapsed(TARIH_1,TARIH_2) {
    TMP1 = TARIH_1.split("/");
    TMP2 = TARIH_2.split("/");
    date1 = new Date(TMP1[2],TMP1[1],TMP1[0]);
    date2 = new Date(TMP2[2],TMP2[1],TMP2[0]);
    var difference =
        Date.UTC(y2k(date1.getYear()),date1.getMonth(),date1.getDate(),0,0,0)
      - Date.UTC(y2k(date2.getYear()),date2.getMonth(),date2.getDate(),0,0,0);
    return difference/1000/60/60/24;
}

function open_request(){
      popup("/menu/oneriler/oneri_ekle.php","Mesaj",570,351);
    }