var doc = document;
var docFrm = document.forms[1];
var success;

function ShowSecretaries(letter){
	document.forms[1].Filter.value = letter;
	document.forms[1].submit();
}

// parse the querystring into a name/value collection
function parseQueryString (str) 
{
  str = str ? str : location.search;
  var query = str.charAt(0) == '?' ? str.substring(1) : str;
  var args = new Object();

  if (query) 
  {
    var fields = query.split('&');
    for (var f = 0; f < fields.length; f++) 
    {
		var field = fields[f].split('=');
		args[unescape(field[0].replace(/\+/g, ' '))] = unescape(field[1].replace(/\+/g, ' '));
    }
  }
  return args;
}

// modify parsed query string value, return rebuilt url
function ChangeQueryStringValue(key, val)
{
	var url = "http://" + window.location.host + window.location.pathname + "?";
	var args = parseQueryString();
	
	args[key] = val;

	var i = 0;
	for (var arg in args) 
	{
		if (i != 0)
			url += "&";
		url += arg + "=" + args[arg];
		i++;
	}
	return url;
}

// move to selected page
function ChangePage(pageNum)
{
	window.location.href = ChangeQueryStringValue("page", pageNum);
}

// change to selected sort order
function ChangeOrder(ord)
{
	window.location.href = ChangeQueryStringValue("sort", ord);
}

// show popup window
function ShowPopup(path, title, width, height, top, left)
{
	var leftPosition;
	var topPosition;
	
	height = typeof height != "undefined" ? height : 400;
	width = typeof width != "undefined" ? width : 400;
	
	if(typeof top == "undefined")
		topPosition = (screen.height) ? (screen.height-height)/2 : 0;
	else
		topPosition = top;
		

	if(typeof left == "undefined")
		leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	else
		leftPosition = left;

	window.open(path, title, "scrollbars=yes,height="+ height +",width="+ width +",status=no,toolbar=no,menubar=no,location=no,resizable=no, top=" + topPosition + ", left=" + leftPosition);
}


// vehicle print
function PrintVehicle(vehicleid)
{
	if(vehicleid.length <1)
		return false;
	path = "/funeral-profession/search-for/funeral-cars-for-sale/printvehicle.aspx?vehicleid=" + vehicleid;
	ShowPopup(path, "PrintVehicle", 638, 700);
}

// vehicle print
function PrintSQMReport(InspectionId)
{
	if(InspectionId.length <1)
		return false;
	path = "/funeral-profession/nafd-members/printreport.aspx?InspectionId=" + InspectionId;
	ShowPopup(path, "PrintReport", 638, 700);
}


function PrintVacancy(id)
{
	if(id.length <1)
		return false;
	path = "/funeral-profession/search-for/search-for-vacancies/print-vacancy.aspx?vacancyid=" + id;
	ShowPopup(path, "PrintVacancy", 638, 700);
}
