
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if (!d.getElementById || !d.createElement) return;
	if (!d.getElementById("homepage_image")) return;
	
	imgs = d.getElementById("homepage_image").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	
	if (imgs.length > 0)
	{
	    imgs[0].style.display = "block";
	    imgs[0].xOpacity = .99;
	    //d.getElementById("homepage_image").style.height = imgs[0].offsetHeight + 'px';
    	
	    setTimeout(so_xfade, duration);
	}
	
}

function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		
		//d.getElementById("homepage_image").style.height = imgs[nIndex].offsetHeight + 'px';
		current = nIndex;
		
		
		setTimeout(so_xfade, duration);
	} else {
		setTimeout(so_xfade,50);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
}

function pushdown(full, index)
{
    var pusherid = 'content_block_' + index + '_pusher';
    var imageid = 'content_block_' + index + '_image';
    var contentbodyid = 'content_block_' + index + '_body';
    var image = document.getElementById(imageid);
    var pusher = document.getElementById(pusherid);
    var contentbody = document.getElementById(contentbodyid);
    var ver = getVersion();
    var offset = 0 // the amount that needs to be dedcuted to make IE work
    if (ver == -1)
    {
        offset = 12;
    } 
    if (pusher != null && image != null && contentbody != null)
    {
        if(full)
        {
            pusher.style.height = (contentbody.offsetHeight - image.offsetHeight - offset) + 'px';
            
        }
        else
        {
            pusher.style.height = ((contentbody.offsetHeight - image.offsetHeight) / 2) + 'px';
        }
    }
}

function getVersion()
      // Returns the version of Internet Explorer or a -1 if firefox or a -2 if safari
      // (indicating the use of another browser).
      {
      var rv = -1; // Return value assumes failure.



      if (navigator.appName == 'Microsoft Internet Explorer')
      {
      var ua = navigator.userAgent;
      var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
      if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
      }
      if (navigator.userAgent.indexOf("Safari")!=-1)
      {
      rv = -2;
      }



      return rv;
      }
      
      
 function od_displayImage(strId, strPath, strAlt, strStyle, strClass) {	
 // receives an image id in strPath and potentially an id, alt, class and style attributes
 // if any of the id, alt, class and style attributes are not defined then they are not added to the img
 // declaration
 var ver = getVersion(); 
 if (ver == 5.5 || ver == 6)
 {
 	document.write('<img '+ ((strClass.length == 0)? '' : 'class="'+ strClass +'"') +
 	 ((strId.length == 0)? '' : 'id="'+ strId +'"') +
 	' src="Images/blank.gif" style="width:100%; height:100%; '+strStyle+'; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'DisplayImage.ashx?image=' +strPath+'&width=120&format=png\', sizingMethod=\'image\');"></img>');
 } 
 else {
    document.write('<img '+ ((strClass.length == 0)? '' : 'class="'+ strClass +'"') +
 	 ((strId.length == 0)? '' : 'id="'+ strId +'"') +
 	' src="DisplayImage.ashx?image=' +strPath+'&width=120&format=png" style="'+strStyle+'"></img>');
}
}