<!--
	
var m
function openModal(l){
//	alert(l)
m =  new Control.Modal($(l),{opacity: 0.5});//{containerClassName: 'test',overlayClassName: 'test'});
m.open();
}

function closeModal(){

m.close();

}
//######################################################	
		
var valid

	function set_form_validation(formid){

	valid = new Validation(formid);//, {immediate : true});
	
	}

function submit_form_ajax(form_id, update_div, action, after_action, target, validate) {
//validate form

Element.update('debug','')

if (validate) {
if (typeof(valid) != "undefined") {
if (!valid.validate()){
valid.reset()
return false;
}
}
}

	var url = "/ajax/ajax.asp?a="+action;
	
	var post = Form.serialize(form_id)	

Element.update(target,'<img src=\"inc/indicator_flower.gif\" />')


var opt = {
    // Use POST
    method: 'post',
    // Send this lovely data
    postBody:post ,
    // Handle successful response
    onSuccess: function(t) {
//alert("RESPONSE:"+t.responseText)
		showResponse(t.responseText, form_id,update_div, after_action, target)
    },
    // Handle 404
    on404: function(t) {
     alert('Error 404: location "' + t.statusText + '" was not found.');
    },
    // Handle other errors
    onFailure: function(t) {
		//alert(t.responseText);
	Element.update('debug',t.responseText)

    }
}

//alert(opt.toString());
new Ajax.Request(url, opt);

	}
	
function showResponse(rText, form_id, update_div, after_action, target)
	{

if (after_action != ''){
//prompt('response',rText)
update_data_ajax(after_action, target, ''); //refresh data in a new function
}else{
	//alert(update_div+":"+rText)
Element.update(update_div,rText); //add returned data direct to the data div
}
}


function update_data_ajax (action, target, idd) {
//alert(action)
var pp = 'id='+idd;

	var url = "ajax/ajax.asp?a="+action;
//alert(url)
	Element.update(target,'<img src=\"ajax/indicator_flower.gif\" />   Loading, Please Wait...       [ <a href=\"javascript:window.location.href = window.location.href;\">Reload This Page</a> ]');
	pp = pp.toQueryParams();
	//alert(pp.toString());
	var post = Object.toQueryString(pp);
	
var opt = {
    // Use POST
    method: 'post',
    // Send this lovely data
    postBody:post ,
    // Handle successful response
    onSuccess: function(t) {
	Element.update(target,t.responseText);
    },
    // Handle 404
    on404: function(t) {
        debug.innerHTML = ('Error 404: location "' + t.statusText + '" was not found.');
    },
    // Handle other errors
    onFailure: function(t) {
        debug.innerHTML = ('Error ' + t.status + ' -- ' + t.statusText + ' -- '+t.responseText);
    }
}

 //alert(opt.toString());
new Ajax.Request(url, opt);
	}


//-->