/*###############################################################
			Preload Team Pictures
###############################################################*/
var mydate = new Date();
var time = mydate.getHours() + mydate.getMinutes() + mydate.getSeconds();

var bigBob = new Image();
bigBob.src="http://www.stgeorge-real-estate.com/images/bob/Bob.jpg?date="+time;

var bigShauna = new Image();
bigShauna.src="http://www.stgeorge-real-estate.com/images/bob/Shauna%20Jo.jpg?date="+time;

var bigAngie = new Image();
bigAngie.src="http://www.stgeorge-real-estate.com/images/bob/Angie.jpg?date="+time;

var bigMichelle = new Image();
bigMichelle.src="http://www.stgeorge-real-estate.com/images/bob/Michelle.jpg?date="+time;

/*###############################################################
			Pop-open Picture Function
input: the picture name,
       the element calling this function,
       the text displayed below the picture.

output: nothing
        (appends body to html, no need for output)

###############################################################*/
function openBig(picture, element, txt){
/*
###########  Creating Image Div  ###########
*/
	var image=document.createElement('div');
	var height, width;
	var staffPictures;

	if (picture == "Bob" || picture == "Shauna" || picture == "Angie" || picture == "Michelle"){
		image.appendChild(eval("big"+picture));
		height=eval("big"+picture).height;
		width=eval("big"+picture).width;
		staffPictures = true;
	} else {
		image.appendChild(eval(picture));
		height=eval(picture).height;
		width=eval(picture).width;
		staffPictures = false;
	}
	image.style.height = height+"px";
/*
###########  Creating Text Div  ###########
*/
	var text=document.createElement('div');
	text.style.backgroundColor='#fff';
	var titleText = txt.split(" - ");
	var name=document.createElement('p');

	if (staffPictures){
		name.className="personName";
	} else {
		name.className="popoutText";
	}
	name.innerHTML=titleText[0];
	text.appendChild(name);

	if (staffPictures && titleText[1] !== undefined){
		var title=document.createElement('p');
		title.className="personTitle";
		title.innerHTML=titleText[1];
		text.appendChild(title);
	}

	if (staffPictures && titleText[2] !== undefined){
		var title=document.createElement('p');
		title.className="personTitle";
		title.innerHTML=titleText[2];
		text.appendChild(title);
	}
/*
###########  Creating Main Container Div  ###########
*/
	var content=document.createElement('div');
	content.id = "mouseover-image";
	content.style.border = "3px solid #67573E";
	content.style.position = "absolute";
	content.style.zIndex = "2";
	content.style.width = width+"px";

	if (navigator.userAgent.match('MSIE')){
		if (element.offsetParent) {
			var curleft = element.offsetLeft, curtop = element.offsetTop;
			var newEl = element;
			while (newEl = newEl.offsetParent) {
				curleft += newEl.offsetLeft;
				curtop += newEl.offsetTop;
				if (!newEl.offsetParent)
					break;
			}
		}
	}

	if (staffPictures) {
		if (navigator.userAgent.match('MSIE')){
			content.style.top = (curtop + element.height)+"px";
			content.style.left = (curleft - (element.width*2) - 8)+"px";
		}else{
			content.style.left = (element.offsetLeft - (element.width*2)-8)+"px";
		}
	} else {
		if (navigator.userAgent.match('MSIE')){
			content.style.top = (curtop + element.height)+"px";
			content.style.left = (curleft - (width/2) + (element.width/2))+"px";
		}else{
			content.style.left = (element.offsetLeft - (width/2) + (element.width/2))+"px";
		}
	}

/*
###########  Appending Divs Together  ###########
###########    Inserting into Page    ###########
*/
  content.appendChild(image);
  content.appendChild(text);

  if (navigator.userAgent.match('MSIE')){
    document.body.appendChild(content);
  }else{
    element.parentNode.appendChild(content);
  }
}

function closeBig(){
/*
###########  Removing pop-open from page  ###########
*/
  var pic = document.getElementById('mouseover-image');
  pic.parentNode.removeChild(pic);
}
