// domain identified to allow iframe interaction from img01.newsbank.com
// document.domain = document.domain.split('.').slice(-2).join('.');

document.domain = document.domain.split('.').slice(-2).join('.');


function clearIt(form){
	 for(i=0; i<form.elements.length; i++){
		  with(form.elements[i]){		 
			if(type == "text" || type == "textarea" || type == "password"){
			value = ""
			}
			else if(type.indexOf("select") > -1){	
				for(o=0; o<options.length; o++){				
					if(type == "select-multiple"){
					options[o].selected = false
					}
					else{
					selectedIndex = 0
					}					
				}	
			}
			
		  checked = false		
	 	  }// end with
	 }//end for
var sort = form.elements.p_sort;
var defaultSort = 'YMD_date:A';
for(var i = 0; i < sort.length; i++) {
		sort[i].checked = false;
		if(sort[i].value == defaultSort.toString()) {
			sort[i].checked = true;
		}
	}

}

function setFocus() {
	try{
		document.forms[0].elements[0].focus();	
	}catch(e){}
}

function scrollFitToc(){
	
	/* 
		left for historical purposes, netscape doesn't respect overflow and and leaves either
		a lot of whitespace between main and footer (when coerced to overflow scroll) or when supplied
		in css, displays entire TOC over the footer. This is netscape buggyness, but following the doctrine
		of lowest common denominator all browsers suffer for netscapes negligence. 
	*/
	
	/* 
	if (document.getElementById('toc')){			
		var scrollFit = document.getElementById('content').offsetHeight;			
		var winHeight;
		var bodyHeight;
		if( typeof( window.innerWidth ) == 'number' ) {
		    winHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    winHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		    //IE 4 compatible
		    winHeight = document.body.clientHeight;
		  }
		  
		alert('winHeight: '+winHeight+', scrollFit: '+scrollFit)
		
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight;
		if (test1 > test2){ // all but Explorer Mac
			bodyHeight = document.body.scrollHeight;
		}
		else {	// Explorer Mac; would also work in Explorer 6 Strict, Mozilla and Safari
			bodyHeight = document.body.offsetHeight;
		}
		// >400 is a defensive manuever to prevent pages w/o height and width from masking toc
		if(scrollFit > 400 &&  bodyHeight > winHeight){
			document.getElementById('toc').style.height = scrollFit+"px";
			// netscape 7/8 loses track of set css, must reinforce
			document.getElementById('toc').style.overflow = 'auto';
		}
	}
	*/
}

function showHide(show,hide){
	if(document.getElementById(show) && document.getElementById(hide)){
		document.getElementById(show).style.display = 'block';
		document.getElementById(hide).style.display = 'none';
	}
}


function swapToc(obj){
	try{
		var request = "setParameter.html?f_name="+obj.n+"&f_value="+obj.v;
		iframeSubmit(request,"tocSwapFrame");
		tocObj = obj;
	}catch(e){
		// most likely - page not fully loaded (stalled loading image), do it anyways
		showHide(obj.s,obj.h);
	}
}

function pfSetParameter(val,update){
	try{
		var request = "setParameter.html?f_name="+update.id+"&f_value="+val;
		iframeSubmit(request,"iframe");
	}catch(e){
		// browser security error? supress and allow resize, the value does not have to be added to session
	}
}

function d_expandedTocHandler(k){
	showHide(tocObj.s,tocObj.h);
}

function iframeSubmit(request,el){
	var f = document.getElementById(el);
	if (f.contentDocument) {
		f.contentDocument.location.replace(request); 
	} else if (f.contentWindow) {
		f.contentWindow.location.replace(request); 
	} else if (f.document) {
		f.document.location.replace(request); 
	}
}

/*
function xmlHttp(){		

	xhr = false;		
	if(window.XMLHttpRequest){ 			// Mozilla, Safari,...
		xhr = new XMLHttpRequest();

		if (xhr.overrideMimeType) {
			xhr.overrideMimeType('text/xml');
		}
	}else if(window.ActiveXObject){ 	// IE
			try{ 
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			}catch (e){
				try{xhr = new ActiveXObject("Microsoft.XMLHTTP");}catch (e){}
			}
	}
	return xhr;
}
*/