if (typeof av_css_master == 'undefined') {
	function av_css_master(selector, rules) {
		this.find_selector = function(selector) {
			for (var i=0; i < document.styleSheets.length; i++) {
				var rules = (this.is_msie ? document.styleSheets[i].rules : document.styleSheets[i].cssRules);
				for (var j=0; j < rules.length; j++) if (rules[j].selectorText == selector) return true;
			}
			return false;
		}
		
		this.addRule = function(css, selector, declaration) {
			if (this.is_msie) css.addRule(selector, declaration); else css.insertRule(selector+'{'+declaration+'}', css.cssRules.length);
		}

		this.is_msie = navigator.userAgent.search(/MSIE/) >= 0 ? true : false;

		if (this.find_selector(selector) === false) {
			var newcss = document.createElement('style'); // Creo un nuovo elemento STYLE
			newcss.type = 'text/css';
			newcss.media = 'all';
			document.getElementsByTagName('head')[0].appendChild(newcss);
			newcss = document.styleSheets[document.styleSheets.length-1]; // Recupero lo StyleSheet appena creato
			for (var rule in rules) this.addRule(newcss, rule, rules[rule]); // Inserisco lo stile predefinito
		}
	}
}

/* 
 * *** NOTE ***
 *
 * (IE <= 6) Al momento della chiamata di av_css_master è possibile definire un solo selettore per ogni regola
 * (Konqueror) Il nuovo elemento STYLE non viene creato se non è stato incluso nessun CSS tramite <LINK> o <STYLE>
 *
 * *** ESEMPIO ***
 *
 * av_css_master('#av_guestbook', { 
 *    '#av_guestbook': 'width:500px;margin:auto;background-color:cyan;border:1px solid navy',
 *    '#av_guestbook th': 'border:1px solid navy',
 *    '#av_guestbook td': 'border:1px solid navy',
 *    '#av_guestbook .title': 'background-color:yellow'
 * });
 *
 */

rules = {
	'.av_newsletter': 'margin: 2%; padding: 2%; width: 90%; background: #fcf3f8; border: solid 1px #823A3D; font-family: Arial, Verdana, sans-serif; font-size: 70%;',
	'.av_newsletter .avrow': 'padding: 2%; text-align: center;',
	'.av_newsletter .optional': 'display: none;',
	'.av_newsletter input': 'border: 1px solid #555; font-family: Arial font-size: 75%;',
	'.av_newsletter button': 'font-family: Arial font-size: 75%; solid 1px #823A3D; background : #ffe9ec; margin: 2%',
	'.av_newsletter .field': 'width: 65%;',
	'.av_newsletter .field2': 'border: solid 1px #823A3D;',
	'.av_newsletter .disclaimer': ' color: #fcf3f8; font-size: 0.3em;'
};

av_css_master('.av_newsletter', rules);

var urlc = "http://" + location.host + location.pathname;
urlc = escape(urlc);

document.writeln('<form name="av_newsletter" action="http://it.altervista.org/cgi-bin/av_nl/nl.pl" method="post" class="av_newsletter">');
document.writeln('<div class="avrow"><label class="desc1 optional" for="email"></label>');
document.writeln('<input class="field" id="email" name="email" type="text" title="e-mail" />');
document.writeln('<input class="button" value="OK" type="submit" /></div>');

document.writeln('<div class="avrow"><input class="field2" name="azione" value="iscrivi" id="subscribe" checked type="radio" /><label class="desc2" for="subscribe">Subscribe</label>');
document.writeln('<input class="field2" name="azione" value="rimuovi" id="unsubscribe" type="radio" /><label class="desc2" for="unsubscribe">Unsubscribe</label></div>');
document.writeln('<input name="ID" value="' + urlc + '" type="hidden" />');
document.writeln('<div class="avrow"><a href="http://www.altervista.org" class="avlink disclaimer">Powered by AlterVista Mailing List</a></div>');
document.writeln('</form>');
