﻿/// <reference name="MicrosoftAjax.js"/>

  function trim(str)
        {
                while(str.charAt(0)==' ')
                str=str.substring(1,str.length);
                while(str.charAt(str.length-1)==' ')
                str=str.substring(0,str.length-1);
                return str;
        }
	function trimAll(str,chr)
            {
                var strArr=str.split(chr); 
                str="";
                        for (var i=0;i<strArr.length;i++)
                        {
                            str += strArr[i];
                        }
                        
                return str;
            }

        function actMenu(obj) {
	        var menuChild = $get( obj).getElementsByTagName('a')[0];
	        menuChild.className = "menuon";
        }
       function deactMenu(obj) {
	        var menuChild = $get( obj).getElementsByTagName('a')[0];
	        menuChild.className = "";
        }

        function actMenu_ie(obj) {
       
	        var menuChild = $get( obj).getElementsByTagName('a')[0];
	        menuChild.className = "menuonie";
        }
        
   function SelectMenu(Id) {
             
	        if(  $get("tab" + Id)!=null)  $get("tab" + Id).className ="tab_on";
	        if(  $get("div" + Id)!=null) 
	        {
	            $get("div" + Id).onmouseover="";
	            $get("div" + Id).onmouseout="";
	        }
	        
        }
 

       function SelectTab(tab)
    {

        id=tab.toString().split("#")[1];
        var TabList=document.getElementById('tabs').getElementsByTagName("a");
        var strHref=""
        for(var i=0;i<TabList.length;i++)
        {
            
            var strId=TabList[i].href.toString().split("#")[1];
            if( tab.id!=strId)
            {
                TabList[i].className="";
                document.getElementById(strId).style.display="none";
            }
            
        }
        tab.className="active";
        document.getElementById(id).style.display="block";
    }
    
      function fncOnload()
    {

      var  id=window.location.toString().split("#")[1];
        if (id==null)
        return;
        
        var TabList=document.getElementById('tabs').getElementsByTagName("a");
        var strHref=""
        for(var i=0;i<TabList.length;i++)
        {
            
            var strId=TabList[i].href.toString().split("#")[1];
            if( id!=strId)
            {
                TabList[i].className="";
                document.getElementById(strId).style.display="none";
            }
           else
           {      
             TabList[i].className="active";
             document.getElementById(id).style.display="block";
              
            }
        }
     
    }
    
        function fncYakinda(icerik)
        {
           var x=((screen.width - 600)/2);
            var y= (screen.height - 350)/2-100;
            
			window.open('http://www.manheimturkiye.com/Yakinda.htm?' + icerik + '','newwindow','location=no ,scrollbars=no,status=yes,resizable=no,copyhistory=no,width=600,height=350,left=' + x.toString() +',top=' + y.toString() +''); 
        }
         
        function fncHizmetlerimiz(intIcerik)
        {
        
           var x=((screen.width - 825)/2);
            var y= (screen.height - 625)/2-100;
			window.open('http://www.manheimturkiye.com/Hizmetlerimiz_PopUp.htm?' + intIcerik + '','newwindow','location=no ,scrollbars=no,status=yes,resizable=no,copyhistory=no,width=825,height=625,left=' + x.toString() +',top=' + y.toString() +''); 
           
            
         }
         
         function LightOn(row)
         {
            row.className="gridHighLight";
            
         }
         
         function LightOff(row)
         {
            row.className="";
         }
         
         function Popup(url,w,h)
         {
            var x=((screen.width - w)/2);
            var y= (screen.height - h)/2-50;
            window.open( url ,'newwindow','location=no ,scrollbars=yes,status=yes,resizable=no,copyhistory=no,width='+ w.toString() +',height=' + h.toString() + ',left=' + x.toString() +',top=' + y.toString() +''); 
         }
         
function FormatDate(obj){
        string='__.__.____';
        val=obj.value.replace(/_/g,'');
        val= trimAll(val,"."); 
        val=val.substring(0,8) ;
        val=val.replace(/\s/g,'');
        val1=''
        for (zxc0=0;zxc0<val.length;zxc0++){val1+=val.charAt(zxc0);}
        if (val1.length<3){obj.value=val1+string.substring(val1.length,string.length);}
        else if (val1.length<5){obj.value=val1.substring(0,2) + '.'+val1.substring(2,val1.length)}
        else if (val1.length<9){
            var   val2=val1.substring(0,2) + '.' +val1.substring(2,4) +'.' +val1.substring(4,val1.length);
            obj.value=val2+string.substring(val2.length,string.length);
        }
}

function ValidateDate(dtm)
{
           var patternDate=new RegExp(/^(((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00|[048])))$/); 
           
        if( trim(dtm)=="" ) return true;
        if( dtm=="__.__.____" ) return true;        
        if(patternDate.exec(dtm)==null)  return false ;
        
}
function FormatPlaka(obj){

            val=trimAll(obj.value," ").toUpperCase();
            var val1=''
            for (zxc0=0;zxc0<val.length;zxc0++){val1+=val.charAt(zxc0);}
            if (val1.length<3){if (isNaN(val1)) obj.value=val1.substring(0,val1.length-1);}
            else {
                    var Plaka=RegExp(/^([a-zA-Z]+)([0-9])|([a-zA-Z])$/);
                    if( Plaka.exec(val1.substring(2,val1.length))==null){
                        obj.value=val1.substring(0,2) + val1.substring(2,val1.length-1) 
                    }else 
                    obj.value=val1.substring(0,2) + val1.substring(2,val1.length) 
            }
}

    
function AddRemoveValues(cbox,hdn)
{
        if(cbox.checked)
        {
                hdn.value += cbox.value + ",";
                //alert("checked: "+  hdn.value);
        }
        else
        {
                hdn.value = hdn.value.replace(cbox.value + ",","");
                //alert("unchecked: "+  hdn.value);
        }
}
			

function ShowEditModal(aaid,stokno) {
        var frame = $get('IframeEdit');
        frame.src = "EksikEvrak.aspx?aaid="+ aaid +"&stokno=" + stokno;
        $find('mpeGrid').show();
    }
    
    
 function kontrol_number (deger)
{ var  temp1, temp2
var val;
	val=deger.value
  v_index = val.indexOf(' '); 
	
    var reEx = new RegExp("^[0-9]+$");
    if (deger!="")
    {
         if (!reEx.test(val))
          {
		     /*
		     while (v_index != -1) 
             { 
      			deger = val.replace(' ','');
      			v_index = val.indexOf(' ');
             }
                
				 for (i=0; i <= (val.length); i=i+1)
			   	 {
	   	 		   if (!reEx.test(val.substr(i,1)))
				   {
			            temp1 = val.substr(0,i);
			            temp2 = val.substr(i+1,val.length);
  						deger = temp1+temp2;
						i = i-1;
    				   if (val.length == i+1)
		    		   {i = i + 1;}
		 		   }
	             }
            */

     	 alert("Bu Alana Sadece Rakam Girebilirsiniz.");
     	deger.value= val.replace("^[0-9]+$");
          }
    }
return deger.value;
} 


function getScrollBottom(p_oElem)
{
    return p_oElem.scrollHeight - p_oElem.scrollTop - p_oElem.clientHeight;
}
        
        
        

    

    