function showLink(linkType) // opens up a window so that the bear can be ordered and passes the type and name of the bear
{
	displayLinksMain(linkType); // display the links on the main window
}

function init_links() //process the order information
{
	params = getParams(); // get the URL arguments

	typeOfLink = params[1]; // type of bear being ordered

	setLinks(typeOfLink); // set flags for display of links
	displayReqLinks(); // display the requested links
}

function displayLinksMain(linkType) // display the links on the main window
{
	clearLink_page();
	
	setLinks(linkType); // set flags for display of links
	displayReqLinks(); // display the requested links
}


function setLinks(typeOfLink) // set flags for display of links
{
	makeFlagsFalse(); // make flags false incase there are true flags from previous calls
	
	switch(typeOfLink)
	{
		// generated from drop down boxes
		case 'ShowAllLinks':
			setAllFlags(); // set all flags to true for the display
			break;
		case 'Canada':
			isCanLinks = true; // is Canadian Links Displayed
			break;
		case 'UnitedStates':
			isUsLinks = true; // is US Links Displayed
			break;
		case 'Australia':
			isAustlaLinks = true; // is Ausy links displayed
			break;
		case 'NewZealand':
			isNzLinks = true; // is new zealand links displayed
			break;
		case 'UnitedKindom':
			isUkLinks = true; // is UK links displayed
			break;
		case 'HongKong':
			isHkLinks = true; // is HK links displayed
			break;
		case 'Sweden':
			isSwdnLinks = true; // is Sweden links displayed
			break;
		case 'Germany':
			isGrmnyLinks = true; // is German links displayed
			break;
//		case 'Denmark':
//			isDnmkLinks = true; // is Denmark links displayed
//			break;
		case 'Other':
			isOtherLinks = true; // is other links displayed
			break;
		case 'webrings':
			isWebLinks = true; // if web rings are displayed
			break;

		// generated from the map
		case 'nsa':
			isCanLinks = true; // is Canadian Links Displayed
			isUsLinks = true; // is US Links Displayed
			break;
		case 'europe':
			isUkLinks = true; // is UK links displayed
			isSwdnLinks = true; // is Sweden links displayed
			isGrmnyLinks = true; // is German links displayed
//			isDnmkLinks = true; // is Denmark links displayed
			break;
		case 'asia':
			isHkLinks = true; // is HK links displayed
			break;
		case 'ocean':
			isAustlaLinks = true; // is Ausy links displayed
			isNzLinks = true; // is new zealand links displayed
			break;
	}
}

function setAllFlags() // set all the flags to true for display
{
	isCanLinks = true; // is Canadian Links Displayed
	isUsLinks = true; // is US Links Displayed
	isAustlaLinks = true; // is Ausy links displayed
	isNzLinks = true; // is UK links displayed
	isUkLinks = true; // is UK links displayed
	isHkLinks = true; // is HK links displayed
	isSwdnLinks = true; // is Sweden links displayed
	isGrmnyLinks = true; // is German links displayed
//	isDnmkLinks = true; // is Denmark links displayed
	isOtherLinks = true; // is other links displayed
}

function makeFlagsFalse() // make flags false incase there are true flags from previous calls
{
	isCanLinks = false; // is Canadian Links Displayed
	isUsLinks = false; // is US Links Displayed
	isAustlaLinks = false; // is Ausy links displayed
	isNzLinks = false; // is UK links displayed
	isUkLinks = false; // is UK links displayed
	isHkLinks = false; // is HK links displayed
	isSwdnLinks = false; // is Sweden links displayed
	isGrmnyLinks = false; // is German links displayed
//	isDnmkLinks = false; // is Denmark links displayed
	isOtherLinks = false; // is other links displayed
	isWebLinks = false; // are web links being displayed
}

function displayReqLinks() // display the requested links
{
	// fill in the title

	showLinks_page(); // show requested links

	var tempAllLink = ''; // initialize the string to null
	tempAllLink+="<table><tr><td>";
	
	if(isCanLinks) tempAllLink+= displayLinksCan('can');
	if(isUsLinks) tempAllLink+= displayLinksCan('us');
	if(isAustlaLinks) tempAllLink+= displayLinksCan('austla');
	if(isNzLinks) tempAllLink+= displayLinksCan('nz');
	if(isUkLinks) tempAllLink+= displayLinksCan('uk');
	if(isHkLinks) tempAllLink+= displayLinksCan('hk');
	if(isSwdnLinks) tempAllLink+= displayLinksCan('swdn');
	if(isGrmnyLinks) tempAllLink+= displayLinksCan('grmny');
//	if(isDnmkLinks) tempAllLink+= displayLinksCan('dnmk');
	if(isOtherLinks) tempAllLink+= displayLinksCan('other');
	if(isWebLinks) tempAllLink+= '&nbsp';

	tempAllLink+="</td></tr></table>";

	if(isWebLinks) webringscode();
	
	writeInfo(dispMain,tempAllLink); // write the info out to the page
	
	tempVar="<form><input id='control_but' type='button' value='RETURN TO LINKS' onclick='displayLinks()'></form>"; // change the layer
	writeInfo(disLinkButton,tempVar);
	show(disLinkButton);
}

function webringscode() // display the webrings
{
	if(!isVisible(dispIframe)) show(dispIframe); // show the iframe layer, which will contain the webrings page

	dispIframe_src.src='webrings.html'; // load webrings into the iframe layer
}

function displayLinksCan(cntry) // display links for canada
{
	var tempLink = ''; // initialize the string to null

	var gen_head = new link_head();
	var gen_links = new link();

	// set the head link object
	var newtxt='' // initialize a temporary string
	newtxt=newtxt.concat(cntry);
	newtxt=newtxt.concat('_head');
	gen_head = eval(newtxt); // set the head object to point to the contry of interest


	// set the link object	
	var newtxt='' // initialize a temporary string
	newtxt=newtxt.concat(cntry);
	newtxt=newtxt.concat('_links');
	gen_links = eval(newtxt); // set the links object to point to the country of interest

	// -- create the head --
	tempLink+="<BR><BR><IMG SRC='"+gen_head.loadflagImg().src+"' width='84'><BR>";
	tempLink+="<P>"+gen_head.country+"</P><BR>";
	
	// -- create the list of links --
	for(indLink=0;indLink<gen_links.length;indLink++) // loop over the canadian links
	{
		tempLink+="<A class='"+css_def+"' HREF='"+gen_links[indLink].url+"' target='"+gen_links[indLink].target+"'>";
		tempLink+=gen_links[indLink].name+"</A><BR>";
	}

	return(tempLink);
}

