// Utility and global javascript methods provided by ECS // 

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}


function MM_reloadPage(init) {  //Updated by PVII. Reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function pviiW3Cbg(obj, pviiColor) { //v1.1 by Project VII
	obj.style.backgroundColor=pviiColor
}

function P7_autoLayers() { //v1.2 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;
 var a = parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc) {p7c=new Array();document.p7setc=true;
  for (var u=0;u<10;u++) {p7c[u] = new Array();}}
 for(k=0; k<p7c[a].length; k++) {
  if((g=MM_findObj(p7c[a][k]))!=null) {
   b=(document.layers)?g:g.style;b.visibility="hidden";}}
 for(k=1; k<args.length; k++) {
  if((g=MM_findObj(args[k])) != null) {
   b=(document.layers)?g:g.style;b.visibility="visible";f=false;
   for(j=0;j<p7c[a].length;j++) {
    if(args[k]==p7c[a][j]) {f=true;}}
  if(!f) {p7c[a][p7c[a].length++]=args[k];}}}
}

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];}}
}

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 P7_hideEl(evt) { //v1.5 by PVII-www.projectseven.com
 var b,r,m=false;if(document.layers){b=evt.target;if(b.p7aHide){
 b.visibility="hidden";}else{routeEvent(evt);}
 }else if(document.all&&!window.opera){b=event.srcElement;while(b){
 if(b.p7aHide){break;}b=b.parentElement;}if(!b.contains(event.toElement)){
 b.style.visibility="hidden";}}else if(document.getElementById){
 b=evt.currentTarget;r=evt.relatedTarget;while(r){if(b==r){m=true;
 break;}r=r.parentNode;}if(!m){b.style.visibility="hidden";}}
}

function P7_autoHide() { //v1.5 by PVII-www.projectseven.com
 var i,g;for(i=0;i<arguments.length;i++){
 if((g=MM_findObj(arguments[i]))!=null){g.p7aHide=true;if(document.layers){
 g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_hideEl;}}
}

function clear_textbox()
{
if (document.textform.searchfield.value = " Search ECS Web Site ")
document.textform.searchfield.value ="";
}



window.onload = function(e) {
MM_preloadImages('/journals/doc/ECSLIB-home/images/search_go_on.gif','/journals/doc/ECSLIB-home/images/home_off.jpg','/journals/doc/ECSLIB-home/images/members_on.jpg','/journals/doc/ECSLIB-home/images/education_on.jpg','/journals/doc/ECSLIB-home/images/awards_on.jpg','/journals/doc/ECSLIB-home/images/students_on.jpg','/journals/doc/ECSLIB-home/images/sponsorship_on.jpg','/journals/doc/ECSLIB-home/images/publications_on.jpg','/journals/doc/ECSLIB-home/images/meetings_on.jpg','/journals/doc/ECSLIB-home/images/digital_library_web_down.jpg','/journals/doc/ECSLIB-home/images/member_info_header_down.jpg','/journals/doc/ECSLIB-home/images/home_on.jpg','/journals/doc/ECSLIB-home/images/publications_off.jpg');
}




//Used to open a printer friendly window 
function openPrinterFriendlyWindow(url) { 
// openPrinterFriendly spawns a window with the printer friendly version of this page 
var x = 660; var y = 480; 

if (navigator.appVersion.indexOf("Mac") > 0) { 
openWindow(url, "width=" + x + ",height=" + y + ",toolbar=yes,resizable=yes,scrollbars=yes"); 
} else { openWindow(url, "width=" + x + ",height=" + y + ",status=yes,menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes"); 
} 
} 

//Opens a window 

function openWindow(url, optionString) { 
window.open(url, "", optionString); 
} 
//closes a window 

function closeWindow() { 
window.close(); 
} 






// Utilities added by me - paolo // 

//javascript check for quick search box

function jump2form() {
	document.search_form.possible1.select();
	document.search_form.possible1.focus();
}

function isblank(s) {
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) {
			return false;
		}
	}
	return true;
}

function searchformcheck() {
	//var d = document.search_form.pjournals.options.selected;
	var e = document.search_form.possible1.value;
	if ((e == null) || (e == "") || (e == "Search the ECS Digital Library") || isblank(e)) {
		alert("Please enter word and click 'Submit'.");
		jump2form();
	}
	else {
		return true;
	}
	return false;
}

function keywordFilled() {
	var s = document.search_form.possible1.value;
	if (s == "Search the ECS Digital Library")			
	document.search_form.possible1.value = "";
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=530,height=400,left = 650,top = 312');");
}

function openWindowCustom(baseURL,w,h) {
	openPopup = window.open(baseURL,'open_window','width='+w+',height='+h+',toolbars=0,scrollbars=1,location=no,statusbars=0,menubar=0,resize=no,top=50,left=50');
    openPopup.focus(); 
}
//**********************************************//
