function PopupBlockerWarning()
{
	alert("Please disable the popup blocker for this website!");
}

function ReloadPage()
{
	try
	{
		__doPostBack("btnRefresh", "");
	}
	catch(e)
	{
	}
}

function ReloadOpenerPage()
{
	if(window.opener != null && typeof(window.opener.ReloadPage) != "udefined")
		window.opener.ReloadPage();
}

function OpenWin(url, width, height, name)
{
	height = height || 700;
	width = width || 600;
	var str = "height=" + height + ",innerHeight=" + height ;
	str += ",width=" + width + ",innerWidth=" + width;
	str += ",toolbar=no,resizable=yes,scrollbars=yes,titlebar=no";
	if(window.screen) 
	{
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	var win = window.open(url, name || "blank_", str);
	if(win == null)
	{
		PopupBlockerWarning();
		return;
	}
}

function SelectAll(form, blnSelect)
{
	var nLength = form.elements.length;
	if(typeof(nLength) !=" undefined")
		for(var i=0; i<nLength; i++)
			if(form.elements[i].type == "checkbox")
				form.elements[i].checked = blnSelect;
}

function Prev(button, id)
{
	try
	{
	
		var arrIds = window.opener.arrRecordIds;
		var i = IndexOfItem(arrIds, id);
		if(i > 1)
			ViewRecord(arrIds[i-1]);
	}
	catch(e)
	{
	}
}

function Next(button, id)
{
	try
	{
		var arrIds = window.opener.arrRecordIds;
		var i = IndexOfItem(arrIds, id);
		if(i > 0 && i < arrIds.length - 1)
			ViewRecord(arrIds[i+1]);
	}
	catch(e)
	{
	}
}

function IndexOfItem(arr, item)
{
	for(var i = 0; i < arr.length ; i++)
	 if(arr[i] == item)
		return i;
	return -1;
}

function ViewRecord(id)
{
	var str = new String(document.location);
	var arrPath = str.split("?");
	var arrQueryString = arrPath[1].split("&");
	var arrNameValue = arrQueryString[0].split("=");
	arrNameValue[1] = id;
	arrQueryString[0] = arrNameValue.join("=");
	arrPath[1] = arrQueryString.join("&");
	str = arrPath.join("?");
	document.location = str;
}

function SendMessage(id)
{
	OpenWin("SendMessage.aspx?id=" + id, 600, 500, "send_message");
}
