/* сменить тип */
function changeType(obj){      
    $(".srch_types").hide();
    $("." + $(obj).attr("id")).show();
    return false;
}

function dropFile(btn){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		tr.parentNode.removeChild(tr);
		checkForLast();
	}
}

function addFile(btn){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		var idSuffix = Math.round(Math.random()*1000);
		var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
		thisChilds = newTr.getElementsByTagName('td');

		for (var i = 0; i < thisChilds.length; i++){
			if (thisChilds[i].className == 'header') thisChilds[i].innerHTML = '';
			if (thisChilds[i].className == 'files') thisChilds[i].innerHTML = '<input size="25" name="att[]" value="" class="wideFile" type="file">';
			if (thisChilds[i].className == 'text') thisChilds[i].innerHTML = '<input type="text" size="25" name="descr_photo[]" value="">';
			
		}
		
		checkForLast();
	}
}

function checkForLast(){
	btns = document.getElementsByName('drop');
	for (i = 0; i < btns.length; i++){
		btns[i].disabled = (btns.length == 1) ? true : false;
	}
}
