
/*
Brazil - 		Montevideo@sivananda.org
NeyyarDam- 		YogaIndia@sivananda.org
Nassau - 		Nassau@sivananda.org
Reith, tyrol - 	tyrol@sivananda.org
Netala - 		Delhi@sivananda.org
England - 		London@sivananda.org
GrassValley - 	YogaFarm@sivananda.org
Luthivania - 	Berlin@sivananda.org
WoodBourne - 	YogaRanch@sivanada.org
ValMorin - 		Hqaccounts@sivananda.org
Orleans - 		Orleans@sivananda.org
Spain - 		Madrid@sivananda.org
Austria - 		tyrol@sivananda.org
Madurai - 		YogaIndia@sivananda.org
*/

// a null location
var nolocation	= new Location ( "", "", "" );

/**
  HOW TO ADD A NEW LOCATION:
  
  Step 1.
  ----------
  Copy the below example line as a template to add the new location.
  var location_symbolname	= new Location ( "My City, My Country", "/url/path/to/website/information", "location_email@sivananda.org" );
  
  Step 2.
  ----------
  Paste the line into the list below, and change the placeholders to appropriate names/values:
   - location_symbolname should be changed to a *unique* new name for the location, refer to the list below to see how this is done.
   - "My City, My Country" will appear on the Course Schedule page. Replace with the town/region and country where the course is being provided.
   - "/url/path/to/website/information" - this is the url that will provide a link to the course information page on the provider's website.
   - "location_email@sivananda.org" is the contact email where registrations will be sent to, and also where visitors can enquire.
  
    var taiwan	= new Location ( "Kiao Sung, Taiwan", "/farm", "yogafarm@sivananda.org" );

  Step 3.
  ----------
  Ensure that the grammar and syntax are precise. Comma's, quotation-marks and parentheses are used by the program interpreter
  and errors may occur if any are missing or unnecessarily duplicated. Also ensure that capitalization (i.e. case-sensitivity)
  is preserved as in the example template, and the existing listings.
  Whitespace is ignored, so there is no need to be concerned about extra space between words.
  
  Step 4.
  ----------
  Save this file. The token "location_symbolname" which has been replaced/renamed is the connection to the course in the
  course listings data file. Use this name as the key to link the course to the location information here.
  For example:
  
  var camp	= new Location ( "Val Morin, Canada", "/camp/",	"registrations@sivananda.org" );	
  
  Here, "camp" is the location_symbolname. Below in the example it is used as the key location name for the course:
		# Start course data
		COURSE_SESSION_LOCATION:	camp
		COURSE_SESSION_TITLE:		TTC 
		COURSE_SESSION_DATE_BEGIN:	Sep 6
		COURSE_SESSION_DATE_END:	Oct 3
		COURSE_SESSION_YEAR:		2009
		COURSE_SESSION_LANGUAGES:	English 
		# dollar=$ pound=£ euro=¤	
		COURSE_SESSION_CURRENCY:	$
		COURSE_SESSION_TENTPRICE:	2400
		COURSE_SESSION_DORMPRICE:	2960
		COURSE_SESSION_SHAREDPRICE:	
		COURSE_SESSION_DOUBLEPRICE:	
		COURSE_SESSION_SINGLEPRICE:	3675
		COURSE_SESSION_FORM:		GenericForm
		COURSE_SESSION_FORM_LANG:	en
  
  Other course values can be edited as necessary.
  
 */



/* Section for Location Objects - set these after the Location() function above */ 
var camp			= new Location ( "Val Morin, Canada",		   	"/camp/",										"yogacampregistrations@sivananda.org" );	
var dorset	  		= new Location ( "England",		 				"/ttceurope/",									"London@sivananda.org" );
var farm			= new Location ( "Grass Valley, California",	"/farm/",										"yogafarmttc@gmail.com" );
var ranch	   		= new Location ( "Woodbourne, NY, USA",		 	"/ranch/",										"YogaRanch@sivananda.org" );
var meissen	 		= new Location ( "Meissen, Germany",			"/ttceurope/",									"berlin@sivananda.org" );
var nassau	  		= new Location ( "Nassau, Bahamas",			 	"/nassau/",										"nassau@sivananda.org" ); 
var bahamas	  		= new Location ( "Nassau, Bahamas",			 	"/nassau/",										"nassau@sivananda.org" ); 
var orleans	 		= new Location ( "Orleans, France",			 	"/orleans/",									"orleans@sivananda.org" );
var reith_home	 	= new Location ( "Reith, Tyrol, Austria",	   	"/tyrol/",										"tyrol@sivananda.org" );
var reith	   		= new Location ( "Reith, Tyrol, Austria",	   	"/tyrol/en/yoga-teachers-training.html", 		"tyrol@sivananda.org" );
var reith_attc		= new Location ( "Reith, Tyrol, Austria",	   	"/tyrol/en/yoga-advanced-teacher.html", 		"tyrol@sivananda.org" );
var ecuador			= new Location ( "Vilcabamaba, Ecuador",		"/camp/",										"registrations@sivananda.org" );
var europe			= new Location ( "European Website",		"/europe/",										"tyrol@sivananda.org" );


var mittersill  	= new Location ( "Mittersill, Austria",		 	"/tyrol/",										"tyrol@sivananda.org" );
var spain	   		= new Location ( "Spain",					   	"http://www.sivananda.org/madrid","madrid@sivananda.org" );
var cuenca	  		= new Location ( "Spain",		   				"/madrid/yoga-teacher-training/introduction_en.html","madrid@sivananda.org" );
var uruguay	 		= new Location ( "Uruguay",					 	"/montevideo/",									"montevideo@sivananda.org" );
var garopaba		= new Location ( "Brasil&#134;",	  		  	"http://www.sivananda.org.ar/index.php/component/acymailing/archive/view/mailid-74",	"montevideo@sivananda.org" );
var garopaba_attc	= new Location ( "Brasil&#134;",	  			"http://www.sivananda.org.ar/index.php/component/acymailing/archive/view/mailid-76",	"montevideo@sivananda.org" );
var santillana  	= new Location ( "Spain", 						"/madrid/yoga-teacher-training/introduction_en.html",				"madrid@sivananda.org" );
var lithuania 		= new Location ( "Palanga, Lithuania", 			"/ttceurope/",									"berlin@sivananda.org" );
var austria	 		= new Location ( "Austria",				 		"/ayurveda-europe",								"tyrol@sivananda.org" );
var poland	 		= new Location ( "Poland", 						"http://www.sivananda.eu/en/yoga-teacher-training/teachers-training-course/ttc-venues/osteuropa.html#c2509",									"berlin@sivananda.net" );
var poland_attc = new Location ( "Poland", 						"http://www.sivananda.eu/en/yoga-teacher-training/advanced-teachers-training-course/attc-venues/attc-poland.html",									"berlin@sivananda.net" );
var merlo			= new Location ("Merlo, Argentina",				"http://www.sivananda.org.ar/index.php/component/acymailing/archive/view/mailid-44",		"buenosaires@sivananda.org");			   			
var vietnam			= new Location ("Vietnam",						"/farm/",											"sivanandayogavietnam@gmail.com");			   			
var thailand			= new Location ("Thailand",						"/thailand/",											"yogacampregistrations@sivananda.org");			   			
var medellin		= new Location ( "Colombia",	  		  	"http://www.sivananda.org.uy/index.php/component/acymailing/archive/view/listid-3-mailing-montevideo-2011/mailid-87",	"montevideo@sivananda.org" );



var london	  		= new Location ("London, England",			  	"/london/",										"london@sivananda.org");
var scotland	  	= new Location ("Scotland, U.K.",			  	"/london/",										"london@sivananda.org");
var berlin	  		= new Location ("Berlin, Germany",			  	"/berlin/",										"berlin@sivananda.org");
var munich	  		= new Location ("Munich, Germany",			  	"/munich/",										"munich@sivananda.org");
var vienna	  		= new Location ("Vienna, Austria",			  	"/vienna/",										"vienna@sivananda.org");
var geneva	  		= new Location ("Geneva, Switzerland",		  	"/geneva/",										"geneva@sivananda.org");
var rome	 		= new Location ( "Rome, Italy",					"/rome",										"roma@sivananda.org" );
var umbria			= new Location ("Umbria, Italy",				"/rome/",										"roma@sivananda.org" );
var madrid	  		= new Location ("Madrid, Spain",				"/madrid/",										"madrid@sivananda.org");
var paris	   		= new Location ("Paris, France",				"/paris/",										"paris@sivananda.org");
var buenosaires 	= new Location ("Buenos Aires, Argentina",	  	"/buenosaires/",								"buenosaires@sivananda.org");
var mardelplata  	= new Location ("Mar del Plata, Argentina",	  	"/buenosaires/",								"buenosaires@sivananda.org");
var montevideo  	= new Location ("Montevideo, Uruguay",		  	"/montevideo/",									"montevideo@sivananda.org");
var chicago	 		= new Location ("Chicago, IL, USA",			 	"/chicago/",									"chicago@sivananda.org");
var newyork	 		= new Location ("New York City, USA",		   	"/ny/",											"newyork@sivananda.org");
var sanfrancisco	= new Location ("San Francisco, USA",		  	"/sf/",											"sanfrancisco@sivananda.org");
var losangeles  	= new Location ("Los Angeles, USA",			 	"/la/",											"losangeles@sivananda.org");
var telaviv	 		= new Location ("Tel Aviv, Israel",			 	"/telaviv/",									"telaviv@sivananda.org");
var telavivttc	 		= new Location ("Tel Aviv, Israel",			 	"http://sivananda.co.il/courses/teachers-training-course/?utm_source=international%2Bttc%2Bschedule&utm_medium=international%2Bwebpage&utm_campaign=ttc",									"telaviv@sivananda.org");
var toronto	 		= new Location ("Toronto, Canada",			  	"/toronto/",							"toronto@sivananda.org");
var montreal		= new Location ("Montreal, Canada",			 	"/montreal/",									"montreal@sivananda.org");
var delhi_nataraja 	= new Location ("New Delhi, India - Nataraja",	"/delhi/",										"delhi@sivananda.org");
var delhi_dwarka	= new Location ("New Delhi, India - Dwarka",	"/dwarka/",										"dwarka@sivananda.org");
var chennai	  		= new Location ("Chennai, India",				"/chennai/",										"chennai@sivananda.org");
var trivandrum  	= new Location ("Thiruvananthapuram, Kerala, India",	"/trivandrum/",									"trivandrum@sivananda.org");
var maduraicentre 		= new Location ("Madurai, India",		   		"/maduraicentre/",								"maduraicenter@sivananda.org");
var vrindavan		= new Location ( "Ranikhet, Himalayas, India",		"http://www.sivananda.eu/en/yoga-teacher-training-in-india.html",									"tyrol@sivananda.org" );
var vrindavan_attc		= new Location ( "Ranikhet, Himalayas, India",		"http://www.sivananda.eu/en/advanced-teacher-training-in-india.html",									"tyrol@sivananda.org" );
var maduraiashram 	= new Location ("Madurai, India",		   		"/madurai/",									"YogaIndia@sivananda.org");
var netala	  		= new Location ( "Netala, U' Kashi, India",	 	"/uttarkashi/",									"YogaIndia@sivananda.org" );
var neyyardam   	= new Location ( "Neyyar Dam, India",		   	"/neyyardam/",									"YogaIndia@sivananda.org" );
var portoalegre 	= new Location ( "Porto Alegre, Brasil",		"http://www.yogasivananda.com.br/poa/",			"sivanandayogapoa@gmail.com" );
var riodejaneiro 	= new Location ( "Rio de Janeiro, Brasil",		"http://www.yogasivananda.com.br/rio/",			"yogasivananda@gmail.com" );
var vilnius			= new Location ("Vilnius, Lithuania",			"/vilnius/",											"vilnius@sivananda.org");			   			
var milano			= new Location ("Milan, Italy",					"/milano/",											"milano@sivananda.org");			   			
var taiwan			= new Location ( "Kiao Sung, Taiwan", 			"http://www.sivanandayogafarm.org/page.php?page_id=53", "sivanandayogataiwan@gmail.com" );
var neuquen			= new Location ( "Neuquen", 					"/neuquen", 									"neuquen@sivananda.org" );
var australia		= new Location ( "Australia",	"http://www.sivananda.co.uk/au/"	,									"Australia@sivananda.net" );

var dd_locations_array = new Array(
				 
	new Location( " - Yoga Ashrams & Centres - ", "/locations/", ''),
	new Location( " ",							  "#", ''),					 
	new Location( " - ASHRAMS WORLDWIDE - ",	  "/locations/ashrams.html", ''),					   
	new Location( "Quebec",						 camp.url, ''),					   
	new Location( "New York",					   ranch.url, ''),						 
	new Location( "California",					 farm.url, ''),					 
	new Location( "Bahamas",						nassau.url, ''),					 
	new Location( "Austria",						reith_home.url, ''),						 
	new Location( "France",						 orleans.url, ''),						  
	new Location( "Uttarkashi - North India",	   netala.url, ''),			  
	new Location( "Kerala - South India",		   neyyardam.url, ''),
	new Location( "Madurai - South India",		  maduraiashram.url, ''),
				 		  
	new Location( " ",							  "#", ''),						
	new Location( " - CENTRES NORTH AMERICA - ",  "/locations/northamerica.html", ''),					  
	new Location( "Montreal",					   montreal.url, ''),						 
	new Location( "Toronto",						toronto.url, ''),							
	new Location( "New York",					   newyork.url, ''),					
	new Location( "Chicago",						chicago.url, ''),					   
	new Location( "Los Angeles",					losangeles.url, ''),					 
	new Location( "San Francisco",				  sanfrancisco.url, ''),		 
						  
	new Location( " ",							  "#", ''),					   
	new Location( " - CENTRES SOUTH AMERICA - ",  "/locations/southamerica.html", ''),					  
	new Location( "Buenos Aires",				   buenosaires.url, ''),  
	new Location( "Montevideo",					 montevideo.url, ''),  
	new Location( "Neuquen",					neuquen.url, ''),
			  
	new Location( " ",							  "#", ''),						   
	new Location( " - CENTRES EUROPE - ",		 "/locations/europe.html", ''),	
						 
	new Location( "European Website",		 europe.url, ''),
	new Location( "London",						 london.url, ''),						 
	new Location( "Paris",						  paris.url, ''),					   
	new Location( "Madrid",						 madrid.url, ''),						 
	new Location( "Geneva",						 geneva.url, ''),			   
	new Location( "Berlin",						 berlin.url, ''),					   
	new Location( "Munich",						 munich.url, ''),
	new Location( "Vienna",						 vienna.url, ''),						
	new Location( "Rome",						 	rome.url, ''), 					
	new Location( "Milan",						 	milano.url, ''), 
	new Location( "Vilnius",						 	vilnius.url, ''), 
	
			  
	new Location( " ",							  "#", ''),	 
	new Location( " - CENTRES MIDDLE EAST - ",	"/locations/mideast.html", ''),					  
	new Location( "Tel Aviv",					   telaviv.url, ''),   
									
	new Location( " ",							  "#", ''),	 
	new Location( " - CENTRES INDIA - ",		  "/locations/india.html", ''),					 
	new Location( "New Delhi South, Nataraja",	  delhi_nataraja.url, ''),						  
	new Location( "New Delhi West, Dwarka",			delhi_dwarka.url, ''),
	new Location( "Chennai",						chennai.url, ''),		
	new Location( "Madurai",						maduraicentre.url, ''),							   
	new Location( "Thiruvananthapuram",					 trivandrum.url, ''),
	
	new Location( " ",							  "#", ''),						 
	new Location( " - AFFILIATES - ",			 "/locations/affiliat.html", ''),					   
	new Location( "Affiliated Sivananda Centres",						"/locations/affiliat.html", '')
);




function get_plain_locations_array() {
	
	return new Array( 
					
		new Location( " -- Select Member Location -- ", "", ''),
		new Location( " ",							  "", ''),  
		new Location( "No Current Membership",		  "", ''),  
		new Location( " ",							  "", ''),						
		new Location( " CENTRES NORTH AMERICA",  			"", ''),					  
		new Location( " -- Montreal",					   montreal.title, ''),						 
		new Location( " -- Toronto",						toronto.title, ''),							
		new Location( " -- New York",					   newyork.title, ''),					
		new Location( " -- Chicago",						chicago.title, ''),					   
		new Location( " -- Los Angeles",					losangeles.title, ''),					 
		new Location( " -- San Francisco",				  sanfrancisco.title, ''),		 
							  
		new Location( " ",							  	"", ''),					   
		new Location( " CENTRES SOUTH AMERICA",  			"", ''),					  
		new Location( " -- Buenos Aires",				   buenosaires.title, ''),  
		new Location( " -- Montevideo",					 montevideo.title, ''),  
		new Location( " -- Neuquen",					neuquen.title, ''),
				  
		new Location( " ",							  	"", ''),						   
		new Location( " CENTRES EUROPE",		 			"", ''),						 
		new Location( " -- London",						 london.title, ''),						 
		new Location( " -- Paris",						  paris.title, ''),					   
		new Location( " -- Madrid",						 madrid.title, ''),						 
		new Location( " -- Geneva",						 geneva.title, ''),			   
		new Location( " -- Berlin",						 berlin.title, ''),					   
		new Location( " -- Munich",						 munich.title, ''),
		new Location( " -- Vienna",						 vienna.title, ''),						
		new Location( " -- Rome",						 	rome.title, ''), 	
	new Location( " -- Milan",						 	milano.url, ''), 
	new Location( " -- Vilnius",						 	vilnius.url, ''),
				  
		new Location( " ",							  	"", ''),	 
		new Location( " CENTRES MIDDLE EAST",				"", ''), 
		new Location( " -- Petach Tiqva",				   "Petach Tiqva", ''),					   
		new Location( " -- Tel Aviv",					   telaviv.title, ''),   
										
		new Location( " ",							  	"", ''),	 
		new Location( " CENTRES INDIA",		  			"", ''),					 
		new Location( " -- New Delhi South, Nataraja",	  delhi_nataraja.title, ''),						  
		new Location( " -- New Delhi West, Dwarka",			delhi_dwarka.title, ''),						  
		new Location( " -- Chennai",						chennai.title, ''),		
		new Location( " -- Madurai",						maduraicentre.title, ''),							   
		new Location( " -- Thiruvananthapuram",					 trivandrum.title, ''),
		
		new Location( " ",							  	"", ''),					 
		new Location( " ASHRAMS WORLDWIDE",	  			"", ''),					   
		new Location( " -- Quebec",						 camp.title, ''),					   
		new Location( " -- New York",					   ranch.title, ''),						 
		new Location( " -- California",					 farm.title, ''),					 
		new Location( " -- Bahamas",						nassau.title, ''),					 
		new Location( " -- Austria",						reith.title, ''),						 
		new Location( " -- France",						 orleans.title, ''),						  
		new Location( " -- Uttarkashi - North India",	   netala.title, ''),			  
		new Location( " -- Kerala - South India",		   neyyardam.title, ''),
		new Location( " -- Madurai - South India",		  maduraiashram.title, '')
	);
}








/**
 * (Abstract) Class YogaLocation
 *
 * Base class for displaying location address/email/web-url in a consistently
 * formatted manner. Note that this class should be considered abstract, and
 * is not intended to be directly instantiated.
 */
function YogaLocation () {
	
	this.region		= '';
	this.city 		= '';
	this.center 	= '';
	this.contact	= '';
	this.street 	= '';
	this.citypost 	= '';
	this.phone 		= '';
	this.fax 		= '';
	
	// location, email, url are here for reference only,
	// they are created in the subclass	
	// this.location 	= location; // passed in argument to subclass constructor
	// this.email 		= location.email;
	// this.url 		= location.url;
	
	return this;
}



/**
 * Static properties
 */
YogaLocation.NORTH_AMERICA 		= "North America";
YogaLocation.SOUTH_AMERICA 		= "South America";
YogaLocation.EUROPE 			= "Europe";
YogaLocation.MIDDLE_EAST 		= "Middle East";
YogaLocation.INDIA 				= "India";
YogaLocation.REST_OF_WORLD 		= "Rest Of World";

//
// IMPORTANT:
// 	- The derived classes must define these variables:
//
// _MyDerivedClass_.northamerica_list	= new Array();
// _MyDerivedClass_.southamerica_list	= new Array();
// _MyDerivedClass_.europe_list			= new Array();
// _MyDerivedClass_.middleeast_list		= new Array();
// _MyDerivedClass_.india_list			= new Array();
// _MyDerivedClass_.restofworld_list	= new Array();
// _MyDerivedClass_.locations			= new Array();
// _MyDerivedClass_.l_length			= 0;
//



/**
 * public static void add_location( YogaLocation location )
 *
 * Adds the provided YogaLocation Object (derived as a subclass) to the subclass's
 * locations array property.
 *
 * param YogaLocation location - a YogaLocation (derived) object to add to the 
 *								 derived class's locations array.
 */
YogaLocation.add_location = function ( location ) {
	
	// since YogaLocation is subclassed, get the class of the object that invoked me
	var DerivedClass = location.constructor;
	
	// set the static properties for the class of the object that invoked me
	DerivedClass.locations[ DerivedClass.l_length ] = location;
	DerivedClass.l_length = DerivedClass.locations.length;
}




/**
 * public static void draw_all ( YogaLocation class_ref )
 *
 * Draws the table of all YogaLocations defined for the derived class. Outputs
 * the HTML required to display these.
 *
 * param YogaLocation class_ref - a class that has subclassed YogaLocation.
 */
YogaLocation.draw_all = function ( class_ref ) {
	
	var output = '';
	var DerivedClass = class_ref;
	
	var region_array = new Object();
	region_array.na = '';
	region_array.sa = '';
	region_array.eu = '';
	region_array.me = '';
	region_array.id = '';
	region_array.rw = '';
	
	for ( idx=0; idx<DerivedClass.l_length; idx++ ) {
		
		var location = DerivedClass.locations[idx];
		var location_info = location.draw_location_info();		
		var this_region_id = null;
		
		// figure out the region it belongs to, and populate the corresponding array
		switch ( location.region ) {
			
			case YogaLocation.NORTH_AMERICA:
				this_region_id = "na";
				break;
				
			case YogaLocation.SOUTH_AMERICA:
				this_region_id = "sa";
				break;
				
			case YogaLocation.EUROPE:
				this_region_id = "eu";
				break;
				
			case YogaLocation.MIDDLE_EAST:
				this_region_id = "me";
				break;
				
			case YogaLocation.INDIA:
				this_region_id = "id";
				break;
				
			case YogaLocation.REST_OF_WORLD:
				this_region_id = "rw";
				break;
		}
		
		
		// if it is empty, start with the section title (i.e. the region)
		if ( !region_array[this_region_id] ) { 
			region_array[this_region_id] += '<h3>' + location.region + '</h3>';
		}
		
		// now add the location information
		region_array[this_region_id] += location_info;
	}
	
	
	output = (
				region_array.na
			+	region_array.sa
			+	region_array.eu
			+	region_array.me
			+	region_array.id
			+	region_array.rw
	);
	
	document.write( output );
}




/**
 * public static void TableOfContents ( YogaLocation class_ref )
 *
 * Draws a table of contents for all YogaLocations defined for the derived class. 
 * This table of contents is an organised listing of anchor-links for each location
 * which link to the actual address information elsewhere on the HTML page. Outputs
 * the HTML required to display these.
 *
 * param YogaLocation class_ref - a class that has subclassed YogaLocation.
 */
YogaLocation.TableOfContents = function ( class_ref ) {
	
	
	var na_header 	= '';
	var na_list		= '';
	var eu_header 	= '';
	var eu_list		= '';
	var rw_header 	= '';
	var rw_list		= '';
	var sa_header 	= '';
	var sa_list		= '';
	var me_header 	= '';
	var me_list		= '';
	var id_header 	= '';
	var id_list		= '';
	
	
	var region_output_array = YogaLocation._populate_region_arrays( class_ref );
	

	// this is a hack, clean this up some day...
	if ( region_output_array.na != '' ) {
		na_header = YogaLocation._get_region_header( YogaLocation.NORTH_AMERICA );
		na_list	  = YogaLocation._get_region_list( region_output_array.na );
	}
		
	if ( region_output_array.eu != '' ) {
		eu_header = YogaLocation._get_region_header( YogaLocation.EUROPE );
		eu_list	  = YogaLocation._get_region_list( region_output_array.eu );
	}
	
		if ( region_output_array.id != '' ) {
		id_header = YogaLocation._get_region_header( YogaLocation.INDIA );
		id_list	  = YogaLocation._get_region_list( region_output_array.id );
	}
	
	
	
	
	if ( region_output_array.sa != '' ) {
		sa_header = YogaLocation._get_region_header( YogaLocation.SOUTH_AMERICA );
		sa_list	  = YogaLocation._get_region_list( region_output_array.sa );
	}
	
	if ( region_output_array.me != '' ) {
		me_header = YogaLocation._get_region_header( YogaLocation.MIDDLE_EAST );
		me_list	  = YogaLocation._get_region_list( region_output_array.me );
	}
	
	if ( region_output_array.rw != '' ) {
		rw_header = YogaLocation._get_region_header( YogaLocation.REST_OF_WORLD );
		rw_list	  = YogaLocation._get_region_list( region_output_array.rw );
	}
	

		
	
	var table_output = (
			'<table cellpadding="5" cellspacing="0" border="0" width="100%">'
		  + 	'<tr> '
		  + 		na_header
		  + 		eu_header
		  + 		id_header 
		  + 	'</tr>'
		  +		'<tr>'
		  + 		na_list
		  +			eu_list
		  +			id_list
		  + 	'</tr>'
		  + 	'<tr> '
		  + 		sa_header
		  + 		me_header
		  + 		rw_header
		  
		  + 	'</tr>'
		  +		'<tr>'
		  + 		sa_list
		  +			me_list
		  +			 rw_list
		  + 	'</tr>'
		  + '</table>'
	);
	
	document.write( table_output );
}




/**
 * private static String populate_region_arrays
 *
 * Reads each YogaLocation object, and populates the region-array that this
 * YogaLocation object belongs to (as defined in the object's configuration).
 *
 * param LocationClass - a reference to the subclass implementing YogaLocation
 *
 * returns (String) a formatted list of anchored locations
 */
YogaLocation._populate_region_arrays = function ( LocationClass ) {
	
	
	var region_array = new Object();
	region_array.na = '';
	region_array.sa = '';
	region_array.eu = '';
	region_array.me = '';
	region_array.id = '';
	region_array.rw = '';
	
	
	// read the entire array of defined YogaLocation objects
	for ( idx=0; idx<LocationClass.l_length; idx++ ) {
		
		var location = LocationClass.locations[idx];
		var toc_entry = '<div class="table-body" style="line-height:20px;margin:0px 0px 0px 0px"><a href="#' + location.id + '">' + location.city + '</a></div>';
		
		// figure out the region it belongs to, and populate the corresponding array
		switch ( location.region ) {
			
			case YogaLocation.NORTH_AMERICA:
				region_array.na += toc_entry;
				break;
				
			case YogaLocation.SOUTH_AMERICA:
				region_array.sa += toc_entry;
				break;
				
			case YogaLocation.EUROPE:
				region_array.eu += toc_entry;
				break;
				
			case YogaLocation.MIDDLE_EAST:
				region_array.me += toc_entry;
				break;
				
			case YogaLocation.INDIA:
				region_array.id += toc_entry;
				break;
				
			case YogaLocation.REST_OF_WORLD:
				region_array.rw += toc_entry;
				break;
		}
	}
	
	return region_array;
}






YogaLocation._get_region_header = function ( header ) {
	return '<th>' + header + '</th>';
}





YogaLocation._get_region_list = function ( list ) {
	return '<td valign="top">' + list + '</td>';
}




/**
 * private String draw_location_info
 *
 * Builds a formatted paragraph containing the address and info for the location.
 * Override this method for customized display/formatting of the location addresses.
 *
 * returns (String) the formatted address paragraph
 */
YogaLocation.prototype.draw_location_info = function () {
		
	var showcenter = '';
	if ( this.center ) {
		showcenter 		= '<br>' + this.center;
	}
	
	var showcontact = '';
	if ( this.contact != '' ) {
		showcontact 	= '<br>' + this.contact;
	}
	
	var showstreet = ''
	if ( this.street ) {
		showstreet 		= '<br>' + this.street + ',';
	}
	
	var showcitypost = '';
	if ( this.citypost ) {
		showcitypost	= '<br>' + this.citypost;
	}
	
	var showphone = '';
	if ( this.phone ) {
		showphone 		= '<br>Tel: ' + this.phone;
	}
	
	var showfax = '';
	if ( this.fax != '' ) {
		showfax 		= '<br>Fax: ' + this.fax;
	}
	
	var showemail = '';
	if ( this.email != '' ) {
		showemail 		= '<br>E-mail: <a href="mailto:' + this.email + '">' + this.email + '</a>';
	}
		
	var website_href = this.city; // default is no href, just plain text...
	var showurl = '';
	if ( this.url != '' ) {
		website_href = '<a href="' + this.url + '" target="yogalocation">' + this.city + '</a>';
		showurl		 = '<br>Web: <a href="' + this.url + '" target="yogalocation">' + this.url + '</a>';
	}
	var location_label = '<strong>' + website_href + '</strong>';
	
	
	
	var output_info = (
			  
				'<p>'
			  + '<a name="' + this.id + '"></a>'
			  + location_label
			
			  + 	showcenter
			  +		showcontact
			  + 	showstreet
			  + 	showcitypost
			  + 	showphone
			  + 	showfax	
			  + 	showemail
			  +		showurl
			 
			  + '</p>'
			   + '<p><a href="#">Back to top</a> </p>'
	);
	
	return output_info;
}










