/*


function saveUserProperties()
{
    new Ajax.Updater('myOverlay', site_root+'/users/save/', {asynchronous:true, evalScripts:true, update:null, parameters:Form.serialize('UserProperties')});
    
    return true;
}
*/

function reload()
{
	window.location.reload();
}


var formSubmitted = false;

var activeForm = '';
function submitAjaxForm(formName, url, updateId, onComplete)
{
	var jsonResponse = null;

	new Ajax.Updater(updateId, url, {evalScripts:true, update:updateId, parameters:Form.serialize(formName), onCreate: function() { disableInput(null,null,{opacity:80,color:'white'}); }, onComplete:function(transport, json){ jsonResponse = json; eval(onComplete); enableInput(); }, evalJSON:true});
    
    formSubmitted = true;
    
    if(jsonResponse != null)
    {
	    //alert('validates=');
	    //alert(jsonResponse.validation);
	    //alert('error=');
	    //alert(jsonResponse.errorMessage);
    }
    else
    {
    	return true;
    }
}


function highlightCellBackgrounds(prefix, rowIdx, cellIdx, numCells, color)
{
	for(i=0; i <= numCells; i++)
	{
		cellId = prefix+'_'+rowIdx+'_'+i;

		if(i == cellIdx)
		{
			$(cellId).style.backgroundColor = color;
		}
		else
		{
			$(cellId).style.backgroundColor = '';
		}
	}
	
}


function disableWebsite( websiteId, websiteName)
{
	
	var confirmMessage = "You are about to change the status of '"+websiteName+"' to inactive.\r\nYou may re-activate this website later, are you sure you want to change the status of '"+websiteName+"' to inactive?";
    if(confirm(confirmMessage))
    {
        disableInput(null, null, {opacity:75,color:'white'});

        new Ajax.Request(site_root+'/websites/remove/'+websiteId, {onComplete:function(request){window.location.reload();}, asychronous:true, evalScripts:true});

    }

}


function disableClient( clientId, clientName)
{
	
	var confirmMessage = "You are about to disable the client '"+clientName+"'.\r\nYou may re-activate this client later, are you sure you to delete '"+clientName+"'?";
    if(confirm(confirmMessage))
    {
        disableInput(null, null, {opacity:75,color:'white'});

        new Ajax.Request(site_root+'/clients/remove/'+clientId, {onComplete:function(request){window.location.reload();}, asychronous:true, evalScripts:true});

    }

}


/*

function savePrePublish(templateModelName)
{
    var jsonResponse = null;
    
    var saveAction = /aw_([^_]+)_template/g.exec(templateModelName);
        saveActionModel = saveAction[1];
    
    new Ajax.Request(site_root+'/'+templateModelName+'/save_'+saveActionModel+'/', {onComplete:function(transport, json){ jsonResponse = json; }, asynchronous:false, evalJSON:true});
     
    if(jsonResponse.templateId > 0 && jsonResponse.templateModelId > 0)
    {
        return jsonResponse;
    }
    else
    {
        return false;
    }
}*/
