//---------------------------------------------------------------------
// function used by oec - url art is relative to bcom/client, ebi, bschool, bol, etc.

function openAssembly(id, type, width, height) {
 var i_width;
 if ((new Number(width) + 32) < 375) {
   i_width="375";
 } else if (new Number(width) + 32 > new Number(screen.availWidth)) {
   i_width= new Number(screen.availWidth) - 64;
 } else {
   i_width= new Number(width) + 32;
 }

 var i_height;
 if (new Number(height) + 160 < 400) {
   i_height="400";
 } else if (new Number(height) + 160 > new Number(screen.availHeight)) {
   i_height= new Number(screen.availHeight) - 64;
 } else {
  i_height = new Number(height) + 160;
 }

 window.open("/eb/art?id="+id+"&type="+type, "EB_Media", "resizable=yes,scrollbars=yes,status=yes,width="+i_width+",height="+i_height+",top=0,left=0");

}

function openRelativeAssembly(id, type, width, height) {
 var i_width;
 if ((new Number(width) + 32) < 375) {
   i_width="375";
 } else if (new Number(width) + 32 > new Number(screen.availWidth)) {
   i_width= new Number(screen.availWidth) - 64;
 } else {
   i_width= new Number(width) + 32;
 }

 var i_height;
 if (new Number(height) + 160 < 400) {
   i_height="400";
 } else if (new Number(height) + 160 > new Number(screen.availHeight)) {
   i_height= new Number(screen.availHeight) - 64;
 } else {
  i_height = new Number(height) + 160;
 }

 window.open("art?id="+id+"&type="+type, "EB_Media", "resizable=yes,scrollbars=yes,status=yes,width="+i_width+",height="+i_height+",top=0,left=0");

}

function openFlagHistory(euid, width, height) {
 var i_width;
  if ((new Number(width) + 32) < 375) {
	 i_width="375";
  } else if (new Number(width) + 32 > new Number(screen.availWidth)) {
	 i_width= new Number(screen.availWidth) - 64;
  } else {
	 i_width= new Number(width) + 32;
  }

   var i_height;
if (new Number(height) + 160 < 400) {
   i_height="400";
} else if (new Number(height) + 160 > new Number(screen.availHeight)) {
   i_height= new Number(screen.availHeight) - 64;
} else {
  i_height = new Number(height) + 160;
}

window.open("/eb/article?eu="+euid, "EB_Article", "resizable=yes,scrollbars=yes,status=yes,width="+i_width+",height="+i_height+",top=0,left=0");

}

//---------------------------------------------------------------------
// date display

function showDate() {
  var today = new Date();
  var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  var year = (today.getYear() < 1000) ? today.getYear() + 1900 : today.getYear();

  document.write(months[today.getMonth()] + " " + today.getDate() + ", " + year);
}


//---------------------------------------------------------------------
// search drop-down

function checkSearch() {
	var form = document.forms["searchform"];
	var ct = form.elements["ct"];
	var query = escape(form.elements["query"].value);
      var fuzzyCheck = form.elements["spelling"];
      var fuzzy = "N";
	var DICTIONARY_INDEX = 6;
	var THESAURUS_INDEX = 7;
	if ( fuzzyCheck && fuzzyCheck.checked  )
	{
		fuzzy = "Y";
	}

	var url = "";
	if (ct.options[ct.selectedIndex].value == "dict") {
	  url = "/dictionary?book=Dictionary&va="+query+"&query="+query;
	} else if(ct.options[ct.selectedIndex].value == "thes") {
	  url = "/thesaurus?book=Thesaurus&va="+query+"&query="+query;
	} else {
	  url = "/search?query="+query+"&ct="+ct.options[ct.selectedIndex].value+"&fuzzy="+fuzzy;
	}

	window.parent.location = url;
}


//--------------------------------------------------------------------
//browser check functions

function is_MacIE() {
     return ( navigator.userAgent.toLowerCase().indexOf("mac") != -1 );
}

function is_IE() {
     return (  navigator.userAgent.indexOf("MSIE") != -1 );
}

function get_IEversion() {
     IEPos = navigator.appVersion.indexOf('MSIE');
     return parseInt( navigator.appVersion.substring(IEPos + 5, navigator.appVersion.indexOf(';', IEPos)) );
}

function get_NNversion() {
     return parseFloat(navigator.appVersion);
}

//--------------------------------------------------------------------
// for generic pop up window

function openBrowserWindow(theURL, winName, features) {
	window.open(theURL, winName, features);
}


//-------------------------------------------------------------------
// sized for customer service pop-up window

function openCS(theURL) {
       window.open(theURL, '', 'scrollbars=yes,resizable=yes,width=650,height=420');
}

//---------------------------------------------------------------------
// STTK LaunchTool

function LaunchTool(sttk_id) {
        window.open(sttk_id,'_blank','width=561,height=336,top=20,left=10,resizable=yes');
}


//-----------------------------------------------------------------------
function openVideo(videoID) {
    	window.open("/video/player?vid="+videoID,"videoWin","width=450,height=415");
}

//-----------------------------------------------------------------------
function openTimelinesWindow(prod){
	var wnd;
        if (navigator.appName.indexOf("Netscape") == -1) {
                wnd = window.open("/timelines-" + prod + "/eb_ie.html","Timelines","width=600,height=400,toolbar=no,location=no,top=0,left=0,resizable=no,menubar=no,screenX=50,screenY=50,left=50,top=50");
        } else {
	        wnd = window.open("/timelines-" + prod + "/eb_nn.html","Timelines","width=614,height=414,toolbar=no,location=no,top=0,left=0,resizable=no,menubar=no,screenX=50,screenY=50,left=50,top=50");
	}
	wnd.focus();
}
//-----------------------------------------------------------------------
function redirectTimeline() {
      var form = document.forms["timeline"];
      var type = form.elements["type"].value;
      openTimelinesWindow(type); 
}

