function setShowHideFlag(theForm) {
    if(theForm.showHideFlag != null) {
        alert('theForm.showHideFlag.value ' + 
               theForm.showHideFlag.value);
        if(theForm.showHideFlag.value == 'show') {
            theForm.showHideFlag.value = 'hide';
        } else {
            theForm.showHideFlag.value = 'show';
        }
        alert('After : ' + theForm.showHideFlag.value);
    } else {
        theForm.showHideFlag.value = 'show';
    }
}

function fnDeleteCookie(asAction,theForm)
{
  var ckyDate = new Date;
  ckyDate.setFullYear(ckyDate.getFullYear( ) -10);
  document.cookie = 'searchHistory=; expires=' + 
  ckyDate.toGMTString( ) + ';';
  buttonClicked(asAction,theForm);
}

/**
 * Not Used ?
 *
function fnRequestFreeTrial(ContainerId,theFormIn)
{
  theForm = eval(theFormIn);
  theForm.hdReqId.value = ContainerId;
  theForm.action = "/Insight/ac_freeTrial.do"
  theForm.submit();
}
 **/

function fnLogin(theFormIn)
{
	var theForm = eval(theFormIn);
	var username = theForm.txtUsername.value;
	var password= theForm.txtPassword.value;
	if(username.length <1){
		alert('UserName cannot be blank');
		theForm.txtUsername.focus();
		return ;
	}
	if(password.length <1){
		alert('Password cannot be blank');
		theForm.txtPassword.focus();
		return ;
	}
	theForm.action = SiteUrl + "/au_loginUser.do?"+ "txtUsername=" + username +  "&txtPassword="+ password;
	theForm.hdAction.value = "button_login";
	theForm.submit();
}

function fnLogin(theForm)
{
	
	var username = theForm.txtUsername.value;
	var password= theForm.txtPassword.value;
	if(username.length <1){
		alert('UserName cannot be blank');
		theForm.txtUsername.focus();
		return ;
	}
	if(password.length <1){
		alert('Password cannot be blank');
		theForm.txtPassword.focus();
		return ;
	}
	theForm.action = SiteUrl + "/au_loginUser.do?"+ "txtUsername=" + username +  "&txtPassword="+ password;
	theForm.hdAction.value = "button_login";
	theForm.submit();
}

function fnChkPassword(theFormIn)
{
	var theForm = eval(theFormIn);
	var password= theForm.creditPassword.value;
	if(password == ""){
		alert('Please enter the credit passowrd');
		return;
	}else{
		buttonClicked('continue',theForm);
	}
}

function printRequest(theFormIn)
{
	var theForm = eval(theFormIn);
	var UserTitle = theForm.slUserTitle.value;
	var UserFirstname = theForm.txtUserFirstname.value;
	var UserSurname= theForm.txtUserSurname.value;
	var UserEmail= theForm.txtUserEmail.value;
	if(UserTitle.length <1){
		alert('Please select a title');
		theForm.txtUserFirstname.focus();
		return ;
	}
	if(UserFirstname.length <1){
		alert('FirstName cannot be blank');
		theForm.txtUserFirstname.focus();
		return ;
	}
	if(UserSurname.length <1){
		alert('LastName cannot be blank');
		theForm.txtUserSurname.focus();
		return ;
	}
	if(UserEmail.length <1){
		alert('E-mail address cannot be blank');
		theForm.txtUserEmail.focus();
		return ;
	}
	buttonClicked('printRequest',theForm);   
}

function fnPurchase1(theFormIn)
{
  theForm = eval(theFormIn);
  if(!theForm.ch.checked)
  {
     alert ('You need to agree with Terms and Conditions');
     return;
  }
  theForm.submit();
}

function fnPurchase(theFormIn)
{
  var theForm = eval(theFormIn);
  if(!theForm.ch.checked)
  {
     alert ('You need to agree with Terms and Conditions');
     return;
  }
  theForm.hdAction.value = "0";
  theForm.submit();
}

function proceed()
{
    document.frmPurchase.method="post";
    var vat = document.frmPurchase.vatnumber.value;
    if(vat.length <1){
		alert('vat number is not given');
		document.frmPurchase.action="https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e";
		if(!document.frmPurchase.ch.checked)
		{
		     alert ('You need to agree with Terms and Conditions');
		     return;
		}
    	//document.frmPurchase.submit();
	}else{
	     if(document.frmPurchase.hdAction.value.length < 1 ){	
			alert('vat number is given');
			document.frmPurchase.hdAction.value = "1";
			document.frmPurchase.action="/Insight/paymentGateway.do";
		 }else{
		 	document.frmPurchase.action="https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e";
		 	if(!document.frmPurchase.ch.checked)
			{
			     alert ('You need to agree with Terms and Conditions');
			     return;
			}
		 }
	}
    	
    document.frmPurchase.submit();
}

function fSearchType(field,theForm,opt,seq)
{
  var selbox = "";
  if(seq == 1)
    selbox = theForm.searchFields1
  if(seq == 2)
    selbox = theForm.searchFields2
  if(seq == 3)   
    selbox = theForm.searchFields3
  var val = field.checked;
  {
    var theField = "theForm."+field.name;
    for(var i=0; i<2; i++)
      eval(theField+"["+i+"]").checked = false;
  }
  field.checked = val;
 
  if(opt == 1)
    {
     selbox.options.length = 0;
     selbox.options[selbox.options.length] = new Option('All fields','All fields');
     selbox.options[selbox.options.length] = new Option('All fields(excluding full text)','All fields(excluding full text)');
     selbox.options[selbox.options.length] = new Option('Abstract','Abstract');
     selbox.options[selbox.options.length] = new Option('Article title','Article title');
     selbox.options[selbox.options.length] = new Option('Author','Author');
     selbox.options[selbox.options.length] = new Option('Company name','Company name');
     selbox.options[selbox.options.length] = new Option('Country','Country');
     selbox.options[selbox.options.length] = new Option('ISSN','ISSN');
     selbox.options[selbox.options.length] = new Option('Issue','Issue');
     selbox.options[selbox.options.length] = new Option('Journal title','Journal title');
     selbox.options[selbox.options.length] = new Option('Keywords','Keywords');
     selbox.options[selbox.options.length] = new Option('Page','Page');
     selbox.options[selbox.options.length] = new Option('Reference number','Reference number');
     selbox.options[selbox.options.length] = new Option('Volume','Volume');
  }
  
  
  if(opt == 2)
    {
     selbox.options.length = 0;
     selbox.options.length = 0;
     selbox.options[selbox.options.length] = new Option('Journal title','Journal title');
     selbox.options[selbox.options.length] = new Option('Article title','Article title');
     selbox.options[selbox.options.length] = new Option('Keywords','Keywords');
     selbox.options[selbox.options.length] = new Option('Reference number','Reference number');
     selbox.options[selbox.options.length] = new Option('Author','Author');
    }
  
    
  if(opt == 2 && val == false )
    {
       selbox.options.length = 0;
       selbox.options[selbox.options.length] = new Option('All fields','All fields');
       selbox.options[selbox.options.length] = new Option('All fields(excluding full text)','All fields(excluding full text)');
       selbox.options[selbox.options.length] = new Option('Abstract','Abstract');
       selbox.options[selbox.options.length] = new Option('Article title','Article title');
       selbox.options[selbox.options.length] = new Option('Author','Author');
       selbox.options[selbox.options.length] = new Option('Company name','Company name');
       selbox.options[selbox.options.length] = new Option('Country','Country');
       selbox.options[selbox.options.length] = new Option('ISSN','ISSN');
       selbox.options[selbox.options.length] = new Option('Issue','Issue');
       selbox.options[selbox.options.length] = new Option('Journal title','Journal title');
       selbox.options[selbox.options.length] = new Option('Keywords','Keywords');
       selbox.options[selbox.options.length] = new Option('Page','Page');
       selbox.options[selbox.options.length] = new Option('Reference number','Reference number');
       selbox.options[selbox.options.length] = new Option('Volume','Volume');
    }
    
    if(opt == 3)
        {
         selbox.options.length = 0;
         selbox.options.length = 0;
         selbox.options[selbox.options.length] = new Option('Journal title','Journal title');
         selbox.options[selbox.options.length] = new Option('Article title','Article title');
         selbox.options[selbox.options.length] = new Option('Keywords','Keywords');
         selbox.options[selbox.options.length] = new Option('Reference number','Reference number');
         selbox.options[selbox.options.length] = new Option('Author','Author');
    }
    
    if(opt == 3 && val == false )
        {
           selbox.options.length = 0;
           selbox.options[selbox.options.length] = new Option('All fields','All fields');
           selbox.options[selbox.options.length] = new Option('All fields(excluding full text)','All fields(excluding full text)');
           selbox.options[selbox.options.length] = new Option('Abstract','Abstract');
           selbox.options[selbox.options.length] = new Option('Article title','Article title');
           selbox.options[selbox.options.length] = new Option('Author','Author');
           selbox.options[selbox.options.length] = new Option('Company name','Company name');
           selbox.options[selbox.options.length] = new Option('Country','Country');
           selbox.options[selbox.options.length] = new Option('ISSN','ISSN');
           selbox.options[selbox.options.length] = new Option('Issue','Issue');
           selbox.options[selbox.options.length] = new Option('Journal title','Journal title');
           selbox.options[selbox.options.length] = new Option('Keywords','Keywords');
           selbox.options[selbox.options.length] = new Option('Page','Page');
           selbox.options[selbox.options.length] = new Option('Reference number','Reference number');
           selbox.options[selbox.options.length] = new Option('Volume','Volume');
    }
    
    
  
}



function fSearchTypeQuick(field,theForm,opt)
{

var val = field.checked;
  {
    var theField = "theForm."+field.name;
    for(var i=0; i<2; i++)
      eval(theField+"["+i+"]").checked = false;
      
  }
  field.checked = val; 
  
  if(opt==1)
  {
  theForm.JournalTitle[0].checked = true;
  
  theForm.AllFields[0].checked = false;
  theForm.AllFields[0].disabled = true;
  
  theForm.AllFieldsXFT[0].checked = false;
  theForm.AllFieldsXFT[0].disabled = true;
  
  theForm.Abstract[0].checked = false;
  theForm.Abstract[0].disabled = true;
  
  theForm.CompanyName[0].checked = false;
  theForm.CompanyName[0].disabled = true;
  }
  
  if(opt==0)
    {
    theForm.AllFields[0].checked = true;
    theForm.JournalTitle[0].checked = false;
    theForm.Author[0].checked = false;
    theForm.Keywords[0].checked = false;
    theForm.ArticleTitle[0].checked = false;
    theForm.ReferenceNum[0].checked = false;
    
    theForm.AllFields[0].disabled = false;
    theForm.AllFieldsXFT[0].disabled = false;
    theForm.Abstract[0].disabled = false;
    theForm.CompanyName[0].disabled = false;
  }
  
   if(opt==0 && val == false)
      {
      theForm.AllFields[0].checked = true;
      theForm.JournalTitle[0].checked = false;
      theForm.Author[0].checked = false;
      theForm.Keywords[0].checked = false;
      theForm.ArticleTitle[0].checked = false;
      theForm.ReferenceNum[0].checked = false;
      theForm.AllFieldsXFT[0].checked = false;
      theForm.Abstract[0].checked = false;
      theForm.CompanyName[0].checked = false;
      
      theForm.AllFields[0].disabled = false;
      theForm.AllFieldsXFT[0].disabled = false;
      theForm.Abstract[0].disabled = false;
      theForm.CompanyName[0].disabled = false;
      }
      
      if(opt==1 && val == false)
            {
            theForm.AllFields[0].checked = true;
            theForm.JournalTitle[0].checked = false;
            theForm.Author[0].checked = false;
            theForm.Keywords[0].checked = false;
            theForm.ArticleTitle[0].checked = false;
            theForm.ReferenceNum[0].checked = false;
            theForm.AllFieldsXFT[0].checked = false;
            theForm.Abstract[0].checked = false;
            theForm.CompanyName[0].checked = false;
            
            theForm.AllFields[0].disabled = false;
            theForm.AllFieldsXFT[0].disabled = false;
            theForm.Abstract[0].disabled = false;
            theForm.CompanyName[0].disabled = false;
      }
  
       
}
