<!--

function openInfoDialog(content) {//, hideEffectOptions: {duration:1}
 Dialog.info(content,{windowParameters: {className: "alert_lite",width:250, height:100}, showProgress: true});
	}
		
var m
function openModal(l){
m =  new Control.Modal($(l),{opacity: 0.5,fade: true,overlayCloseOnClick: false});//{containerClassName: 'test',overlayClassName: 'test'});
m.open();

}

function closeModal(){

m.close();

}
//######################################################	
		
var valid

	function set_form_validation(formid){

	valid = new Validation(formid, {immediate : true});
	valid.reset();

	}


function submit_form_ajax(form_id, update_div, action, after_action, target) {
//validate form


Element.update('debug','')
if (typeof(valid) != "undefined") {
if (!valid.validate()){
valid.reset()
return false;
}
}


	var url = "ajax/ajax.asp?a="+action;
//Element.update(target,'<img src=\"inc/indicator_flower.gif\" />')
	//Form.disable(form_id);//disable form
	openInfoDialog('Please wait updating ...')

	var post = Form.serialize(form_id)
	//alert(post)
var opt = {
    // Use POST
    method: 'post',
    // Send this lovely data
    postBody:post ,
    // Handle successful response
    onSuccess: function(t) {
	//new Effect.Fade(update_div, { duration: 3.0 })
	Form.enable(form_id)
	 Dialog.setInfoMessage("Data Updated")
//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) {
	Dialog.closeInfo()
	//Dialog.destroy()
	
	Element.update('debug',t.responseText)
       // alert('Error ' + t.status + ' -- ' + t.statusText);
    }
}

 //alert(opt.toString());
new Ajax.Request(url, opt);

	//var myAjax = new Ajax.Request(url, {method: 'POST',	parameters: pars, onComplete: showResponse});
	}
	
	

//######################################################



function showResponse(rText, form_id, update_div, after_action, target)
	{
	
	
Dialog.closeInfo() //close dialog
//Dialog.destroy()

if (after_action != ''){
//prompt('response',rText)
update_data_ajax(after_action, target, '') //refresh data in a new function
}else{
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> ]')
	var post = 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);

	//var myAjax = new Ajax.Request(url, {method: 'POST',	parameters: pars, onComplete: showResponse});
	}


function update_data_ajax_pdf (action, target, idd) {
//alert(action)
var pp = 'id='+idd

	var url = "/downloadPdf.aspx?cardid="+action;
//alert(url)
	Element.update(target,'<img src=\"ajax/indicator_flower.gif\" />   Loading, Please Wait...')
	var post = 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);

	//var myAjax = new Ajax.Request(url, {method: 'POST',	parameters: pars, onComplete: showResponse});
	}



//######################################################






	
function load_form_ajax(form_id, update_div, action, data_id) {

	var url = "../ajax/ajax.asp?id="+data_id+"&action="+action;
	//alert(form_id+":"+data_id+":"+update_div+":"+action);
	//Form.disable(form_id);//disable form
	openInfoDialog('Please wait loading form ...')
	//Element.update(update_div,)
	var post = "id="+data_id
//	alert(post)
var opt = {
    // Use POST
    method: 'post',
    // Send this lovely data
    postBody:post ,
    // Handle successful response
    onSuccess: function(t) {
	//new Effect.Fade(update_div, { duration: 3.0 })
	//Form.enable(form_id)
	
//alert("RESPONSE:"+t.responseText)
		loadFormData(t.responseText, form_id,update_div)
    },
    // Handle 404
    on404: function(t) {
        alert('Error 404: location "' + t.statusText + '" was not found.');
    },
    // Handle other errors
    onFailure: function(t) {
        alert('Error ' + t.status + ' -- ' + t.statusText);
    }
}
new Ajax.Request(url, opt);
}



//######################################################



function loadFormData(rText, form_id, update_div)
	{
	//alert(form_id)
	Element.update(form_id,rText)
	var valid = new Validation('manage_event');
			
	
Dialog.closeInfo() //close dialog
Dialog.destroy()
}






// ********************************************PostCode Finder START
function checkpostcode(fn, formfield, returnto){
	var formname = fn.name
	var suburb = eval("document."+formname+"."+formfield+".value")
	
	if (suburb == ""){
		alert("Please enter your suburb.")		
		eval("document."+formname+"."+formfield+".style.backgroundColor = \"#bde0f8\"")
		eval("document."+formname+"."+formfield+".focus()")
		return false;
	}else{
		eval("document."+formname+"."+formfield+".style.backgroundColor = \"#ffffff\"")
		var postpage = "../../events/postcodechecker.asp?suburb="+suburb+"&fn="+formname+"&returnto="+returnto
		MP_openBrWindow(postpage,"postcodecheck","scrollbars=yes, width=330, height=200, resizable=yes", "300", "300")
	}
}



function insertpostcode(pc, fname, returncode){
	eval("document."+fname+"."+returncode+".value = "+pc)
}

function MP_openBrWindow(theURL,winName,features, wid, hei) {//v2.0 modified
	LeftPosition = (screen.width) ? (screen.width-wid)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-hei)/2 : 0; 
	featuresAll = features + ',top ='+TopPosition+',left='+LeftPosition
	  window.open(theURL,winName,featuresAll);
}

// ********************************************PostCode Finder END


//var m = ""
//var c = false
//function mm(i){
//
//m = new Control.Modal(i,{beforeClose: function(){
//if(!c)
//{return false;}
//}});
//m.open();
//return false;
//}
//
//function closeM(){
//c = true;
//m.close();
//c = false;
//}