// All script in this file except for portions clearly marked otherwise is
// Copyright (c) 2006 by Kevin McKerron.  All rights reserved.
// Please do not distribute or use without first obtaining permission.
//
// *** THIS IS AN AUTOMATICALLY GENERATED FILE - DO NOT MODIFY!! ***


// The following two lines are from the Netscape sniffer
var agt=navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));


var topmNames = new Array(10);
topmNames[0] = "index";
topmNames[1] = "aboutb";
topmNames[2] = "music";
topmNames[3] = "tv";
topmNames[4] = "movies";
topmNames[5] = "video";
topmNames[6] = "books";
topmNames[7] = "photos";
topmNames[8] = "love";
topmNames[9] = "links";

var topmHilReasons = new Array(10);

function ddUpdate( state )
{
if( state.charAt(0) == 'B' ) {
topmHil(1,2);
document.getElementById('dd_B').style.visibility = "visible";
}else{
topmUnHil(1,2);
document.getElementById('dd_B').style.visibility = "hidden";
}
if( state.charAt(0) == 'C' ) {
topmHil(2,2);
document.getElementById('dd_C').style.visibility = "visible";
if( state.charAt(1) == 'A' ) {
document.getElementById('dda_CA').src = rootUrl + "dd-exp.gif";
document.getElementById('dd_CA').style.visibility = "visible";
}else{
document.getElementById('dda_CA').src = rootUrl + "dd-coll.gif";
document.getElementById('dd_CA').style.visibility = "hidden";
}
if( state.charAt(1) == 'B' ) {
document.getElementById('dda_CB').src = rootUrl + "dd-exp.gif";
document.getElementById('dd_CB').style.visibility = "visible";
}else{
document.getElementById('dda_CB').src = rootUrl + "dd-coll.gif";
document.getElementById('dd_CB').style.visibility = "hidden";
}
if( state.charAt(1) == 'C' ) {
document.getElementById('dda_CC').src = rootUrl + "dd-exp.gif";
document.getElementById('dd_CC').style.visibility = "visible";
}else{
document.getElementById('dda_CC').src = rootUrl + "dd-coll.gif";
document.getElementById('dd_CC').style.visibility = "hidden";
}
}else{
topmUnHil(2,2);
document.getElementById('dd_C').style.visibility = "hidden";
document.getElementById('dda_CA').src = rootUrl + "dd-coll.gif";
document.getElementById('dd_CA').style.visibility = "hidden";
document.getElementById('dda_CB').src = rootUrl + "dd-coll.gif";
document.getElementById('dd_CB').style.visibility = "hidden";
document.getElementById('dda_CC').src = rootUrl + "dd-coll.gif";
document.getElementById('dd_CC').style.visibility = "hidden";
}
if( state.charAt(0) == 'D' ) {
topmHil(3,2);
document.getElementById('dd_D').style.visibility = "visible";
}else{
topmUnHil(3,2);
document.getElementById('dd_D').style.visibility = "hidden";
}
if( state.charAt(0) == 'E' ) {
topmHil(4,2);
document.getElementById('dd_E').style.visibility = "visible";
}else{
topmUnHil(4,2);
document.getElementById('dd_E').style.visibility = "hidden";
}
if( state.charAt(0) == 'F' ) {
topmHil(5,2);
document.getElementById('dd_F').style.visibility = "visible";
}else{
topmUnHil(5,2);
document.getElementById('dd_F').style.visibility = "hidden";
}
if( state.charAt(0) == 'G' ) {
topmHil(6,2);
document.getElementById('dd_G').style.visibility = "visible";
}else{
topmUnHil(6,2);
document.getElementById('dd_G').style.visibility = "hidden";
}
}

function ddInitItem( itemId )
{
	document.getElementById( itemId ).onmouseover = ddItemOver;
	document.getElementById( itemId ).onmouseout = ddItemOut;
}

function ddInit()
{
ddInitItem('ddi_BA');
ddInitItem('ddi_BB');
ddInitItem('ddi_CA');
ddInitItem('ddi_CB');
ddInitItem('ddi_CC');
ddInitItem('ddi_CAA');
ddInitItem('ddi_CAB');
ddInitItem('ddi_CAC');
ddInitItem('ddi_CAD');
ddInitItem('ddi_CAE');
ddInitItem('ddi_CAF');
ddInitItem('ddi_CBA');
ddInitItem('ddi_CBB');
ddInitItem('ddi_CBC');
ddInitItem('ddi_CBD');
ddInitItem('ddi_CBE');
ddInitItem('ddi_CBF');
ddInitItem('ddi_CCA');
ddInitItem('ddi_CCB');
ddInitItem('ddi_CCC');
ddInitItem('ddi_CCD');
ddInitItem('ddi_CCE');
ddInitItem('ddi_DA');
ddInitItem('ddi_DB');
ddInitItem('ddi_EA');
ddInitItem('ddi_EB');
ddInitItem('ddi_EC');
ddInitItem('ddi_ED');
ddInitItem('ddi_EE');
ddInitItem('ddi_FA');
ddInitItem('ddi_FB');
ddInitItem('ddi_FC');
ddInitItem('ddi_FD');
ddInitItem('ddi_GA');
ddInitItem('ddi_GB');
}


var ddCurState;
var ddPostState;
var ddPostTimerId;

function ddGo( baseName )
{
	window.location.href = rootUrl + baseName + ".html";
}

function ddDoPosted()
{
	clearTimeout( ddPostTimerId );
	ddPostTimerId = false;

	ddCurState = ddPostState;
	ddUpdate( ddCurState );
}

function ddPost( state, delay )
{
	var d = (delay === undefined) ? 300 : delay;

	ddPostState = state;

	if( ddPostTimerId )
		clearTimeout( ddPostTimerId );

	ddPostTimerId = setTimeout( ddDoPosted, d );
}

function evStop( ev )
{
	if( !ev ) var ev = window.event;
	if( ev.stopPropagation ) ev.stopPropagation();
	else ev.cancelBubble = true;
}


function ddItemOver( ev )
{
	this.style.background = "#000000";
	ddPost( this.id.substring(4) );
	evStop( ev );
}

function ddItemOut( ev )
{
	this.style.background = "#685b67";
	ddPost("",800);
	evStop( ev );
}

function topmHil( idx, reason )
{
	var bit = (reason === undefined) ? 1 : reason;
	
	var oldRsns = topmHilReasons[idx];
	topmHilReasons[idx] |= bit;

	if( !oldRsns )
	{
		var image = document.getElementById( "topm_"+String.fromCharCode(65+idx) );
		image.src = topmOverSrc[idx];
	}
}

function topmUnHil( idx, reason )
{
	var bit = (reason === undefined) ? 1 : reason;
	
	var oldRsns = topmHilReasons[idx];
	topmHilReasons[idx] &= (~bit);

	if( !topmHilReasons[idx] && oldRsns )
	{
		var image = document.getElementById( "topm_"+String.fromCharCode(65+idx) );
		image.src = topmNormSrc[idx];
	}
}



// newImage by Adobe
function newImage(arg)
{
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// changeImages by Adobe
function changeImages()
{
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function changeImagesByIds()
{
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImagesByIds.arguments.length; i+=2) {
			document.getElementById(changeImagesByIds.arguments[i]).src = changeImagesByIds.arguments[i+1];
		}
	}
}






function doohChBttn( idx, rollState )
{
	var bCollapsed = doohCollapsed[idx];
	var bttn = document.getElementById( "newsBttn" + idx );

	var suffix = (rollState != "") ? ("-" + rollState) : "";
	bttn.src = "newsdooh/bttn" + (bCollapsed?"":"-exp") + suffix + ".gif";
}

function expandDooh( idx )
{
	var theDiv = document.getElementById( "newsExtra" + idx );
	theDiv.style.display = "inline";

	var theEllip = document.getElementById( "newsEllip" + idx );
	theEllip.style.visibility = "hidden";

	var bttn = document.getElementById( "newsBttn" + idx );
	bttn.src = "newsdooh/bttn-exp.gif";
	bttn.alt = "Collapse";
	bttn.title = "Collapse";

	doohCollapsed[idx] = false;
}

function collapseDooh( idx )
{
	var theDiv = document.getElementById( "newsExtra" + idx );
	if( !theDiv )
		return;

	theDiv.style.display = "none";

	var theEllip = document.getElementById( "newsEllip" + idx );
	theEllip.style.visibility = "visible";

	var bttn = document.getElementById( "newsBttn" + idx );
	bttn.src = "newsdooh/bttn.gif";
	bttn.alt = "Expand";
	bttn.title = "Expand";

	doohCollapsed[idx] = true;
}

function togDooh( idx )
{
	if( doohCollapsed[idx] )
		expandDooh( idx );
	else
		collapseDooh( idx );
}

function collapseAllDooh()
{
	var i;
	for( i = 0 ; i < doohCollapsed.length ; i++ )
		collapseDooh( i );
}

function removePicWinElem( id )
{
	var elem = document.getElementById( id );
	if( elem !== null )
		document.getElementById("picbubb").removeChild( elem );
}


function makePCred( filename, height, x, y, id )
{
	var pcred = document.createElement('img');
	pcred.setAttribute('id',id);
	pcred.setAttribute('src',"pcred/"+filename);
	pcred.setAttribute('width',12);
	pcred.setAttribute('height',height);
	pcred.setAttribute('class','pcred');
	pcred.setAttribute('className','pcred');
	pcred.style.left = x + "px";
	pcred.style.top = y + "px";
	return pcred;
}


var curThnFrameDiv;

function setPic( anchor, id, width, height, caption, pcredid, pcredhgt, pacredid, pacredhgt )
{
	if( curThnFrameDiv != null ) {
		curThnFrameDiv.setAttribute('class','thnfrm');
		curThnFrameDiv.setAttribute('className','thnfrm');
	} else
		document.getElementById("picprompt").style.visibility = "hidden";

	removePicWinElem('thepic');
	removePicWinElem('thecap');
	removePicWinElem('thepcred');
	removePicWinElem('thepacred');
	removePicWinElem('thepcslsh');
	removePicWinElem('thepclbl');

	var x = (443 - width) / 2;
	var halfRemHeight = (488 - height) / 2;
	var y = halfRemHeight + (-4);

	var image = document.createElement('img');
	image.setAttribute('id','thepic');
	image.setAttribute('src',"http://photos.iloveyoubrandy.com/inpage/"+id+".jpg");
	image.setAttribute('width',width);
	image.setAttribute('height',height);
	image.setAttribute('class','photo');
	image.setAttribute('className','photo');
	image.style.left = x + "px";
	image.style.top = y + "px";

	var cap = document.createElement('div');
	cap.setAttribute('id','thecap');
	cap.setAttribute('class','photocap');
	cap.setAttribute('className','photocap');
	cap.style.top = (y + height + 3 + (halfRemHeight - 12) / 8) + "px";
	cap.innerHTML = unescape(caption);

	var pcredx = x + width + 2;
	var pcredy = y + height - 1;

	var pacred;
	var slash;
	if( pacredhgt ) {
		pcredy -= pacredhgt;
		pacred = makePCred( pacredid+".png", pacredhgt, pcredx, pcredy, "thepacred" );
		pcredy -= 7;
		slash = makePCred( "862C2D2B.png", 3, pcredx, pcredy, "thepcslsh" );
		pcredy -= 4;
	}

	pcredy -= pcredhgt;
	var pcred = makePCred( pcredid+".png", pcredhgt, pcredx, pcredy, "thepcred" );

	pcredy -= 83;
	var pcredlbl = makePCred( "152C037F.png", 79, pcredx, pcredy, "thepclbl" );

	var picbubb = document.getElementById("picbubb");
	picbubb.appendChild(image);
	picbubb.appendChild(cap);
	picbubb.appendChild(pcred);
	picbubb.appendChild(pcredlbl);
	if( pacred != null ) {
		picbubb.appendChild(pacred);
		picbubb.appendChild(slash);
	}

	curThnFrameDiv = anchor.parentNode;
	curThnFrameDiv.setAttribute('class','selthnfrm');
	curThnFrameDiv.setAttribute('className','selthnfrm');
}




function valCmmt()
{
	var box = document.getElementById('cmmtbox');
	var s = box.value;

	var objRegExp = /^(\s*)$/;

	if(objRegExp.test(s))
		s = s.replace(objRegExp, '');

	if( s.length )
		return true;

	alert( "Please type a comment before pressing Send Comment." );
	return false;
}


/* getElementsByClass is by: Dustin Diaz :: http://www.dustindiaz.com/ */
function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

// This is to fix a bug in IE in which absolute positioning
// relative to the bottom of a container with odd height
// will be out by a pixel.  (The error was documented as
// affecting even heights, but it doesn't seem as such.)
// We force designated containers odd to avoid the bug.
// NOTE THAT THIS ONLY WORKS IF THERE'S NO PADDING OR BORDER
function fixieoddhgts()
{
	var items = getElementsByClass("ieoddhgt",null,null);
	for (var i=0; i < items.length; i++)
	{
		var h = items[i].offsetHeight;
		if( (h % 2) == 1 )
			items[i].style.height = (h+1) + "px";
	}
}


function globalInit()
{
	preloadImages();

	ddInit();

	if( is_ie )
		fixieoddhgts();
}

// iloveyoubrandy.com collects browser information along with submitted comments.
// This is solely for the purpose of being able to investigate any browser related
// problems with the site.
function browserInfo()
{
	document.writeln( '<input type="hidden" name="browser" value="' + navigator.appName + '">' );
	document.writeln( '<input type="hidden" name="browserver" value="' + navigator.appVersion + '">' );
	document.writeln( '<input type="hidden" name="browserminver" value="' + navigator.appMinorVersion + '">' );
}

