function changeDemo ()
{
var img = window.document.getElementById("reward").value;

if (img !=='---')
{
document.getElementById("reward_demo").style.display = "block";
document.getElementById("reward_img").src = "/uploads/medals/"+img;
} else {
document.getElementById("reward_demo").style.display = "none";
}
}

function AutoTranslit1()
    {        
        a=document.formText.alt_cat_name.value;
        document.formText.alt_cat_name.value=raytranslate(a);
    }
    
    function AutoTranslit2()
    {        
        a=document.formText.cat_name.value;
        document.formText.alt_cat_name.value=raytranslate(a);
    }
    
    var cyr=new Array("jo","zh","i","ch","sh","xh","je","ju","ja","a","b","v","g","d","e","z","i","k","l","m","n","o","p","r","s","t","u","f","x","c","b","y","b","j","h","-", "", "", "");
    var lat=new Array("¸","æ","é","÷","ø","ù","ý","þ","ÿ","à","á","â","ã","ä","å","ç","è","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ü","û","ú","æ","õ", " ", "/", "|", "");
    var latcap=new Array("¨","Æ","É","×","Ø","Ù","Ý","Þ","ß","À","Á","Â","Ã","Ä","Å","Ç","È","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","Ü","Û","Ú","Æ","Õ", " ", "/", "|", "");

    function raytranslate(tex)
    {
    var buf=tex;
    var i;
    for (i=0;i<latcap.length;i++)
            {
            buf=trreplace(buf,latcap[i],cyr[i],1,0);
            }

    for (i=0;i<lat.length;i++)
            {
            buf=trreplace(buf,lat[i],cyr[i],1,0);
            }

    tex=buf;
    return tex;
    }

    function trreplace(target,oldTerm,newTerm,caseSens,wordOnly) {

            var work = target;
            var ind = 0;
            var next = 0;

            if (!caseSens) {
              oldTerm = oldTerm.toLowerCase();
              work = target.toLowerCase();
            }

            while ((ind = work.indexOf(oldTerm,next)) >= 0) {
              if (wordOnly) {
                var before = ind - 1;
                var after = ind + oldTerm.length;
                if (!(space(work.charAt(before)) && space(work.charAt(after)))) {
                  next = ind + oldTerm.length;
                  continue;
                }
              }
              target = target.substring(0,ind) + newTerm +
              target.substring(ind+oldTerm.length,target.length);
              work = work.substring(0,ind) + newTerm +
              work.substring(ind+oldTerm.length,work.length);
              next = ind + newTerm.length;
              if (next >= work.length) { break; }
            }

            return target;

    }

    function Help(section) {
      q=window.open('?mod=help&section='+section, 'Help', 'scrollbars=1,resizable=1,width=450,height=400');
    }
    function ShowOrHide(d1, d2) {
      if (d1 != '') DoDiv(d1);
      if (d2 != '') DoDiv(d2);
    }
    function DoDiv(id) {
      var item = null;
      if (document.getElementById) {
        item = document.getElementById(id);
      } else if (document.all){
        item = document.all[id];
      } else if (document.layers){
        item = document.layers[id];
      }
      if (!item) {
      }
      else if (item.style) {
        if (item.style.display == "none"){ item.style.display = ""; }
        else {item.style.display = "none"; }
      }else{ item.visibility = "show"; }
     }

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox
