/*
	STORAGE SECTION FUNCTIONALITY
*/

//////////////////////////////
//	GET ALL DIRECTORIES			//
//////////////////////////////

function getAllDirs( dateStr, searchStr ) {
	displayDiv = "allDirs";
	e = getE( "allDirs" );
	e.innerHTML = "<img src='/admin/_img/animatedLoader.gif' />";
	str = "getAllDirs.php";
	if ( dateStr || searchStr ) str+= "?dateStr=" + dateStr + "&search=" + searchStr;
	getPage( displayDiv, str );
}

//////////////////////////////
//	GET USEAGE FOR _ALL_		//
//////////////////////////////

function doAllDirs() {
	for ( a in dirList ) {
		getStorage( dirList[a], a );
	}
}

//////////////////////////////
//	GET USAGE DATA					//
//////////////////////////////

function getStorage( dir, div ) {
	e = getE( div );
	e.innerHTML = "working...";
	
	displayDiv = div;
	getPage( displayDiv, "getStorage.php?dir=" + dir );
}

//////////////////////////////
//	GET IGNORE LIST					//
//////////////////////////////

var showIgnore = false;
function getIgnoreList() {
	e = getE( "ignoreListDiv" );
	if ( !showIgnore ) {
		e.innerHTML = "working...";
		displayDiv = "ignoreListDiv";
		getPage( displayDiv, "getIgnoreList.php" );
		showIgnore = true;
	}
	else {
		e.innerHTML = "";
		showIgnore = false;
	}
}

//////////////////////////////
//	CONFIRM WHETHER TO ADD	//
//	TO THE INGORE LIST			//
//////////////////////////////

function confirmIgnore( id, dir, val ) {
	e = getE( id );
	if ( val == 0 ) { // ASK FOR CONFIRMATION
		e.innerHTML = "<a href='#' onclick='confirmIgnore( \"" + id + "\", \"" + dir + "\", 1 ); return false;'>Really?</a> | <a href='#' onclick='confirmIgnore( \"" + id + "\", \"" + dir + "\", 2 ); return false;'>Oop!  No!</a>";
	}
	else if ( val == 1 ) { // YES
// 		alert( dir );
		getAddDir( dir );
	}
	else {
		e.innerHTML = "<a href='#' onclick='confirmIgnore( \"" + id + "\", \"" + dir + "\", 0 ); return false;'>Add to Ignore List</a>";
	}
}

//////////////////////////////
//	ADD TO THE IGNORE LIST	//
//////////////////////////////

function getAddDir( dir ) {
	showIgnore = ( showIgnore ) ? false : true;
	getPage( false, "getAddDir.php?dir=" + dir, "getAllDirs();" );
}

//////////////////////////////
//	REMOVE FROM IGNORE LIST	//
//////////////////////////////

function getRemoveDir( id ) {
	showIgnore = ( showIgnore ) ? false : true;
	getPage( false, "getRemoveDir.php?id=" + id, "getAllDirs();" );
}