/************************************
 Common javascripts for the site
************************************/

/* Auto re-direct the page back to the index page */
/* default redirect is true */
var booRedirect
if (self==parent && booRedirect==null){
    document.write('<B>LOADING ...</B><br>')
    document.write('This page will be refreshed in a moment<br>&nbsp;')
    document.write('<META HTTP-EQUIV="refresh" CONTENT="1; URL=index.html">')
}

/* Open a second browser window */
/* NOTE : DO NOT use Base target when using this script */
function OpenWin2(urlString,windowName,w,h,scroll,popup)
{
  var temp2str
  var tempstr
  if (popup==1) {tempstr='height='+h+',width='+w+',toolbar=no,menubar=no,resizable=yes,status=no,location=no'}
     else {tempstr='height='+h+',width='+w+',toolbar=yes,menubar=yes,resizable=yes,status=yes,location=yes'} 
  if (scroll==1) {temp2str=',scrollbars=yes' } else {temp2str=',scrollbars=no'}

  QWin = window.open( urlString, windowName, config=tempstr + temp2str );
  if (window.focus) {QWin.focus()};
}

/* Refresh an image in the page every specific seconds */
/* name - name of the image */
/* source - url of the image */
/* sec - refresh interval */
function imgRefresh (name, sec, source) 
{ 
  var tempstr
  if (!document.images) return;
  source=(!source)?'':source;
  if (source=='') {
  	 document.images[name].src = document.images[name].src;
  } else {
  	document.images[name].src = source; } 
  tempstr="imgRefresh('" + name + "'," + sec + ((source=='')?")":",'" + source + "')");
  setTimeout(tempstr, sec*1000);
} 

/******************************
Find frame
modified to return a status of success
******************************/
function comFindFrame(frameName){
	obj=top; var frameObj=0;
	for(i=0;i<obj.frames.length;i++){
		if(obj.frames[i].name==frameName){frameObj=obj.frames[i]; break;}; ln=obj.frames[i].frames.length
		for(j=0;j<ln;j++){
			if(obj.frames[i].frames[j].name==frameName){frameObj=obj.frames[i].frames[j]; break}; ln2=obj.frames[i].frames[j].frames.length
			for(a=0;a<ln2;a++){
				if(obj.frames[i].frames[j].frames[a].name==frameName){frameObj=obj.frames[i].frames[j].frames[a]; break;}
			}
		}
	}
	return frameObj;
}

/******************************
Set the html code for displaying an image
aspect is "p"-portrait "l"-landscape
******************************/
function DisplayImg(fileName,aspect,tnlength,winlength){
	var tempstr
	var tnstr
	var winstr
	var anum
	anum=winlength / 4 * 3;
	if(aspect=='p' | aspect=='P'){
	  tnstr='height=' + tnlength;
	  winstr=anum + ',' + winlength;
	} else {
	  tnstr='width=' + tnlength;
	  winstr=winlength + ',' + anum;
	}
	tempstr='<a class="LinkTxt" href="javascript:OpenWin2(' + "'" + fileName + "','Photo'," + winstr + ",1,1)"+ '"><img SRC="' + fileName + '" NOSAVE ' + tnstr + '></a>'
	document.write(tempstr)
}

/************* END ******************/
