﻿//*****************************************************************************
//Get the X coordinate of an object.
function findPosX(obj) {
	var curleft = 0;
	
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
		
	return curleft;
}
//*****************************************************************************
//Get the Y coordinate of an object.
function findPosY(obj) {
	var curtop = 0;
	
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
		
	return curtop;
}
//*****************************************************************************
//Perform a search.
function fnSearch(searchPage, query) {
  //Verify the query.
  if (query == "") {
    alert('Please enter one or more search keywords before clicking the search button.');    
  }

  window.location = searchPage + "?k=" + escape(query);
}

//*****************************************************************************
//Perform a search from pressing enter on the keyboard.
function fnTriggerSearch(userEvent, field) {
	var kCode = String.fromCharCode(userEvent.keyCode);
	
	if(kCode == "\n" || kCode == "\r"){
		userEvent.returnValue = false;
		
    fnSearch("/SRT/searchresults.aspx", field.value);
  }
}

//*****************************************************************************
//Open a pop up.
function OpenPopUp(pageURL, pageName) {
  var strOptions = '';

	if (screen.availHeight > 600) { 
		strOptions += ',top=' + (screen.availHeight-600)/2;
	}
	if (screen.availWidth > 400) { 
		strOptions += ',left=' + (screen.availWidth-400)/2;
  }

  var newWin = window.open(pageURL, pageName, 'width=600,height=400,resizable=yes,menubar=no,location=no,scrollbars=yes,status=no,toolbar=no' + strOptions);
  
  newWin.focus();
}


//*****************************************************************************
//Open a large pop up.
function OpenLargePopUp(pageURL, pageName) {
  var strOptions = '';

	if (screen.availHeight > 800) { 
		strOptions += ',top=' + (screen.availHeight-800)/2;
	}
	if (screen.availWidth > 600) { 
		strOptions += ',left=' + (screen.availWidth-600)/2;
  }

  var newWin = window.open(pageURL, pageName, 'width=800,height=600,resizable=yes,menubar=no,location=no,scrollbars=yes,status=no,toolbar=no' + strOptions);
  
  newWin.focus();
}


//*****************************************************************************
var rowDisplay = 'block';

if (document.all) {
  rowDisplay = 'block';
}
else {
  rowDisplay = 'table-row';
}


//*****************************************************************************
//Show or hide a table row.
function ShowHideRow(rowID) {
  var tableRow = document.getElementById(rowID);
  var linkText = document.getElementById("a_" + rowID);
  
  if (tableRow != undefined) {
    //Set the row display.
    if (tableRow.style.display == "none") {
      tableRow.style.display = rowDisplay;
      
      linkText.innerHTML = "Hide Details";
    }
    else {
      tableRow.style.display = "none";
      
      linkText.innerHTML = "View Details";
    }
  }
  
  return false;
}

//*****************************************************************************
//Show or hide a table.
function ShowHideTable(tableID) {
  var table = document.getElementById(tableID);
  var linkText = document.getElementById("a_" + tableID);

  if (table != undefined) {
    //Set the row display.
    if (table.style.display == "none") {
      table.style.display = "block";
      
      linkText.innerHTML = "Hide Details";
    }
    else {
      table.style.display = "none";
      
      linkText.innerHTML = "View Details";
    }
  }
  
  return false;
}


//*****************************************************************************
//Confirm the user wants to cancel.
function ConfirmCancel() {
  if(confirm("Are you sure that you want to cancel your changes?  Please click OK to cancel your changes or Cancel to return to the current page.") == true) {
    return true;
  }
  else {
    return false;
  }
}


//*****************************************************************************
//Confirm the user wants to delete.
function ConfirmDelete() {
  if(confirm("Are you sure that you want to delete the selected record(s)?  Please click OK to delete or Cancel to abort.") == true) {
    return true;
  }
  else {
    return false;
  }
}


//*****************************************************************************
//Confirm lock thread.
function ConfirmLockThread() {
  if(confirm("Are you sure that you want to lock this thread?  Please click OK to lock this thread or Cancel to abort.") == true) {
    return true;
  }
  else {
    return false;
  }
}

//*****************************************************************************
//Confirm unlock thread.
function ConfirmUnlockThread() {
  if(confirm("Are you sure that you want to unlock this thread?  Please click OK to unlock this thread or Cancel to abort.") == true) {
    return true;
  }
  else {
    return false;
  }
}

//*****************************************************************************
//Confirm delete thread.
function ConfirmDeleteThread() {
  if(confirm("Are you sure that you want to delete this thread?  Please click OK to delete this thread or Cancel to abort.") == true) {
    return true;
  }
  else {
    return false;
  }
}

//*****************************************************************************
//Confirm delete post.
function ConfirmDeletePost() {
  if(confirm("Are you sure that you want to delete this reply?  Please click OK to delete this reply or Cancel to abort.") == true) {
    return true;
  }
  else {
    return false;
  }
}

//*****************************************************************************
//Confirm move thread.
function ConfirmMoveThread() {
  if(confirm("Are you sure that you want to move this thread to a different forum?  Please click OK to move this thread or Cancel to abort.") == true) {
    return true;
  }
  else {
    return false;
  }
}
