// Begin Main Talkingheadshot.com Session Javascript

if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}
	// Detect Browser

iframeHasNotLoaded = new Array();

function getSiteLocation()
{
	var locationString = 'undefined';

	if( navigator.location )
	{
		locationString = navigator.location;
	}
	else
	{
		locationString = window.location;
	}

	var folderURL = new String( locationString );

	endPos = folderURL.search( /\?.*$/ );

	if( endPos )
	{
		folderURL = folderURL.substr( 0, endPos );
		return( folderURL.toString() );
	}
	return( locationString );
}

function openWin( scriptUrl, headshotUrl )
{
    winUrl = scriptUrl + '?thsUrl=' + headshotUrl;

    thsWin = window.open( winUrl, "thsWin",
    'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=240,height=215' );
    thsWin.focus();
}

function openReplicatedWin( filePathExt )
{
    var winUrl = getFolderURL( navigator.location ) + filePathExt;

    thsWin = window.open( winUrl, "thsWin",
    'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=240,height=215' );
    thsWin.focus();
}

function getObj( name, oDoc )
{
	this.obj = 0;
	this.style = 0;

	if( !oDoc )
	{
		oDoc = document;
	}

	if( document.layers )
	{
		if( this.obj = oDoc.layers[name] )
		{
			this.style = oDoc.layers[name];
		}
		else
		{
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ )
			{
				y = getObj( divID, oDoc.layers[x].document );
			}
			return y;
		}
	}
	else if( document.getElementById )
	{
		if( this.obj = document.getElementById(name) )
		{
		   this.style = document.getElementById(name).style;
		}
	}
	else if( document.all )
	{
		if( this.obj = document.all[name] )
		{
		   this.style = document.all[name].style;
		}
	}
}

function getPagePos( obj )
{
	this.left = 0;
	this.top = 0;

	if( obj.offsetParent )
	{
		this.left = obj.offsetLeft;
		this.top = obj.offsetTop;

		while( obj = obj.offsetParent )
		{
			this.left += obj.offsetLeft;
			this.top += obj.offsetTop;
		}
	}
}

function objectExists( name, oDoc )
{
	var myObj = new getObj( name, oDoc );

	return( (typeof myObj.obj == 'object') && (myObj.obj != null) );
}

function reWriteDiv( oDiv, oFrame, oString, oRepeat )
{
	var oObj = new getObj( oDiv );
	var oContent = oObj.obj; //create fake objects if needed

	if( !oContent )
	{
	    oContent = new Object();
	}
	if( !window.frames )
	{
	    window.frames = new Object();
	}
	if( typeof( oContent.innerHTML ) != 'undefined' )
	{
	    oContent.innerHTML = oString; //DOM
	}
	else if( oContent.document == document || !oContent.document )
	{
		if( window.frames.length )
		{
			if( !oRepeat )
			{
				window.clearTimeout( iframeHasNotLoaded[oFrame] );
			} //if they rewrite more than once before the iframe loads, only show the last one

			if( !window.frames[oFrame] )
			{ //the iframe is unavailable until its content has loaded

				iframeHasNotLoaded[oFrame] = window.setTimeout( 'reWriteDiv(\'' + oDiv + '\',\'' + oFrame + '\',\'' + escape( oString ) + '\', true )' , 5000 );
			}
			else
			{
				oContent = window.frames[oFrame].window;

				oContent.document.open(); //Separate contents syntax
				oContent.document.write( '<html><head><title>Dynamic content</title></head><body>' + oString + '</body></html>' );
				oContent.document.close();
			}
		}
	} //use iframe

	return 0;
}

function isVisible( objID )
{   // Returns true if the object is currently visible.

    var myObj = new getObj( objID );

    if( myObj.style )
    {
        if( myObj.style.display == 'none' )
        {
            return( false );
        }
    }
    return( true );
}   

function changeVisibility( objID, isObjVisible )
{   // Makes the given object visible or invisible.

    var myObj = new getObj( objID );
    
    if( myObj.style )
    {
        if( isObjVisible )
        {
            myObj.style.display = 'inline';
        }
        else
        {
            myObj.style.display = 'none';
        }
    }
}

function changeColour( objIDbase, colour )
{  // Changes the colour of all the elements with the same objIDbase.
   // That is id="td_1" where objIDbase="td"

   var doLoop = 1;

   for( var i = 1; doLoop; i++ )
   {
      var obj = new getObj( objIDbase + '_' + i );

      if( obj.style )
      {
         obj.style.backgroundColor = colour;
      }
      else
      {
         doLoop = 0;
      }
   }
}

function changeImage( objID, image )
{  // Changes the image of the given element.

   if( document.images )
   {
      var imageObj = new getObj( objID );

      if( imageObj.obj )
      {
         imageObj.obj.src = image;
      }
   }
}

function changeCursor( objID, cursorType )
{
	var myObj = new getObj( objID );
    
	if( myObj.style )
	{
		if( cursorType )
		{
			myObj.style.cursor = cursorType;
		}
		else
		{
			myObj.style.cursor = 'pointer';
		}
	}
}

function swapBranchOpenState( visibleObjID, imageButtonID )
{
    if( isVisible( visibleObjID ) )
    {
        changeVisibility( visibleObjID, false );
        changeImage( imageButtonID, '../graphics/buttons/plus.gif' );
    }
    else
    {
        changeVisibility( visibleObjID, true );
        changeImage( imageButtonID, '../graphics/buttons/minus.gif' );
    }
}

function newImage( arg )
{
	if( document.images )
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function preloadButton( objID ) 
{
	imageArray = document.imageArray;

	if (document.images) 
	{
		eval( objID + '_down = newImage( "/graphics/buttons/' + objID + '-down.gif" );' );
		eval( objID + '_over = newImage( "/graphics/buttons/' + objID + '-over.gif" );' );
	}
}

overdiv="0";
//  #########  CREATES POP UP BOXES 

function event_RevealDescription( e )
{
	if( !e )
	{
		var e = window.event;
	}
	var relTarg;

	if( typeof e.relatedTarget != 'undefined' )
	{
		relTarg = e.relatedTarget;
	}
	else
	{
		relTarg = e.fromElement;
	}

	var tagName;

	if( typeof e.srcElement.name != 'undefined' )
	{
		tagName = e.srcElement.name;
	}
	else if( typeof e.srcElement.id != 'undefined' )
	{
		tagName = e.srcElement.id;
	}
}

function revealObject( objName, left, top )
{
	var revObj = new getObj( objName );

	if( revObj.style != null )
	{
		if( left )
		{
			revObj.style.left = left;
			if( top )
			{
				revObj.style.top = top;
			}
		}
		revObj.style.visibility = 'visible';
	}
}

function popLayer( description )
{
	desc = "<table cellspacing=0 cellpadding=3 border=0>" +
		"<tr><td bgcolor=#ffffdd align=\"center\" class=\"linksBlack\">\n" +
		description  + "\n</td></tr></table>\n";

	if( navigator.family =="nn4" )
	{
		document.divObject.document.write(desc);
		document.divObject.document.close();
		document.divObject.left=x+15;
		document.divObject.top=y-5;
	}
	else if( navigator.family =="ie4" )
	{
		divObject.innerHTML=desc;
		divObject.style.pixelLeft=x+15;
		divObject.style.pixelTop=y-5;
	}
	else if( navigator.family =="gecko" )
	{
		document.getElementById( "divObject" ).innerHTML=desc;
		document.getElementById( "divObject" ).style.left=x+15;
		document.getElementById( "divObject" ).style.top=y-5;
	}
}

function hideLayer()
{
	if( overdiv == "0" )
	{
		if( navigator.family =="nn4" )
		{
			eval( document.divObject.top="-500" );
		}
	}
	else if( navigator.family =="ie4" )
	{
		divObject.innerHTML="";
	}
	else if( navigator.family =="gecko" ) 	{
		document.getElementById("divObject").style.top="-500";
	}
}

function getRadioValue( radioObj )
{
	var radioValue = null;

	if( typeof radioObj != null )
	{
		var radioLength = radioObj.length;

		if( typeof radioObj.length != 'undefined' )
		{
			for( var i = 0; i < radioObj.length; i++ )
			{
				if( radioObj[i].checked )
				{
					radioValue = radioObj[i].value;
				}
			}
		}
		else if( radioObj.checked )
		{
			radioValue = radioObj.checked;
		}
	}
	return( radioValue );
}

//  Track Mouse Position
var isNav = (navigator.appName.indexOf("Netscape") != -1);

function handlerMM(e)
{
	x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
	y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if( isNav )
{
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;

function getFolderURL( fullURL )
{
    var folderURL = new String( fullURL );
    
    endSlashPos = folderURL.search( /[\/\\][^\/\\]*$/ );
    folderURL = folderURL.substr( 0, endSlashPos + 1 );
    
    return( folderURL.toString() );
}



// XML related functions

function supportsXMLHttpRequest()
{
	return( window.XMLHttpRequest || window.ActiveXObject );
}

function getXMLHttpRequest()
{
	if( window.XMLHttpRequest )
	{ // Mozilla, Safari, ...

		http_request = new XMLHttpRequest();
	}
	else if( window.ActiveXObject )
	{ // IE

		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{}
		}
	}
	return( http_request );
}

function xml_getNode( parentNode, tagName )
{
	if( parentNode != null )
	{
		return( parentNode.getElementsByTagName( tagName )[0] );
	}
	return( null );
}

function xml_getNodeValue( parentNode, tagName )
{
	if( parentNode != null )
	{
		node = parentNode.getElementsByTagName( tagName )[0];

		if( node != null )
		{
			if( node.firstChild != null )
			{
				return( node.firstChild.nodeValue );
			}
		}
	}
	return( null );
}

function xml_getNodeText( parentNode, tagName )
{
	if( parentNode != null )
	{
		var nextNode = parentNode.getElementsByTagName( tagName )[0].firstChild;
		var nodeText = '';

		while( nextNode != null )
		{
			nodeText += nextNode.nodeValue;
			nextNode = nextNode.nextSibling;
		}
		return( nodeText );
	}
	return( null );
}

function xml_decode( str )
{
    var tempStr = new String( str );
    tempStr = tempStr.replace( new RegExp( "&quot;", "g" ), "\"" );
    tempStr = tempStr.replace( new RegExp( "&lt;", "g" ), "<" );
    tempStr = tempStr.replace( new RegExp( "&gt;", "g" ), ">" );
    tempStr = tempStr.replace( new RegExp( "&amp;", "g" ), "&" );
    
    return( tempStr.toString() );
}

function xml_encode( str )
{
    var tempStr = new String( str );
    tempStr = tempStr.replace( new RegExp( "&", "g" ), "&amp;" );
    tempStr = tempStr.replace( new RegExp( "\"", "g" ), "&quot;" );
    tempStr = tempStr.replace( new RegExp( "<", "g" ), "&lt;" );
    tempStr = tempStr.replace( new RegExp( ">", "g" ), "&gt;" );
    
    return( tempStr.toString() );
}