init = function() {
	onIeResize();
}

if (window.attachEvent){
	window.attachEvent("onload", init);
	window.attachEvent("onresize", onIeResize);
} else {
	window.onload = sizeIframe;
	window.onresize = sizeIframe;
}
	
function onIeResize(){
	document.getElementById('Content').style.height = (getWinHeight()-100) + 'px';
	document.getElementById('Content').style.width = (getWinWidth()-255) + 'px';
	sizeIframe();
}

function openWindow(sUrl,iWidth,iHeight) {
	iLeft = (screen.availWidth-iWidth)/2
	iTop = (screen.availHeight-iHeight)/2
	window.open(sUrl,'_blank','width='+iWidth+',height='+iHeight+',left='+iLeft+',top='+iTop);
}

function sizeIframe(){
	// Height to distract from offsetHeight, different in IE & FF
	var minHeight = (window.attachEvent)? 4 : 4;
	var minWidth = (window.attachEvent)? 7 : 7;
	if(document.getElementById('ContentFrame')){
		document.getElementById('ContentFrame').style.height = (document.getElementById('Content').offsetHeight-minHeight) + 'px';
		document.getElementById('ContentFrame').style.width = (document.getElementById('Content').offsetWidth-minWidth) + 'px';
	}		
}

function getWinHeight()
{
	var myHeight = 0;
	if (typeof(window.innerHeight ) == 'number')
	{
		//Non-IE
		myHeight = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

function getWinWidth()
{
	var myWidth = 0;
	if (typeof(window.innerWidth ) == 'number')
	{
		//Non-IE
		myWidth = window.innerWidth;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientWidth))
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientWidth))
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}

var liIdentifier = 0;

function iFrameHack(divRef){

	if(document.getElementById(divRef.id+'_iframe')){
		return;
	}
debug('iFrameHack');
	// Obtain the reference to the div
	// divRef = document.getElementById(divId);

	// create a new iframe
	iframeRef=document.createElement('iframe');

	iframeRef.style.border='5px solid yellow';
	iframeRef.style.position='absolute';
	iframeRef.setAttribute('id',divRef.id+'_iframe');

	// set the dimension of the new iframe to the dimension of the reference div
	iframeRef.style.width=divRef.offsetWidth;
	iframeRef.style.height=divRef.offsetHeight;

	// position the iframe on the same position as the reference element
	iframeRef.style.top=divRef.offsetTop;//calcul valabil doar pt ie
	iframeRef.style.left=divRef.offsetLeft;//calcul valabil doar pt ie

	// insert the new iframe after the reference element
	divRef.parentNode.insertBefore(iframeRef,divRef.nextSibling);
}

function debug(str){
	document.getElementById('ContentInner').innerHTML += str+'<br/>';
}

function show_div(el){


	if(el.nodeName == 'LI'){
		var el2 = null;
		for(i = 0; i < el.childNodes.length; i++){
			if(el.childNodes[i].nodeName == 'UL'){
				el2 = el.childNodes[i];
				break;
			}
		}
		
		if(!el2){
			return;
		} else {
			el = el2;
		}
	} else {
		return;
	}

	
	if(el.id == ''){
		el.id = 'ul_'+liIdentifier++;
	}
	
	if(!el.style.display){
		el.style.display='none';
	}
	if(el.style.display=='none'){

		el.style.display='block';

	//	iFrameHack(el);//TODO: ar trebui executata doar pt ie
		if(document.getElementById('ContentFrame')){
			document.getElementById('ContentFrame').style.display = 'none';
		}
	}
	else{
		el.style.display='none';
		if(document.getElementById('ContentFrame')){
			document.getElementById('ContentFrame').style.display = 'block';
		}
		//elimina iframe
	//	iframeRef=document.getElementById(el.id+'_iframe');
	//	if(iframeRef) iframeRef.parentNode.removeChild(iframeRef);
	}

}

function setNav(sUrl) {
	document.getElementById('BreadCrump').innerHTML = sUrl
}