// JavaScript Document

var slideIncrement = 5;
var startpos = 220;
var endpos = 440;
var optState = "closed";

function getSearchform() {
	var searchform = document.getElementById('searchform'); //Get the div that holds the images in a line
	return searchform;
}

function showoptions() {
	var searchform = getSearchform();
	var searchformwidth = searchform.style.width;
	//alert(searchformwidth+","+startpos+"px");
	if (searchformwidth == (startpos+"px")) {
		openoptions();
	} else if (searchformwidth == (endpos+"px")) {
		closeoptions();
	}
}

function openoptions() {
	var searchform = getSearchform(); //Get the div that holds the images in a line
	var startposa = searchform.style.width;
	startposa = startposa.substring(0, startposa.length-2); //Strip the 'px' from the style value
	if (searchform.slide)	{
		window.clearInterval(searchform.slide);
	}
	searchform.slide = window.setInterval(
		function()
		{
			if (parseInt(startposa) < parseInt(endpos)) {
				startposa = parseInt(startposa)+slideIncrement;
				searchform.style.width = startposa + "px";
			} else {
				window.clearInterval(searchform.slide);
			}
		}
	, 1);
	document.getElementById('waitstretch').style.width = endpos - 14 + "px";
	swapOptionButton();
}

function closeoptions() {
	var searchform = getSearchform(); //Get the div that holds the images in a line
	var startposa = searchform.style.width;
	startposa = startposa.substring(0, startposa.length-2); //Strip the 'px' from the style value
	if (searchform.slide)	{
		window.clearInterval(searchform.slide);
	}
	searchform.slide = window.setInterval(
		function()
		{
			if (parseInt(startposa) > parseInt(startpos)) {
				startposa = parseInt(startposa)-slideIncrement;
				searchform.style.width = startposa + "px";
			} else {
				window.clearInterval(searchform.slide);
			}
		}
	, 1);
	document.getElementById('waitstretch').style.width = startpos - 14 + "px";
	swapOptionButton();
}

function swapOptionButton() {
	if (optState == "closed") {
		optState = "open";
		document.getElementById('moreoptions').style.display = 'none';
        document.getElementById('closeoptions').style.display = 'block';
	} else if (optState == "open") {
		optState = "closed";
        document.getElementById('moreoptions').style.display = 'block';
        document.getElementById('closeoptions').style.display = 'none';
	}
}

function hideErrors() {
    document.getElementById('errorwrap').style.display = 'none';
    document.getElementById('errorinner').style.display = 'none';
    if (document.getElementById('errorframe') != undefined) {
        document.getElementById('errorframe').style.display = 'none';
    }
}
