function show_hide_column(tableID,col_no)
{
    var tbl  = document.getElementById(tableID);
    var rows = tbl.getElementsByTagName('tr');

    var stl;
    do_show=rows[0].getElementsByTagName('td')[col_no].style.display;
//  alert("Changig from ["+do_show+"]");
    if (do_show == 'none')
        stl = '';
    else
        stl = 'none';

//  alert("Changing to ["+stl+"]");

    for (var row=0; row<rows.length;row++) {
        var cels = rows[row].getElementsByTagName('td')

        cels[col_no].style.display=stl;
    }
}



function showHideMenu(thisID,thatID)
{
	showHideMenu2(thisID,thatID,'inline');
}

function showHideMenu2(thisID,thatID,visible)
{
        var e = document.getElementById(thisID);
		var e2;
		if (thatID != null)
	        e2 = document.getElementById(thatID);
        if (e.style.display == 'inline' || e.style.display=='' || e.style.display == visible) {
                e.style.display = 'none';
				if (thatID!=null)
					e2.style.display=visible;
        } else {
                e.style.display = visible;
				if (thatID!=null)
					e2.style.display='none';
        }
}

function showDisplayStyle(thisID)
{
    var e = document.getElementById(thisID);
    var ss=e.style.display;
	alert("style = ["+ss+"]");
 }

function showHideTbody(thisID)
{
    var e = document.getElementById(thisID);
    bVis=(e.style.display == 'none');
    if (bVis) {
    	try {
	    	e.style.display='table-row-group';
	    } catch(eee) {
	        e.style.display = 'block';
        }
    } else {
        e.style.display = 'none';
    }
}


function showHideAdvanced()
{
    var e = document.getElementById("advanced");
    bVis=!(e.style.display == 'inline');
    if (bVis)
        e.style.display = 'inline';
    else
        e.style.display = 'none';
}

function popupPage(url)
{
    window.open(url);
}

function deletePage(id)
{
    var answer=confirm("Are you sure you want to delete this page?");
    if (answer) {
        window.location='menu.php?Delete=true&id='+id;
    }
}

function confirmDelete()
{
    var agree=confirm("Are you sure you want to delete this user?");
    if (agree)
        return true ;
    else
        return false ;
}

function confirmDeleteFile(filename)
{
    var agree=confirm("Are you sure you want to delete this file '"+filename+"'?");
    if (agree) {
		document.actionForm.fileName.value=filename;
		document.actionForm.actionName.value='delete';
		document.actionForm.submit();
	}
    else
        return false ;
}

function actionOnFile(filename,action)
{
	document.actionForm.fileName.value=filename;
	document.actionForm.actionName.value=action;
	document.actionForm.submit();
}

function actionConfirm(item,action,question)
{
	var agree=confirm(question);
	if (agree) {
		document.actionForm.itemName.value=item;
		document.actionForm.actionName.value=action;
		document.actionForm.submit();
	} else 
		return false;
}


function doAction(item,action)
{
//	alert("Action ["+action+"] on item ["+item+"]");
//	return false;
	
	document.actionForm.itemName.value=item;
	document.actionForm.actionName.value=action;
	document.actionForm.submit();
}

function doActionGET(item,action)
{
//	alert("Action ["+action+"] on item ["+item+"]");
//	return false;
	
	document.actionForm.itemName.value=item;
	document.actionForm.actionName.value=action;
	document.actionForm.method='get';
	document.actionForm.submit();
}


function action(item,action) //TODO: Deprecated
{
//	alert("Action ["+action+"] on item ["+item+"]");
//	return false;
	
	document.actionForm.itemName.value=item;
	document.actionForm.actionName.value=action;
	document.actionForm.submit();
}

function action3(item,action,item2)
{
//	alert("Action ["+action+"] on item ["+item+"]:["+item2+"]");
//	return false;

	document.actionForm.itemName.value=item;
	document.actionForm.itemName2.value=item2;
	document.actionForm.actionName.value=action;
	document.actionForm.submit();
}


function showPhoto2(file,width,height)
{
	if (width==null)
		width=500;
	if (height==null)
		height=550;
	window.open(file,'Photo','width='+width+',height='+height+',toolbar=no,titlebar=no,status=no,statusbar=no,menubar=no');
}

function showPhoto(pid,gid,width,height)
{
	if (width==null)
		width=500;
	if (height==null)
		height=550;
	window.open("?p="+pid+"&g="+gid,'Photo','width='+width+',height='+height+',toolbar=no,titlebar=no,status=no,statusbar=no,menubar=no');
}

function selectAllCheckboxes(formname,value,skippy) {
	for(var i=0 ; i<formname.elements.length ; i++) {
		var e = formname.elements[i];
		if (skippy!=null && skippy==e.name)
			continue;
		if (e.type == 'checkbox') {
			e.checked=value;
		}
	}
}

function selectCheckboxesByName(formname,value,name) {
	for(var i=0 ; i<formname.elements.length ; i++) {
		var e = formname.elements[i];
		if (name==null || e.name.indexOf(name)!=0)
			continue;
		if (e.type == 'checkbox') {
			e.checked=value;
		}
	}
}





