var htaccess_strings={
	'to_www':'Options +FollowSymLinks\nRewriteEngine on\nRewriteCond %{SERVER_PORT} ^80$\nRewriteCond %{HTTP_HOST} ^www.yourdomain.com$ [NC]\nRewriteRule ^(.*) http://yourdomain.com/$1 [L,R=301]',
	'from_www':'Options +FollowSymLinks\nRewriteEngine on\nRewriteCond %{SERVER_PORT} ^80$\nRewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC]\nRewriteRule ^(.*) http://www.yourdomain.com/$1 [L,R=301]'
}
function use_www(domain){
	domain = domain.replace(/^www\./i,'');
	return htaccess_strings['to_www'].replace(/yourdomain.com/gi, domain);
}
function be_clever(domain){
	domain = domain.replace(/^www\./i,'');
	return htaccess_strings['from_www'].replace(/yourdomain.com/gi, domain);
}

jQuery(document).ready( function(){
	$('#htaccess_domain').emptyText('example.com');
    $("#htaccess_domain").keyup(function () {
		document.getElementById('htaccess_no_www').innerHTML = be_clever(this.value);
		document.getElementById('htaccess_to_www').innerHTML = use_www(this.value);
    });
});
