// BrowserCheck Object
// provides most commonly needed browser checking variables
// 19990326

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.minorv = parseFloat(navigator.appVersion)
	this.ns = (this.b=="ns" && this.minorv!=4.05)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

// automatically create the "is" object
is = new BrowserCheck()


//this function is used to create rollover effect with images
function SwitchGif(imgDocID,ImgObjName)
{
if (is.ns)
	document.images[imgDocID].src = eval(ImgObjName + ".src")

else if (is.ie)
	document.images[imgDocID].src = eval(ImgObjName + ".src")
}

function yellow(cellID,layerID) { 
if(is.ns) {
	document.layers[layerID].bgColor ='#ffffcc';
	}
else {
	document.all[cellID].bgColor = '#ffffcc';
	}
}

function white(cellID,layerID) { 
if(is.ns) {
	document.layers[layerID].bgColor ='#ffffff';
	}
else {
	document.all[cellID].bgColor = '#ffffff';
	}
}

function popup(wURL,wName,wOptions){
	var newwin = window.open(wURL,wName,wOptions);
	return false;
}

function MyShortcuts () {
	var symbol = '<IMG BORDER="0" SRC="/images/bullet.gif" ALT="Bullet point">';
	var shortcuts = '';
	for (var i = 0; i < 5; i++) {
	    if ( alerturl[i] && alerthead[i]) {
		    shortcuts += '&nbsp;&nbsp;' + symbol + '<a href="' + alerturl[i] + '">' + alerthead[i] + '</a>';
	    }
	}
	if (shortcuts != ''){
		document.write('<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="752">'+
		'<tr>'+
		'<td width="17"><IMG BORDER="0" SRC="images/spacer.gif" WIDTH="17" HEIGHT="1" ALT=""></td>'+
	    '<TD width="16" VALIGN="middle" NAME="Breadcrumb">'+
		'	<IMG BORDER="0" SRC="/images/locnav_left.gif" WIDTH="16" HEIGHT="18" ALT="Breadcrumb indicator"></TD>'+
	    '<TD WIDTH="719" BGCOLOR="#FFFFFF" VALIGN="middle" NAME="Breadcrumb">'+
		'	<IMG BORDER="0" SRC="/images/spacer.gif" WIDTH="718" HEIGHT="1" ALT=""><br>'+
		'	My Shortcuts<SPAN CLASS="where">'+ shortcuts +'</SPAN></TD>'+
		'</tr>'+
		'</table>');
	}
}

function algetCookie(name) {
   var dc = document.cookie;
   var prefix = name + "=";
   var begin = dc.indexOf("; " + prefix);
   if (begin == -1) {
     begin = dc.indexOf(prefix);
     if (begin != 0) return null;
   } else {begin += 2;}
   var end = document.cookie.indexOf(";", begin);
   if (end == -1) {end = dc.length;}
   return unescape(dc.substring(begin + prefix.length, end));
 }

function alertSize() {
  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;
      }
    }
  }
  var myDims = new Array(5);
  myDims[0] = myWidth;
  myDims[1] = myHeight;
  myDims[2] = screen.width;
  myDims[3] = screen.height;
  myDims[4] = screen.colorDepth;
  return myDims;
}

function genWinSizeImg() {
  var myDims = new Array(5);
  myDims = alertSize();
  return '<img alt="" height="0" width="0" src="/images/WinSizeImg_ww'+myDims[0]+'_wh'+myDims[1]+'_sw'+myDims[2]+'_sh'+myDims[3]+'_sc'+myDims[4]+'">';
}

function changeLinkHref(linkName, newHref, stopOnFirst){
	var s = "";
	var n = "";
	for (var i=0; i<document.links.length; i++ )
	{
		if (document.links[i].name == linkName)
		{
			document.links[i].href = newHref;
			if (stopOnFirst)
			{
				break;
			}
		}
	}
}

// copy contents of one div to another
function copyDiv( src, dst ) {
	var srcdiv = document.getElementById(src);
	var dstdiv = document.getElementById(dst);
	if ( srcdiv && dstdiv ) {
		dstdiv.innerHTML = srcdiv.innerHTML;
	}
}

function emptyDiv( divid ) {
	var div = document.getElementById(divid);
	if ( div ) {
		div.innerHTML = '';
	}
}


function changeLinkHref(linkName, newHref, stopOnFirst){
	var s = "";
	var n = "";
	for (var i=0; i<document.links.length; i++ )
	{
		if (document.links[i].name == linkName)
		{
			document.links[i].href = newHref;
			if (stopOnFirst)
			{
				break;
			}
		}
	}
}

var latest_imgs_lastdivs = new Array();
function showImg( s_imgid, s_divid, t_imgid, t_teaserid, t_link, f_divid ) {
	var s_img = document.getElementById(s_imgid);
	var t_img = document.getElementById(t_imgid);

	if ( s_img && t_img ) {

		var s_div = document.getElementById(s_divid);
		var t_teaser = document.getElementById(t_teaserid);
		var t_link = document.getElementById(t_link);

		var new_img_src = s_img.alt.substr(10);
		if (new_img_src.length > 0)
		{
			var sep = s_img.alt.indexOf('|');
			var src = '';
			var href = '';
			if (sep > 0)
			{
				src = s_img.alt.substring(10, sep);
				href = s_img.alt.substr(sep+1);
			} else {
				src = s_img.alt.substring(10);
			}
			t_img.src = src;
			if (t_link)
			{
				t_link.href = href;
			}
		}
		if ( t_teaser ) {
			t_teaser.innerHTML = s_img.title;
		}
		// set the first div...
		if (!latest_imgs_lastdivs[f_divid]) {
			latest_imgs_lastdivs[f_divid] = f_divid;
		}
		if ( s_div ) {
			s_div.className='ANThumbSelActive';
			if (latest_imgs_lastdivs[f_divid] != s_divid)
			{
				var l_div = document.getElementById(latest_imgs_lastdivs[f_divid]);
				if ( l_div ) {
					l_div.className='';
				}
				latest_imgs_lastdivs[f_divid] = s_divid;
			}
		}
	}
}
