
/****************************************************************

 These two functions change the visibility property of a <div>
 section. 
 It is compatible with Netscape Navigator 4,
 Internet Explorer 4, and the W3C DOM standards.

****************************************************************/

function show(object) {
	Set_Cookie('active_subtype',object,getExpires(1));
	if (document.layers && document.layers[object])
		document.layers[object].visibility = 'visible';
//	else if (document.all)
//		document.all[object].style.visibility = 'visible';
	else if (document.getElementById) {
		var tmp = document.getElementById(object);
		if (tmp != null) tmp.style.visibility = 'visible';
	}
}

function hide(object) {
	if (document.layers && document.layers[object])
		// Compatable with NS4
		document.layers[object].visibility = 'hidden';
//	else if (document.all)
		// Compatable with IE4
//		document.all[object].style.visibility = 'hidden';
	else if (document.getElementById) {
		// For compatability with W3C DOM2 standard
		var tmp = document.getElementById(object);
		tmp.style.visibility = 'hidden';
	}
}


function mysubmit(layerID,formID) {
	if (document.layers && document.layers[layerID].document.forms[formID]){
		document.layers[layerID].document.forms[formID].submit();
	}  else if (document.all) {
	  /*  At times, on Microsoft Internet Explorer,
		I had trouble getting the stop button to work.
		I thought it had something to do with
		the animation window not being in the top frame.
		But it actually seems to be a problem related to
		using the word 'status' as
		a JavaScript variable.  The problem has not resurfaced
		since I changed this variable name.   */ 


		//document.all[layerID].all[formID].target = '_top';
		document.all[layerID].all[formID].submit();
	}


}


function myGETsubmit(layerID,formID) {

	/* 
		Input:
			layerID	name of a layer
			formID	name of the form holding the URL
				pieces for the requested images

		Calls:
			certain_dates in make_urls.js
			slim_array in make_urls.js

		Summary:
			creates a string of URL parts (beginning, middles and ending)
			that can be appended to the URL for pop_up.html.
			This string is appended after a '?' character and is 
			called the "query."
			The URL and its query are submitted to pop_up.html by the
			"GET" method.

			pop_up.html will take the query and pass it on to popup1.html.

			popup1.html will process the query and create an array of
			complete URLs for all the requested images.
			Then it will animate them.


	*/

	var theForm;
	if (document.layers && document.layers[layerID].document.forms[formID]){
		theForm = document.layers[layerID].document.forms[formID];
	} else if (document.getElementById) {

		/* Galeon understood the namedItem method for nodeList objects, but
		Konqueror didn't.  That forced me to write this loop.  */
		var formList = document.getElementById(layerID).getElementsByTagName("FORM");
		for (var i=0; i<formList.length; i++) {
			if (formList.item(i).name == formID) {
				theForm = formList.item(i);
			}
		}
	} else if (document.all) {
		theForm = document.all[layerID].all[formID];
	} else {
		alert("could not define theForm");
	}
	
	
	
	//alert("theForm.all_middles:"+theForm.all_middles.value);
	var slim_array = new Array();
	slim_array = certain_dates(theForm);
	var tmp_array = slim(slim_array);
	slim_array = tmp_array;
	//alert("slim length:"+slim_array.length+"\nslim:"+slim_array);

	/*
		The full path will be constructed from various parts:
			prefix(static) + middle + suffix(static)
		The middle string is often very similar from frame
		to frame, so I created another variable, longstring,
		in which the common characters are stored.
		Each middle string will be scanned for a dollar sign
		and if there is one, it will be replaced by the
		string, longstring.

	*/

	var all_middles_query = "&all_middles=" + slim_array.join("%20");
	var myQuery = "?date="+theForm.date.value;
	myQuery += "&prefix="+theForm.prefix.value;
	myQuery += "&suffix="+theForm.suffix.value;
	if (theForm.longstring != null) {
		myQuery += "&longstring="+escape(theForm.longstring.value);
	}
	myQuery += all_middles_query;


	if (slim_array.length > 0) {
		//location.href = "../pop_up.html" + myQuery;
		location.href = "../popup1.html" + myQuery;
		//alert("location.href="+ location.href);
	} else {
		var extra_days = document.max_fr_ex_days.extra_days.options[document.max_fr_ex_days.extra_days.selectedIndex].value;

		alert("Sorry! Image category unavailable for " +
			theForm.date.value + ".\n" +
			"Change date or increase \"extra days\".");
	}
}

