function exhib_move_to_current_confirm(page_id) {
	var dialogue = new Dialog.YesNo('Are you sure you want to move this exhibition to the current exhibitions section?', 'Move exhibition', function(){exhib_do_move_to_current(page_id);}, 'Cancel', Dialog.cancel, {height: '90px'});
	dialogue.show();
}
function exhib_do_move_to_current(page_id) {
	var req = new Ajax.Request('/@update/moveexhibtocurrent/'+page_id, {method: 'get', asynchronous:true, parameters:'', onComplete:function(transport) { exhib_do_move_to_current_complete(page_id) } });
}

function exhib_do_move_to_current_complete(page_id) {
	var d = new Date();
	window.location.href = '/@edit/' + page_id  +'?refresh='+d.getTime();
}


function exhib_move_to_previous_confirm(page_id) {
	var dialogue = new Dialog.YesNo('Are you sure you want to move this exhibition to the previous exhibitions section?', 'Move exhibition', function(){exhib_do_move_to_previous(page_id);}, 'Cancel', Dialog.cancel, {height: '90px'});
	dialogue.show();
}

function exhib_do_move_to_previous(page_id) {
	var req = new Ajax.Request('/@update/moveexhibtoprevious/'+page_id, {method: 'get', asynchronous:true, parameters:'', onComplete:function(transport) { exhib_do_move_to_previous_complete(page_id) } });
}

function exhib_do_move_to_previous_complete(page_id) {
	var d = new Date();
	window.location.href = '/@edit/' + page_id  +'?refresh='+d.getTime();
}

/*****************future*********************/
function exhib_move_to_future_confirm(page_id) {
	var dialogue = new Dialog.YesNo('Are you sure you want to move this exhibition to the future exhibitions section?', 'Move exhibition', function(){exhib_do_move_to_future(page_id);}, 'Cancel', Dialog.cancel, {height: '90px'});
	dialogue.show();
}

function exhib_do_move_to_future(page_id) {
	var req = new Ajax.Request('/@update/moveexhibtofuture/'+page_id, {method: 'get', asynchronous:true, parameters:'', onComplete:function(transport) { exhib_do_move_to_future_complete(page_id) } });
}

function exhib_do_move_to_future_complete(page_id) {
	var d = new Date();
	window.location.href = '/@edit/' + page_id  +'?refresh='+d.getTime();
}
/**************************************/

function generate_password(input_id) {
	var input = $(input_id);
	var valid_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789'
	
	var min_length = 6;
	var max_length = 8;
	
    var length=10;
    var password = "";

	length = parseInt(100* Math.random());
	length = (length % (max_length - min_length + 1)) + min_length

    for (i=0; i < length; i++) {
        var n = parseInt(valid_chars.length * Math.random());
        password += valid_chars.substr(n, 1);
    }

    input.value = password;
    return password;

}


function press_move_to_current_confirm(page_id, current_id) {
	var dialogue = new Dialog.YesNo('Are you sure you want to move this exhibition to the current exhibitions section?', 'Move exhibition', function(){press_do_move_to_current(page_id, current_id);}, 'Cancel', Dialog.cancel, {height: '90px'});
	dialogue.show();
}
function press_do_move_to_current(page_id, current_id) {
	var req = new Ajax.Request('/@update/pagemove', {method: 'get', asynchronous:true, parameters:'child_id='+page_id+'&parent_id='+current_id, onComplete:function(transport) { press_do_move_to_current_complete(page_id) } });
}

function press_do_move_to_current_complete(page_id) {
	var d = new Date();
	window.location.href = '/@edit/' + page_id  +'?refresh='+d.getTime();
}




function press_move_to_previous_confirm(page_id, current_id) {
	var dialogue = new Dialog.YesNo('Are you sure you want to move this exhibition to the previous exhibitions section?', 'Move exhibition', function(){press_do_move_to_previous(page_id, current_id);}, 'Cancel', Dialog.cancel, {height: '90px'});
	dialogue.show();
}
function press_do_move_to_previous(page_id, current_id) {
	var req = new Ajax.Request('/@update/pagemove', {method: 'get', asynchronous:true, parameters:'child_id='+page_id+'&parent_id='+current_id, onComplete:function(transport) { press_do_move_to_previous_complete(page_id) } });
}

function press_do_move_to_previous_complete(page_id) {
	var d = new Date();
	window.location.href = '/@edit/' + page_id  +'?refresh='+d.getTime();
}



function press_move_to_future_confirm(page_id, current_id) {
	var dialogue = new Dialog.YesNo('Are you sure you want to move this exhibition to the future exhibitions section?', 'Move exhibition', function(){press_do_move_to_future(page_id, current_id);}, 'Cancel', Dialog.cancel, {height: '90px'});
	dialogue.show();
}
function press_do_move_to_future(page_id, current_id) {
	var req = new Ajax.Request('/@update/pagemove', {method: 'get', asynchronous:true, parameters:'child_id='+page_id+'&parent_id='+current_id, onComplete:function(transport) { press_do_move_to_future_complete(page_id) } });
}

function press_do_move_to_future_complete(page_id) {
	var d = new Date();
	window.location.href = '/@edit/' + page_id  +'?refresh='+d.getTime();
}
