function openWindow(url,w,h) {
	adviceWin = window.open(url,'advice','status=no,width='+w+',height='+h+',menubar=no,scrollbars=yes');
	adviceWin.focus(true);
	}

function clearText(thefield)	{
	if (thefield.defaultValue == thefield.value)
		thefield.value = "";
}

function changeDisplay(ID)	{
//	alert(document.getElementById(ID).style.display);
	if(document.getElementById(ID).style.display == 'block')
		document.getElementById(ID).style.display='none';
	else
		document.getElementById(ID).style.display = 'block';
	
	}
	
function selectOption(itemToSelect,formField)	{
	itemToSelect = itemToSelect.replace('%3A',':')  //here for when in use on a finder.
// Get a reference to the drop-down
	var myDropdownList = formField;

// Loop through all the items
	for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++)	{    
		if (myDropdownList.options[iLoop].id == itemToSelect)	{
// Item is found. Set its selected property, and exit the loop
			myDropdownList.options[iLoop].selected = true;
			break;
			}
		}
	}



function zoom (url) {
	z = window.open('','zoom_popUp','status=0,directories=0,toolbar=0,menubar=0,resizable=1,scrollbars=1,location=0');
	z.document.write('<html>\n<head>\n<title>Picture Zoom</title>\n</head>\n<body>\n<div align="center">\n<img src="' + url + '"><br>\n<form><input type="button" value="Close Window" onClick="self.close(true)"></form>\n</div>\n</body>\n</html>\n');
	z.document.close();
	z.focus(true);
	}


function buttonSwap(imageID,onoff)	{
	document[imageID].src="//static.zoovy.com/merchant/gkworld/_ticket_336384/gk08_p_"+imageID+"_"+onoff+"-192x25.gif";
	}




/*
This function compiles the query based on what is/isn't checked/selected and saves it to a hidden input (query)
used in query based finders
*/
function compileNsubmit()	{
	var query = "";
	var options_keys = new Array();
	var sogs = new Array();
// loop through the form.  If the type is a checkbox AND it is checked, add the key to the options_array.
	for(i=0; i<document.myfinder.elements.length; i++){

		
		if(document.myfinder.elements[i].type == 'checkbox' && document.myfinder.elements[i].checked == true)	{
		// check to see if sogs(SOGID) array exists and create it or add to it.
			if(sogs[document.myfinder.elements[i].name.substr(0,2)] == undefined)	{
				sogs[document.myfinder.elements[i].name.substr(0,2)] = new Array();
				sogs[document.myfinder.elements[i].name.substr(0,2)].push(document.myfinder.elements[i].name);
				
				}
			else
				sogs[document.myfinder.elements[i].name.substr(0,2)].push(document.myfinder.elements[i].name);
		// add the current sog id to the options_keys array ONLY if it isn't already present.			
			if(options_keys.indexOf(document.myfinder.elements[i].name.substr(0,2)) == -1)
				options_keys.push(document.myfinder.elements[i].name.substr(0,2));
		
			}

//get select lists into arrays used to generate query.

		else if(document.myfinder.elements[i].type == 'select-one')	{
			selectId = document.getElementById("finderSelect_"+document.myfinder.elements[i].name);
			if(selectId.value != '')	{
		//		alert("Type is select.\nname = "+document.myfinder.elements[i].name+"\n selected value = "+selectId.value);
		
		//create array for sog value. Not ideal because there is always only 1 value but it humms along with how the checkboxes work.
				sogs[document.myfinder.elements[i].name] = new Array();
				sogs[document.myfinder.elements[i].name].push(document.myfinder.elements[i].value);
		
		// add the current sog id to the options_keys array
				options_keys.push(document.myfinder.elements[i].name);
				}
			}
	
		}
//use the id's in the options_keys array to put the query together. 
//If multiple pogs are present, they must be contained within ().  
//Each value, solo or grouped, needs to be in quotes. 

	for(i = 0; i < options_keys.length; i++)	{
		if(sogs[options_keys[i]].length > 1)	{
			query += '+(';
			for(u = 0; u < sogs[options_keys[i]].length; u++)	{
				if(u != 0)
					query += ' ';
				query += '%22'+sogs[options_keys[i]][u]+'%22';
				}
			query += ')';
			}
		else
			query += '+%22'+sogs[options_keys[i]]+'%22 ';
		}
//set the value of a hidden input so that the query gets passed when the form is submitted.
//	alert(query);
	document.myfinder.query.value = query;
	document.myfinder.submit();
	}

