
	function DESemail(emailname,emailserver) {
		document.write("<a href='mailto:" + emailname + "@" + emailserver +"'>");
		document.write(emailname + "@" + emailserver); 
		document.write("</a>"); 
	}

	// Accessible Pop Ups
	function DESopen(url,width,height,toolbar,scroll) {
		window.open(url, "", "scrollbars="+scroll+",toolbar="+toolbar+",height="+ height +",width="+width);
		return false;
	}

	// Inaccessible drop down target (doesnt matter as its in cm login area)
	function DESgoto(target) {
		if (target != "") {
		  	this.location.href = target;
		}
	}

	var Vote = {
		init : function() {
			if ($('#site_list option').length == 1) $('#site_list').hide();
			if ($('#cm_selector option').length == 1) $('#cm_selector').hide();

			$('#t2').next().removeAttr('name').hide();


			if ($('#country_list').val() > 0) {
				value = $('#country_list').val();

				$.post("/incs/ajax/site_list.php", { country_id : value }, function(result) {
					$('#site_list select').append(result).parent().show();
				});
			}


			$('#country_list').change(function () {
				value = $(this).val();

				$('#t2').next().removeAttr('name').fadeOut('fast', function () {
					$('#cm_selector').slideUp('normal', function () {
						$('#t2 option:not(:first)').remove();
						$('#site_list').slideUp('normal', function () {
							$('#site_list select option:not(:first)').remove();
							if (value > 0) {
								$.post("/incs/ajax/site_list.php", { country_id : value }, function(result) {
									$('#site_list select').append(result).parent().slideDown('fast');
								});
							}
						});
					});
				});
			});


			$('#site_list select').change(function () {
				value = $(this).val();

				if (value == 0) {
					$('#t2').next().removeAttr('name').fadeOut('fast', function () {
						$('#cm_selector').slideUp('normal');
					});

					return;
				}

				$('#t2').fadeOut('fast', function () {
					$('#t2 option:not(:first)').remove();

					$.post("/incs/ajax/cm_list.php", { site_id : value }, function(result) {
						$('#cm_selector').slideDown('fast', function () {
							$('#t2').append(result).fadeIn('fast');
						});
					});
				});
			});



			$('#t2').change(function () {
				$(this).val() == 'other' ? $(this).next().attr('name', $('#t2').attr('name')).fadeIn('fast') : $(this).next().removeAttr('name').fadeOut('fast');
			});
		}
	};

	$(function() { Vote.init(); });

