
var EXPAND = 1;
var CONTRACT = 0;

//--

function BODYOnLoad()
{
  ChangeExpandMode("ExpandProv", CONTRACT);
  ChangeExpandMode("ExpandList", CONTRACT);
  ChangeExpandMode("Expand40Flat", CONTRACT);

  ContractServiceHitsPage(3);
  ContractServiceHitsPage(2);
  ResetSelectBoxes();
}

//--

function OpenHelpWindow(link)
{
  var newWindow = window.open("","","scrollbars=1 resizable=1 width=300 height=300");
  newWindow.location = link;
}

function CallHelpForSearch()
{
  OpenHelpWindow("/Asp/help_service_appr.asp");
}

function ResetSelectBoxes()
{
  //this code is needed to reset if the user presses the BACK button
  document.forms[0].selectServiceCar.selectedIndex = 0;
  document.forms[0].selectServiceHome.selectedIndex = 0;

  document.forms[0].selectApproverCar.selectedIndex = 0;
  document.forms[0].selectApproverHome.selectedIndex = 0;

  document.forms[0].selectServiceBusinessLeisure.selectedIndex = 0;
  document.forms[0].selectApproverBusinessLeisure.selectedIndex = 0;
}


//-- expand code

var expandedContent = "";

var expandName = new Array();
var expandContent = new Array();

function SaveExpandContent(strName)
{
	//find expand content
	var i, l;
	var found = false;
	l = expandName.length;
	i=0;
	while (i<l && !found)
	{
		if (expandName[i] == strName)
		{
			found = true;
		}
		else
		{
			i++;
		}
	}

	//i is now pos of found or place to put new one
	
	//add new name to parallel list if !found

	if (!found) expandName[i] = strName;

	//get content

	var strContent = document.getElementById("div" + strName + "Expand").innerHTML;

	//save content

	expandContent[i] = strContent;
}

function RestoreExpandContent(strName)
{
	//find expand content
	var i, l;
	var found = false;
	l = expandName.length;
	i=0;
	while (i<l && !found)
	{
		if (expandName[i] == strName)
		{
			found = true;
		}
		else
		{
			i++;
		}
	}

	//i is now pos of found

	document.getElementById("div" + strName + "Expand").innerHTML = expandContent[i];
}

function ChangeExpandMode(strName, mode)
{
	var divExpandSymbol = document.getElementById("div" + strName + "Symbol");
	var divExpandText = document.getElementById("div" + strName + "Text");
	var divExpand = document.getElementById("div" + strName + "Expand");

	var strPlusOrMinus;
	var strMode;
	var strText;

	if (mode == EXPAND)
	{
		strPlusOrMinus = "-";
		strMode = "CONTRACT";
		strText = " to hide again...";
		RestoreExpandContent(strName);
	}
	else if (mode == CONTRACT)
	{
		strPlusOrMinus = "+";
		strMode = "EXPAND";
		strText = " to show more...";
		SaveExpandContent(strName);
		divExpand.innerHTML = "";
	}

	divExpandSymbol.innerHTML = "" +
	"<a class='expand' href='javascript:ChangeExpandMode(" +
	"\"" + strName + "\"" +
	"," +
	strMode +
	")'>" +
	strPlusOrMinus +
	"</a>";

	divExpandText.innerHTML = "" +
	"<a href='javascript:ChangeExpandMode(" +
	"\"" + strName + "\"" +
	"," +
	strMode +
	")'>" +
	"click here</a>" +
	strText;

}

//-- end expand code


function ExpandServiceHitsPage(iPage)
{
  RestoreExpandContent("ExpandServiceHits" + iPage);
  document.getElementById("divExpandServiceHits" + iPage + "Text").innerHTML = "";
}

function ContractServiceHitsPage(iPage)
{
  SaveExpandContent("ExpandServiceHits" + iPage);
  document.getElementById("divExpandServiceHits" + iPage  +"Expand").innerHTML = "";
}

function ShowLast3MonthsServiceHits()
{
	window.location = "/?show_service_hits_for_last_3_months=1#service_hits";
}