﻿
<!--
//----------------------------------------------------------------------------------------------------------
function rp_Test() 
{
  alert("Test");
}
//----------------------------------------------------------------------------------------------------------
function rp_Test2() 
{
	var oSpan = document.getElementById("SpanTX");
	
	document.getElementById( oSpan.innerHTML ).style.visibility="hidden";
  alert(oSpan.innerHTML);
}
//----------------------------------------------------------------------------------------------------------
function rp_WordCheckFeedback_js() 
{
 document.getElementById("Label_Checking_ID").style.visibility="visible";
 document.getElementById("Label_CheckFor_ID").style.visibility="hidden";
}

//----------------------------------------------------------------------------------------------------------
function rp_GetRoot_js() 
{
	var sRoot = "/";
	var oForm = document.forms["aspnetForm"]; //aspx required form
	
	if ( oForm != null ) 
	{
		var oHiddenField = document.getElementById("HiddenField_Root_ID");
	
		if ( oHiddenField != null )
			sRoot = oHiddenField.value;
	}
	
	return sRoot;
}
//----------------------------------------------------------------------------------------------------------
function rp_AutoClick_js() 
{
	var oForm = document.forms["aspnetForm"]; //aspx required form
	
	if ( oForm != null ) 
		oForm.submit();
}
//----------------------------------------------------------------------------------------------------------
// Trick, for Firefox compatibilty wiht event handling
//						specify handler as in onkeypress="rp_keypress_js(event);"
//						and defind function as function rp_keypress_js(e) 
//				This is required because window.event is not defined for firefox/opera/safari 
//				Also key is found in e.which 
//----------------------------------------------------------------------------------------------------------
function rp_keypress_js( e ) 
{
	var IE_LB    = ( window.event != null );
	var FF_LB    = ( e.which != null );
	var HexKeyLI = ( IE_LB ? e.keyCode : ( FF_LB ? e.which : 0x00 ) ); // alert( String.fromCharCode( HexKeyLI ) );

	if ( HexKeyLI == 0x0D )
	{
		if ( IE_LB )
		{                        // alert( "Return Key"  ); 
			 e.keyCode = 0x33;
			 e.returnValue = false; // default action cancelled 
			 e.cancelBubble = true; // don't bubble up to other evnet handlers
		}
			
		if ( FF_LB )
		{	                      // alert( "Return Key in Firefox"  ); 
														// e.which cannot be set
			 e.preventDefault();  // default action cancelled 
			 e.stopPropagation(); // don't bubble up to other evnet handlers
		}	
	}
	return HexKeyLI;
}

//----------------------------------------------------------------------------------------------------------
function rp_keypressToClick_js( e ) // If possible, clich the button for the user on carrage return
{
	if ( 0x0D == rp_keypress_js( e ) )			
		rp_AutoClick_js(); 
}

//----------------------------------------------------------------------------------------------------------
function rp_mouseover_js( sElementID, sImagePath ) 
{
  document.images[ sElementID ].src = sImagePath;
}

//- County List Box Fn -------------------------------------------------------------------------------------
function rp_ListBox_County_js( bAtRoot ) 
{	
	//var sRoot		= "../";
	
//	if ( bAtRoot )   
//		sRoot = "";

	var sRoot = rp_GetRoot_js();

	var oBox  = document.getElementById("CntyListBox_ID")
	
	var sText = oBox.options[oBox.selectedIndex].text;	
		
		if ( sText != "Pennsylvania Counties" )
	window.location = sRoot + "PA-Genealogy-and-History/County.aspx?co=" + sText;
}

//- County List Box Fn -------------------------------------------------------------------------------------
function rp_ListBox_Military_js() 
{
	var oBox  = document.getElementById("MilListBox_ID" );

	var sDisc = oBox.options[oBox.selectedIndex].value;	
	
	if ( sDisc != "0" )
		window.location = "docs_new/disc.aspx?disc=" + sDisc;
}

//- County List Box Fn -------------------------------------------------------------------------------------
function rp_ListBox_Inventory_js() 
{
	var oBox  = document.getElementById("ICAListBox_ID" );

	var sDisc = oBox.options[oBox.selectedIndex].value;	
	
	if ( sDisc != "0" )
		window.location = "docs_new/disc.aspx?disc=" + sDisc;
}

//- County List Box Fn -------------------------------------------------------------------------------------
function rp_ListBox_Archives_js() 
{
	var oBox  = document.getElementById( "PAAListBox_ID" );
	
	var sDisc = oBox.options[oBox.selectedIndex].value;	
	
	if ( sDisc != "0" )
		window.location = "docs_new/disc.aspx?disc=" + sDisc;
}

//- County List Box Fn -------------------------------------------------------------------------------------
function rp_ListBox_Favorite_js() 
{
	var oListBox = document.getElementById("SelectCounty_ID");
	var oTextBox;

	if ( ( oListBox != null ) 
		&& ( oListBox.options[ oListBox.selectedIndex ].text != "List of Pennsylvania Counties" )  ) 
	{
		if ( document.getElementById("InputCounty1_ID").value == "" ) 
			oTextBox  = document.getElementById("InputCounty1_ID");
		else 
			if ( document.getElementById("InputCounty2_ID").value == "" ) 
				oTextBox  = document.getElementById("InputCounty2_ID");
			else
				if ( document.getElementById("InputCounty3_ID").value == "" ) 
					oTextBox  = document.getElementById("InputCounty3_ID");
				else
					if ( document.getElementById("InputCounty4_ID").value == "" ) 
						oTextBox  = document.getElementById("InputCounty4_ID");
					else		
						oTextBox  = document.getElementById("InputCounty5_ID");
									
		oTextBox.value = oListBox.options[ oListBox.selectedIndex ].text;			
	}
	
	rp_EnableSubmit_Favorite_js(); // onchange in the input=text element won't fire when value changed programattically
}
//----------------------------------------------------------------------------------------------------------
function rp_ShowPrivacyPolicy_js() 
{
	window.alert("Any personal information you provide will be kept strictly confidential. It will only be used by us to advise you of product offerings in your areas of interest.");
}

//----------------------------------------------------------------------------------------------------------
function valid_Favorite_County_js() 
{
	return 	( document.getElementById("InputCounty1_ID").value != "" ) 
			||	( document.getElementById("InputCounty2_ID").value != "" ) 
			||	( document.getElementById("InputCounty3_ID").value != "" ) 
			||	( document.getElementById("InputCounty4_ID").value != "" ) 
			||	( document.getElementById("InputCounty5_ID").value != "" );
}

//----------------------------------------------------------------------------------------------------------
function valid_Favorite_Contact_js() 
{
	if ( document.getElementById("RadioEMail_ID").checked )
	{
		return ( document.getElementById("TextEMail_ID").value != "" );
	}
	else
	{
		return 	( document.getElementById("TextAddress_ID").value != "" ) 
				&&	( document.getElementById("TextCity_ID").value != "" ) 
				&&	( document.getElementById("TextState_ID").value != "" ) 
				&&	( document.getElementById("TextZip_ID").value != "" );
	}
}

// Trick - Client Script in ASP.NET Web Pages, section Identifying Server Controls in Client Script
//		Note  If your client script references a child control, get the child control's ClientID 
//				property and build it into your dynamic script.
//----------------------------------------------------------------------------------------------------------
function rp_EnableSubmit_Favorite_js() 
{
	var oForm = document.forms["aspnetForm"];             // aspx required form, some elements must be accessed via form
	var oHide = document.getElementById("HiddenTX_ID");   // hidden field with ID specified via Page.ClientScript.RegisterHiddenField
		
	var sButtonID = oForm.HiddenTX_ID.value;              // encoded ClientID of Button stored in hidden field
	var oElement = oForm.elements( sButtonID );           // Button object
  
 oElement.disabled = !valid_Favorite_County_js() || !valid_Favorite_Contact_js();  // see INPUT type=button Element | input type=button Object for possibilites
}

//----------------------------------------------------------------------------------------------------------
function rp_validchars_js( bUseZero, sCode, iCount ) 
{
	var sChars  = "";	
	var iLength = sCode.length;
	var bSpace  = false;
	
	if ( sCode.length < iCount )
		iLength = iCount;
	
	var cChar;
	
 	for ( CharCI = 0; CharCI < iLength; CharCI ++ )
	{			
		cChar = sCode.charAt( CharCI );
	
		switch ( cChar )
		{
			case('1'):
			case('2'):
			case('3'):
			case('4'):
			case('5'):
			case('6'):
			case('7'):
			case('8'):
			case('9'):
			case('A'):
			case('B'):			
			case('C'):	
			case('D'):			
			case('E'):
			case('F'):
					break;			
			case('X'):	
				if ( bUseZero )
						sChars = sChars + cChar;
					break;	
			case('0'):	
				if ( !bUseZero )
						sChars = sChars + cChar;									
					break;	
			case(' '):					
					bSpace = true; 
					break;					
			default:
				sChars = sChars + cChar;
				break;		
		}
	 }
	 
	var sErrors = "";
	var iIndex  = -1;

	// assemble the character list into a string
	for ( CharCI = 0; CharCI < sChars.length; CharCI ++ )
	{			
		if ( sErrors.indexOf( sChars.charAt( CharCI ) ) < 0 )				// add only once
		{
			if ( CharCI > 0 )                                   
				sErrors = sErrors + ", or ";														// put "or" between characters
	
			sErrors = sErrors + '"' + sChars.charAt( CharCI ) + '"';	// put quotes around characters
		}
	}
	
	if ( bSpace )																									// put "space" at end
	{
		if ( sErrors.length > 0 )
			sErrors = sErrors + ", or a space";
		else
			sErrors = "a space";
	}

	return sErrors;
}

// See Page.Validators and ValidatorCollection for info
//     see also replaceChild, replaceNode, insertBefore, appendChlid, createElement
//----------------------------------------------------------------------------------------------------------
function rp_ClientValidate_AuthQury_js( oSrc, args, sName, iLong, slong, bUseZero, sLabelID ) 
{
	var sEntry = String( args.Value );
	var sCount = "";
	var sChars = "";	
	var oLabel = document.getElementById(sLabelID);
	
	sEntry = sEntry.toUpperCase();
	
	if ( sEntry.length < iLong )
		  sCount = "A " + sName + " has " + slong + " characters.  The entry above has too few."; 
	 
	 sChars = rp_validchars_js( bUseZero, sEntry, iLong ); 
	 
	if ( sChars.length > 0 ) 
	{
		oLabel.style.visibility="visible";
		oLabel.innerHTML = "A " + sName + " will not contain:  " + sChars + ".  Please double check the number and try again";

		args.IsValid = false; 
	}
	else
	{
		if ( sCount.length > 0 )
		{
			oLabel.style.visibility="visible";
			oLabel.innerHTML = sCount;
			
			args.IsValid = false; 
		}
		else
		{
		args.IsValid = true; 
		oLabel.style.visibility="hidden"; //double check first
		}
	}
}

// See Page.Validators and ValidatorCollection for info
//     see also replaceChild, replaceNode, insertBefore, appendChlid, createElement
//----------------------------------------------------------------------------------------------------------
function rp_ClientValidate_AuthQuryRegNum_js( oSrc, args ) 
{
	rp_ClientValidate_AuthQury_js( oSrc, args, "registration number", 8, "eight", false, "ValMssgRegNum_b" );
}

//----------------------------------------------------------------------------------------------------------
function rp_ClientValidate_AuthQuryIDNumber_js( oSrc, args ) 
{
	rp_ClientValidate_AuthQury_js( oSrc, args, "ID number", 4, "four", true, "ValMssgIDNum_b");
}

//----------------------------------------------------------------------------------------------------------
function rp_OpenHelpRequest_js( sErrorNo, sRegNumber, sIDNumber ) 
{
	var oSubject    = '';
	var oCommand    = 'mailto:';
	var oCompany    = 'RetrospectPublishing';
	var oDomainType = '.com';
	var oAddress    = "cdhelp" + "@" + oCompany + oDomainType;
	var oViewAddr   = "cdhelp " + "@" + ' Retrospect Publishing . com';
	var oBodySufx   = "for%20Registration%20Number:%20" + sRegNumber + ",%20and%20ID%20Number:%20" + sIDNumber + "%20";
	//-- Authorization Errors
	switch( sErrorNo )
	{
		case("106"):
			oSubject = "?subject=Authorization%20Attempt&amp;body=Condition:%20A106%20";
			break;
		case("107"):
			oSubject = "?subject=Authorization%20Attempt&amp;body=Condition:%20A107%20";
			break;		
		case("108"):
			oSubject = "?subject=Authorization%20Failure&amp;body=Condition:%20A108%20";
			break;			
		case("109"):
			oSubject = "?subject=Authorization%20Failure&amp;body=Condition:%20A109%20";
			break;	
		case("110"):
			oSubject = "?subject=Authorization%20Attempt&amp;body=Condition:%20A110%20";
			break;		
		case("111"):
			oSubject = "?subject=Authorization%20Attempt&amp;body=Condition:%20A111%20";
			break;									
	}
			
	document.write( '<p><a href="' + oCommand + oAddress + oSubject + oBodySufx +'">' + oViewAddr + '</a></p>');
}

//----------------------------------------------------------------------------------------------------------
function rp_anchor_js( sMailBox, sBrowserText, sMssgType ) 
{
	var oText       = '';
	var oSubject    = '';
	var oCommand    = 'mailto:';
	var oCompany    = 'RetrospectPublishing';
	var oDomainType = '.com';
	var oAddress    = "cdhelp" + "@" + oCompany + oDomainType;
	var oViewAddr   = "cdhelp " + "@" + ' Retrospect Publishing . com';

	switch( sMssgType )
	{
		case("Catalog"):
			oSubject = "?subject=Catalog%20Request&body=Please%20send%20a%20catalog%20to%20me%20at%20the%20address%20below.%0D%0A%0D%0AName:%20%0D%0AAddress:%20%0D%0ACity:%20%0D%0AState:%0D%0AZip:%20";
			break;
		case("News"):
			oSubject = "?subject=Newsletter%20Request&body=Please%20send%20the%20free%20newsletter%20to%20me%20at%20the%20address%20below.%0D%0A%0D%0AE-Mail:%20";
			break;		
		case("Book"):
			oSubject = "?subject=Book%20Suggestion&body=Please%20consider%20publishing%20the%20following%20book.%0D%0A%0D%0ABook%20Title:%20%0D%0APA%20County:%20%0D%0A(Optional)%20My%20name:%20";
			break;			
		case("Trouble"):
			oSubject = "?subject=Trouble Report&amp;body=( Note: Please identify the CD-ROM you are using and include a description of the problem and your computer system. )";
			break;	
		case("WordFind"):
			oSubject = "?subject=Word Check Feedback&amp;body=I tried the Word Check feature on you website, and this is my reaction:";
			break;		
		case("WebError"):
			oSubject = "?subject=Difficulty with Website&amp;body=I was directed to the website error page when I tried to:";
			break;		
		case("Purchase"):
			oSubject = "?subject=Need Help With Purchase&amp;body= Please let us know how we can help:";
			break;									
	}
			
	if ( sBrowserText == "Addr" )
		oText = oViewAddr;
	else  
		oText = sBrowserText;
		
	document.write( '<a href="' + oCommand + oAddress + oSubject +'">' + oText + '</a>');
}

//----------------------------------------------------------------------------------------------------------
//-->
