
var current_visible_floorplans_category = '';



DomBuilder = {
	apply : function(o) { 
	  o = o || {};
		var els = ("p|div|span|strong|em|img|table|tr|td|th|thead|tbody|tfoot|pre|code" + 
					   "|h1|h2|h3|h4|h5|h6|ul|ol|li|form|input|textarea|legend|fieldset|" + 
					   "select|option|blockquote|cite|br|hr|dd|dl|dt|address|a|button|abbr|acronym|" +
					   "script|link|style|bdo|ins|del|object|param|col|colgroup|optgroup|caption|" + 
					   "label|dfn|kbd|samp|var").split("|");
    var el, i=0;
		while (el = els[i++]) o[el.toUpperCase()] = DomBuilder.tagFunc(el);
		return o;
	},
	tagFunc : function(tag) {
	  return function() {
	    var a = arguments, at, ch; a.slice = [].slice; if (a.length>0) { 
	    if (a[0].nodeName || typeof a[0] == "string") ch = a; else { at = a[0]; ch = a.slice(1); } }
	    return DomBuilder.elem(tag, at, ch);
	  }
  },
	elem : function(e, a, c) {
		a = a || {}; c = c || [];
		var el = document.createElement(e);
		for (var i in a) if (typeof a[i] != 'function') el.setAttribute(i, a[i]);
		for (var i=0; i<c.length; i++) {
			if (typeof c[i] == 'string') c[i] = document.createTextNode(c[i]);
			el.appendChild(c[i]);
		} 
		return el;
	}
}


function addAnotherItem()
{
/* alert('here'); */

    var html = DomBuilder.apply();
    var next = getItemsCount() + 1

    var textarea = html.TEXTAREA({name : "fmItem" + next})

    textarea.className = "textarea_01";

/*
    textarea.style.width = "350px";
    textarea.style.height = "70px";
*/

    var tr = html.TR(
    html.TD("Item:"),
    html.TD(textarea)
    );


    if(isIE())
    {
            document.getElementById("items").childNodes[0].appendChild(tr);
    }
    else if(isSafari())
    {
            document.getElementById("items").childNodes[1].appendChild(tr);
    }
    else
    {
        document.getElementById("items").appendChild(tr);
    }
}
function getItemsCount()
{
    var result = 0;
    el = document.getElementsByTagName("textarea")
    for (i=0; i < el.length; i++)
    {
        re = /fmItem\d+/
        if (re.test(el[i].name))
        {
            result++
        }
    }

    return result
}

function isIE()
{
    re = /MSIE/
    return re.test(navigator.userAgent)
}

function isSafari()
{
    re = /Safari/
    return re.test(navigator.userAgent)
}




function toggle_floorplans_visibility(id)  
{  
//alert('!!!!');

///    if (document.getElementById(current_visible_floorplans_category))
///    {
///        document.getElementById(current_visible_floorplans_category).style.display = 'none';
///    }

    if (document.getElementById(id).style.display == 'none')
    {
        document.getElementById(id).style.display = '';
    }
    else
    {
        document.getElementById(id).style.display = 'none';
    }

    current_visible_floorplans_category = id;
}  



