//Module JS Functions

function editModuleSettings( moduleID )
    { 
        d = document.getElementById("ScratchPad");
        
        d.style.width='400px';
        setInner('Loading....');
        
        if(xmlhttp)
        {
            xmlhttpdo("/php/jsrpc.php?function=modPrefForm&mid=" + moduleID);
        }
        else
        {
            jsrsdo("modPrefForm", Array("'" + moduleID + "'"))
        }
        
        showElementPositioned('ScratchPad', -420, -200);
    }

    function saveModPref(modForm)
    {
        var moduleID = modForm.mid.value;
        var selectedModule = getSelectedRadio(modForm.moduleName);
        var modulename = modForm.moduleName[selectedModule].value;
        
        d = document.getElementById("module" + moduleID);
        
        if(xmlhttp)
        {
            xmlhttpdo("/php/jsrpc.php?function=saveModPref&modIdx=" + moduleID + "&mod=" + modulename);
        }
        else
        {
            jsrsdo("saveModPref", Array(modulename,moduleID))
        }
        
        hideElement('ScratchPad');
    }
    
        // returns the array number of the selected radio button or -1 if no button is selected
    
function displayPrefs()
{
    basicRPCForm('displayPrefForm', 200, -200, 0);
}    
function platformNewsForm(plat)
{
    d = document.getElementById("ScratchPad");
    
    d.style.width='400px';
    setInner('Loading....');
    
    if(xmlhttp)
    {
        xmlhttpdo("/php/jsrpc.php?function=platformNewsForm&platform=" + plat);
    }
    else
    {
        jsrsdo("platformNewsForm", Array("'" + plat + "'"))
    }
    
    showElementPositioned('ScratchPad', -420, -200);
}


function savePlatformNews(newsForm)
{
    d = document.getElementById('ScratchPad');
   // hideElement('ScratchPad');
    
    var platform = newsForm.platform.value;
    var title1 = newsForm.title1.value;
    var url1 = newsForm.url1.value;
    var title2 = newsForm.title2.value;
    var url2 = newsForm.url2.value;
    var title3 = newsForm.title3.value;
    var url3 = newsForm.url3.value;
    var title4 = newsForm.title4.value;
    var url4 = newsForm.url4.value;
    var title5 = newsForm.title5.value;
    var url5 = newsForm.url5.value;
    
	if(xmlhttp)
    {
       xmlhttpdo("/php/jsrpc.php?function=savePlatformNews&platform=" + platform
            + "&title1=" + title1
            + "&title2=" + title2
            + "&title3=" + title3
            + "&title4=" + title4
            + "&title5=" + title5
            + "&url1=" + URLencode(url1)
            + "&url2=" + URLencode(url2)
            + "&url3=" + URLencode(url3)
            + "&url4=" + URLencode(url4)
            + "&url5=" + URLencode(url5));
    }
    else
    {
        jsrsdo("savePlatformNews", Array(platform, title1, url1, title2, url2, title3, url3, title4, url4, title5, url5));
    }
    
  
}

function saveDisplayPref(prefForm)
{
	var Theme = prefForm.Theme[getSelectedRadio(prefForm.Theme)].value;
	var UpdateTable = 'updateTable';
	if(canChangeUpdatesTable == 1 )
	{
		UpdateTable = prefForm.UpdateTable[getSelectedRadio(prefForm.UpdateTable)].value;
	}
	
	//d = document.getElementById('updatesTable');
	d = document.getElementById('ScratchPad');
	hideElement('ScratchPad');
	if(xmlhttp)
	{
		xmlhttpdo("/php/jsrpc.php?function=saveDisplayPref&theme=" + Theme + "&updateTable=" + UpdateTable + "&platform=" + CurrentPlatform);
	}
	else
	{
		jsrsdo("saveDisplayPref", Array(Theme, UpdateTable, CurrentPlatform))
	}
	
	window.location.reload();
}

function saveThemePref(Theme)
{
    d = document.getElementById('ScratchPad');
    hideElement('ScratchPad');
	if(xmlhttp)
    {
       xmlhttpdo("/php/jsrpc.php?function=saveThemePref&theme=" + Theme);
    }
    else
    {
        jsrsdo("saveThemePref", Array(Theme))
    }
    
    setActiveStyleSheet(Theme)
}
