
// used by many photo sites
var wi = null; 
var f1 = 150;
var f2 = 50;

function win(loc) {
 var w=screen.width-f1-10;
 var h=screen.height-f2;
 dowin(loc,h,w);
}

function photowin(idx) {
 win("photo/" + idx + "/index.html");
 // to test locally
 // win("photo/" + idx + "/lindex.html");
}

function tphotowin(idx) {
 win("http://www.triplepower.org/photo/" + idx + "/index.html");
}

function wincasio(loc) {
 var w=screen.width-f1-10;
 var h=180;
 dowin(loc,h,w);
}

function dowin(loc,h,w) {
 // alert(loc + "-" + h + "-" + w);
 if (!wi || wi.closed) 
  wi = window.open(loc,"Giamma","scrollbars=yes,width="+w+",height="+h+",top=0,left="+f1+",toolbar=no,menubar=yes,location=no,resizable=yes,status=no,directories=no"); 
  // wi = window.open(loc,"Giamma","fullscreen=yes,scrollbars=no,toolbar=yes,menubar=yes,location=no,resizable=yes,status=yes,directories=no"); 
 else { 
  wi.focus(); 
  wi.location = loc; 
 } 
}

// used by my giamma.html
var wi = null; 
var saveUrl = "";
function go_link(url,flag) {
 // alert(url);
 if (flag == null || flag == 0) {
  window.location = url;
 }
 else if (flag == 1) {
  t = 25;
  s = 100;
  d = 6;
  w = screen.width - s - d;
  h = screen.height - (2 * t) - d;

  if (!wi || wi.closed) 
   wi = window.open(url,"GIAMMA","scrollbars=yes,width=" + w + ",height=" + h + ",top=" + t + ",left=" + s + ",toolbar=no,location=no,resizable=yes,status=no,directories=no,menubar=no"); 
  else { 
   wi.focus(); 
   wi.location = url; 
  } 
 }
 else if (flag == 2) {
  newUrl = "http://www.giamma.com/.g/reload.html";
  saveUrl = url;
  t = 0;
  s = 100;
  d = 10;
  w = screen.width - s - d;
  h = screen.height - (2 * t) - 50;

  // always get a new one
  window.open(newUrl,"","scrollbars=yes,width=" + w + ",height=" + h + ",top=" + t + ",left=" + s + ",toolbar=no,location=no,resizable=yes,status=yes,directories=no,menubar=no"); 
 }
}

function spawn_aim() {
 remote = window.open("http://toc.oscar.aol.com/tic.html", "TICTOC",'width=210,height=365,directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0');
 if (remote.opener == null) 
  remote.opener = window;
 remote.opener.name = "TICINFO";
}

function spawn_aimx() {
 remote = window.open("http://toc.oscar.aol.com/aimexpress/content.html", "TICTOC",'width=215,height=365,directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0');
 if (remote.opener == null) 
  remote.opener = window;
 remote.opener.name = "TICINFO";
}

function random(max) {
  var rNum=NaN;
  while (isNaN(rNum)) {
    rNum=Math.floor(Math.random()*(max));
  }
  return rNum;
}

function randomidx(idx) {
 num = random(idx);

 if (num == 0)
  num = 1;

 if (num < 10)
  num = "0" + num;

 return num;
}


