//common js functions

function jumpPage(url) {
	if (url != "") location.href=url;
}			


function openWindow(url, winName, specs) {
	//set defaults
	if (winName == "") winName = "win";
	if (specs == "") specs = "width=600,height=400,scrollbars=yes,resizable=yes"
	
	if (url != "") {
		var win = window.open(url, winName, specs);	
		win.focus();
	}
}	


//show/hide a single div
function showHideSingleDiv(divID) {					
	activeDiv = document.getElementById(divID); //get reference to active div
		
	if (activeDiv.style.display == "block")
		activeDiv.style.display = "none";				
	else
		activeDiv.style.display = "block";		
}


//update hidden frame
//assumes an iframe named 'getvalues' exists on page
function getList(url) {			
	if (url != "") {				
		parent.frames['getvalues'].location.href = url;
	}
}


//submit form w/ select list w/ multiple values (select list items hold urls)
function chooseLocation(selectObj) {
	url = selectObj[selectObj.selectedIndex].value
	if (url != "") location.href=url;
}		


//count characters left in a form field
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...this trims it!
		field.value = field.value.substring(0, maxlimit);
	else // otherwise, update 'characters left' counter
		countfield.value = maxlimit - field.value.length;
}


//strip ms word characters out of form fields
aBad = new Array(8220,8221,8216,8217,8212,8211,8230,183);
aGood = new Array('"','"',"'","'","--","-","...","*");
function fPaste(oTA) {
	sVal = clipboardData.getData("text");
	for (i=0;i<aBad.length;i++)
		sVal = sVal.replace( new RegExp(String.fromCharCode(aBad[i]),"g"),
		
	aGood[i]);
	document.selection.createRange().text = sVal;
	event.returnValue = false;
}


//mark form field w/ error
function raiseErr(item) {
	item.className = "error";
	item.focus();	
}


//clear form field error
function clearErr(item) {
	item.className = "";
}

// OpenIpixWindow()
var wini = null;
function OpenIpixWindow(ipix_string)
{
		h = 400;
		w = 500;
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings =  'height='+ h +',width='+ w +',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
		wini = window.open('/ipix_win.asp?ipix_str=' + ipix_string,'IPIX',settings);
}

// OpenVideoWindow()
var wini = null;
function OpenVideoWindow(video_string, iheight, iwidth)
{
		h = iheight;
		w = iwidth;
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings =  'height='+ h +',width='+ w +',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
		winj = window.open('/video_win.asp?video_str=' + video_string,'VIDEO',settings);
}
