//HC:Popup window script that is dynamic and will regain focus
// Modified link system to use this one script and pass parameters
// for lighter page weight and more flexibility.
function pop(u,n,f){
    var d = "default";
    var sf = "directories,location,menubar,resizable,scrollbars,status,toolbar";
    if (!n){n = d}
    if (!f){f = sf}
    pw = window.open(u,n,f);
    pw.focus();
}

// AP: This function changes the location of the Parent window and closes the corresponding pop-up
function changeParentWindow(url) {
    opener.location=url;
    self.close();
    opener.focus();
}

function changeParentFrameWindow(url) {
    opener.top.location.href=url;
    self.close();
    opener.focus();
}

function closeWindow() {
    self.close ()
}

// AP: Timed window function, takes time parameter in seconds
var timerID = null;
function wait(time) {
    timerID = setTimeout("closeWindow()",time*1000)
}

function changeCssClassAndStatus(docObject, cssClassName, statusText) {
    docObject.className=cssClassName;
    writeStatus(statusText);
}

function writeStatus(text) {
    window.status = text;
}

//////////////////////////////////////////////////////////
///	 couple search functions
///	 
///	 "erases" text in box onFocus
///	 sets value to empty if user doesn't click in box
///
//////////////////////////////////////////////////////////

	var firstNameFocus = false;
	var lastNameFocus = false;
	function nameFocus(fieldName) {
		if(fieldName.name == "rfn") {
			if(!firstNameFocus) {
				firstNameFocus = true;
				fieldName.value = "";
			}
		} else if(fieldName.name == "rln") {
			if(!lastNameFocus) {
				lastNameFocus = true;
				fieldName.value = "";
			}
		}
	}
	
	function onSearchSubmit(theForm) {
		if(theForm.rfn.value == "FIRST NAME") {
			theForm.rfn.value = "";
		}
		if(theForm.rln.value == "LAST NAME") {
			theForm.rln.value = "";
		}
		return true;
	}

	
//////////////////////////////////////////////////////////
///	 Added from Couple Search for consolidation
///	 061605 - Blair
///
///	 Pops up a new window
///
//////////////////////////////////////////////////////////
var newWin;
function onClick() {
	if (!newWin || newWin.closed) {
		newWin = window.open();
		newWin.focus();
	}
	else {
		newWin.focus();
	}
}
function openPopUpWindow(url,popupname,width,height,scrollbars,resizable) {
   	popup = open(url,popupname,"width=" + width + ",height=" + height + ",scrollbars=" + scrollbars + ",resizable=" + resizable);
   	popup.top.focus();
}
//////////////////////////////////////////////////////////
///	 Added from GVR for consolidation
///	 062905 - Blair
///
///	 Netscape 4.0 warning
///
//////////////////////////////////////////////////////////

var win = 0;
function zeroNeedsWarning(queryString, pq) {
  var version  = "4.00";
  var browser  = "netscape";

  var url = "zero_needs_warning.asp?" + queryString + "&ipq=" + pq;
  win = window.open(url,"Warning","width=250,height=200");
  if ( (browser == "IE") && (version > 4) ){
    win.top.focus();
  }
}

function closeWarningWindow() {
  var url = "zero_needs_warning.asp?" + "";
  var version  = "4.00";
  var platform = "unknown";
  var browser  = "netscape";
  if ((platform != "MacPPC") && (browser == "IE") && (version >= 4) && win){
    win.close();
  }
}

function checkIt(quantityNeeded,inputQuantity){
	if(quantityNeeded<inputQuantity){
		alert("Please enter a value not greater than the quantity needed.");
		return false;
	}else{
		return true;
	}
}

function reloadParent() {
  if (window.opener != null && window.opener.closed) {
    new_win=window.opener.reload();
    new_win.top.focus();
  }
  else if (opener != null) {
    opener.parent.location.reload();
    opener.parent.focus();
  }
  else {
    window.open("/login/login.asp");
  }
  self.close();
}

function closeSelfAndSubmitParent() {
  if (window.opener != null) {
    window.opener.updateLayer();
  }
  else {
    window.open("/login/login.asp");
  }
  self.close();
}

function updateParentAndClose(newURL) {
  updateParent(newURL);
  self.close();
}

function updateParent(newURL) {
  if (window.opener != null && window.opener.closed) {
    new_win=window.open(newURL);
    new_win.top.focus();
  }
  else if (opener != null) {
    opener.parent.location=newURL;
    opener.parent.focus();
  }
  else {
    window.open("/login/login.asp");
  }
}

var searchPop;
var name =  "PopWin";

function checkPop(url, properties) {
  var ua = navigator.userAgent.indexOf("AOL");
  if (ua != -1) {
    searchPop = window.open(url, name, properties);
    searchPop.focus();
  }
  else
  {
    if (!searchPop || searchPop.closed)
    {
      searchPop = window.open(url, name, properties);
      searchPop.focus();
    }
    else
    {
      searchPop.focus();
    }
  }
}

function PopUp(url, width, height) {
  var properties = "width=" + width + ",height=" + height + ", scrollbars=no, resizable=no, top=100, left=100";

  checkPop(url, properties)
}

function PopSdp(url, width, height) {
  var properties = "width=" + width + ",height=" + height + ",resizable,top=100,left=100,scrollbars=yes";

  checkPop(url, properties)
}

////////////////////////////////////////////////////////////////////////
///
///
///    below pulled from NGS\web\gvr\guestViewStoreBl.vm
///    to clean up page  (Blair - 05242007)
///
///
//////////////////////////////////////////////////////////////////////////

var searchPop;
var name =  "PopWin";

function checkPop(action, properties) {
		searchPop = window.open(action, name, properties);
		searchPop.focus();
		}

function PopUp(action, width, height) {
	var properties = "width=" + width + ",height=" + height + ", scrollbars=no, resizable=no, top=100, left=100";
	checkPop(action, properties)
}

function openPopupWindow(action,popupname,width,height,left,top,screenX,screenY,scrollbars,resizable) {
	var popup = open(action,popupname,"width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",screenX" + screenX + ",screenY " + screenY + ",scrollbars=" + scrollbars + ",resizable=" + resizable);
	if (null != popup) {
		popup.focus();
}
}

function PopCharity(url, width, height) {
var name =  "PopWin";
var properties = "width=" + width + ",height=" + height + ",top=100,left=100,scrollbars=yes,resizable=yes";
var ua = navigator.userAgent.indexOf("AOL");
	if (ua != -1) {
	searchPop = window.open(url, name, properties);
	searchPop.focus();
	} else {
		if (!searchPop || searchPop.closed) {
		searchPop = window.open(url, name, properties);
		searchPop.focus();
		} else {
		searchPop.focus();
	}
}
}
