function k$(str) {
	if(document.getElementById(str)) {
		return document.getElementById(str);
	}
	else return undefined;
}
function dteSearchFocus() {
	if(k$('dteSearchTxt').value == 'search dog trials') {
		k$('dteSearchTxt').value = '';
	}
}
function dteSearchBlur() {
	if(k$('dteSearchTxt').value == '') {
		k$('dteSearchTxt').value = 'search dog trials';
	}
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   if ((sText.length==0) ||
	   (sText==null))
   {
   	  IsNumber=false;
   }
   else
   {
   		for (i = 0; i < sText.length && IsNumber == true; i++)
   		   {
   		   Char = sText.charAt(i);
   		   if (ValidChars.indexOf(Char) == -1)
   		      {
   		      IsNumber = false;
   		      }
   		   }
   		return IsNumber;
   }
   return IsNumber;
}

// moved from selTrial.php
function dte_waiverset() {
	if (document.trialinfo.getWaiver.checked==true)
	{
	    alert('Thank you. Your agreement to the waivers and releases has been noted. Enjoy the event.');
	}else
	{
	    alert('Please agree to the waivers and releases to enter this event.');
	}
	
}

// jmb
function IsPswd(sText) 
{
  // quotes, ampersands, commas, and < > etc. are not allowed. Tildi is ok.
  // ValidChars is what is allowed.
   var ValidChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%_";
   var IsPswd=true;
   var Char;
   if ((sText.length<4) ||
	   (sText==null))
   {
   	  IsPswd=false;
   }
   else
   {
   		for (i = 0; i < sText.length && IsPswd == true; i++)
   		   {
   		   Char = sText.charAt(i);
   		   if (ValidChars.indexOf(Char) == -1)
   		      {
   		      IsPswd = false;
   		      }
   		   }
   		return IsPswd;
   }
   return IsPswd;
}
// jmb
function IsText(sText) 
{
  // quotes, ampersands, commas, and < > etc. are not allowed. Tildi and backtic(by tildi on keyboard) are ok.
  // ValidChars is what is allowed.
   var ValidChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@#$_~`";
   var IsText=true;
   var Char;
   if ((sText.length<1) ||
	   (sText==null))
   {
   	  IsText=false;
   }
   else
   {
   		for (i = 0; i < sText.length && IsText == true; i++)
   		   {
   		   Char = sText.charAt(i);
   		   if (ValidChars.indexOf(Char) == -1)
   		      {
   		      IsText = false;
   		      }
   		   }
   		return IsText;
   }
   return IsText;
}

// ******** begin - hide button functionality **********
function dte_setHide()
{
  // ** Hide div sections that end in Profile ** //
  // **  Set div section buttion text to SHOW ** // 
   $("div [id$=Profile]").hide();
   $("div [id$=ProfileBtn]").each(function() {
      var btnValueThis=$(this).attr("value");           
      var btnIdLength=$(this).attr("Id").length;        
      btnValueThis = 'Show' + btnValueThis.substr(4);
      $(this).attr({value: btnValueThis});
   });
   
   // *** DOES NOT WORK IN IE7 (syntax is probably bad) *** ///
   //$('#eventTable input, select, textarea').filter('[id*=tev]').attr(
   //  {value: '', title: 'Required', class: 'fred'}
   // ).show();
   
   //$('#tev_name').focus();
   
   //  ** PopUp Window Example **
   //  DesignerWizWin=window.open(
   //  'pageIssues.php','DogTrialEntry - HELP ','toolbar=0, location=0,directories=0, menuBar=0,scrollbars=1, resizable=1,width=400,height=380,left=200, top=50'
   //  );
}
 $(function(){                                          // *** Button is used to hide    ** //
    $("input[type=button]").click(function (e) {        // *** indivial sections of      ** //
      var btnValueThis=$(this).attr("value");           // *** form. Each of which are   ** //
      var divIdThis=$(this).attr("Id");                 // *** a div with a coresponding ** //
      var btnIdLength=$(this).attr("Id").length;        // *** name to the button.       ** //
      var divIdThis=$(this).attr("Id").substr(0,btnIdLength-3);
      divIdThis="#"+divIdThis;                          // manufacture Id of div section
      if ($(this).attr("value").substr(0,4) == 'Hide')  // *** built in seperate tables *** //
      { 
         btnValueThis = 'Show' + btnValueThis.substr(4);
         $(this).attr({value: btnValueThis});
      }else{
         btnValueThis = 'Hide' + btnValueThis.substr(4);
         $(this).attr({value: btnValueThis});
      }
      $(divIdThis).toggle(250, function(){
        $(' td:first input', this).select();
      });
    });
 });
// ******** end - hide button functionality **********

