<!--

/*
 
CONTENTdm Version 4.2000.0     
(c) DiMeMa, Inc. 2006 - All Rights Reserved 

*/

// browser sniffer

var uAgent = navigator.userAgent;
var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var isMac=false,
isSafari=false,
isNetscape=false,
isOpera=false,
isExplorer=false,
isFirefox=false;
var os,br;

ns5 = (bName == "Netscape" && bVer < 5);
ie4 = (bName == "Microsoft Internet Explorer" && bVer < 4);

(ie4 || ns5)?location.replace('needmore.php'):0;

(uAgent.indexOf('Mac')!= -1)?(os = "Mac", isMac=true):os = "PC";
(uAgent.indexOf('MSIE')!= -1)?(br = "Explorer", isExplorer=true):0;
(uAgent.indexOf('Netscape')!= -1)?(br = "Netscape", isNetscape=true):0;
(uAgent.indexOf('Safari')!= -1)?(br = "Safari", isSafari=true):0;
(uAgent.indexOf('Firefox')!= -1)?(br = "Firefox", isFirefox=true):0;
(uAgent.indexOf('Opera')!= -1)?(br = "Opera", isOpera=true):0;


// cookie sniffer

document.cookie="dmtestcookie=dmtestcookie;path=/";

if(!isMac && isExplorer){
cookieEnabled = (document.cookie.indexOf("dmtestcookie") != -1)?true:false;
} else if (typeof navigator.cookieEnabled == "undefined"){
cookieEnabled = (document.cookie.indexOf("dmtestcookie") != -1)?true:false;
} else {
cookieEnabled = (navigator.cookieEnabled)?true:false;
}


// name url

var url = top.parent.location.href;


/*####################### functions ######################## */
/*####################### functions ######################## */
/*####################### functions ######################## */

	
// zoom & pan window

function ImageView(){
window.open(image_viewer_url,'popup','width=760,height=650,status=no,location=no,toolbar=no,menubar=no,scrollbars=auto,resizable=yes,top=20,screenY=20,left=20,screenX=20');}


// Cookies

function getCookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function setCookie(name,value,expires,path,domain,secure) {
var today = new Date();
var expires = new Date(today.getTime() + (24 * 60 * 60 * 1000 * 365));
var path = '/';
    document.cookie = name + "=" +value +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "/") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");        
}

function delCookie(name,value,expires,path,domain,secure) {
var today = new Date();
var expires = new Date(today.getTime() - (24 * 60 * 60 * 1000 * 365));
var path = '/';
    document.cookie = name + "=" +value +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "/") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");        
}

// popup windows

var value = null;
var xpos = 0;
var ypos = 0; 

function pop(value,w,h){

	window.open(value,'popup','width=' + w + ',height=' + h + ',status=0,location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,top=10,screenY=10,left=10,screenX=10');}	

function pop2(value,w,h){

	window.open(value,'popup2','width=' + w + ',height=' + h + ',status=0,location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,top=20,screenY=20,left=20,screenX=20');}	

function clipperpop(value,w,h){

	window.open(value,'clipperpop','width=' + w + ',height=' + h + ',status=0,location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,top=20,screenY=20,left=20,screenX=20');}

function clippop(value,w,h){

	window.open(value,'clippop','width=' + w + ',height=' + h + ',status=0,location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,top=20,screenY=20,left=20,screenX=20');}	



// parse out url variables for form functions

var TopSearchString = unescape(top.location.search);


function TopCisoRoot(){

	if(TopSearchString.indexOf('&')!= -1){;
	cisoroot = TopSearchString.lastIndexOf('CISOROOT') + 1;
	amp = TopSearchString.indexOf('&');
	root = TopSearchString.substring(cisoroot+8,amp);
	}
	if(TopSearchString.indexOf('&')== -1){;
	cisoroot = TopSearchString.lastIndexOf('CISOROOT') + 1;
	root = TopSearchString.substring(cisoroot+8);
	}
	
	var TopRoot = replacetext(root, '%2F', '/');
	
	return TopRoot;

}


function TopCisOptr(){

	TopShortString = TopSearchString.substring(cisoroot+9+root.length);

	if(TopShortString.indexOf('&')!= -1){;
	cisoptr = TopShortString.lastIndexOf('CISOPTR') + 1;
	amp = TopShortString.indexOf('&');
	TopOptr = TopShortString.substring(cisoptr+7,amp);
	}

	if(TopShortString.indexOf('&')== -1){;
	cisoptr = TopShortString.lastIndexOf('CISOPTR') + 1;
	TopOptr = TopShortString.substring(cisoptr+7);
	}
	
	return TopOptr;
}


function PageCisoRoot(){

	SearchString = unescape(top.parent.right.location.search);

	cisoroot2 = SearchString.lastIndexOf('CISOROOT') + 1;
	amp2 = SearchString.indexOf('&');
	root2 = SearchString.substring(cisoroot2+8,amp2);
	PageRoot = replacetext(root2, '%2F', '/');
	
	return PageRoot;
}

function PageCisOptr(){

	SearchString = unescape(top.parent.right.location.search);
	shortsearchstring = SearchString.substring(cisoroot2+9+root2.length);

	if(shortsearchstring.indexOf('&')!= -1){
	cisoptr2 = shortsearchstring.lastIndexOf('CISOPTR') + 1;
	amp2 = shortsearchstring.indexOf('&');
	PageOptr = shortsearchstring.substring(cisoptr2+7,amp2);
	}

	if(shortsearchstring.indexOf('&')== -1){
	cisoptr2 = shortsearchstring.lastIndexOf('CISOPTR') + 1;
	PageOptr = shortsearchstring.substring(cisoptr2+7);
	}
	
	return PageOptr;
}


// clear form values

function clearDefault(el) {

  if (el.defaultValue==el.value) el.value = ""}


// checkbox functions

function checkAll() {
    for (i=0,n=document.searchResultsForm.elements.length;i<n;i++)
        if (document.searchResultsForm.elements[i].type == 'checkbox')
            document.searchResultsForm.elements[i].checked = true;
            isStatus();
}

function clearAll() {
    for (i=0,n=document.searchResultsForm.elements.length;i<n;i++)
		if (document.searchResultsForm.elements[i].type == 'checkbox')
            document.searchResultsForm.elements[i].checked = false;
            isStatus();
}
 

// count text in strings
 
function countInstances(string, word) {
var substrings = string.split(word);
return substrings.length - 1;
}


// make a string from checkbox values

function makeStrFromCheck(form) {
var i;
var outlist = '';
	for (i = 0; i < form.elements.length; i++) {
		if ((form.elements[i].type == 'checkbox') && (form.elements[i].checked == true)) {
		outlist = outlist + '&' +form.elements[i].value;
        }
	}
	return outlist;
}


function bellair(){
	if(!cookieEnabled){
	alert(error_cookies);
	} else {
	document.bell.submit();
	}
}

// duplicate bellair to fix bottom menu option and maintain page conformity

function bellair2(theForm){
	if(!cookieEnabled){
	alert(error_cookies);
	} else {
	theForm.submit();
	}
}


// set session cookie

function dmSessCookie(name,value){
document.cookie=name+"="+value+";path=/";
}


// set bounding box cookie

function dmTextCookie(thebox){
	if(thebox.value != ""){
	document.cookie="SEARCH=dc<0>CISOSEARCHALL<"+thebox.value+">;path=/";
	}	
}


// set bounding box cookie from metadata

function dmMetaTextCookie(text){
	if(text != ""){
	document.cookie="SEARCH=dc<0>CISOSEARCHALL<"+text+">;path=/";
	}	
}


// delete bounding box cookie

function delSearchCookie(){
document.cookie="SEARCH=;path=/";
}

// add multiple items to favorites

function addItemsFav(form){
chkstr = makeStrFromCheck(form);
	if(!cookieEnabled){
	alert(error_cookies);
	} else {
	(document.cookie.indexOf("BUF")!=-1)?buf = getCookie("BUF"):buf = "";
		if(buf != null){
		numv = (buf != '')?countInstances(buf, "/"):0;
		numn = countInstances(chkstr, "&");
		k = 0;
		str = chkstr.split('&');
			for(i=1;i<str.length;i++){
			str[i] = replacetext(str[i],'|','<')+'>';
				if(buf.indexOf(str[i]) != -1){
				k = i;
				}
			}
			if(numv + numn > max_fav){
			alert(too_many_fav);
			} else if(k > 0){
			alert(already_fav);
			} else {
			chstr = replacetext(replacetext(chkstr,'&','>'),'|','<')+">";
			newbuf = buf+chstr.substring(1);
			setCookie("BUF",newbuf);
			alert(added_fav);
			clearAll();
			}
		} else {
		chstr = replacetext(replacetext(chkstr,'&','>'),'|','<')+">";
		newbuf = chstr.substring(1);
		setCookie("BUF",newbuf);
		alert(added_fav);
		clearAll();		
		}
	}	
}


// add single item or complete document to favorites

function addItemFav(r,n){
	if(!cookieEnabled){
	alert(error_cookies);
	} else {
	(document.cookie.indexOf("BUF")!=-1)?buf = getCookie("BUF"):buf = "";
		if(buf != null){
		numv = (buf != '')?countInstances(buf, "/"):0;
			if(numv == "100"){
			alert(too_many_fav);
			} else if(buf.indexOf(r+'<'+n+'>') != -1){
			alert(already_fav);
			} else {
			addbuf = r+'<'+n+'>';
			setCookie('BUF',buf+addbuf);
			alert(added_fav);
			}
		} else {
		addbuf = r+'<'+n+'>';
		setCookie('BUF',addbuf);
		alert(added_fav);
		}
	}
}


// add single page of document to favorites

function addPageFav(){
var proots = PageCisoRoot()+'<'+PageCisOptr()+'>';
	if(!cookieEnabled){
	alert(error_cookies);
	} else {
	(document.cookie.indexOf("BUF")!=-1)?buf = getCookie("BUF"):buf = "";
	numv = countInstances(buf, "/");
		if(numv == "100"){
		alert(too_many_fav);
		} else if(buf.indexOf(proots) != -1){		
		alert(already_fav);
		} else {
		addbuf = PageCisoRoot()+'<'+PageCisOptr()+'>';
		setCookie('BUF',buf+addbuf);
		alert(added_fav);
		}
	}
}


// delete favorites

function deleteFavs(str){
var newbuf = "";
	if(str.indexOf('all') != -1){
	delCookie("BUF");
	location.replace(location.href);
	} else {
	(document.cookie.indexOf("BUF")!=-1)?buf = unescape(getCookie("BUF")):buf = "";
	ifav = buf.split('>');
	ar = str.split(',');
		for(i=0;i<ifav.length-1;i++){
		n = 0;
			for(k=0;k<ar.length;k++){
        		if (i == (ar[k]-1)){
        		n = 1;
        		break;
        		}
			}
			if(n == 0){
			newbuf += ifav[i]+">";
			}
		}
	}
	setCookie("BUF",newbuf);
	location.replace(location.href);
}


// move favorites

function moveFavs(from,to) {
(document.cookie.indexOf("BUF")!=-1)?buf = unescape(getCookie("BUF")):buf = "";
ifav = buf.split('>');

    if ((from > 0) && (from <= ifav.length) && (to > 0) && (to <= ifav.length-1) && (from != to)) {
      from = from - 1;
      to = to - 1;

      if (from < to) {
        tempifav = ifav[from];
        for (i = from; i < to; i++) {
          ifav[i] = ifav[i+1];
        }
        ifav[to] = tempifav;
      } else {
        tempifav = ifav[from];
        for (i = from; i > to; i--) {
          ifav[i] = ifav[i-1];
        }
        ifav[to] = tempifav;
      }

      nifav = "";
      for (i = 0; i < ifav.length; i++) {
      nifav = nifav + ifav[i]+">";
      }
      newbuf = replacetext(nifav, '>>','>');
      setCookie("BUF",newbuf);
      location.replace(location.href);
    }
  }

// replace text

function replacetext(string,text,by) {

	var strLength = string.length, txtLength = text.length;
	
    if ((strLength == 0) || (txtLength == 0)) 
    return string;

    var i = string.indexOf(text);
    
    if ((!i) && (text != string.substring(0,txtLength))) 
    return string;
    
    if (i == -1) 
    return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
	newstr += replacetext(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


// hide show

function showob(object) {

	if (document.getElementById){
	myObject = eval(document.getElementById('' + object + ''));
	myObject.style.visibility = 'visible';
	}
	
    else if (document.layers) {
		if (document.layers[object] != null) 
		document.layers[object].visibility = 'visible';
    	}
    	
    else if (document.all)
	document.all[object].style.visibility = 'visible';
}

function hideob(object) {
	if (document.getElementById){
	myObject = eval(document.getElementById('' + object + ''));
	myObject.style.visibility = 'hidden';
	}
	
    else if (document.layers) {
        if (document.layers[object] != null)
         document.layers[object].visibility = 'hidden';
    }
    
    else if (document.all)
	document.all[object].style.visibility = 'hidden';
}



// global blank init

function init(){}


function StatusOff(id) {

	if (document.getElementById){
		myObject = eval(document.getElementById('' + id + ''));
		myObject.style.color = button_font_color;
	}
	
     if (document.all) {
		document.all[id].style.color = button_font_color;
    }
}

function StatusOn(id) {

	if (document.getElementById){
		myObject = eval(document.getElementById('' + id + ''));
		myObject.style.color = status_off;
	}
	
     if (document.all) {
		document.all[id].style.color = status_off;
    }
}

function changeColor(num) {

	for (n = 1; n < totalitems; n = n+1) {
		if (n == num){
		eval(document.links.item + n + '.style.color="'+(status_on)+'"');
		}
		else{
		eval(document.links.item + n + '.style.color="'+(status_off)+'"');
		}
	}
	return true;
}

function changeClass(id, newClass) {
var thisob = '';
	if(document.getElementById){
	thisob = document.getElementById(''+id+'');
	thisob.className = newClass;
	}
}


// table highlighter

function setPointer(field, action, defaultColor, pointerColor, markColor) {
var newColor
var currentColor

currentColor=field.style.backgroundColor;

if (action == 'over' && currentColor.toLowerCase() == defaultColor.toLowerCase()) {
newColor=pointerColor; }

if (action == 'out' && currentColor.toLowerCase() == pointerColor.toLowerCase()) {
newColor=defaultColor; }

if (newColor) {
field.style.backgroundColor=newColor; }
}


function isStatus(){

	var numChecked = 0;
	var theForm = document.searchResultsForm;

  	for (i=0; i<theForm.elements.length; i++) {
    if (theForm.elements[i].type == 'checkbox' && theForm.elements[i].checked) numChecked++;
  	}
  	
  		if(numChecked != 0){
  		changeClass('adfav[1]', 'submenu');
  		changeClass('adfav[2]', 'submenu');
  		}
  	
		else{
		changeClass('adfav[1]', 'offstatus');
		changeClass('adfav[2]', 'offstatus');
		}
}



// maximize browser window

function maximizeWindow(){

window.moveTo(0,0);
window.resizeTo(screen.availWidth,screen.availHeight);
}


// minimixe browser window

function minimizeWindow(){

	if(screen.availWidth > 800 && screen.availHeight > 600){
	window.moveTo(0,0);
	window.resizeTo('796','596');
	}
}


// determine browser width

function getBrowserWidth(){

var myWidth = 0, myHeight = 0;
	if( typeof(window.innerWidth ) == 'number'){
	myWidth = window.innerWidth; myHeight = window.innerHeight;
	}
	else if(document.documentElement && (document.documentElement.clientWidth ||document.documentElement.clientHeight)){
	myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
	myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}
	setWidth = (pad_height)-0;	
	return myWidth-setWidth;
}


// determine browser height

function getBrowserHeight(){
var menuheight = 20;
var setHeight = (head_height+pad_height)-0;
(isFirefox)?menuheight = menuheight*1.15:0;
(isNetscape)?menuheight = menuheight*1.15:0;
(isMac && isSafari)?menuheight = menuheight*1.14:0;
(isMac && isFirefox)?menuheight = menuheight*1.04:0;
(isMac && isSafari)?setHeight = setHeight*1.01:0;
(isMac && isFirefox)?setHeight = setHeight*1.01:0;
(isMac && isNetscape)?setHeight = setHeight*1.04:0;
var myWidth = 0, myHeight = 0;
	if( typeof(window.innerWidth) == 'number' ){
	myWidth = window.innerWidth; myHeight = window.innerHeight;
	} 
	else if(document.documentElement && (document.documentElement.clientWidth ||document.documentElement.clientHeight)){
	myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} 
	else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
	myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}
	
	if(bot_menu){
	myHeight = myHeight-(menuheight+setHeight);
	} else {
	myHeight = myHeight-setHeight;
	}
return myHeight
}


// reload page after resize to correct iframe size

function reload(){
	if(url.indexOf("document.php") != -1){
	PageCisoRoot();
	querystr = unescape(top.location.search);
	querystr = querystr.replace(/&CISOSHOW=\d*/g,'');
	parent.location.replace('document.php'+querystr+'&CISOSHOW='+PageCisOptr());
	} else {
	parent.location.replace(location.href);
	}
}


// change bgColor of my favorites locally

function setBgColour(bgCol,txCol,lkCol,page){

	if(!cookieEnabled){
	alert(error_cookies);
	} else {
	
		switch(page){
	
		case "compare":
		
		document.bgColor = bgCol;
		parent.left.document.bgColor = bgCol;
		parent.right.document.bgColor = bgCol;
		
		break;

		case "slide":
		
		document.bgColor = bgCol;
		parent.slideframe.document.bgColor = bgCol;
		
		break;
		
		}
	document.cookie="sessionBgColor="+(bgCol+"&"+txCol+"&"+lkCol)+"path=/";	
	}		
}



// set preferences cookie

function setPrefs(which,val){

	if(!cookieEnabled){
	alert(error_cookies);
	} else {
	setCookie(which,val);
	alert(prefs_saved);
	}
}


// set my favorites bgColor

function getBg(page){

sessionBgColor = getCookie("sessionBgColor");
favPrefsBgColor = getCookie('favPrefs');
	if (sessionBgColor != null) {
	sessionBgColor = sessionBgColor.split('&');
	bgCol = sessionBgColor[0];
	}
	else if (favPrefsBgColor != null){
	favPrefs = favPrefsBgColor.split('&');
	bgCol = favPrefs[0];
	}else{
	bgCol = page_bgColor;
	}
	switch(page){	
	case "compare":		
	parent.left.document.bgColor = bgCol;
	parent.right.document.bgColor = bgCol;		
	break;

	case "view":	
	document.bgColor = bgCol;
	break;
	
	case "slide":	
	parent.slideframe.document.bgColor = bgCol;
	break;	
	}
}


function trim(str) { 
    if(str.substring(0,1) == " "){
    str = str.substring(1, str.length);
    }
    if(str.substring(str.length-1,str.length) == " "){
    str = str.substring(0, str.length-1);
    }
return str;
} 

//-->