function submitFormWithSelChar(ch,theForm) {
    
    theForm.hdSelectedCurrency.value=ch;
    theForm.hdAction.value="button_browse";
    theForm.submit();
}

function setComboSelected(comboName, selectedOption) {
    var selectedValue = 0;
    for (var i=0; i<comboName.length; i++) {
        alert(comboName+'.options[' + i + '].value ' + comboName.options[i].value + ' :: '+selectedOption);
        if(comboName.options[i].value == selectedOption){
            alert(i);
            selectedValue = i;
        }
    }
}

function replaceThis(mainStr, find, replace) {
    var main1 = mainStr.substring(0, mainStr.indexOf(find));
    var main2 = mainStr.substring(mainStr.indexOf(find)+find.length);
    return (main1 + replace + main2);
}

function setButtonId(buttonId,theForm) {
    //alert(buttonId);
    theForm.buttonId.value = buttonId;
}

function submitForm(theForm) {
    //alert('form submitted at '+new Date());
    theForm.submit();
}

function setMultiple(theForm) {
    //Options in the multiple combo are selected for submission.
    var aform = eval(theForm);
    var totElements = aform.elements.length;
    var i=0;
    var m=0;
    for(i=0;i<totElements;i++) { 
        if(aform.elements[i].type == "select-multiple") {
            var cmb_len = aform.elements[i].options.length;
            //alert(aform.elements[i].name+' : '+cmb_len);
            if(cmb_len > 0) {
                for(m=0; m<cmb_len; m++) {
                    aform.elements[i].options[m].selected=true;
                  //  alert(aform.elements[i].options[m].selected);
                }
            }
        }
    }
}

function move(inputText, destination) {
    SelectedValue = new Array();
    SelectedText = new Array();
    ExistingValue = new Array();
    ExistingText = new Array();
    
    if(!inputText.value == '') {
        var j=0,k=0;

        flag=true;
        for(m=0;m<destination.options.length;m++) {
            if(destination.options[m].text==inputText.value) {
                flag=false;
                break;
            }
        }
        if(flag) {
            SelectedValue[j]=inputText.value;
            SelectedText[j++]=inputText.value;
        } else {
            ExistingValue[k]=inputText.value;
            ExistingText[k++]=inputText.value;
        }

        destLen = destination.options.length;
        destination.options.length +=SelectedValue.length;
        for(i=0;i<SelectedValue.length;i++) {
            destination.options[i+destLen].value = SelectedValue[i];
            destination.options[i+destLen].text  = SelectedText[i];
        }
        inputText.value = '';
    }
    return false;
}

function removeFromCombo(source) {
    SelectedValue = new Array();
    SelectedText = new Array();
    ExistingValue = new Array();
    ExistingText = new Array();
    
    var j=0,k=0;
    for(i=0;i<source.options.length;i++)
        {
                if(source.options[i].selected==true)
                {
                    SelectedValue[j]=source.options[i].value;
                    SelectedText[j++]=source.options[i].text;
                }
                else
                {
                    ExistingValue[k]=source.options[i].value;
                    ExistingText[k++]=source.options[i].text;
                }
        }
        source.options.length=ExistingValue.length;
        for(i=0;i<ExistingValue.length;i++)
        {
                source.options[i].value = ExistingValue[i];
                source.options[i].text  = ExistingText[i];
        }
    return false;
}

function submitPage(page, targetPage,theForm) {
    theForm.currentPage.value = page;
    setButtonId(targetPage);
    submitForm();
}

function addTextToCombo(aText, aCombo){
  var aValue = aText.value;
  addToCombo(aValue, aCombo);
  aText.value='';
}

function addToCombo(aValue, aCombo){
    var sizeOfCombo = aCombo.options.length;
    if(sizeOfCombo == 0) {
        aCombo.options[0] = new Option(aValue , aValue);
    } else {
        aCombo.options[sizeOfCombo] = new Option(aValue , aValue);
    }
}

function addToCombo1(aText, aValue, aCombo)
{
    var sizeOfCombo = aCombo.options.length;
    if(sizeOfCombo == 0) {
        aCombo.options[0] = new Option(aText , aValue);
    } else {
        aCombo.options[sizeOfCombo] = new Option(aText , aValue);
    }
}

/* Selected values will be removed from Combo */
function removeFromCombo(aCombo) {
    for(i=0;i<aCombo.options.length;i++) {
        if(aCombo.options[i].selected == true) {
            aCombo.options[i] = null;
        }
    }
    return false;
}

function addToText(aValue, aText){
    aText.value = aValue;
}

function selectAllCheckBox(aThis, aHidden,theForm){
    var hidVal = aHidden.value;
    var aform = eval(theForm);
    var totElements = aform.elements.length;
    var i=0;
    var bool = aThis.checked;
    for(i=0;i<totElements;i++) { 
        if(aform.elements[i].type == "checkbox") {
        	if(bool) {
	            if(aform.elements[i].checked == false) {
	            	aform.elements[i].checked=true;
	            	hidVal =  hidVal + ':' + aform.elements[i].value;
	            }
	    	} else {
	            if(aform.elements[i].checked == true) {
	            	aform.elements[i].checked=false;
	            }	    		
            	 hidVal =  '';
    		}
        }
    }
    aHidden.value = hidVal;
    aform.hdSelectAll.value = "SelectAll";
    //alert(aHidden.value);
}

function selectSiteAllCheckBox(aThis, aHidden,theForm){
	var hidVal = aHidden.value;
    var aform = eval(theForm);
    var totElements = aform.elements.length;
    var i=0;
    var bool = aThis.checked;
    for(i=0;i<totElements;i++) { 
        if(aform.elements[i].type == "checkbox") {
        	if(bool) {
	            if(aform.elements[i].checked == false) {
	            	aform.elements[i].checked=true;
	            	hidVal =  hidVal + ';' + aform.elements[i].value;
	            }
	    	} else {
	            if(aform.elements[i].checked == true) {
	            	aform.elements[i].checked=false;
	            }	    		
            	 hidVal =  '';
    		}
        }
    }
    aHidden.value = hidVal;
    //alert(aHidden.value);
}


function unCheckAllCheckBox(aThis,theForm)
{
    var aform = eval(theForm);
    var bool = aThis.checked;
    if(aThis== aform.AllFieldsXFT[0])
    {
     aform.AllFields[0].checked = false;
     aform.AllFieldsXFT[0].checked =true;
    } 
    else if(aThis== aform.AllFields[0])
    {
      aform.AllFieldsXFT[0].checked = false;
    }  
    
	if(bool) {
        aform.Abstract[0].checked = false;
        aform.Author[0].checked = false;
        aform.Keywords[0].checked = false;
        aform.CompanyName[0].checked = false;
        aform.ArticleTitle[0].checked = false;
        aform.ReferenceNum[0].checked = false;
        aform.JournalTitle[0].checked = false;
        }
	    	
 }
    	
    	
function unCheckAll(aThis,theForm)
{
	
	var bool = aThis.checked;
	var aform = eval(theForm);
	if(bool) {
		aform.AllFields[0].checked = false;
		aform.AllFieldsXFT[0].checked = false;
	}	
}	

function setCheckBox(aThis, aHidden){
	var hidVal = aHidden.value;
    if(aThis.checked == true) {
    	hidVal =  hidVal + ':' + aThis.value;
    } else if(aThis.checked == false){
    	var str = hidVal;
    	if(str.indexOf(':'+aThis.value) >= 0) {
		var s1 = str.substring(0,str.indexOf(':'+aThis.value));
		var s2 = str.substring(str.indexOf(':'+aThis.value)+(':'+aThis.value).length);
		hidVal =  s1 + s2;
		}
    }
    aHidden.value = hidVal;
    //alert(aHidden.value);
}

function setSiteCheckBox(aThis, aHidden){
	var hidVal = aHidden.value;
    if(aThis.checked == true) {
    	hidVal =  hidVal + ';' + aThis.value;
    } else if(aThis.checked == false){
    	var str = hidVal;
    	if(str.indexOf(':'+aThis.value) >= 0) {
		var s1 = str.substring(0,str.indexOf(';'+aThis.value));
		var s2 = str.substring(str.indexOf(';'+aThis.value)+(';'+aThis.value).length);
		hidVal =  s1 + s2;
		}
    }
    aHidden.value = hidVal;
    //alert(aHidden.value);
}

function fnBlank()
{
  // Do Nothing
}

function fnExternalSearch(path, searchTerm)
{
  if(searchTerm == "")
  {
  	return false;
  }	
  else
  {
	  document.location.href = path + 
	  "/searchQuickOptions.do?hdAction=button_search&ExSearchTerm=" + searchTerm;
   }
}



function fnLoad1(theForm)
{
  var szDivID= theForm.slResourceBox.options[theForm.slResourceBox.selectedIndex].value;
  if(document.layers)	   //NN4+
  {
    document.layers[szDivID].display=  "block" ;
  }
  else if (document.getElementById && document.getElementById(szDivID) != null)
  {
    node = document.getElementById(szDivID).style.display='block';
  }
  else if(document.getElementById)	  //gecko(NN6) + IE 5+
  {
    var obj = document.getElementById(szDivID);
    obj.style.display= "block";       
  }
  else if(document.all)	// IE 4
  {
    document.all[szDivID].style.display= "block";
  }
}
function fnHide(theForm)
{
  var i;
  var theForm = theForm;
  var resourceLength = theForm.slResourceBox.options.length;
  for(i=0;i<resourceLength;i++)
  {
    var context =theForm.slResourceBox.options[i].value;
    if(document.layers)	   //NN4+
    {
      document.layers[context].display= "none";
    }
    else if (document.getElementById && document.getElementById(context) != null)
    {
      node = document.getElementById(context).style.display='none';
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
      var obj = document.getElementById(context);
      obj.style.display= "none";
    }
    else if(document.all)	// IE 4
    {
      document.all[context].style.display= "none";
    }
  }
  //alert(document.getElementById(szDivID).style.display);
  document.submit=false;
}
function fnShow(szDivID,theForm)
{
  if(document.layers)	   //NN4+
  {
    document.layers[szDivID].display=  "block" ;
  }
  else if (document.getElementById && document.getElementById(szDivID) != null)
  {
    node = document.getElementById(szDivID).style.display='block';
  }
  else if(document.getElementById)	  //gecko(NN6) + IE 5+
  {
    var obj = document.getElementById(szDivID);
    obj.style.display= "block";       
  }
  else if(document.all)	// IE 4
  {
    document.all[szDivID].style.display= "block";
  }
  document.submit=false;
}

function fnChgResources(theForm)
{
  var selectedIndex = theForm.slResourceBox.selectedIndex;
  var selectedValue = theForm.slResourceBox.options[selectedIndex].value;

  fnHide(); fnShow(selectedValue);
}

function fnlinkResources(status,theForm)
{
  var selectedIndex = theForm.slResourceBox.selectedIndex;
  var selectedValue = theForm.slResourceBox.options[selectedIndex].value;
  
  if (document.location.href.indexOf(".com/") > 0)
    server = document.location.href.substring(0,document.location.href.indexOf(".com/")+4);

  if (server.indexOf("xtra") < 0)
  {
  if(selectedValue == 'Authors')
  document.location.href = server+'/info/authors/';
  else if (selectedValue == 'Librarians')
  document.location.href = server+'/info/librarians/';
  if(selectedValue == 'Partners')
  document.location.href = server+'/info/products_services/partnerships/';
  if(selectedValue == 'Researchers')
  document.location.href = server+'/info/researchers/';
  else if (selectedValue == 'Managers')
  document.location.href = 'http://www.managementfirst.com';
  }
  else
  {
  if(selectedValue == 'Authors')
  document.location.href = server+'/info/emx/authors/';
  else if (selectedValue == 'Researchers')
  document.location.href = server+'/info/emx/researchers/';
  if(selectedValue == 'Faculty')
  document.location.href = server+'/info/emx/faculty/';
  if(selectedValue == 'Students')
  document.location.href = server+'/info/emx/students/';
  if(selectedValue == 'DeanDirectors')
    document.location.href = 'http://deans.emeraldinsight.com';
    
  if(selectedValue == 'Librarians')  
  document.location.href = server+'/info/librarians/emx.html';
  else if (selectedValue == 'Managers')
  {
   if(status == 'notLoggedIn') 
     document.location.href = 'http://www.managementfirst.com';
   else if(status == 'loggedIn') 
     document.location.href = 'http://www.managementfirst.com/wwwtest/emx/welcome.php?id=ex';
  }
  }
}

function fnValidateSearch(Action,theForm)
{
  var valid = true;
  var selectedValue = "";

  var radLength=theForm.rdSearch.length;

    for(var i=0;i<radLength;i++)
    {
      if(theForm.rdSearch[i].checked)
      {	
        selectedValue = theForm.rdSearch[i].value;
      }
    }

  if(selectedValue == "doi" )
  {
    if( theForm.txtDOI.value == "" ) 
    {
      alert("Please enter a DOI value to search on");
      valid=false;
    }
  }
  else if ( selectedValue == "date") 
  {
    if( theForm.txtStartDate.value == "") 
    {
      alert("Please enter a valid Start Date");
      valid=false;
    }
    else if( theForm.txtEndDate.value == "" ) 
    {
      alert("Please enter a valid End Date");
      valid=false;
    }else if(DateCompare(theForm.txtStartDate.value,theForm.txtEndDate.value)< 0) 
    {
      alert("End Date is less than Start Date");		
      valid = false;
    }
  }
  
  if(valid == true)
  {
    theForm.hdAction.value = "button_Search";
    theForm.submit();
  } 
}

function Callonload()
{

 document.getElementById("SCRIPT").style.visibility = 'visible';
 document.getElementById("NOSCRIPT").style.visibility ='hidden';
 //document.all.SCRIPT.style.visibility = 'visible';
 //document.all.NOSCRIPT.style.visibility ='hidden';
}