function showHideIt(El,imgDiv, bHide){
	getS(imgDiv).visibility =  (bHide) ? 'hidden' : 'visible';
}

function searchIt(){
	var theSearch = getEl('extra').value;
	if(theSearch!="") ajaxpage('searchAction.php?q='+theSearch, "searchResults");
}

function validateForm(theForm){
	var valid = new Validation(theForm, {
		onSubmit:false,
		stopOnFirst:true
	});
    var result = valid.validate();
	
	if(result) submitForm(theForm);
}

function submitForm(theForm){
	var theForm = getEl(theForm);
	theForm.target = "helperFrame";
	theForm.submit();
}

var oldDiv = null;
var oldID = null;
var oldDivI;
function openList(ID, theDiv, theImg, divI){

	if(oldDiv){
		closeList(oldID, oldDiv);
	} else{
		getAllPos();
	}
	ajaxpage('openList.php?ID='+ID, theDiv);
	oldDiv = theDiv;
	oldID = ID;
	if(theImg!=null){
		oldDivI = divI;
		bigImg(theImg);
	}
}

function closeList(ID, theDiv){
	ajaxpage('refreshRow.php?ID='+oldID, oldDiv);
	if(oldDivI!=null)getEl('bigImg_' + oldDivI).innerHTML  = "";
	oldDiv = null;
}

function bigImg(theImg){
	ajaxpage('bigImg.php?IMG='+theImg, 'bigImg_' + oldDivI);
}

var coors = new Array();
function getAllPos(){

	for(i=0;i<5;i++){
		var myDiv = getEl("subItem_"+i);
		if(myDiv!=null){
			coors[i] = new Array();
			coors[i] = findPos(myDiv);		
		}
	}

}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function getEl(v) { return(document.getElementById(v)); }
function getS(v) { return(getEl(v).style); }