/*
+-----------------------------------------------------------------+
| Fn name:    popwin                                              |
+-----------------------------------------------------------------+
| Purpose:    Opens popup window w/fixed window options           |
+-----------------------------------------------------------------+
| Inputs:     string URL                                          |
|             string name (name of popup window)                  |
|             int w (width of popup window)                       |
|             int h (height of popup window)                      |
+-----------------------------------------------------------------+
| Returns:    nothing                                             |
+-----------------------------------------------------------------+
*/
function popwin(URL, name, w, h)
{
   var winl = (screen.width - w) / 2;
   var wint = (screen.height - h) / 2;
	window.open(URL, name, "width="+w+", height="+h+", status=yes, scrollbars=yes, resizable=no, menubar=no, toolbar=no, left="+winl+", top="+wint);
}


/*
+-----------------------------------------------------------------+
| Fn name:    popwin2                                             |
+-----------------------------------------------------------------+
| Purpose:    Opens popup window w/customizable window options    |
+-----------------------------------------------------------------+
| Inputs:     string URL                                          |
|             string name (name of popup window)                  |
|             int w (width of popup window)                       |
|             int h (height of popup window)                      |
|             string opts (other popup window options)            |
+-----------------------------------------------------------------+
| Returns:    nothing                                             |
+-----------------------------------------------------------------+
| History:    10/31/2005 - cpn_id is set to empty string if not   |
|                          passed instead of "undefined" [ft]     |
+-----------------------------------------------------------------+
*/
function popwin2(URL, name, w, h, opts)
{
   var winl = (screen.width - w) / 2;
   var wint = (screen.height - h) / 2;
	window.open(URL, name, "width="+w+", height="+h+", left="+winl+", top="+wint + opts);
}


/*
+-----------------------------------------------------------------+
| Fn name:    cWin                                                |
+-----------------------------------------------------------------+
| Purpose:    Opens coupon popup window for online FS which       |
|             adjusts path to site root folder                    |
+-----------------------------------------------------------------+
| Inputs:     int client_id                                       |
|             int cpn_id                                          |
|             string linkshare_id                                 |
+-----------------------------------------------------------------+
| Returns:    nothing                                             |
+-----------------------------------------------------------------+
| History:    03/16/2006 - yes status b/c IE 6 SP2 shows it       |
|                          regardless for some reason,            |
|                          top/left added [ft]                    |
|             12/01/2005 - linkshare tracking argument added [ft] |
|             10/31/2005 - cpn_id is set to empty string if not   |
|                          passed instead of "undefined" [ft]     |
+-----------------------------------------------------------------+
*/
function cWin(client_id, cpn_id, linkshare_id)
{
   if (!cpn_id) { cpn_id = ''; }
   
   var host = location.host;
   var pathname = location.pathname;
   var path = '';
   
   // include linkshare tracking id in query string if present
   if (linkshare_id)
      var url = 'html/client/coupon_ofs_popup.php?client_id=' + client_id + '&cpn_id=' + cpn_id +
                '&u1=' + linkshare_id;
   else
      var url = 'html/client/coupon_ofs_popup.php?client_id=' + client_id + '&cpn_id=' + cpn_id;
      
   var opts = 'width=470, height=330, resizable=no, scrollbars=yes, top=50, left=50';
   
   myRegExp = /fabuloussavings.com/i;
   var host_online = myRegExp.test(host);
   
   myRegExp = /[\/]/g;
   var str = pathname.match(myRegExp);
   
   // exclude fwd slashes after domain name & end of url and adjust if local
   path_adj = (host_online) ? str.length - 1 : str.length - 3;
   
   for (i = 1; i <= path_adj; ++i) { path += '../'; }
   window.open(path + url, '', opts);
}