var aIds = Array( 'pg_801e316097' );
var aId  = Array ();
function ChangePage( to_hide, to_show )
{
   var tbl_hide = document.getElementById( aIds[to_hide] );
   var tbl_show = document.getElementById( aIds[to_show] );

   if ( typeof(tbl_hide)=='object' && tbl_hide!=null )
    if ( typeof(tbl_show)=='object' && tbl_show!=null )
    {
       tbl_hide.style.display = 'none';
       tbl_show.style.display = '';
    }
	
}
function NotEmpty( old_res, id, field_title )
{
   if ( old_res==0 )
   {
      var el = document.getElementById( id );
      if ( typeof(el)=='object' && el!=null )
        if ( el.value=='' )
        {
           alert( 'You should fill "' + field_title + '"' );
           return 1;
        }
   }
   return 0;
}
function CheckLeapYear( id )
{
   var aDaysNum = Array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
   var id_cut   = id.substr( 6, id.length-6 );
   var day_sel   = document.getElementById( 'fld_d_' + id_cut );
   var month_sel = document.getElementById( 'fld_m_' + id_cut );
   var year_sel  = document.getElementById( 'fld_y_' + id_cut );

   if ( typeof(day_sel)=='object' && day_sel!=null )
    if ( typeof(month_sel)=='object' && month_sel!=null )
     if ( typeof(year_sel)=='object' && year_sel!=null )
     {
        if ( month_sel.selectedIndex==1 )
        {
          if ( year_sel.value % 400==0 || (year_sel.value % 100!=0 && year_sel.value % 4==0) ) aDaysNum[1] = 29;
        }
        var day_sel_ix = day_sel.selectedIndex;
        day_sel.options.length = 0;

        for ( i=1; i<=aDaysNum[month_sel.selectedIndex]; i++ )
        {
           if ( document.createElement )
           {
              var newOpt = document.createElement( "OPTION" );
              newOpt.text = i;
              newOpt.value = i;
              ( day_sel.options.add ) ? day_sel.options.add(newOpt) : day_sel.add(newOpt, null);
           }
           else
           {
              day_sel.options[i-1] = new Option( i, i, false, false );
           }
        }
        if ( day_sel.options.length < (day_sel_ix+1) )
           day_sel.selectedIndex = day_sel.options.length-1;
        else day_sel.selectedIndex = day_sel_ix;
     }
}
function NumbersOnly( old_res, id, field_title )
{
   if ( old_res==0 )
   {
      var el = document.getElementById( id );
      if ( typeof(el)=='object' && el!=null )
      {
         var re = /^[0-9]+$/;
         if (el.value.search(re) == -1 )
         {
            alert( '"' + field_title + '" must be a number' );
            return 1;
         }
      }
   }
   return 0;
}
function NotEmpty( old_res, id, field_title )
{
   if ( old_res==0 )
   {
      var el = document.getElementById( id );
      if ( typeof(el)=='object' && el!=null )
        if ( el.value=='' )
        {
           alert( 'You should fill "' + field_title + '"' );
           return 1;
        }
   }
   return 0;
}
function Email( old_res, id, field_title )
{ 
   if ( old_res==0 )
   {
      var el = document.getElementById( id );
      if ( typeof(el)=='object' && el!=null && el.value!='' )
      {
         var re = /^[a-zA-Z0-9_\.\-]+@([a-zA-Z0-9][a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}$/;

         if (el.value.search(re) != -1 )  return 0;
         else
         {
            alert( '"'+field_title+'" must be email' );
            return 1;
         }
      }
   }
   return 0;
}

var dFilterStep;

function dFilterStrip (dFilterTemp, dFilterMask)
{
    dFilterMask = replace(dFilterMask,'#','');
    for (dFilterStep = 0; dFilterStep < dFilterMask.length++; dFilterStep++)
		{
		    dFilterTemp = replace(dFilterTemp,dFilterMask.substring(dFilterStep,dFilterStep+1),'');
		}
		return dFilterTemp;
}

function dFilterMax (dFilterMask)
{
 		dFilterTemp = dFilterMask;
    for (dFilterStep = 0; dFilterStep < (dFilterMask.length+1); dFilterStep++)
		{
		 		if (dFilterMask.charAt(dFilterStep)!='#')
				{
		        dFilterTemp = replace(dFilterTemp,dFilterMask.charAt(dFilterStep),'');
				}
		}
		return dFilterTemp.length;
}

function dFilter (key, textbox, dFilterMask)
{
        if (key==96) key=48;
		if (key==97) key=49;
		if (key==98) key=50;
		if (key==99) key=51;
		if (key==100) key=52;
		if (key==101) key=53;
		if (key==102) key=54;
		if (key==103) key=55;
		if (key==104) key=56;
		if (key==105) key=57;

		dFilterNum = dFilterStrip(textbox.value, dFilterMask);
		
		if (key==9)
		{
		    return true;
		}
		else if (key==8&&dFilterNum.length!=0)
		{
		 	 	dFilterNum = dFilterNum.substring(0,dFilterNum.length-1);
		}
 	  else if ( ((key>47&&key<58)||(key>95&&key<106)) && dFilterNum.length<dFilterMax(dFilterMask) )
		{
        dFilterNum=dFilterNum+String.fromCharCode(key);
		}

		var dFilterFinal='';
    for (dFilterStep = 0; dFilterStep < dFilterMask.length; dFilterStep++)
		{
        if (dFilterMask.charAt(dFilterStep)=='#')
				{
					  if (dFilterNum.length!=0)
					  {
				        dFilterFinal = dFilterFinal + dFilterNum.charAt(0);
					      dFilterNum = dFilterNum.substring(1,dFilterNum.length);
					  }
				    else
				    {
				        dFilterFinal = dFilterFinal + "";
				    }
				}
		 		else if (dFilterMask.charAt(dFilterStep)!='#')
				{
				    dFilterFinal = dFilterFinal + dFilterMask.charAt(dFilterStep); 			
				}

		}


		textbox.value = dFilterFinal;
    return false;
}

function replace(fullString,text,by) {

    var strLength = fullString.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return fullString;

    var i = fullString.indexOf(text);
    if ((!i) && (text != fullString.substring(0,txtLength))) return fullString;
    if (i == -1) return fullString;

    var newstr = fullString.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(fullString.substring(i+txtLength,strLength),text,by);

    return newstr;
}
function CeckDis( )
{
    var fagr = document.getElementById('box_confirm');
	if (fagr.checked)
	{
	   document.getElementById("subbut").disabled=false;
	   document.getElementById("subbut").style.backgroundColor  = '#a2a2a2';

       var subs = document.getElementById( "subbut_s" );
       if ( typeof(subs)=='object' && subs!=null )
       {
          subs.disabled=false;
		  subs.style.backgroundColor  = '#a2a2a2';
	   }
	}
	else
    {
	  document.getElementById("subbut").disabled=true;
      document.getElementById("subbut").style.backgroundColor  = '#FAEBD7';
          
      var subs = document.getElementById( "subbut_s" );
      if ( typeof(subs)=='object' && subs!=null )
      {
         subs.disabled=true;
		 subs.style.backgroundColor  = '#FAEBD7';
	  }
	}    
}
