

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      Functions     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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.01
  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 && d.getElementById) x=d.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_openBrWindow(theURL,winName,features) { //v2.0
  myWin = window.open(theURL,winName,features);
  myWin.focus();
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     Flash / Image Replacer    ~~~~~~~~~~~~~~~

                    
var MM_contentVersion = 5;
var MM_FlashCanPlay = 0;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
	    var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i) {
		if (isNaN(parseInt(words[i]))) {
			continue;
		}
		var MM_PluginVersion = words[i]; 
	    }
	    MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE="VBScript">\n '); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next\n ');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT>\n ');
}
// End of Flash Detection Script 

// Function to show the gif banner if not users browser is not able to display flash 
function showgif(imagename,w,h) 
{ 
document.open();
document.write('<img src="' + imagename + '" width="' + w + '" height="' + h + '" border="0" galleryimg="no">');
document.close();  
}

// Script to show the flash banner if the users browser supports flash 
function showflash(flashname,w,h) 
{ 
document.open();
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + w + '" height="' + h + '" id=ShockwaveFlash1>');
document.write('<param name="movie" value="' + flashname + '">');
document.write('<param name="quality" value="high">');
document.write('<embed src="' + flashname + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + w + '" height="' + h + '" align="absmiddle"></embed>');
document.write('</object>');
document.close();
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     validForm      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function validForm() {

	if (isWhitespace(document.frmContactUs.fname.value)) 
	{
	     alert("Please enter First Name");
	     document.frmContactUs.fname.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.lname.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmContactUs.lname.focus();
	     return false;
	}  

	if (isWhitespace(document.frmContactUs.address.value)) 
	{
	     alert("Please enter Address ");
	     document.frmContactUs.address.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.city.value)) 
	{
	     alert("Please enter City");
	     document.frmContactUs.city.focus();
	     return false;
	}  
	if ( (document.frmContactUs.state.options[document.frmContactUs.state.options.selectedIndex].value)=="0")
	{
	     alert("Please enter State");
	     document.frmContactUs.state.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.zip.value)) 
	{
	     alert("Please enter Zip");
	     document.frmContactUs.zip.focus();
	     return false;
	}  
	 if (validateZIP(document.frmContactUs.zip)==false) {
				document.frmContactUs.zip.focus();
				return false;
	} 
	
	if (!check3Phone( 'phone1', 'phone2', 'phone3', true )) return false;
	if (!check3Phone( 'fax1', 'fax2', 'fax3', false )) return false;
	
	if (isWhitespace(document.frmContactUs.email.value)) 
	{
	     alert("Please enter email ");
	     document.frmContactUs.email.focus();
	     return false;
	}  
	if (document.frmContactUs.email.value.length>0){ 
	var myEmail = NonSpace(document.frmContactUs.email.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmContactUs.email.focus();
			return false;
	}  
	}			

	if (isWhitespace(document.frmContactUs.comments.value)) 
	{
	     alert("Please enter Message ");
	     document.frmContactUs.comments.focus();
	     return false;
	}  
	
	if(document.frmContactUs.CAcademies && document.frmContactUs.CAcademies.selectedIndex == -1)
	{
		alert("Please select Academy(s)!");
		document.frmContactUs.CAcademies.focus();
		return false;
	}
	
	if (isWhitespace(document.frmContactUs.captcha.value)) 
	{
	     alert("Please enter Image Captcha");
	     document.frmContactUs.captcha.focus();
	     return false;
	}  
	
	return true;
}





//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     validQuickEnrollment      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function validQuickEnrollment() {

	if (isWhitespace(document.QuickEnrollmentFrm.fname.value)) 
	{
	     alert("Please enter First Name");
	     document.QuickEnrollmentFrm.fname.focus();
	     return false;
	}  
	if (isWhitespace(document.QuickEnrollmentFrm.lname.value)) 
	{
	     alert("Please enter Last Name");
	     document.QuickEnrollmentFrm.lname.focus();
	     return false;
	}  

	if (document.QuickEnrollmentFrm.month.options.selectedIndex==0) {
		 alert("Please select your birthday month");
	     document.QuickEnrollmentFrm.month.focus();
	     return false;
	}

	if (document.QuickEnrollmentFrm.year.options.selectedIndex==0) {
		 alert("Please select your birthday year");
	     document.QuickEnrollmentFrm.year.focus();
	     return false;
	}
	
	if (!check3Phone( 'QEphone1', 'QEphone2', 'QEphone3', true )) return false;
	
	if (isWhitespace(document.QuickEnrollmentFrm.email.value)) 
	{
	     alert("Please enter email ");
	     document.QuickEnrollmentFrm.email.focus();
	     return false;
	}  
	if (document.QuickEnrollmentFrm.email.value.length>0){ 
		var myEmail = NonSpace(document.QuickEnrollmentFrm.email.value);
		if (isEmail(myEmail)==false) {
				alert("Please enter a valid E-Mail address, like: name@companyname.com ");
				document.QuickEnrollmentFrm.email.focus();
				return false;
		}
	}
	
	if (document.QuickEnrollmentFrm.grade.options.selectedIndex==0) {
		 alert("Please select Last Grade Completed");
	     document.QuickEnrollmentFrm.grade.focus();
	     return false;
	}
	

	return true;
}





//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     validPartnerForm      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function validPartnerForm() {

	if (isWhitespace(document.frmContactUs.fname.value)) 
	{
	     alert("Please enter First Name");
	     document.frmContactUs.fname.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.lname.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmContactUs.lname.focus();
	     return false;
	}  

	if (isWhitespace(document.frmContactUs.address.value)) 
	{
	     alert("Please enter Address ");
	     document.frmContactUs.address.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.city.value)) 
	{
	     alert("Please enter City");
	     document.frmContactUs.city.focus();
	     return false;
	}  
	if ( (document.frmContactUs.state.options[document.frmContactUs.state.options.selectedIndex].value)=="0")
	{
	     alert("Please enter State");
	     document.frmContactUs.state.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.zip.value)) 
	{
	     alert("Please enter Zip");
	     document.frmContactUs.zip.focus();
	     return false;
	}  
	 if (validateZIP(document.frmContactUs.zip)==false) {
				document.frmContactUs.zip.focus();
				return false;
	} 
	
	if (!check3Phone( 'phone1', 'phone2', 'phone3', true )) return false;
	if (!check3Phone( 'fax1', 'fax2', 'fax3', false )) return false;
	
	if (isWhitespace(document.frmContactUs.email.value)) 
	{
	     alert("Please enter email ");
	     document.frmContactUs.email.focus();
	     return false;
	}  
	if (document.frmContactUs.email.value.length>0){ 
	var myEmail = NonSpace(document.frmContactUs.email.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmContactUs.email.focus();
			return false;
	}  
	}			

	if (isWhitespace(document.frmContactUs.comments.value)) 
	{
	     alert("Please enter Message ");
	     document.frmContactUs.comments.focus();
	     return false;
	}  
	
	if(document.frmContactUs.CAcademies && document.frmContactUs.CAcademies.selectedIndex == -1)
	{
		alert("Please select Academy(s)!");
		document.frmContactUs.CAcademies.focus();
		return false;
	}
	
	if (isWhitespace(document.frmContactUs.captcha.value)) 
	{
	     alert("Please enter Image Captcha");
	     document.frmContactUs.captcha.focus();
	     return false;
	}  
	
	 return true;
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     validAlumniForm      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function validAlumniForm() {

	if (isWhitespace(document.frmContactUs.fname.value)) 
	{
	     alert("Please enter First Name");
	     document.frmContactUs.fname.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.lname.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmContactUs.lname.focus();
	     return false;
	}  
	
	if ((document.frmContactUs.selGradYear.options[document.frmContactUs.selGradYear.options.selectedIndex].value)=="0")
	{
	     alert("Please select Graduation Year");
	     document.frmContactUs.selGradYear.focus();
	     return false;
	}  
	
	if (isWhitespace(document.frmContactUs.email.value)) 
	{
	     alert("Please enter email ");
	     document.frmContactUs.email.focus();
	     return false;
	}  
	if (document.frmContactUs.email.value.length>0){ 
	var myEmail = NonSpace(document.frmContactUs.email.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmContactUs.email.focus();
			return false;
	}  
	}			

	if (isWhitespace(document.frmContactUs.captcha.value)) 
	{
	     alert("Please enter Image Captcha");
	     document.frmContactUs.captcha.focus();
	     return false;
	}  
	
	return true;
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidEmail      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidEmail() {
	if (isWhitespace(document.myform.email.value)) 
	{
	     alert("Please enter Email ! ");
	     document.myform.email.focus();
	     return false;
	} 
	if (document.myform.email.value.length>0){ 
	var myEmail = NonSpace(document.myform.email.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.email.focus();
			return false;
	}  
	}		
	if (document.myform.email.value.length>0){ 
		document.myform.email.value = NonSpace(document.myform.email.value);
		myext = getEmail(document.myform.email.value);
		if (myext=="aol.com"){ 
				alert("Texans Can sincerely appreciates your interest in our Academy.\n\n Due to high turnover of Aol accounts, \n we would appreciate your entering another email address.");
			document.myform.email.focus();
			return false;
		}	
	}	
	if (document.myform.zip && (document.myform.zip.value != "zip code" && !isWhitespace(document.myform.zip.value))) { 
	 if (validateZIP(document.myform.zip)==false) {
				document.myform.zip.focus();
				return false;
	} 
	}
	document.myform.action ="e_newsletter.asp";
	document.myform.submit();
	return true;
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidEmailUns      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidEmailUns() {
	if (isWhitespace(document.frmUns.email.value)) 
	{
	     alert("Please enter Email ! ");
	     document.frmUns.email.focus();
	     return false;
	} 
	if (document.frmUns.email.value.length>0){ 

		var myEmail = NonSpace(document.frmUns.email.value);
		if (isEmail(myEmail)==false) {
				alert("Please enter a valid E-Mail address, like: name@companyname.com ");
				document.frmUns.email.focus();
				return false;
		}  
	}		
	return true;
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidEMailing      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidEMailing() {
	var radio_choice = false;
	if (isWhitespace(document.myform.MEmail.value)) 
	{
	     alert("Please enter Email ! ");
	     document.myform.MEmail.focus();
	     return false;
	} 
	if (document.myform.MEmail.value.length>0){ 
		var myEmail = NonSpace(document.myform.MEmail.value);
		if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.MEmail.focus();
			return false;
	}  
	}
	if (document.myform.MEmail.value.length>0){ 
		document.myform.MEmail.value = NonSpace(document.myform.MEmail.value);
		myext = getEmail(document.myform.MEmail.value);
		if (myext=="aol.com"){ 
				alert("Texans Can sincerely appreciates your interest in our Academy.\n\n Due to high turnover of Aol accounts, \n we would appreciate your entering another email address.");
			document.myform.MEmail.focus();
			return false;
		}	
	}	
	if (!isWhitespace(document.myform.MZip.value)) { 
	 if (validateZIP(document.myform.MZip)==false) {
				document.myform.MZip.focus();
				return false;
	} 
	}
	
	if (!check3Phone( 'phone1', 'phone2', 'phone3', false )) return false;
	
	if (document.myform.MLocationID){
		if (document.myform.MLocationID.checked==true)
		radio_choice = true; 

		for (counter = 0;  counter < document.myform.MLocationID.length; counter++)
		{
			if (document.myform.MLocationID[counter].checked)
			radio_choice = true; 
		}
	}
	if (!radio_choice)
	{
	     alert("Please check Version of Newsletter to Receive!");
		return (false);
	}	
	
	if (isWhitespace(document.myform.captcha.value)) 
	{
	     alert("Please enter Image Captcha");
	     document.myform.captcha.focus();
	     return false;
	}  
	
return true;

}


//________________________________________________________________________________________________
//_____________________      ValidEEmployment     _____________________________________________________________


function ValidEEmployment() {
	if (isWhitespace(document.myform.EmplResFName.value)) 
	{
	     alert("Please enter First Name  ");
	     document.myform.EmplResFName.focus();
	     return false;
	}
	if (isWhitespace(document.myform.EmplResLName.value)) 
	{
	     alert("Please enter Last Name  ");
	     document.myform.EmplResLName.focus();
	     return false;
	}
	if (isWhitespace(document.myform.EmplResAddress.value)) 
	{
	     alert("Please enter Address  ");
	     document.myform.EmplResAddress.focus();
	     return false;
	}
	if (isWhitespace(document.myform.EmplResCity.value)) 
	{
	     alert("Please enter City  ");
	     document.myform.EmplResCity.focus();
	     return false;
	}
	if (document.myform.EmplResState.value==0) 
	{
	     alert("Please enter State  ");
	     document.myform.EmplResState.focus();
	     return false;
	}
	if (isWhitespace(document.myform.EmplResZip.value)) {
		alert("Please enter Zip code  ");
	     document.myform.EmplResZip.focus(); 
		 return false;
	} 
	if (validateZIP(document.myform.EmplResZip)==false) {
		 document.myform.EmplResZip.focus();
		 return false;
	}
	
	if (!check3Phone( 'phone1', 'phone2', 'phone3', false )) return false;
	
	if (isWhitespace(document.myform.EmplResFile.value)) 
	{
	     alert("Please upload your Resume ");
	     document.myform.EmplResFile.focus();
	     return false;
	}
	
	return true;
}




//________________________________________________________________________________________________
//_____________________      gotoNewsletter    _________________________________________________________

function gotoNewsletter() { 
	document.myform.action = "NewsLetters.asp";
	document.myform.submit();
}


//________________________________________________________________________________________________
//_____________________      ValidMailing    _________________________________________________________

function ValidMailing() {

	if (isWhitespace(document.frmMailing.email.value)) 
	{
	     alert("Please enter Email ! ");
	     document.frmMailing.email.focus();
	     return false;
	} 
	if (document.frmMailing.email.value.length>0){ 
		var myEmail = NonSpace(document.frmMailing.email.value);
		if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmMailing.email.focus();
			return false;
		}  
	}		
	if (document.frmMailing.email.value.length>0){ 
		document.frmMailing.email.value = NonSpace(document.frmMailing.email.value);
		myext = getEmail(document.frmMailing.email.value);
		if (myext=="aol.com"){ 
				alert("Texans Can sincerely appreciates your interest in our Academy.\n\n Due to high turnover of Aol accounts, \n we would appreciate your entering another email address.");
			document.frmMailing.email.focus();
			return false;
		}	
	}	
	if ( (document.frmMailing.selDonation.options[document.frmMailing.selDonation.options.selectedIndex].value)=="0")	{
			alert("Please enter select one option!");
			document.frmMailing.selDonation.focus();
			return false;
	}

	 return true;
}




//________________________________________________________________________________________________
//_____________________      ValidVolunteer    _________________________________________________________

function ValidVolunteer() {

if (isWhitespace(document.myform.VolunteerFName.value)) 
	{
	     alert("Please enter First Name! ");
	     document.myform.VolunteerFName.focus();
	     return false;
	}
if (isWhitespace(document.myform.VolunteerLName.value)) 
	{
	     alert("Please enter Last Name! ");
	     document.myform.VolunteerLName.focus();
	     return false;
	}
if (isWhitespace(document.myform.VolunteerAddress.value)) 
	{
	     alert("Please enter Address! ");
	     document.myform.VolunteerAddress.focus();
	     return false;
	}

if (isWhitespace(document.myform.VolunteerCity.value)) 
	{
	     alert("Please enter City! ");
	     document.myform.VolunteerCity.focus();
	     return false;
	}
	if ( (document.myform.VolunteerStateID.options[document.myform.VolunteerStateID.options.selectedIndex].value)=="0")	{
			alert("Please enter State!");
			document.myform.VolunteerStateID.focus();
			return false;
	}

if (isWhitespace(document.myform.VolunteerZip.value)) 
	{
	     alert("Please enter Zip! ");
	     document.myform.VolunteerZip.focus();
	     return false;
	}

	if (!isWhitespace(document.myform.VolunteerZip.value)) { 
	 if (validateZIP(document.myform.VolunteerZip)==false) {
				document.myform.VolunteerZip.focus();
				return false;
	} 
	}
if (!check3Phone( 'phone1', 'phone2', 'phone3', true )) return false;
if (isWhitespace(document.myform.VolunteerEmail.value)) 
	{
	     alert("Please enter Email! ");
	     document.myform.VolunteerEmail.focus();
	     return false;
	}
	
if (!(isWhitespace(document.myform.VolunteerEmail.value))) {		
	 if (isEmail(document.myform.VolunteerEmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.VolunteerEmail.focus();
			return false;
	 }
	 }	

	if(document.myform.VolunteerAcademies.selectedIndex == -1)
	{
		alert("Please select Academy(s)!");
		document.myform.VolunteerAcademies.focus();
		return false;
	}
	
	if(document.myform.VolunteerInterest && !document.myform.VolunteerInterest[0])
	{
		if(!document.myform.VolunteerInterest.checked)
		{
			alert("Please select Interested in volunteering for!");
			document.myform.VolunteerInterest.focus();
			return false;
		}
	}
	else if(document.myform.VolunteerInterest && document.myform.VolunteerInterest[0])
	{
		var bChecked = false;
		
		for(i=0; i < document.myform.VolunteerInterest.length; i++)
		{
			if(document.myform.VolunteerInterest[i].checked) bChecked = true;
		}
		
		if(!bChecked)
		{
			alert("Please select Interested in volunteering for!");
			document.myform.VolunteerInterest[0].focus();
			return false;
		}
	}
	
	 return true;
}



//________________________________________________________________________________________________
//_____________________      NonSpace     _____________________________________________________________

function NonSpace(field) {

	var xpos =0;
	var xlen =field.length;
	var xpos1 =0;
	var xpos2 =xlen;

	for (var i=0; i < xlen; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == " ") {xpos++;}
		else {var xpos1=xpos;break;  }
	}
	field = field.substring(xpos1, xlen)
	var xlen1 = field.length;

	for (var i=0; i < xlen1; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp != " ") {xpos1++;}
		else {xpos2=i;break;  }
	}
	field = field.substring(0, xpos2)
	return field;
}


//________________________________________________________________________________________________
//_____________________      isEmail     _____________________________________________________________

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}




//________________________________________________________________________________________________
//_____________________      IsPhone     _____________________________________________________________

function IsPhone(str)          // is phone str valid
    {
    if (str.length != 12) 
              // nope - wrong str length
		{
		alert('Invalid PhoneNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
    {
    if (i == 3 || i == 7)
    {
      if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . PhoneNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
    {
      if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. PhoneNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}



//________________________________________________________________________________________________
//_____________________      IsFax     _____________________________________________________________

function IsFax(str)          // is Fax str valid
    {
    if (str.length != 12) 
              // nope - wrong str length
		{
		alert('Invalid FaxNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
    {
    if (i == 3 || i == 7)
    {
      if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . FaxNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
    {
      if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. FaxNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}



//________________________________________________________________________________________________
//_____________________      validateZIP     _____________________________________________________________

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.value.length!=5 && field.value.length!=10) {
alert("Please enter your 5 digit or ( 5 + 4 ) digit  ZIP  code.");
return false;
}
for (var i=0; i < field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your ZIP code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.value.length==10) && ""+field.value.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four  ZIP  code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}


//________________________________________________________________________________________________
//_____________________      isNum     _____________________________________________________________

function isNum(chr)            // is character a number?
  {
  if (chr < "0" || chr > "9")  // nope
    return false;
  else                         // yep
    return true;
  }


//________________________________________________________________________________________________
//_____________________      isNumber19     _____________________________________________________________

function isNumber19(InString)  {
        RefString="123456789";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only: 1 - 9 ");
				return false;
			}
		}
        return true;
}


//________________________________________________________________________________________________
//_____________________      isNumber09     _____________________________________________________________

function isNumber09(InString)  {
        RefString="0123456789";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only: 0 - 9 ");
				return false;
			}
		}
        return true;
}

//________________________________________________________________________________________________
//_____________________      isNumberZip     _____________________________________________________________

function isNumberZip(InString)  {
        RefString="0123456789-";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter a valid Zip Code! ");
				return false;
			}
		}
        return true;
}


//________________________________________________________________________________________________
//_____________________      ValidPercent     _____________________________________________________________

function ValidPercent(field)  {
        RefString="0123456789.";
        for (Count=0; Count < field.length; Count++)  {
            TempChar= field.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
						alert ("Please enter a valid percent (99.99 or a number <=100) !");
				return false;
			}
		}
		
	var xpos =0;
	var xlen =field.length;
	for (var i=0; i < xlen ; i++) {
		temp = field.substring(i, i+1);
		if (temp == ".") {xpos=i;}
	}

	if (xpos == 0) {var per=field;}
	else {var per =field.substring(0,xpos);}
	if (per > 100) {
			alert ("Please enter a valid percent (99.99 or a number <=100) !");
			return false; }
	else
		{ return true;}

}



//________________________________________________________________________________________________
//_____________________      getExtension     _____________________________________________________________

function getExtension(field) {
	var xpos =0;
	var xlen =field.length;
	for (var i=xlen; i > 0 ; i--) {
		temp = "" + field.substring(i, i-1);
		if (temp != ".") {xpos--;}
			else {break;
		}
	}
	var myext =field.substring(xlen+xpos, xlen).toLowerCase();
		if ((myext != "gif") && (myext != "jpg") && (myext != "jpeg") && (myext != "bmp") && (myext != "jpe") && (myext != "swf")){
				alert ("Please Upload an Image with GIF,JPEG,JPE,JPG,BMP or SWF extension !");
		return false; }
		else
		{ return true;}

}


//________________________________________________________________________________________________
//_____________________      getEmail     _____________________________________________________________

function getEmail(field) {
	var xpos =0;
	var xlen =field.length;
	for (var i=xlen; i > 0 ; i--) {
		temp = "" + field.substring(i, i-1);
		if (temp != "@") {xpos--;}
			else {break;
		}
	}
	var xx =field.substring(xlen+xpos, xlen).toLowerCase();
	return (xx);
}




//________________________________________________________________________________________________
//_____________________      warnEmpty     _____________________________________________________________

var reWhitespace = /^\s+$/
// warnEmpty (theField, s)             Notify user that required field theField is empty.


// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.

function warnEmpty (theField, s)
{   theField.focus()
    alert(mPrefix + s + mSuffix)
    return false
}


//________________________________________________________________________________________________
//_____________________      isEmpty     _____________________________________________________________

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



//________________________________________________________________________________________________
//_____________________      isWhitespace     _____________________________________________________________

function isWhitespace (s)

{   // Is s empty?
//    return (isEmpty(s));
    return (isEmpty(s) || reWhitespace.test(s));
}






function Start(page) {
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=550,height=250,top=50,left=50");
}



//---------------- valid phone ----------------
// VARIABLE DECLARATIONS

var digits = "0123456789";

// whitespace characters
var whitespace = " \t\n\r";

// decimal point character differs by language and culture
var decimalPointDelimiter = "."

// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-./ ";

// characters which are allowed in US phone numbers
var validUSPhoneChars = digits + phoneNumberDelimiters;

// U.S. phone numbers have 10 digits.
// They are formatted as 123-456-7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;

// CONSTANT STRING DECLARATIONS

// m = "missing"

var mPrefix = "You did not enter a value into the "
var mSuffix = " field. This is a required field. Please enter it now."

// s --- "string"

var sPhone = "Phone Number"

// i is an abbreviation for "invalid"
var iUSPhone = "This field must be a 10 digit U.S. phone number (like 415-555-1212). Please reenter it now."
// p is an abbreviation for "prompt"
var pEntryPrompt = "Please enter a "
var pUSPhone = "10 digit U.S. phone number (like 415-555-1212)."
var defaultEmptyOK = false

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}


function isUSPhoneNumber (s)
{   if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}

// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, pu focus in it, and return false.


function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}


function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "", 3, "-", 3, "-", 4))
}


function checkUSPhone (theField, emptyOK)
{   if (checkUSPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
       if (!isUSPhoneNumber(normalizedPhone, false)) 
          return warnInvalid (theField, iUSPhone);
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
          theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}


function isInt(chr)           
{
	if (isNaN(chr))
	{return false; }
	else
	  {
		if (chr>0)
		{ return true;	}
		else
		  { return false; }	  
	   }
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     isZip      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function validZIP(field) {
	var valid = "0123456789-";
	var hyphencount = 0;

	if (field.length!=5 && field.length!=10) {
		alert("Please enter your 5 digit or 5 digit+4 zip code.");
		return false;
	}
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1") {
				alert("Invalid characters in your zip code.  Please try again.");
		return false;
	}
	if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
		alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
		return false;
	}
}
return true;
}  





//	**************  3 fields input PHONE format *****************

function clearCharacters( oCtrl ) {
	oCtrl.value = oCtrl.value.replace(/\D/g,'');
}
function focusNext( oCtrl, NextCtrlID ) {
	if(oCtrl.value.length==3)
	{
		if (document.getElementById(NextCtrlID))
			document.getElementById(NextCtrlID).focus();
	}
}

function check3Phone( PhoneFieldID1, PhoneFieldID2, PhoneFieldID3, isRequired )
{
	
	if( (document.getElementById(PhoneFieldID1)) && (document.getElementById(PhoneFieldID2)) && (document.getElementById(PhoneFieldID3)) )
	{
		var PhoneField1 = document.getElementById(PhoneFieldID1);
		var PhoneField2 = document.getElementById(PhoneFieldID2);
		var PhoneField3 = document.getElementById(PhoneFieldID3);
		
		if ((PhoneField1.value.length > 0 ) || (PhoneField2.value.length > 0) || (PhoneField3.value.length > 0)) {
			
			if (PhoneField1.value.length < 3 ) {
				alert('This field must be a 3 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField1.focus();
				return false;
			}
			if (PhoneField2.value.length < 3) {
				alert('This field must be a 3 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField2.focus();
				return false;
			}
			if (PhoneField3.value.length < 4) {
				alert('This field must be a 4 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField3.focus();
				return false;
			}
		}
		else
		{
			if ( isRequired ) 
			{
				alert("Please enter Phone ");
				PhoneField1.focus();
				return false;
			}
		}
	}
	
	return true;
}


function changeMediaBox(obj, ref) {
	obj.checked = ref.value==0?false:true;
}

function changeMediaBoxById(obj, ref) {
	document.getElementById(obj).checked = ref.value==0?false:true;
}

function oldReports(oID)
{
	document.getElementById(oID).style.display = (document.getElementById(oID).style.display == "none") ? "block" : "none";
}

//------------- Car Form ------------------------------------------------------------------------------




function changeClass(Elem, myClass) 
{
	if(document.getElementById(Elem)){
		document.getElementById(Elem).className = myClass;
	}
}

function chkSameAddress(obj)
{
	if(obj.checked)
		changeClass('donationdiv','hideElem');
	else
		changeClass('donationdiv','showElem');
}	


//--------------------------CarInfoFrm-------------------------------------------------------------

function validateCarInfoFrm(myform) {
			
		var oForm = document.forms.CarInfoFrm;
			
		if (oForm.first.value.replace( / /g, "") == "")
		{
			alert("Please enter First Name !");
			oForm.first.focus();
			return false;
		}  
		if (oForm.last.value.replace( / /g, "") == "")
		{
			alert("Please enter Last Name !");
			oForm.last.focus();
			return false;
		}  
		oForm.Email.value = NonSpace(oForm.Email.value);
		if (oForm.Email.value.replace( / /g, "") == "")
		{
			alert("Please enter Email !");
			oForm.Email.focus();
			return false;
		}  

		if (oForm.Email.value != "" && !isEmail(oForm.Email.value)) {
			alert ("Please enter a valid Email Address !");
			oForm.Email.focus();
			return false;
		}
		if(oForm.Address.value.replace( / /g, "") == ""){
			alert("Please fill the Address field !");
			oForm.Address.focus();
			return false;
		}
		if(oForm.City.value.replace( / /g, "") == ""){
			alert("Please fill the City field !");
			oForm.City.focus();
			return false;
		}
		if(oForm.donorState.value.length<1){
			alert("Please select State !");
			oForm.donorState.focus();
			return false;
		}
		if(oForm.Zip.value==""){
			alert("Please fill the Zip field !");
			oForm.Zip.focus();
			return false;
		}
		if (!validZIP(oForm.Zip.value)) {
			oForm.Zip.focus();
			return false;
		}
		
		if (!check3Phone( 'Hphone1', 'Hphone2', 'Hphone3', false )) return false;
		if (!check3Phone( 'Wphone1', 'Wphone2', 'Wphone3', false )) return false;
		if ((oForm.Hphone1.value=="") && (oForm.Wphone1.value=="")){
			alert("Please provide at least one phone number!");
			oForm.Wphone1.focus();
			return false;
		}
		
		if ((oForm.SameD.checked) == false) {
		if (oForm.CarZip.value != "" && !validZIP(oForm.CarZip.value)) {
			oForm.CarZip.focus();
			return false;
		}
		}
		
		if(oForm.Make.value.length<1){
			alert("Please select Car Make !");
			oForm.Make.focus();
			return false;
		}
		if(oForm.Model && oForm.Model.value.length<1){
			alert("Please select Car Model field !");
			oForm.Model.focus();
			return false;
		}
		if(oForm.CarYear.value==""){
			alert("Please fill the Car Year field !");
			oForm.CarYear.focus();
			return false;
		}
		if (oForm.CarYear.value !="" && !checkYear(oForm.CarYear) ){
			oForm.CarYear.focus();
			return false;
		}
		crtDate = new Date();
		if (oForm.CarYear.value.length>0){ 
		if ((oForm.CarYear.value < 1950 )||(crtDate.getFullYear() < oForm.CarYear.value)) {
			    alert("Please provide a valid Year!");
				return false;
			}				
		}	
		if(oForm.CarColor.value.length<1){
		    alert("Please provide the Car Color!");
			oForm.CarColor.focus();
			return false;
		}
	return true;
}	



//-------------------------- Misc Donation Form -------------------------------------------------------------

function validateMiscDonatationFrm(myform) {
			
		var oForm = document.forms.MiscInfoFrm;
			
		if (oForm.first.value.replace( / /g, "") == "")
		{
			alert("Please fill in the First Name!");
			oForm.first.focus();
			return false;
		}  
		if (oForm.last.value.replace( / /g, "") == "")
		{
			alert("Please fill in the Last Name!");
			oForm.last.focus();
			return false;
		}  
		oForm.Email.value = NonSpace(oForm.Email.value);
		if (oForm.Email.value.replace( / /g, "") == "")
		{
			alert("Please fill in the Email!");
			oForm.Email.focus();
			return false;
		}  

		if (oForm.Email.value != "" && !isEmail(oForm.Email.value)) {
			alert ("Please enter a valid Email Address !");
			oForm.Email.focus();
			return false;
		}
		
		if(oForm.Address.value=="" || oForm.Address.value.replace( / /g, "")=="" || isWhitespace(oForm.Address.value) ){
			alert("Please fill in the Address!");
			oForm.Address.focus();
			return false;
		}
		
		if(oForm.City.value=="" || oForm.City.value.replace( / /g, "")=="" || isWhitespace(oForm.City.value) ){
			alert("Please fill in the City!");
			oForm.City.focus();
			return false;
		}
		
		if(oForm.donorState.value.length<1){
			alert("Please select the State!");
			oForm.donorState.focus();
			return false;
		}
		
		
		
		if(oForm.Zip.value=="" || oForm.Zip.value.replace( / /g, "")=="" || isWhitespace(oForm.Zip.value) ){
			alert("Please fill in the Zip!");
			oForm.Zip.focus();
			return false;
		}
		
		if (!isWhitespace(oForm.Zip.value) && !validZIP(oForm.Zip.value)) {
			oForm.Zip.focus();
			return false;
		}
				
		if (!check3Phone( 'Hphone1', 'Hphone2', 'Hphone3', false )) return false;
		if (!check3Phone( 'Wphone1', 'Wphone2', 'Wphone3', false )) return false;
		if ((oForm.Hphone1.value=="") && (oForm.Wphone1.value=="")){
			alert("Please provide at least one phone number!");
			oForm.Wphone1.focus();
			return false;
		}
		
		
		if (!isWhitespace(oForm.MiscZip.value) && !validZIP(oForm.MiscZip.value)) {
			oForm.MiscZip.focus();
			return false;
		}
		
		if(oForm.MiscItem.value=="" || oForm.MiscItem.value.replace( / /g, "")=="" || isWhitespace(oForm.MiscItem.value) ){
			alert("Please fill in the Name of Item(s)!");
			oForm.MiscItem.focus();
			return false;
		}
					
		
		
	return true;
}	


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidTaxr()      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidTaxr() {
	if (isWhitespace(document.myform.FName.value)) 
	{
			alert("Please enter First Name !");
			document.myform.FName.focus();
			return false;
	}	
	if (isWhitespace(document.myform.LName.value)) 
	{
			alert("Please enter Last Name !");
			document.myform.LName.focus();
			return false;
	}	
	if (isWhitespace(document.myform.StockNo1.value)) 
	{
			alert("Please enter Reference Number !");
			document.myform.StockNo1.focus();
			return false;
	}	
	if (!(isWhitespace(document.myform.StockNo1.value))){ 
		if (StockValidation(document.myform.StockNo1.value)==false) {
				document.myform.StockNo1.focus();
				return false;
		}	
	}	
	if (!(isWhitespace(document.myform.StockNo1.value))){ 
		if (document.myform.StockNo1.value.length != 2 && document.myform.StockNo1.value.length != 3) {
			    alert(" Please enter the Reference Number in the correct format. \n If you do not have the correct Reference Number, \n please contact us at 1-866-835-KIDS.");
				document.myform.StockNo1.focus();
				return false;
		}	
	}		
	if (isWhitespace(document.myform.StockNo2.value)) 
	{
			alert("Please enter Reference Number !");
			document.myform.StockNo2.focus();
			return false;
	}		
	if (!(isWhitespace(document.myform.StockNo2.value))){ 
		if (StockValidation(document.myform.StockNo2.value)==false) {
				document.myform.StockNo2.focus();
				return false;
		}	
	}		
	if (!(isWhitespace(document.myform.StockNo2.value))){ 
		if (document.myform.StockNo2.value.length <5 || document.myform.StockNo2.value.length >10 ) {
			    alert(" Please enter the Reference Number in the correct format. \n If you do not have the correct Reference Number, \n please contact us at 1-866-835-KIDS.");
				document.myform.StockNo2.focus();
				return false;
		}	
	}		
 }
 


function StockValidation(nString)  {
        var RefString="0123456789";
		var InString = nString;
	
        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
           
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only!");
				return false;
			}
		}
	    return true;
} 

function checkYear (theField, emptyOK)
{   if (checkYear.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isYear(theField.value, false)) 
       return warnInvalid (theField, iYear);
    
     var chkDate=new Date(Date())
     var sYear=chkDate.getFullYear()
    
    if (theField.value>sYear)
    
       return warnInvalid (theField, cYear);
       
    else return true;
}

function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}

//--------------year check------------------------------------------------------------------------
// isNonnegativeInteger (s [,eok])     True if string s is an integer >= 0.
var iYear = "This field must be a 4 digit year number.  Please reenter it now."
var pYear = "2 or 4 digit year number."
var cYear = "The year must be lesser than current year.  Please reenter it now."

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number >= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
} 



function isValidZIP(field) {
	var valid = "0123456789-";
	var hyphencount = 0;

	if (field.length!=5 && field.length!=10) return false;
	
	for (var i=0; i < field.length; i++)
	{
		temp = "" + field.substring(i, i+1);
		if (temp == "-") hyphencount++;
		if (valid.indexOf(temp) == "-1") return false;
		if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) return false;
	}
	return true;
} 

function checkLimit(iLimit, LimitedAreaID, CounterID, showAlert) {
	var oCounter = document.getElementById(CounterID);
	var oText = document.getElementById(LimitedAreaID);
	var prevCounter = iLimit - oCounter.value;
	oCounter.value = iLimit - oText.value.length;
	if(oCounter.value < 0){
		oCounter.value=0;
		if(showAlert){
			alert('The limit of ' + iLimit + ' characters is exceeded!');
		}
		oText.value = oText.value.substring(0,iLimit);
		return false;
	}
	return true;
}


/* weblog */


// ********** Update Value **********
function setText(oID, sValue)
{
	var obj = document.getElementById(oID)
	obj.innerHTML = sValue;
}

// ********** Update Value **********
function setCSS(oID, sValue)
{
	var obj = document.getElementById(oID)
	obj.className = sValue;
}


// ********** Open Section **********
function openSection(oID, bFlag)
{
	if(document.getElementById(oID))
	{
		if(bFlag)
			document.getElementById(oID).style.display = "block";
		else
			document.getElementById(oID).style.display = "none";
	}
	else
	{
		alert("Wrong section ID!")
	}
}

function isSectionOpen(oID)
{
	if(document.getElementById(oID))
	{
		return document.getElementById(oID).style.display == "block" ? true : false ;
	}
	else
	{
		alert("Wrong section ID!")
	}
}

function showAnswer(id)
{
	if(!id) return;
	var ind = id.replace(/qLabel/g, "");
	
	setText(id, isSectionOpen("aLabel" + ind) ? '<span class="lf weblog-sign">&nbsp;+</span>Question:&nbsp;&nbsp;' : '<span class="lf weblog-sign q-label-active">&nbsp;&#8722;</span><span class="q-label-active">Question:&nbsp;&nbsp;</span>');
	setCSS("qtext" + ind, isSectionOpen("aLabel" + ind) ? "" : "q-text-active")
	
	openSection("aLabel" + ind, !isSectionOpen("aLabel" + ind));
	openSection("aText" + ind, !isSectionOpen("aText" + ind));
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     doValidateWeblog      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function doValidateWeblog()
{
	var objForm = document.forms.frmWeblog;
	var objCurrent;
	
	objCurrent = objForm.txtQuestion;
	if(isWhitespace(objCurrent.value))
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter Question!");
	    objCurrent.focus();
	    return false;
	}
	else
	{
		changeClass(objCurrent.id,'formField');
	}
	
	objCurrent = objForm.captcha;
	if(isWhitespace(objCurrent.value))
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter Image Captcha!");
	    objCurrent.focus();
	    return false;
	}
	else
	{
		changeClass(objCurrent.id,'formField');
	}
	
	
	return true;
}


function checkWeblogLogin(domain)
{
	var objForm = document.forms.theForm;
	var objCurrent;
	
	var objCurrent = objForm.UserName;
	if(isWhitespace(objCurrent.value) || objCurrent.value == "account")
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter email account!");
	    objCurrent.focus();
	    return false;
	}
	else if(!isEmail(objCurrent.value + domain))
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter a valid email account!");
	    objCurrent.focus();
	    return false;
	}
	else
	{
		changeClass(objCurrent.id,'formField');
	}
	
	var objCurrent = objForm.UserPassword;
	if(isWhitespace(objCurrent.value) || objCurrent.value == "password")
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter password!");
	    objCurrent.focus();
	    return false;
	}
	else
	{
		changeClass(objCurrent.id,'formField');
	}
	
	return true;
}


function checkWeblogForgotPassword(domain)
{
	var objForm = document.forms.theForm;
	var objCurrent;
	
	var objCurrent = objForm.UserName;
	if(isWhitespace(objCurrent.value) || objCurrent.value == "account")
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter email account!");
	    objCurrent.focus();
	    return false;
	}
	else if(!isEmail(objCurrent.value + domain))
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter a valid email account!");
	    objCurrent.focus();
	    return false;
	}
	else
	{
		changeClass(objCurrent.id,'formField');
	}
	
	return true;
}




function checkWeblogCreateAccount(domain)
{
	var objForm = document.forms.theForm;
	var objCurrent, objSiblingCurrent;
	
	objCurrent = objForm.UserName;
	objCurrent.value = stripWhiteChars(objCurrent.value);
			
	if(isWhitespace(objCurrent.value))
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter email account!");
	    objCurrent.focus();
	    return false;
	}
	else if(!isEmail(objCurrent.value + domain))
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter a valid email account!");
	    objCurrent.focus();
	    return false;
	}
	else
	{
		changeClass(objCurrent.id,'formField');
	}
	
	
	return true;
}


function checkWeblogCompleteAccount(domain)
{
	var objForm = document.forms.theForm;
	var objCurrent, objSiblingCurrent;
	
		
	objCurrent = objForm.UserPassword;
	objSiblingCurrent = objForm.ConfirmPassword;
	
	objCurrent.value = stripWhiteChars(objCurrent.value);
	objSiblingCurrent.value = stripWhiteChars(objSiblingCurrent.value);
	
		
	if(isWhitespace(objCurrent.value))
	{
		changeClass(objCurrent.id,'errformField');
		alert("Please enter password!");
		objCurrent.focus();
		return false;
	}
	else if(objCurrent.value.length < 4) 
	{
		changeClass(objCurrent.id,'errformField');
		alert("Password minimum lenght must be 4 characters!");
		objCurrent.focus();
		return false;
	}	
	else if(isWhitespace(objSiblingCurrent.value))
	{
		changeClass(objSiblingCurrent.id,'errformField');
		alert("Please confirm password!");
		objSiblingCurrent.focus();
		return false;
	}
	else if(objCurrent.value != objSiblingCurrent.value)
	{
		changeClass(objSiblingCurrent.id,'errformField');
		alert("Passwords don't match! Please re-enter!");
		objSiblingCurrent.focus();
		return false;
	}
	else
	{
		changeClass(objCurrent.id, 'formField');
		changeClass(objSiblingCurrent.id, 'formField');
	}
	
	return true;
}



function setFocus(input)
{
	setTimeout("eval('document.forms[0].' + '" + input + "').focus()", 200);
}

function stripWhiteChars(str)
{
    if(!str || typeof str != 'string')
        return '';

    return str.replace(/\s/g,'');
}

/* end weblog */



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      Function Paging() - Paging Buttons    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function Paging(oVal)
{
	var oForm = document.forms[0];
	 
	oForm.crtPage.value = oVal;
	oForm.submit();
}




//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      Function Grouping() - Next / Previous Paging Buttons     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function Grouping(oParam, oVal)
{
	var oForm = document.forms[0];
	
	if (oParam)	 // Next
		oForm.crtGroup.value = parseInt(eval(oForm).crtGroup.value) + 1;
	else	 // Previous
		oForm.crtGroup.value = parseInt(eval(oForm).crtGroup.value) - 1;
		
	oForm.crtPage.value = oVal;
	oForm.submit();
}


//~~~~~~~      resetMultipleCombo      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function resetMultipleCombo(oSelect)
{
	if(oSelect.selectedIndex == 0 || oSelect.selectedIndex == -1) oSelect.selectedIndex = 0;
}




