blockEvent = function (event)
{
	event = event || window.event;
	if(event.stopPropagation) event.stopPropagation();
	else event.cancelBubble = true;
	if(event.preventDefault) event.preventDefault();
	else event.returnValue = false;
}

show = function (e)
{
	var error = false;
	var target = e ? e.target : window.event.srcElement;
	while (target.id.search('selector') == -1 && !error)
	{
		target = target.parentNode;
		if (target.tagName == 'body') var error = true;
	}
	blockEvent(e);
	if (!error)
	{
		var id = parseInt(target.id.replace('selector', ''));
		var _id = id == 2 ? 1 : 2;
		get ('list' + _id).style.display = 'none';
		get ('selector' + _id).className = '';
		
		get('list' + id).style.display = target.className == 'sel' ? 'none' : '';
		//get('form').style.display = get('line2').style.display = get('tabs').style.display = target.className == 'sel' ? '' : 'none';
		target.className = target.className == 'sel' ? '' : 'sel';
	}
}

function handleMouseMove(event)
{
	form1.move(event);
}

function handleMouseUp()
{
	form1.drop();
}


window.onload = function ()
{
	form1 = new PriceForm('interval', 'line', 'min', 'max', 'minvalue', 'maxvalue', 'minfield', 'maxfield', 0, 2950, 'form', 'formnoscript',  50);
	form1.prepare();

	form1.eMin.onmousedown = function (e) {form1.drag(e)};
	form1.eMax.onmousedown = function (e) {form1.drag(e)};
	
	document.onmousemove = handleMouseMove;
	document.onmouseup = handleMouseUp;

	window.onresize = function () {form1.resize()};
	
	if (get('selector1') && get('selector2'))
	{
		var and = document.createElement('LI');
		and.className = 'and';
		and.innerHTML = 'and';
		get('selector1').parentNode.appendChild(and);
		get('selector1').parentNode.appendChild(get('selector2'));
		get('selector1').onclick = get('selector2').onclick = show;
	}
	
	if (get('list1') && get('list2') && get('firstline'))
	{
		get('list1').parentNode.insertBefore(get('list2'), get('firstline'));
		get('list1').className = get('list2').className = 'property_type_content';
		get('firstline').style.display = get('tabs').style.display = get('list1').style.display = get('list2').style.display = 'none';
	}
	
	if (get('span1') && get('span2'))
	{
		var a1 = document.createElement('A');
		a1.href = '#';
		a1.innerHTML = get('span1').innerHTML;
		get('span1').innerHTML = '';
		get('span1').appendChild(a1);
		var a2 = document.createElement('A');
		a2.href = '#';
		a2.innerHTML = get('span2').innerHTML;
		get('span2').innerHTML = '';
		get('span2').appendChild(a2);
	}
}

