var type = "?";
var iframe;

navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);



/*

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(navHover);
addLoadEvent(loadIFRAMEnow);
addLoadEvent(function() {
  // more code to run on page load 

  applyStyle();

});

*/

function applyStyle()
{

	var link = document.getElementById("applystyle");
	
	if (link)
	{
		var ss = document.createElement("link");
		ss.type = "text/css";
		ss.rel = "stylesheet";
		ss.href = link.href;

		if (document.layers) {
			type="NN";
			iframe.document.getElementsByTagName("head")[0].appendChild(ss);
		} else {
			if (document.all) {
				if (document.getElementById) {
					type="IE5+";
					iframe.document.createStyleSheet(ss.href);
				} else {
					type="IE4";
					iframe.document.createStyleSheet(ss.href);
				}
			} else {
				type="FF";
				iframe.document.getElementsByTagName("head")[0].appendChild(ss);
			}
		}
	}
	
	document.getElementById("pagecontent").innerHTML = "";
	document.getElementById('contentcell').style.visibility = "visible";
  
}


	
	
function loadIFRAMEnow()
{

if (document.layers) {
	type="NN";
	 iframe = document.frames["contentFRAME"];
} else {
	if (document.all) {
		if (document.getElementById) {
			type="IE5+";
			  iframe = window.frames["contentFRAME"];
		} else {
			type="IE4";
			  iframe = window.frames["contentFRAME"];
		}
	} else {
		type="FF";
		 iframe = window.frames["contentFRAME"];
	}
}

document.getElementById('contentcell').style.visibility = "hidden";

//alert(type);

if (document.layers) {
	type="NN";
	document.getElementById("contentFRAME").contentDocument = document.getElementById("pagecontent").innerHTML;
	ss.href = "http:////ngklaw.com//uploads//ngklawContent.css";
	iframe.document.getElementsByTagName("head")[0].appendChild(ss);
	document.getElementById("pagecontent").innerHTML = "";
} else {
	if (document.all) {
		if (document.getElementById) {
			type="IE5+";
			document.getElementById('contentcell').height = document.getElementById("menucell").clientHeight;
			iframe.document.body.innerHTML = document.getElementById("pagecontent").innerHTML;
		} else {
			type="IE4";
			document.getElementById('contentcell').height = document.getElementById("menucell").clientHeight;
			iframe.document.body.innerHTML = document.getElementById("pagecontent").innerHTML;
		}
	} else {
		type="FF";
		document.getElementById('contentcell').height = document.getElementById("menucell").clientHeight;
		iframe.document.body.innerHTML = document.getElementById("pagecontent").innerHTML;
	}
}

applyStyle();


}

function getAnchorPositionByID(frameObj, anchorID) {
  if (document.layers) {
    var anchor=frameObj.document.getElementById(anchorID);
    return { x: anchor.x, y: anchor.y };
  }
  else if (document.getElementById) { 
    var anchor=frameObj.document.getElementById(anchorID);
    var coords = {x: 0, y: 0 };
    while (anchor) {
	coords.x += anchor.offsetLeft;
	coords.y += anchor.offsetTop;
	anchor = anchor.offsetParent;
    }
    return coords;
  }
}

function scrollWin(linky){

if (document.layers) {
	type="NN";
	 _scrollWin(linky.href.substring(1));
} else {
	if (document.all) {
		if (document.getElementById) {
			type="IE5+";
			  _scrollWin(linky.hash.substring(1));
		} else {
			type="IE4";
			  _scrollWin(linky.hash.substring(1));
		}
	} else {
		type="FF";
		var url = (linky.href.indexOf('#') != -1) ? linky.href.substring(linky.href.indexOf('#')).substring(1) : linky.href.substring(1);
		 _scrollWin(url);

	}
}
}

function toTop(){
clearTimeout(timer)
if(window.frames["contentFRAME"].document.body.scrollTop >= scrollSteps){
window.frames["contentFRAME"].scrollBy(0,-scrollSteps)
timer=setTimeout("toTop()",10)
}
else{
clearTimeout(timer)
window.frames["contentFRAME"].document.body.scrollTop=0
}

}

function _scrollWin(id){
	frame=window.frames["contentFRAME"];
	var obj=frame.document.getElementById(id);
	var coords = getAnchorPositionByID(frame, id);
	frame.scrollTo(coords.x , coords.y);
}

function toTop(){
clearTimeout(timer)
if(window.frames["contentFRAME"].document.body.scrollTop >= scrollSteps){
window.frames["contentFRAME"].scrollBy(0,-scrollSteps)
timer=setTimeout("toTop()",10)
}
else{
clearTimeout(timer)
window.frames["contentFRAME"].document.body.scrollTop=0
}
}