function showAPopUp(ItemId) {
    if (document.getElementById)
    {
        if (document.getElementById(ItemId).style.visibility == 'hidden')// Show
        {
            document.getElementById(ItemId).style.visibility = 'visible';
            document.getElementById(ItemId).style.display = 'block';
                        //document.getElementById(ItemId).style.background =  "#0EA2E0";
            document.getElementById(ItemId).innerHTML = document.getElementById(ItemId).innerHTML;
        }
        else// Hide
        {
            document.getElementById(ItemId).style.visibility = 'hidden';
            document.getElementById(ItemId).style.display = 'none';
            document.getElementById(ItemId).innerHTML = document.getElementById(ItemId).innerHTML;
        }
    }
        return false;
}
function hide_show(id){
    if(document.getElementById(id)){
        var it = document.getElementById(id);
    }
   if(it.style.visibility != 'hidden'){
        it.style.display = 'none';
        it.style.visibility = 'hidden';
   }else{
        it.style.display = 'block';
        it.style.visibility = 'visible';
   }
   adjust();
}

function add_to_call(id){
    //alert(id);
    //Effect.BlindUp('race_' + id);
    Effect.Squish('race_' + id);
    GETitforme('?add_this_race='+id);
}

function rem_from_call(id){
    Effect.Squish('pc_race_' + id);
    GETitforme('?rem_this_race=' + id);
}



function GETitforme(gstring){
    loadXMLDoc('/inc/ryr_data.inc.php'+gstring);
}

//ajax functions START __________
var xmlhttp;
function loadXMLDoc(url){
    if (window.XMLHttpRequest){// code for Mozilla, etc.
    xmlhttp=new XMLHttpRequest();
    xmlhttp.onreadystatechange=xmlhttpChange;
    //alert(url);
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
    }else if (window.ActiveXObject){// code for IE
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlhttp){
            xmlhttp.onreadystatechange=xmlhttpChange;
            xmlhttp.open("GET",url,true);
            xmlhttp.send(null);
        }
    }
}
function postXMLDoc(url,formname){
    if (window.XMLHttpRequest){// code for Mozilla, etc.
    xmlhttp=new XMLHttpRequest();
        if (xmlhttp){
            var fields = new Array();
            if(formname){
                var ajax = formname;
            }
            //loop through form elements and retrieve field NAMEs and Values
            for (var x = 0; x < eval("document."+ajax+".elements.length"); x++){
                // join them into a string.
                eval("fields.push(document."+ajax+".elements[x].name+'='+document."+ajax+".elements[x].value)");
            }
            elem = 'errors';
            //sendf looks like "username=myusername&password=mypass"
            var sendf = fields.join('&');
            
            
            xmlhttp.open("POST", url, true);
            xmlhttp.onreadystatechange=xmlhttpChange;
            xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//          xmlhttp.setRequestHeader('Content-Type', 'multipart/form-data');
            xmlhttp.send(sendf);                
        }
    }else if (window.ActiveXObject){// code for IE
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlhttp){
            var fields = new Array();
            if(formname){
                var ajax = formname;
            }
            //loop through form elements and retrieve field NAMEs and Values
            for (var x = 0; x < eval("document."+ajax+".elements.length"); x++){
                // join them into a string.
                eval("fields.push(document."+ajax+".elements[x].name+'='+document."+ajax+".elements[x].value)");
            }
            elem = 'errors';
            //sendf looks like "username=myusername&password=mypass"
            var sendf = fields.join('&');
            
            
            xmlhttp.open("POST", url, true);
            xmlhttp.onreadystatechange=xmlhttpChange;
            xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//          xmlhttp.setRequestHeader('Content-Type', 'multipart/x-www-form-urlencoded');

            
            xmlhttp.send(sendf);                
        }
    }
}   
function xmlhttpChange(){
    //alert(xmlhttp.status);
    if (xmlhttp.readyState==4){// if xmlhttp shows "loaded"
        if (xmlhttp.status==200){// if "OK"
            //alert(xmlhttp.responseText);          
            //eval(xmlhttp.responseText);
            var temp = new Array();
            temp = xmlhttp.responseText.split('|');
            //alert('wilma-inner');
            //alert(temp[0]);
            
            if(temp[1]){
                //document.getElementById(temp[0]).innerHTML= temp[1];
                document.getElementById('wilma-inner').innerHTML= temp[1];
            }
            if(temp[2]){                
                eval(temp[2]);
            }
        }else{
            alert("Problem retrieving data")
        }
    }
}   
    
//ajax functions END __________

//open new window from form function
function open_new_location(url){
	window.open(url,'opened from RW SA','');
}
function openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
}
//end of open new window from form function

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 adjust(){
    if(document.getElementById('right-col')){
        var left_coll = document.getElementById('content').scrollHeight;
        var right_coll = document.getElementById('right-col').scrollHeight;
        
        if(left_coll > right_coll){
            document.getElementById('right-col').style.height = left_coll + "px";
        }
        if(left_coll < right_coll){
            document.getElementById('content').style.height = right_coll + "px";
        }
    }
}
