// JavaScript Document
function CloseOpenChild(pid) {
	var arrChilds = document.getElementsByName('parent_' + pid);
	if(arrChilds.length > 0) {
		for(i = 0; i < arrChilds.length; i++) {
			if(arrChilds[i].className == 'off') {
				arrChilds[i].className = 'on';
			}
			else {
				arrChilds[i].className = 'off';
			}
			CloseOpenChild(arrChilds[i].id);
		}
	}
}

function CloseOpenWraper(w) {
	if(document.getElementById(w) != null) {
		if(document.getElementById(w).className == 'div-child on') {
			document.getElementById(w).className = 'off';
			document.getElementById('icon_' + w).innerHTML = '+';
		}
		else {
			document.getElementById(w).className = 'div-child on';
			document.getElementById('icon_' + w).innerHTML = '-';
		}
		 
	}
}

function CheckNull() {
	return true;
}

var _itv;
var _checked;
var _propid;

function check_child(parentid, state) {
	DoAction('process-div','GET','check_childs.php','pid=' + parentid,'checking sub categories..');
	_itv = setInterval('check_finish()', 100);
	_checked = state;
}
function check_finish() {
	if(_ajaxCompleted) {
		clearInterval(_itv);
		check_child_selected();		
	}
}
function check_child_selected() {
	var ids = document.getElementById('return-childs').value;
	var arr_id = ids.split(',');
	var controls = document.forms["IUForm"].elements.length;
	for(var i=0; i < controls; i++) {
		for(var j=0; j < arr_id.length; j++) {
			if(document.forms["IUForm"].elements[i].id == arr_id[j] && document.forms["IUForm"].elements[i].type == "checkbox") {
				document.forms["IUForm"].elements[i].checked = _checked;
				document.forms["IUForm"].elements[i].disabled = _checked;
			}
		}
	}
	select_property();
}

var props = '';
function select_property() {
	var str_props = '';
	var controls = document.forms["IUForm"].elements.length;
	for(var i=0; i < controls; i++) {
		if(document.forms["IUForm"].elements[i].checked == true) {
			 str_props += document.forms["IUForm"].elements[i].id + ',';
		}
	}
	get_property(str_props);
}

function get_property(props) {
	DoAction('div-query','GET','getproperties.php','props=' + props,'Building your query...');
}

function MouseOverOut(Obj, state) {
	if(state == 'over' && Obj.className != 'property-select')
		Obj.className = 'property-over';
	if(state == 'out' && Obj.className != 'property-select')
		Obj.className = 'property-item';
}