// JavaScript Document

//### toggleSeminarDiv( divID )
//##
//#   show/hide div containing seminars
function autoLoadSeminars(){

	//##make the address into a string
	var loc = ''+window.location+'';
	
	if( loc.indexOf( 'find-seminar.aspx' ) == -1 ){ return; } //###we're not on the right page, so leave this block
	
	//##test is said string contains the query string we want [passed back from the CANCEL button of the reg form]
	//##if so, get the query string and make the HttpRequest
	if( loc.indexOf( 'lng' ) != -1 ){
		
		var query_string = loc.substring( loc.indexOf( '?' )+1 );		
		var zip = query_string.substring( query_string.indexOf( 'zip=' )+4, query_string.indexOf( '&distance' ) );
		var address = 'zip_locator_app.aspx?'+query_string;
	
		document.Form1.user_zip.value = zip;
		xmlRequest( address, 'locations_list' );

	}
	
	
}

//### then run the function duh




//### toggleSeminarDiv( divID )
//##
//#   show/hide div containing seminars
function toggleSeminarDiv( divID ){
//	try{
//		if( document.getElementById( divID ).style.display == 'none' ){
//			
//			closeAllSeminars()
//			document.getElementById( divID ).style.display = 'block'
//			
//		}else{
//			
//			closeAllSeminars()
//			
//		}
//	}catch(e){}
}


//### closeAllSeminars()
//##
//#   hide all seminar divs
function closeAllSeminars(){
//	try{
//	
//		var i = 0;
//		while( 1 == 1 ){ //#using an infinite loop
//			
//			document.getElementById( 'div_'+i ).style.display = 'none';
//			i++;
//			
//		}
//	
//	}catch(e){ //#when she throws the exception, change the inner HTML of toggle_div and kick out of the routine
//		
//		document.getElementById('toggle_div').innerHTML = "";
//		document.getElementById('toggle_div').innerHTML = '<a href="#" onclick=" expandAllSeminars(); return false; ">Expand All Locations</a>';
//	
//		return; 
//	}
}


//### expandAllSeminars()
//##
//#   show/expand all locations to show off shiney seminars!!
function expandAllSeminars(){
//	try{
//	
//		var i = 0;
//		while( 1 == 1 ){ //#some people may oppose this way of thinking. 
//			
//			document.getElementById( 'div_'+i ).style.display = 'block';
//			i++;
//			
//		}
//		
//	}catch(e){ //#change the inner HTML of toggle_div and exit the routine
//	
//		document.getElementById('toggle_div').innerHTML = "";
//		document.getElementById('toggle_div').innerHTML = '<a href="#" onclick=" closeAllSeminars(); return false; ">Collapse All Locations</a>';
//		return; 
//		
//	}
}


//### expandAllSeminars()
//##
//#   show/expand all locations to show off shiney seminars!!
function goBackToLocations(){
	
	var loc = ''+window.location+'';
	var query_string = loc.substring( loc.indexOf( '?' )+1 );
	window.location = 'find-seminar.aspx?'+query_string
	
}


//painfully extracts non-numeric values from field.
function filterNumber( oTarget ){
	oTarget.value = oTarget.value.replace( /[^0-9]/g, '' );
}





function isItFive( oTarget ){

	
	//document.forms[0]['list_reps'].focus();
	if( oTarget.value.length == 5 ){
		
		
		document.getElementById('zip_tr').style.display = 'none';
		document.getElementById('zip_error').innerHTML = '';
		document.getElementById('locations_list').innerHTML = 'Searching...';
		processAddress( oTarget.form )
		
	}else{
		
		document.getElementById('zip_tr').style.display = '';
		document.getElementById('zip_error').style.display = 'block';
		document.getElementById('zip_error').innerHTML = "The zip code entered must be 5 digits.";
		oTarget.select();
		
	}
	
}


function checkEnter(e){ //e is event object passed from function invocation
	
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)

		isItFive( getObject('user_zip') );

	}
	else{
		return false;
	}

}


function getObject( ID ){

	return document.getElementById(ID);
	
}

	