// JavaScript Document

var module = 'newsletter';

function trySubscribeNewsletter() {
        var namer = getValue( 'name' );
        var email = getValue( 'email' );
        var statepaper = $( "input[name='statepaper']" ).attr('checked');
        var localpaper = $( "input[name='localpaper']" ).attr('checked');
        var agreeopt = $( "input[name='agree']" ).attr('checked');
        var localpaperoption = $( "select[name='localpaper_option']" ).val();
	var ajax = new myAjax( module );
	ajax.action = 'trySubscribeNewsletter';
	ajax.post( 'statepaper='+statepaper+'&localpaper='+localpaper+'&localpaper_option='+localpaperoption+'&agree='+agreeopt+'&name='+namer+'&email='+email+'&act=subscribe');
	ajax.onLoad = function() {
		alert( this.response );
	}
}

function activateQueue( queue, div ) {
	var ajax = new myAjax( module );
	ajax.action = 'activateQueue';
	ajax.post( 'queue='+queue );
	ajax.onLoad = function() {
		getQueueIcon( queue, div );
	}
}

function deactivateQueue( queue, div ) {
	var ajax = new myAjax( module );
	ajax.action = 'deactivateQueue';
	ajax.post( 'queue='+queue );
	ajax.onLoad = function() {
		getQueueIcon( queue, div );
	}
}

function getQueueIcon( queue, div ) {
	var ajax = new myAjax( module );
	ajax.action = 'getQueueIcon';
	ajax.post( 'queue='+queue, div );
}


function activateEmail( email, aid ) {
	var ajax = new myAjax( module );
	ajax.action = 'activateEmail';
	ajax.post( 'email='+email );
	ajax.onLoad = function() {
		getIcon( email, aid, 'active' );
	}
}

function deactivateEmail( email, aid ) {
	var ajax = new myAjax( module );
	ajax.action = 'deactivateEmail';
	ajax.post( 'email='+email );
	ajax.onLoad = function() {
		getIcon( email, aid, 'active' );
	}
}

function confirmEmail( email, cid ) {
	var ajax = new myAjax( module );
	ajax.action = 'confirmEmail';
	ajax.post( 'email='+email );
	ajax.onLoad = function() {
		getIcon( email, cid, 'confirmed' );
	}
}

function deconfirmEmail( email, cid ) {
	var ajax = new myAjax( module );
	ajax.action = 'deconfirmEmail';
	ajax.post( 'email='+email );
	ajax.onLoad = function() {
		getIcon( email, cid, 'confirmed' );
	}
}

function getIcon( email, target, type ) {
	var ajax = new myAjax( module );
	ajax.action = 'getIcon';
	ajax.post( 'email='+email+'&type='+type, target );
}

