function Viewer () {
	
}
Viewer.prototype.startSandglass = function (fct,params,me) {
	//dump("start from "+fct+'\n');
	$('sandglass').className="visible";
}

Viewer.prototype.stopSandglass = function (fct,params,me) {
	//dump("stop from "+fct+'\n');
	$('sandglass').className="hidden";
}


Viewer.prototype.showDiv = function (elementID) {
if ($('gcollectiondisplay').className=='') {
		$('gcollectiondisplay').className='hidden';
	}

	var divs = document.getElementsByTagName("div");
	for (var i = 0, len = divs.length; i <len ;i=i+1) {
		if (divs[i].id == elementID) {
			divs[i].className = "visible";
		} else {
			if (divs[i].id != "sandglass") {
				if (divs[i].className.search(/visible/) != -1) {
					divs[i].className = divs[i].className.replace(/visible/,"hidden");
				}
			}
		}
	}
	len = null;
}

Viewer.prototype.resetNavigation = function (dummy) {
	DeleteChildren($('navigation'));
	$('navigation').innerHTML = " ";
}

Viewer.prototype.addNavigation = function (text,id,className) {
	DeleteChildren($('navigation'));
	$('navigation').innerHTML = 	$('navigation').innerHTML + " &gt; <a id=\"" + id + "\" class=\"" + className + "\" href=\"#\">" + text + "</a>&nbsp;";
	Behaviour.apply("Viewer.prototype.addNavigation");
}


Viewer.prototype.onAppReset = function (fct,params,me) {
	me.viewer.resetNavigation();
};

Viewer.prototype.onSendLogon = function (fct,params,me) {
	this.viewer.startSandglass(fct, params, me);
};

Viewer.prototype.onShowLogon = function (fct,params,me) {
	//$('errorboxlogon').className = "hidden";
	this.viewer.addNavigation("logon","navlogon");
	this.viewer.showDiv("loginform");
	$('username').focus();
};


Viewer.prototype.onLogonReturn = function() {
	//this.viewer.stopSandglass();
	clearTable('vcolslides');
	clearTable('gcollectionlist');
	clearTable('collectionlist');
	clearTable('vcolslides_v');
}

Viewer.prototype.onAuthError = function (fct,params,me) {
//	this.viewer.showDiv("loginform");
	$('username').focus();
	this.viewer.stopSandglass(fct,params,me);
	$('errorboxlogon').innerHTML = me.authError;
	$('errorboxlogon').className = "errorbox";
	//this.viewer.showDiv("errorbox");
};
Viewer.prototype.onStartWork = function () {
	
};

Viewer.prototype.onGetCollections = function (fct,params,me) {
	this.viewer.startSandglass(fct, params, me);
	this.viewer.showDiv("cgtreelist");
}

Viewer.prototype.onGetCollectionsReturn = function (fct,params,me) {
	this.viewer.addNavigation("Collections","navcollections");
	this.viewer.stopSandglass();
	//this.viewer.showDiv("collectionlist");
	$('gcollectiondisplay').className=$('gcollectiondisplay').className.replace(/hidden/,'');
	//window.alert($('gcollectiondisplay').className);
}

Viewer.prototype.onAllCGsReturn = function (fct,params,me) {
	this.viewer.stopSandglass();
	this.viewer.showDiv("cgtreelist");
	this.viewer.addNavigation("Collectiongroups","navcollectiongroups");
}

Viewer.prototype.ongetAllCGs = function (fct,params,me) {
	this.viewer.startSandglass(fct, params, me);
	this.viewer.resetNavigation();
}



Viewer.prototype.onshowAddCG = function () {

};

Viewer.prototype.onAddCG = function () {

};

Viewer.prototype.onAddCGReturn = function () {

};

Viewer.prototype.onShowCollections = function () {
	this.viewer.stopSandglass(fct, params, me);
	this.viewer.showDiv("collectiondisplay");
};


Viewer.prototype.onAddCollection = function (fct,params,me) {
	this.viewer.showDiv("collection_d");
	this.viewer.addNavigation("New Collection");
};

Viewer.prototype.onSearchCollections = function (fct,params,me) {
	this.viewer.startSandglass(fct, params, me);
	this.viewer.showDiv("collectiondisplay");

}
Viewer.prototype.onSearchCollectionsReturn = function (fct,params,me) {
	this.viewer.stopSandglass(fct, params, me);
	this.viewer.showDiv("collectiondisplay");

}

Viewer.prototype.onEditCollection = function (fct, params, me) {
return true;
}

Viewer.prototype.onEditSlideReturn = function (fct, params, me) {
	$('cs_title').focus();
	//window.alert("focus should be on edit title");
}


Viewer.prototype.onGetCollection = function (fct, params, me) {
	this.viewer.startSandglass(fct, params, me);
}
Viewer.prototype.onGetCollectionReturn = function (fct, params, me) {
	//this.viewer.stopSandglass(fct, params, me);
	
	//this.viewer.showDiv("collection_d");
}

Viewer.prototype.onGetCollectionView = function (fct, params, me) {
	$('vcolslides_v').className="hidden";
	this.viewer.startSandglass(fct, params, me);
}
Viewer.prototype.onGetCollectionViewReturn = function (fct, params, me) {
	if (params[0] != 'no result') {
		this.viewer.stopSandglass(fct, params, me);
		this.viewer.showDiv("collectionview");
	}
}


Viewer.prototype.onShowcollectiontab_g = function (fct, params, me) {
	this.viewer.stopSandglass(fct, params, me);
	this.viewer.showDiv("collection_g");	
}

Viewer.prototype.onShowcollectiontab_v = function (fct, params, me) {
	this.viewer.stopSandglass(fct, params, me);
	this.viewer.showDiv("collection_v");
	var tmp=$('addslidescoll_input');
	tmp.focus();
	//if(this.authRequired) {
		//$('addslidescoll_input').tabindex ="1";
		
	//}	
}

Viewer.prototype.onShowcollectiontab_d = function (fct, params, me) {
	this.viewer.stopSandglass(fct, params, me);
	this.viewer.showDiv("collection_d");	
}

Viewer.prototype.onAddCGtoCol = function (fct, params, me) {
	this.viewer.startSandglass(fct, params, me);
}

Viewer.prototype.onAddCGtoColReturn = function (fct, params, me) {
	this.viewer.stopSandglass(fct, params, me);
}

Viewer.prototype.onRemoveCGfromCol = function (fct, params, me) {
	this.viewer.startSandglass(fct, params, me);
}

Viewer.prototype.onRemoveCGFromColReturn = function (fct, params, me) {
	this.viewer.stopSandglass(fct, params, me);
}

Viewer.prototype.onStartSearch = function (fct, params, me) {
	this.viewer.startSandglass(fct, params, me);
}
Viewer.prototype.onStartSearchReturn = function (fct, params, me) {
	this.viewer.stopSandglass(fct, params, me);
}
Viewer.prototype.onShowSearchForm = function (fct, params, me) {
	this.viewer.stopSandglass(fct, params, me);
	this.viewer.showDiv("searchform");
}


Viewer.prototype.onAppGetLookupDataReturn = function (fct, params, me) {
	this.viewer.stopSandglass(fct, params, me);
}
Viewer.prototype.onAppGetLookupData = function (fct, params, me) {	
	this.viewer.startSandglass(fct, params, me);
}

Viewer.prototype.onShowSearchResult = function (fct, params, me) {
		//this.viewer.showDiv("gcollectiondisplay");
		this.viewer.showDiv("searchform");
}

Viewer.prototype.onGetCollectionvSlidesTableReturn = function (fct, params,me) {
		this.viewer.stopSandglass(fct,params,me);	
}

Viewer.prototype.onGetCollectionvSlidesTable = function (fct, params,me) {
this.viewer.startSandglass(fct,params,me);
}
