function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_openVoteWindow(p_id,a_id) { 
  wn=window.open('/vote/viewresults.cfm?p_id='+p_id+'&a_id='+a_id,'voteresults','width=450  ,height=250,scrollbars=yes');
  wn.focus();
}

function openprintable(j_id){
	printwindow=window.open('/nqcontent.cfm?a_name=printarticle&p_id='+j_id,'printwindow','width=800,height=520,scrollbars=yes');
	printwindow.focus();
return true;
}

function openWindow(url) {
  popupWin = window.open(url, 'remote', 'dependent,width=500,height=550,left=100,top=100,scrollbars=yes')
}

function openPhotoWindow(url) {
  popupWin = window.open(url, 'remote', 'dependent,width=780,height=550,left=100,top=100,scrollbars=yes')
}

function openMailWindow(url) {
  popupWin = window.open(url, 'remote', 'dependent,width=450,height=550,left=100,top=100,scrollbars=yes')
}


function openFormWindow(url) {
  popupWin = window.open(url, 'remote', 'dependent,width=484,height=475,left=100,top=100,scrollbars=yes')
}


function openWindowSmall(url) {
  popupWin = window.open(url, 'remote', 'dependent,width=450,height=170,left=100,top=100')
}

function openWindowVote(url) {
  popupWin = window.open(url, 'remote', 'dependent,width=450,height=470,left=100,top=100,scrollbars=yes')
}

//left menu
//Define variables
	var isNav4, isIE;
	var imgoff="/images/squares.gif";
	var imgon="/images/squares_on.gif";
	var imgon_ns="/images/squares_on.gif";
	var txton='FFFFFF';
	var txtoff='333333';
	
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

if (parseInt(navigator.appVersion) >=4 ) {
	if (navigator.appName == "Netscape") {
		isNav4 = true
	} else {
		isIE4 = true
		col1 = "all."
		styleObj = ".Style"
	}
}
	
function rolloverthat(i,whichtd){
	if (isNav4 == true) {
		var im=eval("document."+"im"+i);
		im.src=imgon_ns;
	} else {
			im=eval("document.all."+"im"+i);
			im.src=imgon;
			
			target=eval("document.all."+"bot"+i)
			target.style.backgroundColor=tdcol
			
			var tx=eval("document.all."+"tx"+i);
			tx.color=txton;
					
			whichtd.style.cursor="hand";
			whichtd.style.backgroundColor=mytdcol;
		}
	}

function rolloutthat(i,whichtd){
	if (isNav4 == true) {
		var im=eval("document."+"im"+i);
		im.src=imgoff;
	} else {

			im=eval("document.all."+"im"+i);
			im.src=imgoff;
			
			target=eval("document.all."+"bot"+i);
			target.style.backgroundColor=""
			
			var tx=eval("document.all."+"tx"+i);
			tx.color=txtoff;

			whichtd.style.cursor="";
			whichtd.style.backgroundColor="";

		}
	}
//left menu

function gotarget(srcElement,settarget) {
	window.location.href=settarget+srcElement;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof(window.onload)!= 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function resizeFrameById(frameId){
	var iframe;
	if(document.frames)
		iframe = document.frames[frameId];
	else
		iframe = window.frames[frameId];
	
	document.getElementById(frameId).height = iframe.document.body.scrollHeight;
	//document.getElementById(frameId).width = iframe.document.body.scrollWidth;
}


function resizeFrame(frameNumber){
	var iframe;
	if(document.frames)
		iframe = document.frames["middleFrameSet_" + frameNumber];
	else
		iframe = window.frames["middleFrameSet_" + frameNumber];
	
	document.getElementById("middleFrameSet_" + frameNumber).height = iframe.document.body.scrollHeight;//.body.scrollHeight;
}

function getObjPosLeft(obj, abIncludeAbsObjects) {
	var curLeft = 0;
	var bIncludeAbsObjects = true;
	
	if (abIncludeAbsObjects != null)
		bIncludeAbsObjects = abIncludeAbsObjects;
	
    while (obj.offsetParent)
    {
	if ((!bIncludeAbsObjects) && (obj.style.position.toLowerCase() == "absolute"))
		break;

        curLeft += obj.offsetLeft;
        obj = obj.offsetParent;
    }
    return curLeft;
}

function getObjPosTop(obj, abIncludeAbsObjects) {
    var curtop = 0;
	var bIncludeAbsObjects = true;

	if (abIncludeAbsObjects != null)
		bIncludeAbsObjects = abIncludeAbsObjects;

    while (obj.offsetParent)
    {
		if ((!bIncludeAbsObjects) && (obj.style.position.toLowerCase() == "absolute"))
			break;

        curtop += obj.offsetTop;
        obj = obj.offsetParent;
    }
    return curtop;
}

function dhtmlselect(selectid, selectwidth, optionwidth){
	var selectbox=document.getElementById(selectid)
	document.write('<div id="dhtml_'+selectid+'" class="dhtmlselect">'+selectbox.title+" "+combodropimage+'</div>');
	var dhtmlselectbox=document.getElementById("dhtml_"+selectid)
	selectbox.style.visibility="hidden";
	if (typeof selectwidth!="undefined")
		dhtmlselectbox.style.width=selectwidth
	if (combodropimage!="")
		dhtmlselectbox.getElementsByTagName("img")[0].style.left=dhtmlselectbox.offsetWidth+0+"px"
}

function dhtmlselectOptions(selectid, selectwidth, optionwidth){
	var selectbox=document.getElementById(selectid);
	window.closeTimeoutId = null;
	document.write('<div id="dropdown_'+selectid+'" class="dropdown" style="height: 300px;overflow-y: scroll;overflow-x: hidden;">')
	for (var i=0; i<selectbox.options.length; i++)
		document.write('<a href="'+selectbox.options[i].value+'">'+selectbox.options[i].text+'</a>')
	document.write('</div>')
	var optionsDiv = document.getElementById('dropdown_'+selectid);
	var dhtmlselectbox=document.getElementById("dhtml_"+selectid);
	optionsDiv.style.zIndex=combozindex
	combozindex--
	if (typeof optionwidth!="undefined"){
		optionsDiv.style.width=optionwidth;
	}
	optionsDiv.onmouseover=function(){
		if(window.closeTimeoutId != null){
			window.clearTimeout(window.closeTimeoutId);
			window.closeTimeoutId = null;
		}
		optionsDiv.style.display="block";
	}
	optionsDiv.onmouseout=function(){
		window.optionsDiv = optionsDiv;
		window.closeTimeoutId = window.setTimeout('window.optionsDiv.style.display="none"', 300);
	}
	dhtmlselectbox.onmouseover=function(){
		if(window.closeTimeoutId != null){
			window.clearTimeout(window.closeTimeoutId);
			window.closeTimeoutId = null;
		}
		dhtmlSetPosition(selectid);
		optionsDiv.style.display="block";
	}
}

function dhtmlSetPosition(selectid){
	var optionsDiv = document.getElementById('dropdown_'+selectid);
	var dhtmlselectbox=document.getElementById("dhtml_"+selectid);			
	optionsDiv.style.top=getObjPosTop(dhtmlselectbox,true) + "px";
	optionsDiv.style.left=getObjPosLeft(dhtmlselectbox,true) + "px";

}

function dhtmlselectInit(){
	combodropimage='/demo/css/graphic/nq_yaml/images/select.gif' //path to "drop down" image
	combodropoffsetY=2 //offset of drop down menu vertically from default location (in px)
	combozindex=1000
	
	if (combodropimage!="")
		combodropimage='<img class="downimage" src="'+combodropimage+'" title="Select an option" />'

	dhtmlselect("quicklinks", "110px", "200px");
}
