
isFocus = 0;

function FormatPhoneNumber(thisis) {
var tempstr,newstr,str,i,str2 ;
	var commapos,aftercomma,commacount;
	i=0;

	if (isFocus == 1)
	{
		isFocus = 0; 
		return false; 
	}
	
	thisis.value = trimNumber(thisis.value);
	str = thisis.value;

	while ( 14 > i) {
		str = str.replace(" ", "");
		i = i + 1;
	}  
	 
	if ((str.length > 0) && (str.substr(0, 1) == "0")) 
	{  
	    str =str.substr(1);
	    thisis.value = str;
	}
		 
	if ((str.length > 3) && (str.substr(3, 1) == "0"))  
	{    
	    newstr = "";
		newstr = str.substr(0, 3)  +""+ str.substr(4);  
		str = newstr;
	    thisis.value = newstr;
	}
	
	if (str.length > 8) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3, 3) + " " + tempstr.substr(6, 2) + " " + tempstr.substr(8); 
		thisis.value = newstr;
	}
	else if (str.length > 6) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3, 3) + " " + tempstr.substr(6); 
		thisis.value = newstr;
	}
	else if (str.length > 3) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3); 
		thisis.value = newstr;
	}
	
	 if (thisis.value.length > 13)
	{
	    thisis.value = thisis.value.substr(0,13);
	} 
}


function FormatGSMNumber(thisis) {
var tempstr,newstr,str,i,str2 ;
	var commapos,aftercomma,commacount;
	i=0;

	if (isFocus == 1)
	{
		isFocus = 0; 
		return false; 
	}
	
	thisis.value = trimNumber(thisis.value);
	str = thisis.value;

	while ( 14 > i) {
		str = str.replace(" ", "");
		i = i + 1;
	}  
	 
//	if ((str.length > 0) && (str.substr(0, 1) == "0")) 
//	{  
//	    str =str.substr(1);
//	    thisis.value = str;
//	}

	if ((str.length > 0) && (str.substr(0, 1) != "5")) 
	{  
	    str =str.substr(1);
	    thisis.value = str;
	}
		 
	if ((str.length > 3) && (str.substr(3, 1) == "0"))  
	{    
	    newstr = "";
		newstr = str.substr(0, 3)  +""+ str.substr(4);  
		str = newstr;
	    thisis.value = newstr;
	}
	
	if (str.length > 8) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3, 3) + " " + tempstr.substr(6, 2) + " " + tempstr.substr(8); 
		thisis.value = newstr;
	}
	else if (str.length > 6) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3, 3) + " " + tempstr.substr(6); 
		thisis.value = newstr;
	}
	else if (str.length > 3) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3); 
		thisis.value = newstr;
	}
	
	 if (thisis.value.length > 13)
	{
	    thisis.value = thisis.value.substr(0,13);
	} 
}


function Only_Numeric(e) {	
	var whichCode = (window.Event) ? e.which : e.keyCode;
	//alert(whichCode);
	if (whichCode == 13) return true;  // Enter
//	if (whichCode == 44) return true;  // Comma
	if (whichCode > 57 ) return false;
	if (whichCode < 48 && whichCode > 13) return false;
}

function trimNumber(s) {
	s = s.replace(/^\s*/,'').replace(/\s*$/, '');
	return s;
}


function FormatTaxNumber(thisis) {
var tempstr,newstr,str,i ;
	i=0;

	if (isFocus == 1)
	{
		isFocus = 0; 
		return false; 
	}
	
	thisis.value = trimNumber(thisis.value);
	str = thisis.value;
	
	while ( 14 > i) {
		str = str.replace(" ", "");
		i = i + 1;
	}   
	
	 if (str.length > 6) 
	{
		tempstr = str;
		newstr = ""; 
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3, 3) + " " + tempstr.substr(6); 
		thisis.value = newstr;
	}
	else if (str.length > 3) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3); 
		thisis.value = newstr;
	} 
	
	 if (thisis.value.length > 13)
	{
	    thisis.value = thisis.value.substr(0,13);
	} 
}



  function FormatTcNumber(thisis) {
var tempstr,newstr,str,i ;
	i=0;

	if (isFocus == 1)
	{
		isFocus = 0; 
		return false; 
	}
	
	thisis.value = trimNumber(thisis.value);
	str = thisis.value;
	
	while ( 14 > i) {
		str = str.replace(" ", "");
		i = i + 1;
	}   
	
	 if (str.length > 7) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3, 4) + " " + tempstr.substr(7); 
		thisis.value = newstr;
	}
	else if (str.length > 3) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 3) + " " + tempstr.substr(3); 
		thisis.value = newstr;
	} 
	
	 if (thisis.value.length > 13)
	{
	    thisis.value = thisis.value.substr(0,13);
	} 
}


 function FormatCardNumber(thisis) {
var tempstr,newstr,str,i ;
	i=0;

	if (isFocus == 1)
	{
		isFocus = 0; 
		return false; 
	}
	
	thisis.value = trimNumber(thisis.value);
	str = thisis.value;
	
	while ( 19 > i) {
		str = str.replace(" ", "");
		i = i + 1;
	}   
	
	 if (str.length > 12) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 4) + " " + tempstr.substr(4, 4) + " "  + tempstr.substr(8, 4) + " "+ tempstr.substr(12); 
		thisis.value = newstr;
	}
	else if (str.length > 8) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 4) + " " + tempstr.substr(4, 4) + " " + tempstr.substr(8); 
		thisis.value = newstr;
	}
	else if (str.length > 4) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 4) + " " + tempstr.substr(4); 
		thisis.value = newstr;
	} 
	
	 if (thisis.value.length > 19)
	{
	    thisis.value = thisis.value.substr(0,19);
	} 
}

function Collapse(objID) 
{

    var obj=objID*1;

    for(i=0;i<150;i++)
    {
     //   divs=document.getElementById("TreeView3n"+i+"Nodes");
    // ctl00_LeftContent1_Menu1_TreeView3n0Nodes

   var     divs=document.getElementById("ctl00_LeftContent1_Menu1_TreeView3n"+i+"Nodes");

        if(divs!=null && obj!=i)
        {
            divs.style.display="none";
        } else if(divs!=null)
        {  
            divs.style.display="block";        
        }
    }        
}

function  CollapseL2(L2)
{ 
     for(i=0;i<150;i++)
    {   
     var     divs=document.getElementById("ctl00_LeftContent1_Menu1_TreeView3n"+i+"Nodes");

        if(divs!=null)
       {
            var ndx= divs.innerHTML.indexOf(L2);
            if(ndx>0)
                divs.style.display="block";     
            else 
                divs.style.display="none";
       } 
    }
}
