function showPos(which) {
	document.getElementById('posture_' + which).style.display = 'block';
}

function hidePos(which) {
	document.getElementById('posture_' + which).style.display = 'none';
}


function getDirections() {

	var newAddy = document.addyForm.newaddy.value;
	var newCSZ = document.addyForm.newCSZ.value;

	var thisDirectionURL = 'http://maps.yahoo.com/py/ddResults.py?Pyt=Tmap&tarname=&tardesc=&osd=&newname=&newdesc=&dsd=&newHash=&newTHash=&newErr=&newTErr=&newFL=Use+Address+Below&newaddr='
	+ newAddy + '&newcsz=' + newCSZ + '&newcountry=us&newTFL=Use+Address+Below&newtaddr=10078+San+Pablo+Ave&newtcsz=El+Cerrito%2C+CA+94530-3927&newtcountry=us&Submit=Get+Directions&stp=a&stx=&csz=';

	window.open(thisDirectionURL, 'yahooMap');

}


function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

var fading = false;

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 3.5;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 80);
    } else {
		setOpacity(obj, 100);
		fading = false;
		//re-src for _1
		var oldSrc = document.getElementById(replace(objId, '_2' ,'_1')).src;
		oldSrc = oldSrc.substring(oldSrc.lastIndexOf('/') + 1, oldSrc.length);
		document.getElementById(replace(objId, '_2' ,'_1')).src = getImage();
		photos = replace(photos, '|' + oldSrc.substring(1, oldSrc.indexOf('.')), '');
		//window.status = oldSrc + '|' + photos;

	}
  }
}

function fadeOut(objId,opacity,direction) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >= 0) {
      setOpacity(obj, opacity);
      opacity -= 3.5;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 80);
    } else {
		setOpacity(obj, 0);
		fading = false;
		//re-src for _2
		var oldSrc = document.getElementById(objId).src;
		oldSrc = oldSrc.substring(oldSrc.lastIndexOf('/') + 1, oldSrc.length);
		document.getElementById(objId).src = getImage();
		photos = replace(photos, '|' + oldSrc.substring(1, oldSrc.indexOf('.')), '');
		//window.status = oldSrc + '|' + photos;
	}
  }
}

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};


	function replace(string,text,by) {
		// Replaces text with by in string
		var strLength = string.length, txtLength = text.length;
		if ((strLength == 0) || (txtLength == 0)) return string;

		var i = string.indexOf(text);
		if ((!i) && (text != string.substring(0,txtLength))) return string;
		if (i == -1) return string;

		var newstr = string.substring(0,i) + by;

		if (i+txtLength < strLength)
			newstr += replace(string.substring(i+txtLength,strLength),text,by);

		return newstr;
	}


	function exists(thing) {

	if (thing != null) {
		if ((thing + '') == '0') {
			return(true);
		} else if (thing) {
			return(true);
		}
	}

	return(false);
}


var thisImagePop = null;
var thisCurrImage = null;

function popPic(thisURL) {

	var imgURL = thisURL;

	thisCurrImage = new Image;
	thisCurrImage.src= imgURL;

	thisImagePop = window.open(imgURL, 'pic', 'title=0,resizable=1,scrollbars=0,status=0,width=300,height=300');

	thisImagePop.focus();
	watchResize();
} 

function watchResize() {

	if (thisCurrImage.height > 0) {
		thisImagePop.resizeTo(thisCurrImage.width + 50, thisCurrImage.height + 80);
	} else {
		setTimeout('watchResize()', 100);
	}

}
