var main_w = 708;
var main_h = 499;

var panes = new Array();

// need left-edge spiral
// need to make a little margin in the textboxes
// need rounded corners
// need pagenumber
// need [Contents] and corners



function init_panedefs()
{
	var f, w, h, t, x, y, xspace, yspace, off_w, off_h, ow, oh, p, n;

p = 'Cover';

		w = main_w;
		h = main_h;
		x = 0;
		y = 0;
		mkpane(p, w, h, x, y, "Images/cover_wlogo.jpg", "Cover");

		w = 50;
		h = 20;
		x = 610;
		y = 460;
		mkanchor(p, 0, w, h, x, y, "Enter", "pane:1-1", 1);

p = '1-1';

		mkpane(p, 0, 0, 0, 0, "", "Overview");

		n = 0;
		mksubimage(p, n++, 348, 122, 330,  30, "Images/overview_NCA.jpg");
		mksubimage(p, n++, 302, 444,  20,  20, "misc/overview.png");
		mksubimage(p, n++, 154, 256, 340, 230, "misc/overview_legend.png");
		mksubimage(p, n++, 209,  27, 380, 170, "misc/overview_unit.png");

		w = 141;
		h = 40;
		x = 521;
		y = 248;
		yspace = 11;
		n = 0;
		mkanchor(p, n++, w, h, x, y, "When The Pavement Ends Video", "Other/When The Pavement Ends.wmv", 1); y += h + yspace;
		h = 25;
		mkanchor(p, n++, w, h, x, y, "Welcome Message", "Other/welcometxt.pdf", 1); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "About This Book", "Other/about.pdf", 1); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Quick Start Video", "Other/Quick Start Video.wmv", 1); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Data Disclaimer", "Images/datadisclaimer.jpg", 1); y += h + yspace;
		h = 35;
		mkanchor(p, n++, w, h, x, y, "How To Use This Map", "Other/How To Use This Map - Intro.wmv", 1);
		
		// needs finishing

p = '1-2';

		t = "Our Partners";
		f = "Images/ourpartners_background.jpg";
		w = 659;
		h = 503;

		off_w = Math.floor((main_w - w)/2);;
		off_h = 0;

		mkpane(p, w, h, off_w, off_h, f, t);

		var links = new Array();
		var i = 0;
		links[i++] = 'www.blackrockdesert.org/';
		links[i++] = 'nevadawilderness.org/';
		links[i++] = 'nevadaoutdoorschool.org/';
		links[i++] = 'highrocktrekkers.com/';
		links[i++] = 'emigranttrailswest.org/';
		links[i++] = 'www.octa-trails.org/';
		links[i++] = 'www.thedeserttrail.org/';
		links[i++] = 'www.desert-survivors.org/';
		links[i++] = 'nevadarockart.com/';
		links[i++] = 'agri.nv.gov/nwac/';
		links[i++] = 'www.surprisevalleychamber.com/';
		links[i++] = 'www.winnemucca.nv.us/';
		links[i++] = 'americorps.org/';
		links[i++] = 'www.unr.edu/content/';
		links[i++] = 'www.unr.edu/cla/anthro/';
		links[i++] = 'www.unr.edu/cla/anthro/sundance.htm';
		links[i++] = 'www.dri.edu/';

		x = off_w + 290;
		y = off_h + 124;
		for (var i = 0; i < 17; i++) {
			mkanchor(p, i, 340, 16, x, y, "", 'http://' + links[i], 0);
			y += 21;
		}


p = '1-3';
	
		w = 674; off_w = Math.floor((main_w - w)/2);
		h = 432; off_h = Math.floor((main_h - h)/2);
		x = off_w;
		y = off_h;
		mkpane(p, w, h, x, y, "Images/background_background.jpg", "Background");

		w = 198;
		h = 51;
		x = main_w - off_w - w;
		y = 0;
		n = 0;
		mksubimage(p, n, w, h, x, y, "Images/background.jpg");

		w = 182;
		h = 51;
		x = off_w + 44;
		y = off_h + 71;
		yspace = 18;
		n = 0;
		mkanchor(p, n++, w, h, x, y, "History", "Images/background_history.jpg", 0); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Legislation", "Images/background_legislation.jpg", 0); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "The Land", "Other/The Land.wmv", 0); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Management", "Images/background_management.jpg", 0); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Contemporary Uses", "Images/background_contempuse.jpg", 0);
		
		n = 0;
		mktext(p, n++, "caption_eastfork"); // textsdiv.php
		
		// looks pretty complete, but
		// needs pagenumber
		// needs [contents] button
		
p = '2-1';

		w = 670;
		h = 425;

		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2);

		mkpane(p, w, h, off_w, 48, "Images/besafe_background.jpg", "Be Safe in the NCA");

		w = 297;
		h = 48;
		x = main_w - off_w - w;
		y = 0;
		mksubimage(p, 0, w, h, x, y, "Images/besafe.jpg");

		w = 217;
		h = 45;
		x = off_w + 400;
		y = off_h + 281;
		mkanchor(p, 0, w, h, x, y, "Survival Awareness", "Other/survival_awareness.pdf", 0);

		y = y + 60;
		mkanchor(p, 1, w, h, x, y, "Survival Checklist", "Other/Survival_Checklist.pdf", 0);
		
		// needs [contents] button
		// links need alt= text
		
		
p = '2-2';
	
		t = "Weather Conditions";
		f = "Images/weathercond_background.jpg";
		w = 670;
		h = 425;
		
		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2) + 5;
		x = off_w;
		y = off_h;
		mkpane(p, w, h, x, y, f, t);

		f = "Images/weatherconditions.jpg";
		w = 307;
		h = 48;
		x = main_w - off_w - w;
		y = 0;
		mksubimage(p, 0, w, h, x, y, f);

		w = 180;
		h = 80;
		x = off_w + 39;
		y = off_h + 303;
		xspace = 24;
		mkanchor(p, 0, w, h, x, y, "Weather Characteristics", "Images/weather_characteristics.jpg", 0); x += w + xspace;
		mkanchor(p, 1, w, h, x, y, "NCA Weather Averages", "Images/weather_averages-gerlach.jpg", 0); x += w + xspace;
		mkanchor(p, 2, w, h, x, y, "Current Weather in Gerlach", "http://www.wrh.noaa.gov/forecast/MapClick.php?site=REV&llon=-120.721247&rlon=-118.568747&tlat=42.089584&blat=39.934584&smap=1&mp=0&map.x=158&map.y=168", 0); x += w + xspace;
		
		// last button needs link to NWS Reno forecast page for Gerlach
		

p = '2-3';

		mkpane(p, 428, 480, 0, 0, "Images/gateway_map.jpg", "Gateway Communitites and Services");

		n = 0;
		mksubimage(p, n++, 211, 122, 440, 0, "Images/gatewayservices.jpg");
		mksubimage(p, n++, 221, 95, 470, 170, "misc/gateway_depicts.png");
		
		w = 170;
		h = 40;
		x = 470;
		y = 283;
		n = 0;
		mkanchor(p, n++, w, h, x, y, "Services and Emergency Information", "Other/services_table.pdf", 1);	y += 50;
		mkanchor(p, n++, w, h, x, y, "Nevada Mileage Chart", "Images/NV_mileage.jpg", 1);
		
//		n = 0;
		mkanchor(p, n++, 51, 22, 240,  29, "", "Images/gateway_denio.jpg", 0);
		mkanchor(p, n++, 73, 29, 357,  27, "", "Images/gateway_mcdermitt.jpg", 0);
		mkanchor(p, n++, 65, 32,   0,  81, "", "Images/gateway_cedarville.jpg", 0);
		mkanchor(p, n++, 85, 38, 339, 196, "", "Images/gateway_winnemucca.jpg", 0);
		mkanchor(p, n++, 67, 24,  96, 239, "", "Images/gateway_gerlach.jpg", 0);
		mkanchor(p, n++, 68, 19, 100, 263, "", "Images/gateway_empire.jpg", 0);
		mkanchor(p, n++, 49, 28, 296, 246, "", "Images/gateway_imlay.jpg", 0);
		mkanchor(p, n++, 70, 25, 255, 328, "", "Images/gateway_lovelock.jpg", 0);
		mkanchor(p, n++, 52, 26, 108, 383, "", "Images/gateway_nixon.jpg", 0);
		mkanchor(p, n++, 81, 16,  88, 408, "", "Images/gateway_wadsworth.jpg", 0);
		mkanchor(p, n++, 58, 20, 159, 425, "", "Images/gateway_fernley.jpg", 0);
		mkanchor(p, n++, 68, 30,  84, 436, "", "Images/gateway_renosparks.jpg", 0);

		// needs button link to "services and emergency information" pdf
		// needs button link to mileage chart image


p = '2-4';

		t = "Beware of Hazards";
		f = "Images/hazards_background.jpg";
		w = 678;
		h = 444;
		off_h = 46;
		
		mkpane(p, w, h, 0, off_h, f, t);
		
		mksubimage(p, 0, 280, 46, 380, 0, "Images/beware-hazards.jpg");
		
		w = 235;
		h = 47;
		
		x = 60;
		y = off_h + 42;
		yspace = 13;
		
		mkanchor(p, 0, w, h, x, y, "Hot Springs Safety", "Other/hotspringssafety.pdf", 0); y += h + yspace;
		mkanchor(p, 1, w, h, x, y, "Hot Springs Video", "Other/Hot Springs Video.avi", 0); y += h + yspace;
		mkanchor(p, 2, w, h, x, y, "Wet Playa Awareness", "Other/wetplaya.pdf", 0); y += h + yspace;
		mkanchor(p, 3, w, h, x, y, "Railroad Crossings", "Other/rrcrossawareness.pdf", 0);
		
		// needs pagenumber
		// needs [Contents] button
		// needs section-flip upper and lower corner buttons
		

p = '2-5';
	
		// alert("2-5 not implemented");


p = '3-1';

		t = "Explore the NCA";
		f = "Images/explore-NCA_rules-button.jpg";
		w = 688;
		h = 503;
		
		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2);
		x = off_w;
		y = off_h;
		
		mkpane(p, w, h, x, y, f, t);

		w = 245;
		h = 65;
		x = off_w + 70;
		y = off_h + 315;

		mkanchor(p, 0, w, h, x, y, "Rules on Public Lands within the NCA", "Other/proposed-sup-rules.pdf", 0);


p = '3-2';

		t = "Flora and Fauna Viewing";
		f =  "Images/binoculars_shadow.jpg";
		w = 655;
		h = 392;
		
		x = 20;
		y = 44;
		
		mkpane(p, w,  h, x, y, f, t);
		mksubimage(p, 0, 365, 44, 300, 0, "Images/florafaunaviewing.jpg");

		w = 145;
		h = 26;
		x = 46;
		y = 442;
		xspace = 5;
		n = 0;
		mkanchor(p, n++, w, h, x, y, "Wildlife", "Other/wildlife.pdf", 1); x += w + xspace;
		mkanchor(p, n++, w, h, x, y, "Wild Horses and Burros", "Other/horseandburro.pdf", 1); x += w + xspace;
		mkanchor(p, n++, w, h, x, y, "Wildflowers", "Other/wildflowers.pdf", 1); x += w + xspace;
		mkanchor(p, n++, w, h, x, y, "Bird Watching", "Other/birdwatching.pdf", 1);
		

p = '3-3';
	
		t = "Outdoor Recreation Activities";
		f = "Images/hiking-boots_cutout.jpg";
		w = 463;
		h = 429;
		x = 240;
		y = 47;
		mkpane(p, w, h, x, y, f, t);

		n = 0;
		f = "Images/outdoorrecactivities.jpg";
		w = 428;
		h = 47;
		x = main_w - w - 20;
		y = 0;
		mksubimage(p, n++, w, h, x, y, f);
		
		f = "Images/NDOWlogo6.jpg";
		w = 74;
		h = 108;
		x = 100;
		y = 400;
		mksubimage(p, n++, w, h, x, y, f);


		w = 150;
		h = 20;
		x = 60;
		y = 42;
		yspace = 20;

		n = 0;
		mkanchor(p, n++, w, h, x, y, "Hunting and Fishing", "Other/huntingandfishing.pdf", 1); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "OHV and ATV Use", "Other/ohvatvuse.pdf", 1); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Camping", "Other/camping.pdf", 1); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Hiking", "Other/hiking.pdf", 1); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Rock Hounding", "Other/rockhounds.pdf", 1); y += h + yspace;
		mkanchor(p, n++, w, h, x, y, "Stargazing", "Other/stargazing.pdf", 1);

		mkanchor(p, n++, 100, 40, 60, 450, "Visit NDOW for hunting<br/>and fishing information");


p = '3-4';
	
		t = "Black Rock Desert Playa";
		f = "Images/blackrockdesert.jpg";
		w = 659;
		h = 503;
		
		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2);
		
		mkpane(p, w, h, off_w, off_h, f, t);
		mktextbox(p, 0, 610, 140, 20, 290, "blackrockdesertplaya_rtf");


p = '3-5';
	
		t = "High Rock Canyon and Side Canyons";
		f = "Images/highrockcanyon.jpg";
		w = 688;
		h = 503;
		
		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2);

		mkpane(p, w, h, off_w, off_h, f, t);
		mktextbox(p, 0, 610, 140, 20, 290, "highrockcanyon_rtf");


p = '3-6';
	
		t = "Mountain Ranges and Wilderness Areas";
		f = "Images/mountainsranges.jpg";
		w = 659;
		h = 503;

		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2);

		mkpane(p, w, h, off_w, off_h, f, t);
		mktextbox(p, 0, 610, 140, 25, 290, "mtrangeswildareas_rtf");


p = '3-7';
	
		t = "Historic Sites and Trails";
		f = "Images/historicsites.jpg";
		w = 688;
		h = 503;
		
		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2);

		mkpane(p, w, h, off_w, off_h, f, t);
		mktextbox(p, 0, 610, 140, 25, 290, "historicsitesandtrails_rtf");

p = '3-8';
	
	
p = '4-1';

		t = "Special Recreation Permits";
		f = "Images/specialrecpermits.jpg";
		w = 688;
		h = 503;

		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2);

		mkpane(p, w, h, off_w, off_h, f, t);
		mktextbox(p, 0, 610, 140, 40, 80, "special_rec_permits_rtf");
		

p = '4-2';
	
		t = "Burning Man Festival";
		f = "Images/cutout_burningman.jpg";
		w = 493;
		h = 498;
		
		mkpane(p, w, h, 0, 0, f, t);
		
		f = "Images/burningmanfestival.jpg";
		w = 317;
		h = 52;
		
		mksubimage(p, 0, w, h, 360, 0, f);
		
		mktextbox(p, 0, 290, 340, 370, 85, "burningman_rtf");


p = '4-3';
	
		t = "Amateur Rocketry";
		f = "Images/rocketry.jpg";
		w = 686;
		h = 498;
		
		ow = Math.floor((main_w - w)/2);
		oh = Math.floor((main_h - h)/2);

		mkpane(p, w, h, ow, oh, f, t);
		
		mktextbox(p, 0, 280, 385, 337, 56, "amateurrocketry_rtf");


p = '4-4';
	
		t = "Land Sailing";
		f = "Images/cutout_land-sail.jpg";
		w = 663;
		h = 440;
		
		mkpane("4-4", w, h, 0, 50, f, t);
		
		f = "Images/landsailing.jpg";
		w = 196;
		h = 50;
		
		mksubimage(p, 0, w, h, 400, 0, f);
		
		mktextbox(p, 0, 310, 235, 0, 120, "landsailing_rtf");
		

p = '4-5';

		t = "Organized Activities";
		f = "Images/organizedactivities.jpg";
		w = 344;
		h = 500;
		
		mkpane(p, w, h, 325, 0, f, t);
		
		mktextbox(p, 0, 300, 290, 0, 50, "organized_activities_rtf");
		
		// needs friends button


p = '5-1';
	
		t = "References";
		f = "Images/cover_background-only.jpg";
		w = 670;
		h = 435;
		
		off_w = Math.floor((main_w - w)/2);
		off_h = Math.floor((main_h - h)/2);

		mkpane(p, w, h, off_w, 51, f, t);		

		f = "Images/references.jpg";
		w = 178;
		h = 51;

		mksubimage(p, 0, w, h, 500, 0, f);
		
		mktextbox(p, 0, 600, 250, 35, 190, "references_rtf");


p = '5-2';
	
		t = "Acknowledgements";
		f = "Images/cover_background-only.jpg";
		w = 670;
		h = 435;
		
		mkpane(p, w, h, 0, 49, f, t);
		
		f = "Images/acknowledgements.jpg";
		w = 283;
		h = 49;
		
		mksubimage(p, 0, w, h, 300, 0, f);
		
		mktextbox(p, 0, 600, 250, 15, 180, "acknowledgements_rtf");


p = '5-3';
	
p = '5-4';
	
p = '5-5';

}

function mkpane(p, w, h, x, y, f, t)
{
var o = new Object();
o.title = t;
o.backgroundImage = f;
o.width = w;
o.height = h;
o.offx = x;
o.offy = y;
o.subimage = new Array();
o.button = new Array();
o.anchor = new Array();
o.textbox = new Array();
o.texts = new Array();
panes[p] = o;
}

function mkbutton(p, b, w, h, x, y, t, c)
{
var o = new Object();
o.width = w;
o.height = h;	
o.offx = x;
o.offy = y;
o.title = t;
o.href = c;
panes[p].button[b] = o;
}

function mkanchor(p, b, w, h, x, y, t, c, a)
{
var o = new Object();
o.width = w;
o.height = h;	
o.offx = x;
o.offy = y;
o.title = t;
o.href = c;
o.anchor = 0;
if (a) o.anchor = t;
panes[p].anchor[b] = o;
}

function mksubimage(p, b, w, h, x, y, f)
{
var o = new Object();
o.width = w;
o.height = h;	
o.offx = x;
o.offy = y;
o.filename = f;
panes[p].subimage[b] = o;
}

function mktextbox(p, n, w, h, x, y, d)
{
var o = new Object();
o.width = w;
o.height = h;
o.offx = x;
o.offy = y;
o.divname = d;
panes[p].textbox[n] = o;
}

function mktext(p, n, d)
{
panes[p].texts[n] = new Object();
panes[p].texts[n].divname = d;
}

/*********************************/

function rightbutton_cover()		 { setpane("Cover"); }
function rightbutton_survival()		 { setpane("2-1"); }
function rightbutton_wheretogo()	 { setpane("3-1"); }
function rightbutton_specialevents() { setpane("4-1"); }
function rightbutton_references()	 { setpane("5-1"); }

var funcarray = new Array ( 
rightbutton_cover, 
rightbutton_survival, 
rightbutton_wheretogo, 
rightbutton_specialevents,
rightbutton_references
);

/*********************************/


function setpane(pane)
{
	clearpane();
	mkrightbuttons();
	setuppane(pane);
}

function clearpane()
{
	var maindiv = document.getElementById('main');
	maindiv.style.backgroundImage = '';
	
	while (maindiv.firstChild) { maindiv.removeChild(maindiv.firstChild); }

	var myp = document.getElementById('pane2');
	myp.style.visibility = 'hidden';
	myp.innerHTML = '';
}

function mkrightbuttons()
{
	var maindiv = document.getElementById("main");
	var h = 105;
	
	for (var i = 0; i < 5; i++) {
		var obj = document.createElement('button');
		with (obj.style) {
			backgroundImage = "url(misc/button" + i + ".png)";
			backgroundRepeat = "no-repeat";
			backgroundColor = "transparent";
			border = 0;
			width = 38;
			height = h - 2;
			position = "absolute";
			left = 708;
			top = h * i;
		}	
		obj.onclick = funcarray[i];
		maindiv.appendChild(obj);
	}
}

function setuppane(tag)
{
	var maindiv = document.getElementById('main');
	
	var bg = document.createElement('div');
	bg.id = 'bg';

	if (panes[tag].backgroundImage) {
		var fname = "url(" + panes[tag].backgroundImage + ")";
		with (bg.style) {
			backgroundImage = fname;
			backgroundRepeat = "no-repeat";
			backgroundPosition = "center";
			width = panes[tag].width;
			height = panes[tag].height;
			position = "absolute";
			left = panes[tag].offx;
			top = panes[tag].offy;
		}
	}
	
	maindiv.appendChild(bg);

	if (panes[tag].subimage) {
	
		var nsubimages = panes[tag].subimage.length;
		for (var i = 0; i < nsubimages; i++) {
			var psub = panes[tag].subimage[i];
			var fname = "url(" + psub.filename + ")";
			var tmpdiv = document.createElement('div');
			with (tmpdiv.style) {
				backgroundImage = fname;
				position = "absolute";
				left = psub.offx;
				top = psub.offy;
				height = psub.height;
				width = psub.width;
			}
	
			maindiv.appendChild(tmpdiv);
		}
	}
	
	if (panes[tag].button) {
	
		var nbuttons = panes[tag].button.length;
		for (var i = 0; i < nbuttons; i++) {
		
			var pb = panes[tag].button[i];
			
			var butt = document.createElement('button');
			butt.href = pb.href;
			
			var objtext = document.createTextNode(pb.title);
			butt.appendChild(objtext);

			
			with (butt.style) {
				position = "absolute";
				left = pb.offx;
				top = pb.offy;
				height = pb.height;
				width = pb.width;
			}
			
			maindiv.appendChild(butt);
		}
	}

	if (panes[tag].anchor) {

		var nanchors = panes[tag].anchor.length;
		for (var i = 0; i < nanchors; i++) {
			var pa = panes[tag].anchor[i];
			var a = document.createElement('a');
			var href = pa.href;
			if (href.indexOf("pane:") == 0) {
				var colon = href.indexOf(":");
				var p = href.substr(colon+1);
				a.href = 'javascript:;';
				a.addEventListener('click', function() { setpane(p); }, false);
			} else {
				a.href = pa.href;
			}

			with (a.style) {
				position = "absolute";
				left = pa.offx;
				top = pa.offy;
				height = pa.height;
				width = pa.width;
			}

			if (pa.anchor) {
				with (a.style) {
					backgroundColor = "beige";
					border = 1;
				}
				a.innerHTML = pa.anchor;
			} else {
				with (a.style) {
					backgroundColor = "transparent";
					border = 0;
				}
			}

			maindiv.appendChild(a);
		}
	}

	if (panes[tag].textbox) {

		var nboxes = panes[tag].textbox.length;
		for (var i = 0; i < nboxes; i++) {
			var obj = panes[tag].textbox[i];
			var divname = obj.divname;
			
			var hp = document.getElementById('holder_pane');
			with (hp.style) {
				width = obj.width;
				height = obj.height;
				position = "relative";
				top = obj.offy;
				left = obj.offx;
			}
			
			var myp = document.getElementById('pane2');
			myp.innerHTML = document.getElementById(obj.divname).innerHTML;
			with (myp.style) {
				visibility = '';
				width = obj.width;
				height = obj.height;
				padding = 5;
				borderStyle = "solid";
				borderColor = "black";
				borderWidth = 2;
			}
		}
	}
	
	if (panes[tag].texts) {
	
		var ntexts = panes[tag].texts.length;
		for (var i = 0; i < ntexts; i++) {
			var d = document.getElementById(panes[tag].texts[i].divname);
			var newdiv = document.createElement('div');
			with (newdiv.style) {
				position = d.style.position;
				top = d.style.top;
				left = d.style.left;
				color = d.style.color;
			}
			newdiv.innerHTML = d.innerHTML;
			maindiv.appendChild(newdiv);
		}
	}
	
	var pgdiv = document.createElement('div');
	with (pgdiv.style) {
		position = 'absolute';
		top = 500;
		left = 350;
	}
	pgdiv.innerHTML = tag;
	maindiv.appendChild(pgdiv);
}

