function relocate_to(url, target_ref)
{
	var hash = "";
	
	if (url.indexOf("#") >= 0)
	{
		hash = url.substring(url.indexOf("#"));
		url = url.substring(0, url.indexOf("#"));
	}
	
	if (url.indexOf("?") == -1)
		url += "?";

	if (url.indexOf("?") != (url.length - 1))
		url += "&";

	var target;
	if (target_ref == null)					target = "top";
	else if (typeof target_ref == "object")	target = target_ref.name;
	else if (typeof target_ref == "string")	target = target_ref;
	
	var obj = eval(target);
	
	if (typeof sc != "undefined")
		url += "sc=" + sc + "&";
	
	obj.location.href = url + hash;
	
	return true;
}


function build_location_parameter()
{ 
	var continent_index = document.this_page.continent[document.this_page.continent.selectedIndex].value;
	var country_index 	= document.this_page.country[document.this_page.country.selectedIndex].value;
	
	document.this_page.action 			= "mail_agent.asp?location=" + continent_index + "£" + country_index;
	document.this_page.submit();
}		



function validate_not_blank(field, name)
{
	// strip all spaces at start and end of line
	var regx_output = new String(field.value);
	var re1 = new RegExp("^[ ]*|([ ]*)\$", 'g');
	field.value = regx_output.replace(re1, "");
	
	if (field.value == "")
	{
		alert(format_str('Feltet "%s" må ikke være blankt.', name));
		focus_field(field);
		return false;
	}
	return true;
}



function change_image_over(img_id, elem_name)
{
	alert(img_id+"--"+elem_name)
	document.elem_name.src = "images/job/" + img_id;
}
function change_image_out(img_id, elem_name)
{ alert(img_id+"--"+elem_name)
	document.elem_name.src = "images/job/" + img_id;
}




function show_print_job(sa_id)
{
	var width = 710;
	var height = 600;
	var top = 50;
	var left = 50;
	window.open("print_job.asp?sa_id=" + sa_id, "", "toolbar=no,directories=no,menubar=no,scrollbars=yes,status=yes,resizable=1,left=" + left + ",top=" + top + ",width=" + width + ",height=" + height);
}




function show_create_mail_agent()
{
	var width = 480;
	var height = 500;
	var top = 50;
	var left = 50;
	window.open("mail_agent.asp", "", "toolbar=no,directories=no,menubar=no,scrollbars=yes,status=yes,resizable=1,left=" + left + ",top=" + top + ",width=" + width + ",height=" + height);
}




function show_delete_mail_agent()
{
	var width = 710;
	var height = 600;
	var top = 50;
	var left = 50;
	window.open("mail_agent.asp?delete=1", "toolbar=no,directories=no,menubar=no,scrollbars=yes,status=yes,resizable=1,left=" + left + ",top=" + top + ",width=" + width + ",height=" + height);
}
