// JavaScript Document


<!-- MM Built-ins 
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//-->

function searchSubmit(){
	if (!MM_findObj('articleSearch').global_search.value == ''){
		document.articleSearch.submit();
	}
}


// adding LEFT and RIGHT functionality in javascript
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


// -- BEGIN Select List

function WA_AddValueToList(ListObj,TextString,ValString,Position)  {
  if (isNaN(parseInt(Position)))   {
    Position = ListObj.options.length;
  }
  else  {
    Position = parseInt(Position);
  }
  if (ListObj.length > Position)  {
  ListObj.options[Position].text=TextString;
  if (ValString != "")  {
    ListObj.options[Position].value = ValString;
  }
    else  {
      ListObj.options[Position].value=TextString;
    }
  }
  else  {
    var LastOption = new Option();
    var OptionPosition = ListObj.options.length;
    ListObj.options[OptionPosition] = LastOption;
    ListObj.options[OptionPosition].text = TextString;
    if (ValString != "")  {
      ListObj.options[OptionPosition].value = ValString;
    }
    else  {
      ListObj.options[OptionPosition].value=TextString;
    }
  }
}

function WA_subAwithBinC(a,b,c)
{

	var i = c.indexOf(a);
	var l = b.length;

	while (i != -1)	{
		c = c.substring(0,i) + b + c.substring(i + a.length,c.length);  //replace all valid a values with b values in the selected string c.
  i += l
		i = c.indexOf(a,i);
	}
	return c;

}

function WA_AddSubToSelected(sublist,targetlist,repeatvalues,leavetop,leavebottom,noseltop,noselbot,topval,toptext)     {
  for (var j=0; j<noseltop; j++)     {
    sublist.options[j].selected = false;
  }
  for (var k=0; k<noselbot; k++)     {
    sublist.options[sublist.options.length-(k+1)].selected = false;
  }
  if (sublist.selectedIndex >= 0)      {
   if (leavebottom)     {
      botrec = new Array(2);
      if (targetlist.options.length > 0)  {
        botrec[0] = targetlist.options[targetlist.options.length-1].value;
        botrec[1] = targetlist.options[targetlist.options.length-1].text;
        targetlist.options[targetlist.options.length-1] = null;
      }
    }
    if (!leavetop && targetlist.options.length > 0)     {
      if (targetlist.options[0].value == topval)     {
        targetlist.options[0] = null;  
      }
    }
    else     {
      if (leavetop && toptext != '')     {
	    targetlist.options[0] = new Option();
        targetlist.options[0].value = topval;
        targetlist.options[0].text = toptext;
      }
    }
    for (var o=0; o<sublist.options.length; o++)     {
      if (sublist.options[o].selected && o >= noseltop && o < sublist.options.length - noselbot)     {
        theText = sublist.options[o].text;
        theValue = sublist.options[o].value;
        addvalue = true;
        if (!repeatvalues)      {
          for (var p=0; p<targetlist.options.length; p++)     {
            if (theValue == targetlist.options[p].value)      {
              addvalue = false;
            }
          }
        }
        if (addvalue)  WA_AddValueToList(targetlist,theText,theValue,targetlist.options.length);
      }
    }
    if (leavebottom && botrec[1])     {
      WA_AddValueToList(targetlist,botrec[1],botrec[0],targetlist.options.length);
    }
  }
  for (var l=0; l < targetlist.options.length; l++)    {
    targetlist.options[l].selected = false;
  }
}

function WA_RemoveSelectedFromList(theBox,nottoremove,noneselectedoption,noneselectedvalue,noneselectedtext)     {
  var n=0;
  var selectedArray = new Array();
  for (var j=0; j<theBox.options.length; j++)     {
    if (!theBox.options[j].selected || nottoremove.indexOf("|WA|" + theBox.options[j].value + "|WA|") >= 0)     {
      theBox.options[n].value = theBox.options[j].value;
      theBox.options[n].text = theBox.options[j].text;
      n++;
    }
    else {
	    selectedArray[selectedArray.length] = j;
    }
  }
  for (var k=0; k<selectedArray.length; k++)  {
    theBox.options[selectedArray[k]].selected = false;
  }
  m = n;
  while (m<=j)     {
    theBox.options[n] = null;
    m++;
  }
  if (theBox.options.length == noneselectedoption && noneselectedtext != "")     {
    noneselectedvalue = WA_subAwithBinC("|WA|",",",noneselectedvalue);
    noneselectedtext = WA_subAwithBinC("|WA|",",",noneselectedtext);
    WA_AddValueToList(theBox,noneselectedtext,noneselectedvalue,0);
  }
  for (var l=0; l < theBox.options.length; l++)    {
    theBox.options[l].selected = false;
  }
}

function WA_MoveListOption(sourceselect,optionIndex,moveAdder)     {
  var oldvals = new Array(sourceselect.options[optionIndex + moveAdder].value, sourceselect.options[optionIndex + moveAdder].text, sourceselect.options[optionIndex + moveAdder].selected);
  sourceselect.options[optionIndex+moveAdder].value    = sourceselect.options[optionIndex].value;
  sourceselect.options[optionIndex+moveAdder].text     = sourceselect.options[optionIndex].text;
  sourceselect.options[optionIndex+moveAdder].selected = sourceselect.options[optionIndex].selected;
  sourceselect.options[optionIndex].value      = oldvals[0];
  sourceselect.options[optionIndex].text       = oldvals[1];
  sourceselect.options[optionIndex].selected   = oldvals[2];
}

function WA_MoveSelectedInList(sourceselect,tomove,topnum,botnum)     {
  if (tomove == "0")     {
    for (var n=topnum+1; n<sourceselect.options.length-botnum; n++)      {
      if (sourceselect.options[n].selected && !sourceselect.options[n-1].selected)    {
        WA_MoveListOption(sourceselect,n,-1);
      }
    }
  }
  else     {
    for (var n=(sourceselect.options.length-botnum)-2; n>=topnum; n--)      {
      if (sourceselect.options[n].selected && !sourceselect.options[n+1].selected)    {
        WA_MoveListOption(sourceselect,n,1);
      }
    }
  }
}

function WA_SelectAllInTarget(boxtoselect, valstonotselect)       {
  for (var x=0; x<boxtoselect.options.length; x++)       {
    if (valstonotselect.indexOf("|WA|" + boxtoselect.options[x].value + "|WA|") < 0) {
		boxtoselect.options[x].selected = true;
    }
    else       {
		boxtoselect.options[x].selected = false;
    }
  }
}



// --- END Select List Scripts



// Select None / Select All for multiple select list
// e.g. javascript:listClear(document.form.colors, 0);
function listClear(listname, action){
if(action == 0){
	selectem = false;
  }else{
	selectem = true};
	for (i=0; i<listname.length; i++) { 
	listname.options[i].selected = selectem;
	} 
}

<!-- show / hide scripot 
	var isIE=document.all?true:false;
	var isDOM=document.getElementById?true:false;
	var isNS4=document.layers?true:false;
	
	/* _w : which ID (1) or (2) */
	/* _h : (h)ide or (s)how */
	function toggleT(_w,_h) {
	  if (isDOM)
	  {
		if (_h=='s') document.getElementById(_w).style.visibility='visible';
		if (_h=='h') document.getElementById(_w).style.visibility='hidden';
	  }
	  else if (isIE) {
		if (_h=='s') eval("document.all."+_w+".style.visibility='visible';");
		if (_h=='h') eval("document.all."+_w+".style.visibility='hidden';");
	  }
	  else if(isNS4)
	  {
		if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';");
		if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';");
	  }
	}
	function toggleDisplay(_w,_h) {
	  if (isDOM)
	  {
		if (_h=='s') document.getElementById(_w).style.display='block';
		if (_h=='h') document.getElementById(_w).style.display='none';
	  }
	  else if (isIE) {
		if (_h=='s') eval("document.all."+_w+".style.display='block';");
		if (_h=='h') eval("document.all."+_w+".style.display='none';");
	  }
	  else if(isNS4)
	  {
		if (_h=='s') eval("document.layers['"+_w+"'].display='block';");
		if (_h=='h') eval("document.layers['"+_w+"'].display='none';");
	  }
	}
//-->


