
// Extends the length of the side column to be no
// shorter than the length of the main column

var initialSideHeight = -1;

function fnColumnExtend(tolengthofthis,lengthofthis)
{
 var o1, o2;
 
 o1 = document.getElementById(tolengthofthis);
 o2 = document.getElementById(lengthofthis);
 if (o2)
 {
  if (initialSideHeight < 0) initialSideHeight = o2.offsetHeight;
  
  if (o2.offsetHeight < o1.offsetHeight)
   o2.style.height = (o1.offsetHeight) + "px";
  else
  {
   if (o2.offsetHeight > o1.offsetHeight)
   {
   	if (o1.offsetHeight > initialSideHeight)
	   o2.style.height = (o1.offsetHeight) + "px";
	else
		o2.style.height = (initialSideHeight) + "px";
    }
  }
 }
}

// Changes BibleGateway.com <a> links to open in new browser window
function fixGatewayLinks()
{
 var f, o; 
 
 if (f = document.getElementById('biblegateway'))
 {
  o = f.getElementsByTagName('a');
  for (var i=0; i<o.length; i++)
  
  	  o[i].setAttribute('target','_blank');
 }
}

// Creates dynamically an email address field on screen
function crAddr(id,ida,recipient,domain)
{

var o = document.getElementById(id);
var s = recipient + '\u0040' + domain;
while (s.match('#') == '#')
	  s = s.replace('#','.');
	  
if (o.innerText)
  o.innerText = s;
else
	o.textContent = s;
	
o = document.getElementById(ida);
s = "mailto:" + s;
	  
o.href=s;
}

// for opening a page within the pageopener.asp framework
function fnPageOpener(o)
{
 var bMatch = false;
 var sClasses = o.className.split(",");
 for (var i=0; i < sClasses.length; i++)
 {
  if (sClasses[i] == "pageOpener")
  {
  	 bMatch = true;
	 break;
  }
 }
 
 if (bMatch)
 {
  o.href = 'pageopener.asp?page=' + oHref + '&addr=<%=source_u%>';
  }
}

// for forcing a link to open in a new target window
// <a href="xxx" onClick="javascript:fnLinkNewWindow(this);">aaa</a>
function fnLinkNewWindow(o)
{
  o.setAttribute('target','_blank');
}

function getPropertyValue(elm, property) {

alert(document.getElementById(elm).currentStyle[property]);
if(document.all) { //IE
return document.getElementById(elm).currentStyle[property]; // or runtimeStyle instead of currentStyle
}
else { //Moz.
return document.defaultView.getComputedStyle(document.getElementById(elm), null).getPropertyValue(property, null);
}
}
	
	  
function getPageSize()
{
var xScroll, yScroll;

if (window.innerHeight && window.scrollMaxY) 
{
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} 
else if (document.body.scrollHeight > document.body.offsetHeight)
// all but Explorer Mac
{ 
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} 
else 
// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
{ 
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}

var windowWidth, windowHeight;

if (self.innerHeight) 
// all except Explorer
{
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} 
else if (document.documentElement && document.documentElement.clientHeight) 
// Explorer 6 Strict Mode
{ 
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} 
else if (document.body) 
// other Explorers
{ 
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}

// for small pages with total height less then height of the viewport
if (yScroll < windowHeight)
pageHeight = windowHeight;
else 
pageHeight = yScroll;

// for small pages with total width less then width of the viewport
if (xScroll < windowWidth)
pageWidth = windowWidth;
else 
pageWidth = xScroll;

//alert(pageWidth + ','+ pageHeight + ','+ windowWidth + ','+ windowHeight);

arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
return arrayPageSize;
}


var http = createRequestObject();

function createRequestObject() 
{
 var xmlhttp;
		
 try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
 catch(e) {
	    try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	    catch(f) { xmlhttp=null; }
 }
	
 if(!xmlhttp&&typeof XMLHttpRequest!="undefined") 
 {
  xmlhttp=new XMLHttpRequest();
 }
 
 return  xmlhttp;
}


function getFormParameters(obj)
{
 var getstr = '';
	 
      for (i=0; i<obj.length; i++) {
			
         if (obj[i].type.toLowerCase() == "textarea") {
			 if (getstr != '') getstr += '&';
             getstr += obj[i].id + "=" + obj[i].value;
         }
	  
         if (obj[i].tagName.toLowerCase() == "input") {
            if (obj[i].type.toLowerCase() == "text") {
			   if (getstr != '') getstr += '&';
               getstr += obj[i].id + "=" + obj[i].value;
            }
			
            if (obj[i].type.toLowerCase() == "password") {
			   if (getstr != '') getstr += '&';
               getstr += obj[i].id + "=" + obj[i].value;
            }
			
            if (obj[i].type.toLowerCase() == "checkbox") {
			   if (getstr != '') getstr += '&';
               if (obj[i].checked) {
                  getstr += obj[i].id + "=" + obj[i].value;
               } else {
                  getstr += obj[i].id + "=&";
               }
            }
            if (obj[i].type.toLowerCase() == "radio") {
			   if (getstr != '') getstr += '&';
               if (obj[i].checked) {
                  getstr += obj[i].id + "=" + obj[i].value;
               }
            }
         }   
         if (obj[i].tagName.toLowerCase() == "select") {
			   if (getstr != '') getstr += '&';
            var sel = obj[i];
            getstr += sel.id + "=" + sel.options[sel.selectedIndex].value;
         }
         
      }
  
	  if (getstr != '') getstr = '?' + getstr;
	  
  return getstr;
}

function stripSpaces(x)
{
    while (x.substring(0,1) == ' ') x = x.substring(1);
    while (x.substring(x.length-1,x.length) == ' ') x = x.substring(0,x.length-1);
    return x;
}

function fValidateEmailAddr(s)
{
  var result = false;
  var theStr = new String(s);
  var index = theStr.indexOf('@');
  if (index > 0)
  {
    var pindex = theStr.indexOf('.',index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
  }
  return result;
}


var win=null;

function popup(destAddr,width,height)
{
var x, y;

 var myWidth = 0, myHeight = 0;
 
  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;
  }
  
  if (width < 0) width=myWidth;
  if (height < 0) height=myHeight;

  if (width < 400) width = 400;
  if (height < 300) height = 300;

x = (screen.width)/3 - width/3;
if (x < 10) x = 10;
y = (screen.height)/3 - height/2;
if (y < 10) y = 10;

win=window.open(destAddr,'nvp',settings='width='+width+',height='+height+',top='+y+',left='+x+',resizable=yes,scrollbars=yes,location=no,status=no,directories=no,menubar=no,toolbar=no');
}

