var leftPos = "";
var topPos  = "";
var w       = "";

if(screen){
  leftPos = screen.availWidth * .1;
  topPos  = screen.availHeight * .25;
}

function obw(n){
  theURL   = 'clip.php?n='+n	
  winName  = 'new'
  features = 'width=300,height=300,scrollbar=no,left='+leftPos+',top='+topPos+''
  w        = open(theURL,winName,features); 
}

function spiff(){if(w && !w.closed){w.close();}}

/*
window.onfocus = function(){if(w && !w.closed){w.close();}}
*/

function $(id){
  return document.getElementById(id);
}

function fillField(name, id, iw, ih){
  $("petname").value = name;
  var currentImage   = $("absImg").childNodes[0];
  if(currentImage){ 
    $("absImg").removeChild(currentImage); 
  }
  var newImg    = document.createElement("img");
  newImg.src    = '../ai/'+id+'.jpg';
  newImg.width  = iw;
  newImg.height = ih;
  newImg.alt    = name;
  newImg.title  = name;
  $("absImg").appendChild(newImg);
  /* OR WE COULD DO THIS :: $("absImg").innerHTML = '<img src="../ai/'+id+'.jpg" width="'+iw+'" height="'+ih+'" alt="'+name+'" />';*/
}


/* MAILING LIST BEHAVIOR */
onload = function(){  
  var em = document.forms["addMe"]["em"];
  em.onfocus = function(){
    modifyText(em, "email address");
  }
  em.onblur  = function(){
    modifyText(em, "email address");
  }
}

/* GENERIC FORM TEXT REPLACE FUNCTIONS */
function modifyText(field, text){
  if(field.value == text){
    updateField(field, '');
  }
  else if(field.value == ''){
    updateField(field, text);
  }
}
function updateField(field, text){
  field.value = text;
}
/* END OF MAILING LIST BEHAVIOR */

function openBrowserWindow(theURL,winName,features){ 
  if (w && !w.closed){w.close();} w = open(theURL,winName,features);
}
