// JavaScript to interpolate random ../images into a page. 
var ic = 30; // Number of alternative ../images 
var header = new Array(ic); // Array to hold filenames 
header[0] = "images/intro1.jpg"; 
header[1] = "images/intro2.jpg"; 
header[2] = "images/intro3.jpg"; 
header[3] = "images/intro4.jpg"; 
header[4] = "images/intro5.jpg";
header[5] = "images/intro6.jpg";
header[6] = "images/intro7.jpg"; 
header[7] = "images/intro8.jpg"; 
header[8] = "images/intro9.jpg"; 
header[9] = "images/intro10.jpg"; 
header[10] = "images/intro11.jpg";
header[11] = "images/intro12.jpg";
header[12] = "images/intro13.jpg";
header[13] = "images/intro14.jpg";
header[14] = "images/intro15.jpg";
header[15] = "images/intro16.jpg";
header[16] = "images/intro17.jpg";
header[17] = "images/intro18.jpg";
header[18] = "images/intro19.jpg";
header[19] = "images/intro20.jpg";
header[20] = "images/intro21.jpg";
header[21] = "images/intro22.jpg";
header[22] = "images/intro23.jpg";
header[23] = "images/intro24.jpg";
header[24] = "images/intro25.jpg";
header[25] = "images/intro26.jpg";
header[26] = "images/intro27.jpg";
header[27] = "images/intro28.jpg";
header[28] = "images/intro29.jpg";
header[29] = "images/intro30.jpg";


function pickRandom(range) { 
if (Math.random) 
return Math.round(Math.random() * (range-1)); 
else { 
var now = new Date(); 
return (now.getTime() / 1000) % range; }} 
// Write out an IMG tag, using a randomly-chosen image name. 
var choice = pickRandom(ic);
// --> }


writeDrag.writeId = "cntnt";
writeDrag.offX = "c";
writeDrag.offY = "c";

// required arg's: event, image path and file name (as this.href)
// important but optional arg's: width of image, height of image 
// other optional arg's: txt, layer width, offx, offy
function wrapContent(e, img, txt, wd, offx, offy) {
  var w, h, imgStr, cntnt, win, str, myWidth = 0, myHeight = 0, foto, hfoto;
 
 if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  foto = new Image(); 
  foto.src = img;
  hfoto = foto.height;
  if (hfoto > myHeight) {
  h=(myHeight*0.85)}
  else  {
  h=hfoto}
    
  imgStr = '<img src="' + img + '"' + (w? ' width="' + w + '"': "") + (h? ' height="' + h + '"': "") + '>';
  if ( dragObj.supported && typeof document.body.innerHTML != "undefined" ) {
    cntnt = '<table height="' + (myHeight-12) + '" width="100%"><td valign="middle" align="center" ><div class="img">' + imgStr + '</div>';
    if (txt) cntnt += '<div class="msg">' + txt + '</div></td></table>';  
    wd = myWidth; 
    hd = myHeight;
    writeDrag.set(e, cntnt, wd, offx, offy);
 
 } else { // non-capable browsers will open sub window
    w = w+80 || wd || 250; h = h+80 || 250; // size
    win = window.open('', 'subwin', 'resizable,width='+w+',height='+h+',left=100,top=100');
    if (win && !win.closed) win.resizeTo(w,h); 
    str = '<html><head><title>Image Display</title></head>';
  	str += '<body style="text-align:center">';
    str += imgStr + (txt? '<p>' + txt + '</p>':"");
  	str += '</body></html>'
  	win.document.write(str);
  	win.document.close();
    if (win && !win.closed) win.focus(); 
  } 
  return false;
}
 
