// JavaScript Document
function showBodyLoading(){
	document.getElementById('thebody').innerHTML = "<center><img src='images/graphics/loading205.gif' alt='Loading' style='margin:50px;'></center>";
}

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}
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 getSearchResults(gcriteria){
	gcriteria = gcriteria.replace(/&/, "%26");
	gsearch=1;
	variables = '?txtGlobalSearch='+gcriteria;
	time=1000
	if (document.getElementById('radGSearch0').checked == true){
	variables += '&radGSearch0='+document.getElementById('radGSearch0').value;
	setTimeout("showResultados('results0','"+gcriteria+"', '"+gsearch+"')",time);
	time += 1500;
	gsearch +=1;
	}
	if (document.getElementById('radGSearch1').checked == true){
	variables += '&radGSearch1='+document.getElementById('radGSearch1').value;
	setTimeout("showResultados('results1','"+gcriteria+"', '"+gsearch+"')",time);
	time += 1500;
	gsearch +=1;
	}
	if (document.getElementById('radGSearch2').checked == true){
	variables += '&radGSearch2='+document.getElementById('radGSearch2').value;
	setTimeout("showResultados('results2','"+gcriteria+"', '"+gsearch+"')",time);
	time += 1000;
	gsearch +=1;
	}
	if (document.getElementById('radGSearch3').checked == true){
	variables += '&radGSearch3='+document.getElementById('radGSearch3').value;
	setTimeout("showResultados('results3','"+gcriteria+"', '"+gsearch+"')",time);
	time += 1000;
	gsearch +=1;
	}
	if (document.getElementById('radGSearch4').checked == true){
	variables += '&radGSearch4='+document.getElementById('radGSearch4').value;
	setTimeout("showResultados('results4','"+gcriteria+"', '"+gsearch+"')",time);
	time += 1500;
	gsearch +=1;
	}
	if (document.getElementById('radGSearch5').checked == true){
	variables += '&radGSearch5='+document.getElementById('radGSearch5').value;
	setTimeout("showResultados('results5','"+gcriteria+"', '"+gsearch+"')",time);
	time += 1000;
	gsearch +=1;
	}
	if (document.getElementById('radGSearch6').checked == true){
	variables += '&radGSearch6='+document.getElementById('radGSearch6').value;
	}
	//window.open('search/results.php'+variables,'_blank');
	showResults('search/results.php', variables);
}

function checkGSearch(anscount){
	if(document.getElementById('radGSearch'+anscount).checked != true){
		document.getElementById('radGSearch'+anscount).checked = true;
		MM_swapImage('checkbox'+anscount,'','images/graphics/checkbox_checked.gif',0);
	}
	else {
		document.getElementById('radGSearch'+anscount).checked = false;
		MM_swapImage('checkbox'+anscount,'','../images/graphics/checkbox.gif',0);
		document.getElementById('radGSearch6').checked = false;
		MM_swapImage('checkbox6','','images/graphics/checkbox.gif',0);
	}

}

function checkAll(){
	if(document.getElementById('radGSearch6').checked != true){
		document.getElementById('radGSearch6').checked = true;
		document.getElementById('radGSearch0').checked = true;
		document.getElementById('radGSearch1').checked = true;
		document.getElementById('radGSearch2').checked = true;
		document.getElementById('radGSearch3').checked = true;
		document.getElementById('radGSearch4').checked = true;
		document.getElementById('radGSearch5').checked = true;
		MM_swapImage('checkbox6','','images/graphics/checkbox_checked.gif',0);
		MM_swapImage('checkbox0','','images/graphics/checkbox_checked.gif',0);
		MM_swapImage('checkbox1','','images/graphics/checkbox_checked.gif',0);
		MM_swapImage('checkbox2','','images/graphics/checkbox_checked.gif',0);
		MM_swapImage('checkbox3','','images/graphics/checkbox_checked.gif',0);
		MM_swapImage('checkbox4','','images/graphics/checkbox_checked.gif',0);
		MM_swapImage('checkbox5','','images/graphics/checkbox_checked.gif',0);
	}
	else {
		document.getElementById('radGSearch6').checked = false;
		document.getElementById('radGSearch0').checked = false;
		document.getElementById('radGSearch1').checked = false;
		document.getElementById('radGSearch2').checked = false;
		document.getElementById('radGSearch3').checked = false;
		document.getElementById('radGSearch4').checked = false;
		document.getElementById('radGSearch5').checked = false;
		MM_swapImage('checkbox6','','images/graphics/checkbox.gif',0);
		MM_swapImage('checkbox0','','images/graphics/checkbox.gif',0);
		MM_swapImage('checkbox1','','images/graphics/checkbox.gif',0);
		MM_swapImage('checkbox2','','images/graphics/checkbox.gif',0);
		MM_swapImage('checkbox3','','images/graphics/checkbox.gif',0);
		MM_swapImage('checkbox4','','images/graphics/checkbox.gif',0);
		MM_swapImage('checkbox5','','images/graphics/checkbox.gif',0);
	}

}

function showResultados(area, gcriteria, gsearch){
	//alert(gcriteria);
	document.getElementById('hidResultArea').value=area; //puts the result area to be displayed into a hidden field so taht ajax script knows which div area to load date into
	if(area == "results0")
		showSpecific('search/listings.php','?txtGlobalSearch='+gcriteria+'&gsearch='+gsearch);
	if(area == "results1")
		showSpecific('search/news.php','?txtGlobalSearch='+gcriteria+'&gsearch='+gsearch);
	if(area == "results2")
		showSpecific('search/publicationsrelevance.php','?txtGlobalSearch='+gcriteria+'&gsearch='+gsearch);
	if(area == "results3")
		showSpecific('search/industrydirectoryrelevance.php','?txtGlobalSearch='+gcriteria+'&gsearch='+gsearch);
	if(area == "results4")
		showSpecific('presentations/presentations.php','?txtGlobalSearch='+gcriteria+'&gsearch='+gsearch);
	if(area == "results5")
		showSpecific('search/biosrelevance.php','?txtGlobalSearch='+gcriteria+'&gsearch='+gsearch);
}

/*
function showHide(results){
	var switch_display = document.getElementById('results'+results);
	
	if(switch_display.className != 'show'){
		switch_display.className = 'show';
		//document.getElementById('collapse'+results).innerHTML = 'Collapse';
		//MM_swapImage('hide'+results,'','../images/graphics/delete.gif',0);
	}
	else {
		switch_display.className = 'hide';
		//document.getElementById('collapse'+results).innerHTML = 'UnCollapse';
		//MM_swapImage('hide'+results,'','../images/graphics/add.gif',0);
	}
}
*/


function sendItem(type,id){
	//alert(id);
	if(document.getElementById('chkSend'+type+id).checked != true){
		document.getElementById('chkSend'+type+id).checked = true;
		MM_swapImage('send'+type+id,'','../images/graphics/checkbox_checked.gif',0);
	}
	else {
		//document.frmGlobalSearch.radGSearch[anscount].checked = false;
		document.getElementById('chkSend'+type+id).checked = false;
		MM_swapImage('send'+type+id,'','../images/graphics/checkbox.gif',0);
	}
}

function selectAll(type){
	count = document.getElementById('hid'+type+'Count').value;
	
	if (document.getElementById('hidOption').value == "check"){
		document.getElementById('btnAll').value = "Deselect All";
		document.getElementById('hidOption').value = "uncheck";
		for(i=0;i<count;i++){
		document.getElementById('chkSend'+i).checked = true;
		}
	} else {
		document.getElementById('btnAll').value = "Select All";
		document.getElementById('hidOption').value = "check";
		for(i=0;i<count;i++){
		document.getElementById('chkSend'+i).checked = false;
		}
	}
	
	
	
}

var timeout	= 500;
var closetimer	= 100;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
function showSectionType(section){
var switch_display = document.getElementById('link' + section);
	if(switch_display.className != 'activetab'){
		document.getElementById('link' + section).className = 'activetab';
	}
	var i;
	for (var i = 4; i <= 19; i++) {
	   var close_display = document.getElementById('link' + i);
	   if (close_display != switch_display){
			document.getElementById('link' + i).className = 'fadetab';
	   }
	}
}
function showNewsSection(section){
var switch_display = document.getElementById('display' + section);
	if(switch_display.className != 'show'){
		switch_display.className = 'show';
		document.getElementById('link' + section).className = 'tabs';
		if(switch_display != document.getElementById('displayAD')){
			document.getElementById('displayAD').className = 'hide';
			document.getElementById('linkAD').className = 'tabs_';
			
		}
		if(switch_display != document.getElementById('displayEP')){
			document.getElementById('displayEP').className = 'hide';
			document.getElementById('linkEP').className = 'tabs_';
			
		}
		if(switch_display != document.getElementById('displayMA')){
			document.getElementById('displayMA').className = 'hide';
			document.getElementById('linkMA').className = 'tabs_';
			
		}
		if(switch_display != document.getElementById('displayMN')){
			document.getElementById('displayMN').className = 'hide';
			document.getElementById('linkMN').className = 'tabs_';
			
		}
		if(switch_display != document.getElementById('displayCM')){
			document.getElementById('displayCM').className = 'hide';
			document.getElementById('linkCM').className = 'tabs_';
			
		}
		if(switch_display != document.getElementById('displayQP')){
			document.getElementById('displayQP').className = 'hide';
			document.getElementById('linkQP').className = 'tabs_';
			
		}
		if(switch_display != document.getElementById('displayPC')){
			document.getElementById('displayPC').className = 'hide';
			document.getElementById('linkPC').className = 'tabs_';
			
		}
	}
}
function showProcessing(tab){
	document.getElementById('processing'+tab).className = "show";
}

var hi = parseInt(0);
var pagehistory=new Array();
var pagequery = new Array();
function goBack(currentpagestring, currentquerystring, findme){
	if (findme != "yes"){
		pagehistory[hi] = currentpagestring;
		pagequery[hi] = currentquerystring;
		//alert(hi+currentpagestring+currentquerystring);
		hi++;
	} else {
		hi = (hi-2);
		if (pagehistory[hi] == undefined){
			showResults('default.php','?','no');
		} else {
			showResults(pagehistory[hi],pagequery[hi],'');
		}
		//alert(hi+","+pagehistory[hi]+","+pagequery[hi]);
	}
}

function showEdit(num){
	switch_display = document.getElementById('listing'+num);
	if (switch_display.className != "show"){
		switch_display.className = "show";
		document.getElementById('listingbar'+num).className = "listingbarsa";
		for(i=0; i<document.getElementById('hidListingsCount').value; i++){ //hidListingsCount
			if (i != num){
				document.getElementById('listing'+i).className = "hide";
				document.getElementById('listingbar'+i).className = "listingbars";
			}
		}
	}
	else {
		switch_display.className = "hide";
	}
}

function showBMSection(section){
var switch_display = document.getElementById('display' + section);
	if(switch_display.className != 'show'){
		switch_display.className = 'show';
		document.getElementById('link' + section).className = 'activetab';
	}
	var i;
	for (var i = 0; i <= 5; i++) {
	   var close_display = document.getElementById('display' + i);
	   if (close_display != switch_display){
			close_display.className = 'hide';
			document.getElementById('link' + i).className = 'fadetab';
	   }
	}
}


function confirmDelete(){
	if (button == "Delete"){
		var confirmation = confirm("Are you sure you want to delete the selected bookmark(s)?");
		if (confirmation == true){
			return true;
		}
		else{
			return false;
		}
	}
	if (button == "Print"){
		return true;
	}
	if (button == "Email"){
		return true;
	}
}
function addtoFavorites(){
	var ver = navigator.appName;
	var num = parseInt(navigator.appVersion);
	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
	document.write('<A HREF="javascript:window.external.AddFavorite(url,who);" ');
	document.write('onMouseOver=" window.status=');
	document.write("txt; return true ");
	document.write('"onMouseOut=" window.status=');
	document.write("' '; return true ");
	document.write('">'+ txt + '</a>');
	}else{
	txt += "  (Ctrl+D)";
	document.write(txt);
	}
}
function entrance2(){
	if(navigator.appName=="Netscape"){
		alert("Thank You \n Your Changes Have Been Saved!");
	}
	if(navigator.appName=="Microsoft Internet Explorer"){
		alert("Thank You \n Your Changes Have Been Saved!");
	}
}
// close layer when click-out
//document.onclick = mclose; 




function packagecheck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 return true					
}
function packagevalidate(){
	var msg = "";
	var emailID=document.PackageEntry.txtEmail;
	if (emailID.value == ""){
		msg += "Please Provide an Email Address \n";
	}
	if (document.PackageEntry.txtName.value == ""){
		msg += "Please Provide Your Name \n";
	}
	if (packagecheck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	if (msg != ""){
		alert(msg);
		return false;
	}
	else{
		return true;
	}
}

function showArea(areanumber){
	var switch_display = document.getElementById('displayArea_' + areanumber);
	if(switch_display.className != 'show'){
		switch_display.className = 'show';
	}
	else {
		//switch_display.className = 'hide';
	}
	var i;
	for (var i = 0; i <= 2; i++) {
		 var close_display = document.getElementById('displayArea_' + i);
		 if (close_display != switch_display){
			close_display.className = 'hide';
		 }
	}
}

function toggleDisplay(value)
{
	if(document.getElementById('displayArea_' + value).style.display == 'none')
	{
		document.getElementById('displayArea_' + value).style.display = '';
		document.getElementById('sectionLink_' + value).innerHTML = "<a href='javascript:toggleDisplay(" + value + ")' style='font-size:10px;text-decoration:none;color:#FFFFFF'>- collapse</a>";
	}
	else
	{
		document.getElementById('displayArea_' + value).style.display = 'none';
		document.getElementById('sectionLink_' + value).innerHTML = "<a href='javascript:toggleDisplay(" + value + ")' style='font-size:10px;text-decoration:none;color:#FFFFFF'>+ expand</a>";
	}
}


