function register_page_load()
{
	document.forms["f_register"].rfn.focus();
}

function logon_page_load()
{
	document.forms["f_logon"].le.focus();
}

function set_search(s_name, s_value)
{
	var sSearchString
	
	if (s_name == "wr")
	{
		sSearchString = searchLoc(s_name, s_value);
		sSearchString = searchLoc("sr", "-1", sSearchString);
		sSearchString = searchLoc("zn", "-1", sSearchString);
	}
	else if (s_name == "sr")
	{
		sSearchString = searchLoc(s_name, s_value);
		sSearchString = searchLoc("zn", "-1", sSearchString);
	}
	else
	{
		sSearchString = searchLoc(s_name, s_value);
	}
	
	document.location.search = sSearchString
}

function searchLoc(s_name, s_value)
{
	var x, bNameFound;
	var sLocSearch, sSearchParts, sNewLocSearch;
	var aSearchPairs, aSearch;
	
	if (!arguments[2])
	{
		sLocSearch = document.location.search;
	}
	else
	{
		sLocSearch = arguments[2];
	}
	
	sSearchPart = sLocSearch.replace(/\?/, "");
	aSearchPairs = sSearchPart.split("&");
	
	sNewLocSearch = "?";
	bNameFound = false;
	for (x = 0; x < aSearchPairs.length; x++)
	{
		aSearch = aSearchPairs[x].split("=");
		if (aSearch[0] == s_name)
		{
			aSearch[1] = s_value;
			bNameFound = true;
		}
		
		if (aSearchPairs[x].length > 0)
		{
			if (sNewLocSearch.length == 1)
			{
				sNewLocSearch += aSearch[0] + "=" + aSearch[1];
			}
			else
			{
				sNewLocSearch += "&" + aSearch[0] + "=" + aSearch[1];
			}
		}
	}
	
	if (!bNameFound)
	{
		if (sNewLocSearch.length == 1)
		{
			sNewLocSearch += s_name + "=" + s_value;
		}
		else
		{
			sNewLocSearch += "&" + s_name + "=" + s_value;
		}
	}
	
	return sNewLocSearch;
}

function setCheckBoxes(id_value, check_it)
{
	var x;
	var oForm, oElements;
	var aChkbox;
	
	oForm = document.forms[0];
	oElements = oForm.elements;
	
	for (x = 0; x < oElements.length; x++)
	{
		if (oElements[x].type == "checkbox")
		{	
			aChkbox = oElements[x].id.split("_");
			if (aChkbox[0] == id_value || aChkbox[1] == id_value)
			{
				oElements[x].checked = check_it;
			}
		}
	}
}

function getCheckBoxes()
{
	var x;
	var oForm, oElements;
	var aChkbox;
	var sResorts = "";
	
	oForm = document.forms[0];
	oElements = oForm.elements;
	
	for (x = 0; x < oElements.length; x++)
	{
		if (oElements[x].type == "checkbox" && oElements[x].checked)
		{	
			aChkbox = oElements[x].id.split("_");
			if (aChkbox[0] == "grouped" || aChkbox[0] == "single")
			{
				sResorts += aChkbox[1] + ",";
			}
		}
	}
	
	if (sResorts.length != 0)
	{
		oForm.selected_resorts.value = sResorts.substr(0, sResorts.length - 1);
		oForm.submit();
	}
	else
	{
		alert("No resorts where selected, nothing was added.");
	}
}

function removeResorts()
{
	var x;
	var oForm, oElements;
	var aChkbox;
	var sResorts = "";
	
	oForm = document.forms.resorts;
	oElements = oForm.elements;
	
	for (x = 0; x < oElements.length; x++)
	{
		if (oElements[x].type == "checkbox" && oElements[x].checked)
		{	
			aChkbox = oElements[x].id.split("_");
			if (aChkbox[0] == "resort")
			{
				sResorts += aChkbox[1] + ",";
			}
		}
	}
	
	if (sResorts.length != 0)
	{
		oForm.resorts.value = sResorts.substr(0, sResorts.length - 1);
		oForm.submit();
	}
	else
	{
		alert("No resorts where selected, nothing was added.");
	}
}

/*
	View, Edit, Delete Links
*/
function viewLinkInfo(link_id)
{
	document.location.search = "?pg=2&lid=" + link_id;
}

function editLinkInfo(link_id)
{
	document.location.search = "?pg=2&lid=" + link_id;
}

function deleteLinkInfo(link_id)
{
	if (confirm("Are you sure you wish to remove this Link?"))
	{
		document.location.search = "?pg=3&lid=" + link_id;
	}
}

function addResorts(link_id)
{
	var sURL = "atr-ip-get-resorts.asp?lid=" + link_id;
	var new_win = window.open(sURL,"add_resorts","width=800, height=600, resizable, scrollbars, status");
}