// 

function wopen(url, name, w, h)
{
// Fudge factors for window framing, toolbar, etc. space.
  w += 60;
  h += 130;
 var win = window.open(url,
  name, 
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
   'status=no, toolbar=no, scrollbars=no, resizable=yes');
 win.resizeTo(w, h);
 win.focus();
}

function wopenpdf(url, name, w, h, title)
{
// Fudge factors for window framing, toolbar, etc. space.
//  w += 60;
//  h += 130;
 var win = window.open(url,
  name, 
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
 'left=30, top=20, status=yes, toolbar=no, scrollbars=yes, resizable=yes');
 win.resizeTo(w, h);
 win.focus();
 win.document.title = "MusclePlus Flashcards";  // this does not work to change the title
}


function wopen_centered(url, name, w, h)
{
// Fudge factors for window framing, toolbar, etc. space.
  w += 60;
  h += 130;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=yes');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

var popUpWin = '';
var describeIt = '';
var picture = '';
var imagealt = '';
function makePopUpWin(pic,alt,wide,high,text){
   var tall = high + 60  // adjust for spacing to border above and below picture
   var side = wide + 40  // adjust for spacing to border on sides of picture
   if (tall > 700) {     
      tall = 700;       // Keep bottom of window from going off bottom of screen (on 768x1020 display)
      side = side + 20; // Also add a width for scrollbar
   }
   describeIt = text
   picture = pic
   imagealt = alt
   if (popUpWin && !popUpWin.closed) {
      popUpWin.close();
   }
   popUpWin = eval("window.open('','newWin','height="+tall+",width="+side+",left=30,top=20,scrollbars=yes,resizable=yes')"); 
   if (!popUpWin.opener) popUpWin.opener = self;
   update();
   //popUpWin.resizeTo(side, tall);  //This sets the OUTER dimensions of window, but window.open sets INNER dimensions
   popUpWin.focus();
}

function update() {
   popUpWin.document.open();  
   // content for the popup window is defined here
   popUpWin.document.write("<html><head><title>Bodylight Books - " + describeIt + "</title>");
   popUpWin.document.write('<style type="text/css">');
   popUpWin.document.write('body {margin:0px; text-align:center; background: #26354A;}');
   popUpWin.document.write('.cText {color:#FFFFFF; font-family:Arial,Helvetica,Sans; font-size:11px;}');
   popUpWin.document.write('.dText {color:#FFFFFF; font-family:Arial,Helvetica,Sans; font-size:14px; line-height:20px;}');
   popUpWin.document.write('.bLeft {position:absolute; top:5px; left:20px; text-align:left; vertical-align:middle;}');
   popUpWin.document.write('.bRight {position:absolute; top:5px; right:20px; }');
   popUpWin.document.write('</style>');
   popUpWin.document.write("</head>");
   popUpWin.document.write("<body>");
   //popUpWin.document.write('<body TOPMARGIN="10" LEFTMARGIN="10" MARGINWIDTH="0" MARGINHEIGHT="0" text="#FFFFFF" bgcolor="#26354A" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"><center>');
   popUpWin.document.write('<div class="bLeft"><span class="dText">' + describeIt + '</span><br /></div>');
   popUpWin.document.write('<div class="bRight"><input type="button" onClick="window.close()" value="Close this window" /></div>');
   popUpWin.document.write('<img src="mm_spacer.gif" alt="" width="1" height="30" border="0" /><br />');
   popUpWin.document.write("<img src='" + picture + "' alt='" + imagealt + "'><br />");
   popUpWin.document.write('<span class="cText">&copy;2011 Bodylight Books</span><br />');
   //popUpWin.document.write("<a href='#' onClick='self.close()'>");
   //popUpWin.document.write("Close this window</a></center><br />");
   popUpWin.document.close();
}


