function init(){
	//fill in all the automatically generated form elements.
		// locally installed fonts...
		//function generateList(i_start,i_increment,i_end, i_initial,s_units, s_selectid)

		// h1 form...
			//generateList(0.1,0.1,12, 1,"em", '#h1form [@name="font-size"]');
			//generateList(-1,0.05,1, 0,"em", '#h1form [@name="letter-spacing"]'); //h1ls");
			//generateList(0.1,0.1,12, 1.2,"em", '#h1form [@name="line-height"]');//"h1lh");
			//generateList(-1,0.05,1, 0,"em", '#h1form [@name="word-spacing"]');//"h1ws");
			//generateList(0,0.1,3, 1,"em", '#h1form [@name="margin-top"]');
			//generateList(0,0.1,3, 1,"em", '#h1form [@name="margin-bottom"]');
			//generateList(0,1,50, 0,"px", '#h1form [@name="margin-left"]');
			//generateList(0,1,50, 0,"px", '#h1form [@name="margin-right"]');
			//generateList(0,0.1,3, 1,"em", '#h1form [@name="text-indent"]');
			//document.formids = "";
			$("#h1form :input").each(function(i){
				$(this).get(0).onchange = function(){ updateCSSElement(this,"#content h1");};
				$(this).get(0).onkeypress = function(){ updateCSSElement(this,"#content h1");};
				updateCSSElement(this,"#content h1");
			});
			
			//$("div#h1form :input").each(function(i){
			//	document.formids += i + "::" + this.name + ": " + this.value + "<br />";
			//});
			//$("div#h1content").html(document.formids);
			
//			h2form = $("#h1form").clone();
//			$(h2form).removeAttr('id');
//			$(h2form).attr("id","h2form");
//			$(".formlabel", h2form).html("h2");
//
//			//console.log("h2form::",h2form.attr("id"));
//			$("#h1form").after(h2form);
			//console.log("h2form::",$("div#h2form").attr("id"));
			$(":input",$("#h2form")).each(function(i){
				//$(this).unbind();
				$(this).get(0).onchange = function(){ updateCSSElement(this,"#content h2");};
				$(this).get(0).onkeypress = function(){ updateCSSElement(this,"#content h2");};
				updateCSSElement(this,"#content h2");
			});
			
			
//			pform = $("#h1form").clone();
//			$(pform).removeAttr('id');
//			$(pform).attr("id","pform");
//			$(".formlabel", pform).html("p");
//			$("#h2form").after(pform);
//
//			//console.log("h2form::",h2form.attr("id"));
//			
			//console.log("h2form::",$("div#h2form").attr("id"));
			$("#pform :input").each(function(i){
				//$(this).unbind();
				$(this).get(0).onchange = function(){ updateCSSElement(this,"#content p");};
				$(this).get(0).onkeypress = function(){ updateCSSElement(this,"#content p");};
				updateCSSElement(this,"#content p");
			});
}

function updateCSSElement(othat,starget) {
//	othat.each(function(i){
//		document.formids += i + "::" + this.name + ": " + this.value + "<br />";
//	});
	//alert(starget +": " + othat.name +"::"+ othat.value);
	$("div#feedback").html(starget +": " + othat.name +"::"+ othat.value);
	$(starget).css(othat.name , othat.value);
	//console.log("update:: %s:%s:%s",othat.name,starget,othat.value);
}

function getPrecision(f_num) {
	var str = f_num.toString();
		
	if (str.indexOf('.') == -1) {
		return 0;
	}
	return str.length - str.indexOf('.');
}

function generateList(i_start,i_increment,i_end, i_initial,s_units, s_selectid){
	var listHTML="";
	var i=0;
	var s_select = "";
	var i_select = -1;
	var i_count = 0;
	//formHTML= '<label>'+ s_selectid +'<select name="'+ s_selectid +'">';
	for (i=i_start; i<=i_end; i += i_increment) {
		i = parseFloat(i.toFixed(getPrecision(i_increment)));
		
		listHTML+= '\n<option value="'+ i + '' + s_units + '"';
		
		if (i==i_initial) {
			s_select = i+s_units;
			i_select = i_count;
			listHTML+= 'selected="selected"';
		}
		
		listHTML+='>'+ i + '' + s_units +'</option>';
		
		i_count++;
	}
	//formHTML+='  </select></label>';
	var temp = $(s_selectid);
	temp.html(listHTML);
	if (s_select != "") {
		temp.attr("value",s_select);
		temp.attr("selectedIndex",i_select);
		temp.trigger("change");
		}
}
