// calculates the windowheight - source: www.alistapart.com

function getWindowHeight()
{
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') 
	{
		windowHeight=window.innerHeight;
	}
	else 
	{
		if (document.documentElement && document.documentElement.clientHeight) 
		{
			windowHeight=document.documentElement.clientHeight;
		}
		else 
		{
			if (document.body&&document.body.clientHeight) 
			{
				windowHeight=document.body.clientHeight;
			}
		}
	}
	
	return windowHeight;
}

function getRefToDiv(divID) {
    if( document.layers ) { //Netscape layers
        return document.layers[divID]; }
    if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
        return document.getElementById(divID); }
    if( document.all ) { //Proprietary DOM; IE4
        return document.all[divID]; }
    if( document[divID] ) { //Netscape alternative
        return document[divID]; }
    return false;
}

function fixHeights() 
{
	if(getRefToDiv('topcontainer'))
	{
	
		var left=getRefToDiv('topleft').offsetHeight;
		var right=getRefToDiv('topright').offsetHeight;
		getRefToDiv('topleft').style.height=Math.max(left,right) + 'px';
		getRefToDiv('topright').style.height=Math.max(left,right) + 'px';
		getRefToDiv('topcontainer').style.height=6 + Math.max(left,right) + 'px';
		
	}
	
	var windowHeight=getWindowHeight();
	
	var usedHeight=getRefToDiv('container').offsetHeight;
	
	if(usedHeight < windowHeight)
	{
		getRefToDiv('footerwrap').style.marginTop = (windowHeight-usedHeight+2)+'px';
	}
	else
	{
		getRefToDiv('footerwrap').style.marginTop = '3px';
	}
	
}


function expand()
{
	getRefToDiv('collapse').style.display='inline';
	getRefToDiv('expand').style.display='none';
	getRefToDiv('hidden').style.display='block';
	fixHeights();
}


function collapse()
{
	getRefToDiv('collapse').style.display='none';
	getRefToDiv('expand').style.display='inline';
	getRefToDiv('hidden').style.display='none';
	fixHeights();
}


function addSmiley(smiley)
{
	getRefToDiv('smilies').value = document.getElementById('smilies').value + ' ' + smiley + ' ';
}


function template()
{
	getRefToDiv('smilies').value = '<div class="row" style="padding-top:0px; margin-top:0px;">\n'
	+'<div class="portleft">\n'
	+'<h3>Preview:</h3>\n'
	+'<a href="portfolio/img.jpg" onclick="window.open(this.href,\'_blank\');return false;">\n'
	+'<img src="portfolio/img.jpg" class="portfolio" alt="" />\n'
	+'</a>\n'
	+'<h3>Type:</h3>\n'
	+'...<br />\n'
	+'<h3>Tools - Coding used:</h3>\n'
	+'</div>\n'
	+'<div class="portright">\n'
	+'text here text here text here text here text here text here text here text here \n'
	+'</div>\n'
	+'</div>\n'
	+'<div class="spacer">\n'
	+'&nbsp;\n'
	+'</div>';
}
