var isW3C=(document.getElementById) ? true : false;
var intADH=0
var intADM=0
var intADS=0

var intLDH=0
var intLDM=0
var intLDS=0

var intRDH=0
var intRDM=0
var intRDS=0

var intLSelectAll=1
var intRSelectAll=1

var intAP=1
var intANR=10
var intANRTP=0
var intRTNR=0
var Atxt=''

var intRP=1
var intRNR=10
var intRNRTP=0
var intRTNR=0
var Rtxt=''

var intLP=1
var intLNR=10
var intLNRTP=0
var intLTNR=0
var Ltxt=''

function FigureTextNoQuantity(x){
 var rx=x
 var paren=rx.lastIndexOf("(")
 return rx.substring(0,paren-1)
}

function EscapeTotal(x){
 x=escape(x)
 while (x.indexOf("*") != -1){
  x=x.replace("*","%2A")
 }
 while (x.indexOf("@") != -1){
  x=x.replace("@","%40")
 }
 while (x.indexOf("-") != -1){
  x=x.replace("-","%2D")
 }
 while (x.indexOf("_") != -1){
  x=x.replace("_","%5F")
 }
 while (x.indexOf("+") != -1){
  x=x.replace("+","%2B")
 }
 while (x.indexOf(".") != -1){
  x=x.replace(".","%2E")
 }
 while (x.indexOf("/") != -1){
  x=x.replace("/","%2F")
 }
 return x
}
//Artist
function GotoArtist(){
 elemX3A=(isW3C)?document.getElementById("X3A"):(document.all("X3A")); 
 elemX3A.focus()
 if (elemX3A.setSelectionRange){
  elemX3A.setSelectionRange(elemX3A.value.length,elemX3A.value.length)
 }else if (elemX3A.createTextRange){
  var range=elemX3A.createTextRange()
  range.collapse(true)
  range.moveEnd('character',elemX3A.value.length)
  range.moveStart('character',elemX3A.value.length)
  range.select()
 }
}
function ArtistOnBlur(){
 ArtistHideSuggest()
}
function ArtistMouseOutSuggest(x){
 var elemDS=(isW3C)?document.getElementById("Ad"+intADS):(document.all("Ad"+intADS)); 
 elemDS.style.backgroundColor="#FFFFC8"
 intADS=0
}
function ArtistKeyDown(evt){
 var unicode=evt.keyCode? evt.keyCode : evt.charCode
 if (intADS!=0){
  var elemDS=(isW3C)?document.getElementById("Ad"+intADS):(document.all("Ad"+intADS)); 
  elemDS.style.backgroundColor="#FFFFC8"
  intADS=0
 }
 if (unicode==40){
  if (intADM!=0){
   if (intADS!=0){
    var elemDS=(isW3C)?document.getElementById("Ad"+intADS):(document.all("Ad"+intADS)); 
    elemDS.style.backgroundColor="#FFFFC8"
   }
   intADH+=1
   if (intADH>intADM){intADH=1}
   ArtistHighlightSuggest(intADH)
   return
  }else{
   return
  }
 }else if(unicode==38){
  elemX3A=(isW3C)?document.getElementById("X3A"):(document.all("X3A")); 
  if (intADM!=0){
   if (intADS!=0){
    var elemDS=(isW3C)?document.getElementById("Ad"+intADS):(document.all("Ad"+intADS)); 
    elemDS.style.backgroundColor="#FFFFC8"
   }
   intADH--
   if (intADH<1){intADH=intADM}
   ArtistHighlightSuggest(intADH)
   return
  }else{
   return
  }
 }else{
  if (intADS!=0){
   var elemDS=(isW3C)?document.getElementById("Ad"+intADS):(document.all("Ad"+intADS)); 
   elemDS.style.backgroundColor="#FFFFC8"
  }
  intADS=0
  intADH=0
 }
}
function ArtistKeyUp(evt){
 var unicode=evt.keyCode? evt.keyCode : evt.charCode
 elemX3A=(isW3C)?document.getElementById("X3A"):(document.all("X3A")); 
 if (unicode==40 || unicode==38){
  if (elemX3A.setSelectionRange){
   elemX3A.setSelectionRange(elemX3A.value.length,elemX3A.value.length)
  }else if (elemX3A.createTextRange){
   var range=elemX3A.createTextRange()
   range.collapse(true)
   range.moveEnd('character',elemX3A.value.length)
   range.moveStart('character',elemX3A.value.length)
   range.select()
  }
  return false
 }else if (unicode==37 || unicode==39){
  return false
 }else if (unicode==34){
  if (elemX3A.value!=''){intAP++;GetArtists('d');GotoArtist();ArtistShowAllSuggest()}
  return false
 }else if (unicode==33){
  if (elemX3A.value!=''){intAP--;GetArtists('d');GotoArtist();ArtistShowAllSuggest()}
  return false
 }
 intAP=1
 Atxt=elemX3A.value
 GetArtists('-')
}
function GetArtists(z){
 var elemA=(isW3C)?document.getElementById("X3A"):(document.all("X3A"));
 elemA.value=Atxt
 if (elemA.value==''){
  ArtistHideSuggest()
  return
 }
 if (intAP==0){
  intAP=1
 }
 if (z=='d' && (intAP-1)*intANR>=intATNR){
  intAP--
 }
 var elemP1=(isW3C)?document.getElementById("Ap1"):(document.all("Ap1"));
 var elemP1a=(isW3C)?document.getElementById("Ap1a"):(document.all("Ap1a"));
 if (elemA.value==''){
  return
 }
 if (window.XMLHttpRequest){
  xmlhttp=new XMLHttpRequest()
 }else{
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
 }
 var zzl=Atxt.length
 var zz=EscapeTotal(Atxt)
 xmlhttp.open("GET","http://www.ebreggae.com/ArtistSuggest.aspx?Q="+zz+"&P="+intAP+"&NR="+intANR,true)
 xmlhttp.onreadystatechange=function(){
  if (xmlhttp.readyState==4 && xmlhttp.status==200){
   for (var ii=1;i<11;i++){
    var elem=(isW3C)?document.getElementById("Ap"+ii):(document.all("Ap"+ii)); 
    elem.firstChild.nodeValue="-"
   }
   strResponse=xmlhttp.responseText
   x=strResponse
   intATNR=0
   intANRTP=0
   if (x.indexOf("@@@")!=-1){
    intATNR=x.substring(x.indexOf("@@@")+3)
    if (intAP*intANR<=intATNR){
     intANRTP=intANR
    }else{
     intANRTP=intATNR-(intAP*intANR)
     if (intANRTP<0){intANRTP=intATNR-(intAP*intANR)}
    }
    x=x.substring(0,x.indexOf("@@@"))
   }
   ArtistHideSuggest()
   if (x.substring(0,2)=="**"){x=x.substring(2)}
   if (x.indexOf("**")==-1){
    if (x.length==0){
     intADM=0
     ArtistShowPages(intATNR,z)
     return
    }else{
     intADM=1
     elemP1.firstChild.nodeValue=x.substring(0,zzl)
     elemP1a.firstChild.nodeValue=x.substring(zzl)
     ArtistShowSuggest(intADM)
     ArtistShowPages(intATNR,z)
     return
    }
   }else{
    intADM=1
    elemP1.firstChild.nodeValue=x.substring(0,zzl)
    elemP1a.firstChild.nodeValue=x.substring(zzl,x.indexOf("**"))
    x=x.substring(x.indexOf("**")+2)
    ArtistShowSuggest(intADM)
   }
   for (var i=2;i<11;i++){
    if (x.substring(0,2)=="**"){x=x.substring(2)}
    intADM+=1
    var elem=(isW3C)?document.getElementById("Ap"+i):(document.all("Ap"+i)); 
    var elema=(isW3C)?document.getElementById("Ap"+i+"a"):(document.all("Ap"+i+"a")); 
    if (x.indexOf("**")==-1){
     elem.firstChild.nodeValue=x.substring(0,zzl)
     elema.firstChild.nodeValue=x.substring(zzl)
     ArtistShowSuggest(intADM)
     ArtistShowPages(intATNR,z)
     return
    }else{
     elem.firstChild.nodeValue=x.substring(0,zzl)
     elema.firstChild.nodeValue=x.substring(zzl,x.indexOf("**"))
     x=x.substring(x.indexOf("**")+2)
     ArtistShowSuggest(intADM)
    }
   }
   if (strResponse.indexOf("@@@@ERROR") ==1){
    ArtistHideSuggest()
   }
  }
 }
 xmlhttp.send(null)
}
function ArtistShowPages(x,z){
 if (x>intANR){
  var elemAdP=(isW3C)?document.getElementById("AdP"):(document.all("AdP"));
  var elemApP=(isW3C)?document.getElementById("ApP"):(document.all("ApP"));
  var elemApT=(isW3C)?document.getElementById("ApT"):(document.all("ApT"));
  elemAdP.style.visibility="visible"
  varTotalPages=parseInt(x/intANR)+1
  varToRec=(x<intAP*intANR)?x:intAP*intANR
  elemApP.firstChild.nodeValue='Page '+intAP+' of '+varTotalPages
  elemApT.firstChild.nodeValue=x+' Suggestions'
  var elemD=(isW3C)?document.getElementById("Adn"):(document.all("Adn"));
  var elemU=(isW3C)?document.getElementById("Aup"):(document.all("Aup"));
 }else{
  elemApP.firstChild.nodeValue=''
 }
 
}
function ArtistHighlightSuggest(x){
 if (intADS!=0){
  var elemDS=(isW3C)?document.getElementById("Ad"+intADS):(document.all("Ad"+intADS)); 
  elemDS.style.backgroundColor="#FFFFC8"
 }
 elemX3A=(isW3C)?document.getElementById("X3A"):(document.all("X3A")); 
 var elem=(isW3C)?document.getElementById("Ap"+x):(document.all("Ap"+x));
 var elema=(isW3C)?document.getElementById("Ap"+x+"a"):(document.all("Ap"+x+"a"));
 var elemDH=(isW3C)?document.getElementById("Ad"+x):(document.all("Ad"+x)); 
 elemDH.style.backgroundColor="#CAC999"
 intADS=x
 elemX3A.value=elem.firstChild.nodeValue+FigureTextNoQuantity(elema.firstChild.nodeValue)
}
function ArtistMouseOverSuggest(x){
 if (intADS!=0){
  var elemDS=(isW3C)?document.getElementById("Ad"+intADS):(document.all("Ad"+intADS)); 
  elemDS.style.backgroundColor="#FFFFC8"
 }
 var elemDH=(isW3C)?document.getElementById("Ad"+x):(document.all("Ad"+x)); 
 elemDH.style.backgroundColor="#CAC999"
 intADS=x
}
function ArtistClickSuggest(x){
 elemX3A=(isW3C)?document.getElementById("X3A"):(document.all("X3A")); 
 var elem=(isW3C)?document.getElementById("Ap"+x):(document.all("Ap"+x));
 var elema=(isW3C)?document.getElementById("Ap"+x+"a"):(document.all("Ap"+x)+"a");
 elemX3A.value=elem.firstChild.nodeValue+FigureTextNoQuantity(elema.firstChild.nodeValue)
 elemX3A.focus()
 if (elemX3A.setSelectionRange){
  elemX3A.setSelectionRange(elemX3A.value.length,elemX3A.value.length)
 }else if (elemX3A.createTextRange){
  var range=elemX3A.createTextRange()
  range.collapse(true)
  range.moveEnd('character',elemX3A.value.length)
  range.moveStart('character',elemX3A.value.length)
  range.select()
 }
}
function ArtistHideSuggest(){
 var elem=(isW3C)?document.getElementById("Adivmain"):(document.all("Adivmain")); 
 var elemTA=(isW3C)?document.getElementById("X3TA"):(document.all("X3TA")); 
 var elemAZ=(isW3C)?document.getElementById("X3AZ"):(document.all("X3AZ")); 
 elem.style.visibility="hidden"
 elemTA.style.visibility="visible"
 elemAZ.style.visibility="visible"
 for (var i=1;i<11;i++){
  var elem=(isW3C)?document.getElementById("Ad"+i):(document.all("Ad"+i)); 
  elem.style.visibility="hidden"
 }
 var elem=(isW3C)?document.getElementById("AdP"):(document.all("AdP")); 
 elem.style.visibility="hidden"
 intADS=0
 intADH=0
}
function ArtistShowAllSuggest(){
 var elem=(isW3C)?document.getElementById("Adivmain"):(document.all("Adivmain")); 
 var elemTA=(isW3C)?document.getElementById("X3TA"):(document.all("X3TA")); 
 var elemAZ=(isW3C)?document.getElementById("X3AZ"):(document.all("X3AZ")); 
 elem.style.visibility="visible"
 elemTA.style.visibility="hidden"
 elemAZ.style.visibility="hidden"
 for (var i=1;i<=intANRTP;i++){
  var elem=(isW3C)?document.getElementById("Ad"+i):(document.all("Ad"+i)); 
  elem.style.visibility="visible"
 }
 var elem=(isW3C)?document.getElementById("AdP"):(document.all("AdP")); 
 elem.style.visibility="visible"
}
function ArtistShowSuggest(x){
 var elem=(isW3C)?document.getElementById("Adivmain"):(document.all("Adivmain")); 
 var elemTA=(isW3C)?document.getElementById("X3TA"):(document.all("X3TA")); 
 var elemAZ=(isW3C)?document.getElementById("X3AZ"):(document.all("X3AZ")); 
 elem.style.visibility="visible"
 elemTA.style.visibility="hidden"
 elemAZ.style.visibility="hidden"
 elem.style.height=x*20
 var elem=(isW3C)?document.getElementById("Ad"+x):(document.all("Ad"+x)); 
 elem.style.visibility="visible"
}

//Label
function GotoLabel(){
 elemX3L=(isW3C)?document.getElementById("X3L"):(document.all("X3L")); 
 elemX3L.focus()
 if (elemX3L.setSelectionRange){
  if (intLSelectAll==1){
   elemX3L.setSelectionRange(0,elemX3L.value.length)
   intLSelectAll=0
  }
 }else if (elemX3L.createTextRange){
  if (intLSelectAll==1){
   var range=elemX3L.createTextRange()
   range.collapse(true)
   range.moveEnd('character',elemX3L.value.length)
   range.moveStart('character',0)
   range.select()
   intLSelectAll=0
  }
 }
}
function LabelOnBlur(){
 LabelHideSuggest()
}
function LabelMouseOutSuggest(x){
 var elemDS=(isW3C)?document.getElementById("Ld"+intLDS):(document.all("Ld"+intLDS)); 
 elemDS.style.backgroundColor="#FFFFC8"
 intLDS=0
}
function LabelKeyDown(evt){
 var unicode=evt.keyCode? evt.keyCode : evt.charCode
 if (intLDS!=0){
  var elemDS=(isW3C)?document.getElementById("Ld"+intLDS):(document.all("Ld"+intLDS)); 
  elemDS.style.backgroundColor="#FFFFC8"
  intLDS=0
 }
 if (unicode==40){
  if (intLDM!=0){
   if (intLDS!=0){
    var elemDS=(isW3C)?document.getElementById("Ld"+intLDS):(document.all("Ld"+intLDS)); 
    elemDS.style.backgroundColor="#FFFFC8"
   }
   intLDH+=1
   if (intLDH>intLDM){intLDH=1}
   LabelHighlightSuggest(intLDH)
   return
  }else{
   return
  }
 }else if(unicode==38){
  if (intLDM!=0){
   if (intLDS!=0){
    var elemDS=(isW3C)?document.getElementById("Ld"+intLDS):(document.all("Ld"+intLDS)); 
    elemDS.style.backgroundColor="#FFFFC8"
   }
   intLDH--
   if (intLDH<1){intLDH=intLDM}
   LabelHighlightSuggest(intLDH)
   return
  }else{
   return
  }
 }else if (unicode==13){
  return
 }else{
  if (intLDS!=0){
   var elemDS=(isW3C)?document.getElementById("Ld"+intLDS):(document.all("Ld"+intLDS)); 
   elemDS.style.backgroundColor="#FFFFC8"
  }
  intLDS=0
  intLDH=0
 }
}
function LabelKeyUp(evt){
 var unicode=evt.keyCode? evt.keyCode : evt.charCode
 elemX3L=(isW3C)?document.getElementById("X3L"):(document.all("X3L")); 
 if (unicode==40 || unicode==38){
  if (elemX3L.setSelectionRange){
   elemX3L.setSelectionRange(elemX3L.value.length,elemX3L.value.length)
  }else if (elemX3L.createTextRange){
   var range=elemX3L.createTextRange()
   range.collapse(true)
   range.moveEnd('character',elemX3L.value.length)
   range.moveStart('character',elemX3L.value.length)
   range.select()
  }
  return false
 }else if (unicode==37 || unicode==39){
  return false
 }else if (unicode==34){
  if (elemX3L.value!=''){intLP++;GetLabels('d');GotoLabel();LabelShowAllSuggest()}
  return false
 }else if (unicode==33){
  if (elemX3L.value!=''){intLP--;GetLabels('d');GotoLabel();LabelShowAllSuggest()}
  return false
 }else if (unicode==13){
  return
 }
 intLP=1
 Ltxt=elemX3L.value
 GetLabels('-')
}
function GetLabels(z){
 var elemA=(isW3C)?document.getElementById("X3L"):(document.all("X3L"));
 elemA.value=Ltxt
 if (elemA.value==''){
  LabelHideSuggest()
  return
 }
 if (intLP==0){
  intLP=1
 }
 if (z=='d' && (intLP-1)*intLNR>=intLTNR){
  intLP--
 }
 var elemP1=(isW3C)?document.getElementById("Lp1"):(document.all("Lp1"));
 var elemP1a=(isW3C)?document.getElementById("Lp1a"):(document.all("Lp1a"));
 if (elemA.value==''){
  return
 }
 if (window.XMLHttpRequest){
  xmlhttp=new XMLHttpRequest()
 }else{
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
 }
 LNE()

 var zzl=Ltxt.length
 var zz=EscapeTotal(Ltxt)
 xmlhttp.open("GET","http://www.ebreggae.com/LabelSuggest.aspx?Q="+zz+"&P="+intLP+"&NR="+intLNR,true)
 xmlhttp.onreadystatechange=function(){
  if (xmlhttp.readyState==4 && xmlhttp.status==200){
   for (var ii=1;i<11;i++){
    var elem=(isW3C)?document.getElementById("Lp"+ii):(document.all("Lp"+ii)); 
    elem.firstChild.nodeValue="-"
   }
   strResponse=xmlhttp.responseText
   x=strResponse
   intLTNR=0
   intLNRTP=0
   if (x.indexOf("@@@")!=-1){
    intLTNR=x.substring(x.indexOf("@@@")+3)
    if (intLP*intLNR<=intLTNR){
     intLNRTP=intLNR
    }else{
     intLNRTP=intLTNR-(intLP*intLNR)
     if (intLNRTP<0){intLNRTP=intLTNR-(intLP*intLNR)}
    }
    x=x.substring(0,x.indexOf("@@@"))
   }
   LabelHideSuggest()
   if (x.substring(0,2)=="**"){x=x.substring(2)}
   if (x.indexOf("**")==-1){
    if (x.length==0){
     intLDM=0
     LabelShowPages(intLTNR,z)
     return
    }else{
     intLDM=1
     elemP1.firstChild.nodeValue=x.substring(0,zzl)
     elemP1a.firstChild.nodeValue=x.substring(zzl)
     LabelShowSuggest(intLDM)
     LabelShowPages(intLTNR,z)
     return
    }
   }else{
    intLDM=1
    elemP1.firstChild.nodeValue=x.substring(0,zzl)
    elemP1a.firstChild.nodeValue=x.substring(zzl,x.indexOf("**"))
    x=x.substring(x.indexOf("**")+2)
    LabelShowSuggest(intLDM)
   }
   for (var i=2;i<11;i++){
    if (x.substring(0,2)=="**"){x=x.substring(2)}
    intLDM+=1
    var elem=(isW3C)?document.getElementById("Lp"+i):(document.all("Lp"+i)); 
    var elema=(isW3C)?document.getElementById("Lp"+i+"a"):(document.all("Lp"+i+"a")); 
    if (x.indexOf("**")==-1){
     elem.firstChild.nodeValue=x.substring(0,zzl)
     elema.firstChild.nodeValue=x.substring(zzl)
     LabelShowSuggest(intLDM)
     LabelShowPages(intLTNR,z)
     return
    }else{
     elem.firstChild.nodeValue=x.substring(0,zzl)
     elema.firstChild.nodeValue=x.substring(zzl,x.indexOf("**"))
     x=x.substring(x.indexOf("**")+2)
     LabelShowSuggest(intLDM)
    }
   }
   if (strResponse.indexOf("@@@@ERROR") ==1){
    alert("error")
   }
  }
 }
 xmlhttp.send(null)
}
function LabelShowPages(x,z){
 if (x>intLNR){
  var elemAdP=(isW3C)?document.getElementById("LdP"):(document.all("LdP"));
  var elemApP=(isW3C)?document.getElementById("LpP"):(document.all("LpP"));
  var elemApT=(isW3C)?document.getElementById("LpT"):(document.all("LpT"));
  elemAdP.style.visibility="visible"
  varTotalPages=parseInt(x/intLNR)+1
  varToRec=(x<intLP*intLNR)?x:intLP*intLNR
  elemApP.firstChild.nodeValue='Page '+intLP+' of '+varTotalPages
  elemApT.firstChild.nodeValue=x+' Suggestions'
  var elemD=(isW3C)?document.getElementById("Ldn"):(document.all("Ldn"));
  var elemU=(isW3C)?document.getElementById("Lup"):(document.all("Lup"));
 }else{
  elemApP.firstChild.nodeValue=''
 }
 
}
function LabelHighlightSuggest(x){
 if (intLDS!=0){
  var elemDS=(isW3C)?document.getElementById("Ld"+intLDS):(document.all("Ld"+intLDS)); 
  elemDS.style.backgroundColor="#FFFFC8"
 }
 elemX3L=(isW3C)?document.getElementById("X3L"):(document.all("X3L")); 
 var elem=(isW3C)?document.getElementById("Lp"+x):(document.all("Lp"+x));
 var elema=(isW3C)?document.getElementById("Lp"+x+"a"):(document.all("Lp"+x+"a"));
 var elemDH=(isW3C)?document.getElementById("Ld"+x):(document.all("Ld"+x)); 
 elemDH.style.backgroundColor="#CAC999"
 intLDS=x
 elemX3L.value=elem.firstChild.nodeValue+FigureTextNoQuantity(elema.firstChild.nodeValue)
 LE()
}
function LabelMouseOverSuggest(x){
 if (intLDS!=0){
  var elemDS=(isW3C)?document.getElementById("Ld"+intLDS):(document.all("Ld"+intLDS)); 
  elemDS.style.backgroundColor="#FFFFC8"
 }
 var elemDH=(isW3C)?document.getElementById("Ld"+x):(document.all("Ld"+x)); 
 elemDH.style.backgroundColor="#CAC999"
 intLDS=x
}
function LabelClickSuggest(x){
 elemX3L=(isW3C)?document.getElementById("X3L"):(document.all("X3L")); 
 var elem=(isW3C)?document.getElementById("Lp"+x):(document.all("Lp"+x));
 var elema=(isW3C)?document.getElementById("Lp"+x+"a"):(document.all("Lp"+x)+"a");
 elemX3L.value=elem.firstChild.nodeValue+FigureTextNoQuantity(elema.firstChild.nodeValue)
 LE()
 elemX3L.focus()
 if (elemX3L.setSelectionRange){
  elemX3L.setSelectionRange(elemX3L.value.length,elemX3L.value.length)
 }else if (elemX3L.createTextRange){
  var range=elemX3L.createTextRange()
  range.collapse(true)
  range.moveEnd('character',elemX3L.value.length)
  range.moveStart('character',elemX3L.value.length)
  range.select()
 }
}
function LabelHideSuggest(){
 var elem=(isW3C)?document.getElementById("Ldivmain"):(document.all("Ldivmain")); 
 var elemTL=(isW3C)?document.getElementById("X3TL"):(document.all("X3TL")); 
 elem.style.visibility="hidden"
 elemTL.style.visibility="visible"
 for (var i=1;i<11;i++){
  var elem=(isW3C)?document.getElementById("Ld"+i):(document.all("Ld"+i)); 
  elem.style.visibility="hidden"
 }
 var elem=(isW3C)?document.getElementById("LdP"):(document.all("LdP")); 
 elem.style.visibility="hidden"
 intLDS=0
 intLDH=0
}
function LabelShowAllSuggest(){
 var elem=(isW3C)?document.getElementById("Ldivmain"):(document.all("Ldivmain")); 
 var elemTL=(isW3C)?document.getElementById("X3TL"):(document.all("X3TL")); 
 elem.style.visibility="visible"
 elemTL.style.visibility="hidden"
 for (var i=1;i<=intLNRTP;i++){
  var elem=(isW3C)?document.getElementById("Ld"+i):(document.all("Ld"+i)); 
  elem.style.visibility="visible"
 }
 var elem=(isW3C)?document.getElementById("LdP"):(document.all("LdP")); 
 elem.style.visibility="visible"
}
function LabelShowSuggest(x){
 var elem=(isW3C)?document.getElementById("Ldivmain"):(document.all("Ldivmain")); 
 var elemTL=(isW3C)?document.getElementById("X3TL"):(document.all("X3TL")); 
 elem.style.visibility="visible"
 elemTL.style.visibility="hidden"
 elem.style.height=x*20
 var elem=(isW3C)?document.getElementById("Ld"+x):(document.all("Ld"+x)); 
 elem.style.visibility="visible"
}

//Rhythm
function GotoRhythm(){
 elemX3R=(isW3C)?document.getElementById("X3RY"):(document.all("X3RY")); 
 elemX3R.focus()
 if (elemX3R.setSelectionRange){
  if (intRSelectAll==1){
   elemX3R.setSelectionRange(0,elemX3R.value.length)
   intRSelectAll=0
  }
 }else if (elemX3R.createTextRange){
  if (intRSelectAll==1){
   var range=elemX3R.createTextRange()
   range.collapse(true)
   range.moveEnd('character',elemX3R.value.length)
   range.moveStart('character',0)
   range.select()
   intRSelectAll=0
  }
 }
}
function RhythmOnBlur(){
 RhythmHideSuggest()
}
function RhythmMouseOutSuggest(x){
 var elemDS=(isW3C)?document.getElementById("Rd"+intRDS):(document.all("Rd"+intRDS)); 
 elemDS.style.backgroundColor="#FFFFC8"
 intRDS=0
}
function RhythmKeyDown(evt){
 var unicode=evt.keyCode? evt.keyCode : evt.charCode
 if (intRDS!=0){
  var elemDS=(isW3C)?document.getElementById("Rd"+intRDS):(document.all("Rd"+intRDS)); 
  elemDS.style.backgroundColor="#FFFFC8"
  intRDS=0
 }
 if (unicode==40){
  if (intRDM!=0){
   if (intRDS!=0){
    var elemDS=(isW3C)?document.getElementById("Rd"+intRDS):(document.all("Rd"+intRDS)); 
    elemDS.style.backgroundColor="#FFFFC8"
   }
   intRDH+=1
   if (intRDH>intRDM){intRDH=1}
   RhythmHighlightSuggest(intRDH)
   return
  }else{
   return
  }
 }else if(unicode==38){
  if (intRDM!=0){
   if (intRDS!=0){
    var elemDS=(isW3C)?document.getElementById("Rd"+intRDS):(document.all("Rd"+intRDS)); 
    elemDS.style.backgroundColor="#FFFFC8"
   }
   intRDH--
   if (intRDH<1){intRDH=intRDM}
   RhythmHighlightSuggest(intRDH)
   return
  }else{
   return
  }
 }else if (unicode==13){
  return
 }else{
  if (intRDS!=0){
   var elemDS=(isW3C)?document.getElementById("Rd"+intRDS):(document.all("Rd"+intRDS)); 
   elemDS.style.backgroundColor="#FFFFC8"
  }
  intRDS=0
  intRDH=0
 }
}
function RhythmKeyUp(evt){
 var unicode=evt.keyCode? evt.keyCode : evt.charCode
 elemX3RY=(isW3C)?document.getElementById("X3RY"):(document.all("X3RY")); 
 if (unicode==40 || unicode==38){
  if (elemX3RY.setSelectionRange){
   elemX3RY.setSelectionRange(elemX3RY.value.length,elemX3RY.value.length)
  }else if (elemX3RY.createTextRange){
   var range=elemX3RY.createTextRange()
   range.collapse(true)
   range.moveEnd('character',elemX3RY.value.length)
   range.moveStart('character',elemX3RY.value.length)
   range.select()
  }
  return false
 }else if (unicode==37 || unicode==39){
  return false
 }else if (unicode==34){
  if (elemX3RY.value!=''){intRP++;GetRhythms('d');GotoRhythm();RhythmShowAllSuggest()}
  return false
 }else if (unicode==33){
  if (elemX3RY.value!=''){intRP--;GetRhythms('d');GotoRhythm();RhythmShowAllSuggest()}
  return false
 }else if (unicode==13){
  return
 }
 intRP=1
 Rtxt=elemX3RY.value
 GetRhythms('-')
}
function GetRhythms(z){
 var elemA=(isW3C)?document.getElementById("X3RY"):(document.all("X3RY"));
 elemA.value=Rtxt
 if (elemA.value==''){
  RhythmHideSuggest()
  return
 }
 if (intRP==0){
  intRP=1
 }
 if (z=='d' && (intRP-1)*intRNR>=intRTNR){
  intRP--
 }
 var elemP1=(isW3C)?document.getElementById("Rp1"):(document.all("Rp1"));
 var elemP1a=(isW3C)?document.getElementById("Rp1a"):(document.all("Rp1a"));
 if (elemA.value==''){
  return
 }
 if (window.XMLHttpRequest){
  xmlhttp=new XMLHttpRequest()
 }else{
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
 }
 RNE()
 var zzl=Rtxt.length
 var zz=EscapeTotal(Rtxt)
 xmlhttp.open("GET","http://www.ebreggae.com/RhythmSuggest.aspx?Q="+zz+"&P="+intRP+"&NR="+intRNR,true)
 xmlhttp.onreadystatechange=function(){
  if (xmlhttp.readyState==4 && xmlhttp.status==200){
   for (var ii=1;i<11;i++){
    var elem=(isW3C)?document.getElementById("Rp"+ii):(document.all("Rp"+ii)); 
    elem.firstChild.nodeValue="-"
   }
   strResponse=xmlhttp.responseText
   x=strResponse
   intRTNR=0
   intRNRTP=0
   if (x.indexOf("@@@")!=-1){
    intRTNR=x.substring(x.indexOf("@@@")+3)
    if (intRP*intRNR<=intRTNR){
     intRNRTP=intRNR
    }else{
     intRNRTP=intRTNR-(intRP*intRNR)
     if (intRNRTP<0){intRNRTP=intRTNR-(intRP*intRNR)}
    }
    x=x.substring(0,x.indexOf("@@@"))
   }
   RhythmHideSuggest()
   if (x.substring(0,2)=="**"){x=x.substring(2)}
   if (x.indexOf("**")==-1){
    if (x.length==0){
     intRDM=0
     RhythmShowPages(intRTNR,z)
     return
    }else{
     intRDM=1
     elemP1.firstChild.nodeValue=x.substring(0,zzl)
     elemP1a.firstChild.nodeValue=x.substring(zzl)
     RhythmShowSuggest(intRDM)
     RhythmShowPages(intRTNR,z)
     return
    }
   }else{
    intRDM=1
    elemP1.firstChild.nodeValue=x.substring(0,zzl)
    elemP1a.firstChild.nodeValue=x.substring(zzl,x.indexOf("**"))
    x=x.substring(x.indexOf("**")+2)
    RhythmShowSuggest(intRDM)
   }
   for (var i=2;i<11;i++){
    if (x.substring(0,2)=="**"){x=x.substring(2)}
    intRDM+=1
    var elem=(isW3C)?document.getElementById("Rp"+i):(document.all("Rp"+i)); 
    var elema=(isW3C)?document.getElementById("Rp"+i+"a"):(document.all("Rp"+i+"a")); 
    if (x.indexOf("**")==-1){
     elem.firstChild.nodeValue=x.substring(0,zzl)
     elema.firstChild.nodeValue=x.substring(zzl)
     RhythmShowSuggest(intRDM)
     RhythmShowPages(intRTNR,z)
     return
    }else{
     elem.firstChild.nodeValue=x.substring(0,zzl)
     elema.firstChild.nodeValue=x.substring(zzl,x.indexOf("**"))
     x=x.substring(x.indexOf("**")+2)
     RhythmShowSuggest(intRDM)
    }
   }
   if (strResponse.indexOf("@@@@ERROR") ==1){
    alert("error")
   }
  }
 }
 xmlhttp.send(null)
}
function RhythmShowPages(x,z){
 if (x>intRNR){
  var elemAdP=(isW3C)?document.getElementById("RdP"):(document.all("RdP"));
  var elemApP=(isW3C)?document.getElementById("RpP"):(document.all("RpP"));
  var elemApT=(isW3C)?document.getElementById("RpT"):(document.all("RpT"));
  elemAdP.style.visibility="visible"
  varTotalPages=parseInt(x/intRNR)+1
  varToRec=(x<intRP*intRNR)?x:intRP*intRNR
  elemApP.firstChild.nodeValue='Page '+intRP+' of '+varTotalPages
  elemApT.firstChild.nodeValue=x+' Suggestions'
  var elemD=(isW3C)?document.getElementById("Rdn"):(document.all("Rdn"));
  var elemU=(isW3C)?document.getElementById("Rup"):(document.all("Rup"));
 }else{
  elemApP.firstChild.nodeValue=''
 }
 
}
function RhythmHighlightSuggest(x){
 if (intRDS!=0){
  var elemDS=(isW3C)?document.getElementById("Rd"+intRDS):(document.all("Rd"+intRDS)); 
  elemDS.style.backgroundColor="#FFFFC8"
 }
 elemX3RY=(isW3C)?document.getElementById("X3RY"):(document.all("X3RY")); 
 var elem=(isW3C)?document.getElementById("Rp"+x):(document.all("Rp"+x));
 var elema=(isW3C)?document.getElementById("Rp"+x+"a"):(document.all("Rp"+x+"a"));
 var elemDH=(isW3C)?document.getElementById("Rd"+x):(document.all("Rd"+x)); 
 elemDH.style.backgroundColor="#CAC999"
 intRDS=x
 elemX3RY.value=elem.firstChild.nodeValue+FigureTextNoQuantity(elema.firstChild.nodeValue)
 RE()
}
function RhythmMouseOverSuggest(x){
 if (intRDS!=0){
  var elemDS=(isW3C)?document.getElementById("Rd"+intRDS):(document.all("Rd"+intRDS)); 
  elemDS.style.backgroundColor="#FFFFC8"
 }
 var elemDH=(isW3C)?document.getElementById("Rd"+x):(document.all("Rd"+x)); 
 elemDH.style.backgroundColor="#CAC999"
 intRDS=x
}
function RhythmClickSuggest(x){
 elemX3RY=(isW3C)?document.getElementById("X3RY"):(document.all("X3RY")); 
 var elem=(isW3C)?document.getElementById("Rp"+x):(document.all("Rp"+x));
 var elema=(isW3C)?document.getElementById("Rp"+x+"a"):(document.all("Rp"+x)+"a");
 elemX3RY.value=elem.firstChild.nodeValue+FigureTextNoQuantity(elema.firstChild.nodeValue)
 RE()
 elemX3RY.focus()
 if (elemX3RY.setSelectionRange){
  elemX3RY.setSelectionRange(elemX3RY.value.length,elemX3RY.value.length)
 }else if (elemX3RY.createTextRange){
  var range=elemX3RY.createTextRange()
  range.collapse(true)
  range.moveEnd('character',elemX3RY.value.length)
  range.moveStart('character',elemX3RY.value.length)
  range.select()
 }
}
function RhythmHideSuggest(){
 var elem=(isW3C)?document.getElementById("Rdivmain"):(document.all("Rdivmain")); 
 var elemLR=(isW3C)?document.getElementById("X3LR"):(document.all("X3LR")); 
 var elemTL=(isW3C)?document.getElementById("X3TL"):(document.all("X3TL")); 
 elem.style.visibility="hidden"
 elemLR.style.visibility="visible"
 elemTL.style.visibility="visible"
 for (var i=1;i<11;i++){
  var elem=(isW3C)?document.getElementById("Rd"+i):(document.all("Rd"+i)); 
  elem.style.visibility="hidden"
 }
 var elem=(isW3C)?document.getElementById("RdP"):(document.all("RdP")); 
 elem.style.visibility="hidden"
 intRDS=0
 intRDH=0
}
function RhythmShowAllSuggest(){
 var elem=(isW3C)?document.getElementById("Rdivmain"):(document.all("Rdivmain")); 
 var elemLR=(isW3C)?document.getElementById("X3LR"):(document.all("X3LR")); 
 var elemTL=(isW3C)?document.getElementById("X3TL"):(document.all("X3TL")); 
 elem.style.visibility="visible"
 elemLR.style.visibility="hidden"
 elemTL.style.visibility="hidden"
 for (var i=1;i<=intRNRTP;i++){
  var elem=(isW3C)?document.getElementById("Rd"+i):(document.all("Rd"+i)); 
  elem.style.visibility="visible"
 }
 var elem=(isW3C)?document.getElementById("RdP"):(document.all("RdP")); 
 elem.style.visibility="visible"
}
function RhythmShowSuggest(x){
 var elem=(isW3C)?document.getElementById("Rdivmain"):(document.all("Rdivmain")); 
 var elemLR=(isW3C)?document.getElementById("X3LR"):(document.all("X3LR")); 
 var elemTL=(isW3C)?document.getElementById("X3TL"):(document.all("X3TL")); 
 elem.style.visibility="visible"
 elemLR.style.visibility="hidden"
 elemTL.style.visibility="hidden"
 elem.style.height=x*20
 var elem=(isW3C)?document.getElementById("Rd"+x):(document.all("Rd"+x)); 
 elem.style.visibility="visible"
}

