// From:
// http://developer.mozilla.org/en/docs/DOM:window.open

var WindowObjectReferencePre = null; // global variable
var WindowObjectReference = null; // global variable

function openPreview (strUrl) {
  	// window.open(strurl, "ringpreview","width=350,height=300,statusbar=auto,toolbar=0,scrollbars=no,resizable,menubar=no");
	if(WindowObjectReference == null || WindowObjectReference.closed)
  	{
	    WindowObjectReference = window.open(strUrl, "ringpreview",
	           "width=350,height=300,statusbar=auto,toolbar=0,scrollbars=yes,resizable,menubar=no");
	  }
	  else if(previousUrl != strUrl)
	  {
	    WindowObjectReference = window.open(strUrl, "ringpreview", "width=350,height=300,statusbar=auto,toolbar=0,scrollbars=yes,resizable,menubar=no");
	    /* if the resource to load is different,
	       then we load it in the already opened secondary window and then
	       we bring such window back on top/in front of its parent window. */
	    WindowObjectReference.focus();
	  }
 	 else
	  {
	    WindowObjectReference.focus();
	  };
	  previousUrl = strUrl;
  /* explanation: we store the current url in order to compare url
     in the event of another call of this function. */
}


var WindowObjectReference = null; // global variable

function openBuyLink(strUrl, strWindowName) {

if(WindowObjectReference == null || WindowObjectReference.closed)
  {
    WindowObjectReference = window.open(strUrl, "ringbuy",
           "width=800,height=800,statusbar=auto,toolbar=0,scrollbars=yes,resizable,menubar=no");
  }
  else if(previousUrl != strUrl)
  {
    WindowObjectReference = window.open(strUrl, "ringbuy", "width=800,height=800,statusbar=auto,toolbar=0,scrollbars=yes,resizable,menubar=no");

    WindowObjectReference.focus();
  }
  else
  {
    WindowObjectReference.focus();
  };
  previousUrl = strUrl;
  /* explanation: we store the current url in order to compare url
     in the event of another call of this function. */
}