
function getHeight(obj)
{
	var height = obj.offsetHeight;
	if (height > 0)
		return height;
	if (!obj.firstChild)
		return 0;
	// use the first child's height
	return obj.firstChild.offsetHeight;
}

function inputPost( postContent ) {
	var postPartsArr = document.getElementsByName('postpart');
	var partsCount = postPartsArr.length;
	var smallHeight = getHeight(postPartsArr[0]);
	var insertPart = 0;
	
	for ( i = 1; i < partsCount; i++ ) {
		tempHeight = getHeight(postPartsArr[i]);
		if (getBrowser() != 'IE7' && getBrowser() != 'IE') {
			if ( smallHeight > tempHeight ) {
				insertPart = i;
				smallHeight = tempHeight;
			}
		} else {
			if ( smallHeight > tempHeight && tempHeight != 0 ) {
				insertPart = i;
				smallHeight = tempHeight;
			}
		}
	}
	postPartsArr[insertPart].innerHTML += postContent;
}

function setPostPartsHeight() {
	var postPartsArr = document.getElementsByName('postpart');
	var partsCount = postPartsArr.length;
	var maxHeight = getHeight(postPartsArr[0]);
	var insertPart = 0;
	
	for ( i = 1; i < partsCount; i++ ) {
		tempHeight = getHeight(postPartsArr[i]);
		if ( maxHeight < tempHeight ) {
			maxHeight = tempHeight;
		}
	}
	for ( i = 0; i < partsCount; i++ ) {
		postPartsArr[i].style.height = maxHeight + 'px';
	}
}

function setDescriptionHeight() {
	var leftObj = document.getElementById('entryleft');
	var rightObj = document.getElementById('entryright');
	var descObj = document.getElementById('post_description');
	var leftHeight = getHeight(leftObj);
	var rightHeight = getHeight(rightObj);
	var descHeight = getHeight(descObj);

	if ( leftHeight < rightHeight )	{
		leftObj.style.height = (rightHeight - 2) + 'px';
	} else {
		descObj.style.height = (descHeight + (leftHeight - rightHeight - 18)) + 'px';
	}
}

function getXY(el)
{
    
    if (el.offsetParent == null) {
       return false;
    }
    
    var parentNode = null;
    var pos = [];
    var box;
    
    if (el.getBoundingClientRect) { // IE
       box = el.getBoundingClientRect();
       var doc = document;
       /*if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
          doc = parent.document;
    
          if ( !this.isAncestor(doc.documentElement, el) ) {
             return false;
          }
    
       }*/
    
       var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
       var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
    
       return [box.left + scrollLeft, box.top + scrollTop];
    }
    else { // safari, opera, & gecko
       pos = [el.offsetLeft, el.offsetTop];
       parentNode = el.offsetParent;
       if (parentNode != el) {
          while (parentNode) {
             pos[0] += parentNode.offsetLeft;
             pos[1] += parentNode.offsetTop;
             parentNode = parentNode.offsetParent;
          }
       }
       /*if (isSafari && el.style.position == 'absolute' ) { // safari doubles in some cases
          pos[0] -= document.body.offsetLeft;
          pos[1] -= document.body.offsetTop;
       }*/
    }
    
    if (el.parentNode) { parentNode = el.parentNode; }
    else { parentNode = null; }
    
    while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
    { // account for any scrolled ancestors
       if (parentNode.style.display != 'inline') { // work around opera inline scrollLeft/Top bug
          pos[0] -= parentNode.scrollLeft;
          pos[1] -= parentNode.scrollTop;
       }
    
       if (parentNode.parentNode) { parentNode = parentNode.parentNode; }
       else { parentNode = null; }
    }
    
    
    return pos;
}

function getBrowser()
{
    var ua = navigator.userAgent.toLowerCase();
    
    if (ua.indexOf('msie 7')>-1)
    {
        return 'IE7';
    }
    
    if (ua.indexOf('opera')>-1)
    {
        return 'opera';
    }
    
    if (ua.indexOf('webkit')>-1)
    {
        return 'safari';
    }
    
    if (window.ActiveXObject)
    {
        return 'IE';
    }
    
    if (ua.indexOf('firefox')>-1)
    {
        return 'Firefox';
    }
    return false;
}

function set_contactinfo( email, phone ) {
	document.getElementById('emailinfo').innerHTML = email;
	document.getElementById('phoneinfo').innerHTML = phone;
}

