var pathoxrules = {
	'#submitlogonform' : function () {
		element.onclick = function () {
			Appl.appSendLogon.fire();
			return false;
		};
	},
	'#logonbutton' : function () {
		element.onclick = function () {
			Appl.ForceLogon.fire();
			return false;
		}
	},
	'#logoffbutton' : function () {
		element.onclick = function () {
			//window.alert("logoff clicked");
			Appl.ForceLogoff.fire();
			return false;
		}
	},

	'.logonbutton' : function () {
		element.onclick = function () {
			Appl.appReset.fire();
			return false;
		}
	},	
	'#searchcoll': function () {
		element.onclick = function () {
			Appl.SearchCollections.fire($("searchcollection").value.toString());
		}
	},
	'#searchcollectionform': function () {
		element.onsubmit = function () {
			return false;
		}
	},
	'#searchcollreset': function () {
		element.onclick= function () {
			$('searchcollection').value="";
			Appl.SearchCollections.fire($("searchcollection").value.toString());
		}
	},
	'#searchcollection': function () {
		element.onkeyup = function (val) {
			var pK = document.all? window.event.keyCode:val.which;
			if (pK == "") {
				pK = val.keyCode;
			}
			if (pK== 13 ) {
				Appl.SearchCollections.fire($("searchcollection").value.toString());
				return false;
			}			
		};
	},
	'.cres' : function () {
		element.onclick = function () {
			Appl.currentcollection=this.id.split("_")[3];
			Appl.GetCollection.fire(Appl.currentcollection.toString());
			//Appl.Showcollectiontab_d.fire(Appl.currentcollection);			
		}
	},
	'.vSlide': function () {
		element.onclick = function () {
			Appl.currentcollection=this.id.split("_")[3];
			Appl.cc_slides_startfrom = 1;
			Appl.GetCollectionView.fire(Appl.currentcollection.toString());
			//Appl.DisplayCollection.fire(Appl.currentcollection);
			//Appl.Showcollectiontab_d.fire(Appl.currentcollection);
		};
	},
	'.collectiontab_d' : function () {
		element.onclick = function () {
			Appl.Showcollectiontab_d.fire();
		}
	},
	'.collectiontab_v' : function () {
		element.onclick = function () {
			Appl.Showcollectiontab_v.fire();
		}
	},
	'.collectiontab_g' : function () {
		element.onclick = function () {
			Appl.Showcollectiontab_g.fire();
		}
	},	

	'#startsearch' : function () {
		element.onclick = function () {
			$('startfrom').value=1;
			Appl.startSearch.fire($('form_startsearch').elements,Appl);
		}
	},
	'#backtosearchform': function () {
		element.onclick = function () {
			Appl.showSearchForm.fire(Appl);	
		}
	},
	'#cv_search': function () {
		element.onclick = function () {
			if (!Appl.authRequired) {
			document.title="vCollections";
			}
			var qs = document.URL.split("?");
			if (qs.length > 1) {
			Appl = null;
				window.open(qs[0],"_self");
			} else {
				Appl.showSearchForm.fire(Appl);
			}	
		}
	},
	'.diaglink' : function () {
		element.onclick = function () {
			Appl.getDiagnosis.fire(this.parentNode.id,this.id, this.parentNode.parentNode.firstChild.firstChild.id.split("_")[2], Appl);
			return false;
		}
	},
	'.courseinfolink': function () {
		element.onclick = function () {
			Appl.getCourseinfo.fire(this.parentNode.id,this.id,this.parentNode.parentNode.firstChild.firstChild.id.split("_")[2], Appl);
			return false;
		}
	},
	'#alldiag_linkshow' : function () {
		element.onclick = function () {
			Appl.getAlldiagnoses.fire('', Appl);
			return false;
		}
	},
	'#alldiag_linkhide': function () {
		element.onclick = function () {
			Appl.getAllcourseinfo.fire('', Appl);
			return false;
		}
	},
	'#cc_showmax' : function () {
		element.onchange = function () {
			Appl.cc_slides_maxrows = this.value;
			//window.alert(Appl.cc_slides_showmax);
			Appl.GetCollectionView.fire(Appl.currentcollection.toString());
			return false;
		}
	},
	'.co_link' : function () {
		element.onclick = function () {
		$('startfrom').value = this.id.toString().split("_")[2];
			
			Appl.startSearch.fire($('form_startsearch').elements,Appl);
			return false;
		}
	},
	'#co_showmax' : function () {
		element.onchange = function () {
			$('maxrows').value = this.value;
			//window.alert(Appl.cc_slides_showmax);
			Appl.startSearch.fire($('form_startsearch').elements,Appl);
			return false;
		}
	},
	'.cc_link' : function () {
		element.onclick = function () {
		Appl.cc_slides_startfrom = this.id.toString().split("_")[2];
			
			Appl.GetCollectionView.fire(Appl.currentcollection.toString());		
			return false;
		}
	},
	'.even' : function () {
		element.onmouseover = function () {
			this.className="even hover";
		};
		element.onmouseout = function () {
			this.className="even";
		};
		element.onclick = function () {
			if (this.parentNode.id == 'gcollectionlist1' && Appl.authRequired == false) {
				Appl.cc_slides_startfrom = 1;
				Appl.GetCollectionView.fire(this.id.split("_")[1],Appl);
			}
		}
	},
	'.odd' : function () {
		element.onmouseover = function () {
			this.className="odd hover";
		};
		element.onmouseout = function () {
			this.className="odd";
		};
		element.onclick = function () {
			if (this.parentNode.id == 'gcollectionlist1' && Appl.authRequired == false) {
				Appl.cc_slides_startfrom = 1;
				Appl.GetCollectionView.fire(this.id.split("_")[1],Appl);
				return false;
			}
		}
	},
	'#mode_t': function () {
		element.onclick = function () {
			Appl.cc_mode='T';
			Appl.GetCollectionView.fire(Appl.currentcollection.toString());
		}
	},
	'#mode_i': function () {
		element.onclick = function () {
			Appl.cc_mode='I';
			Appl.GetCollectionView.fire(Appl.currentcollection.toString());
		}
	},
	'#resetsearch' : function () {
		element.onclick = function () {
			$('search_collectiontype').options[0].selected = true;
			$('search_targetgroup').options[0].selected = true;
			$('search_organizer').options[0].selected = true;
			$('search_topogroup').options[0].selected = true;
			$('searchcollection_text').value="";
			Appl.startSearch.fire($('form_startsearch').elements,Appl);
		}
	}
}
//-------------------------------------------------------------------------------------------------
var pathoxrules_mod = {
	'#checkit' : function () {
		element.onclick = function () {
			Appl.getAllCGs.fire();
			return false;
		}
	},
	'.deleteCG' : function () {
		element.onclick = function () {
			if (window.confirm("do you really want to delete this CollectionGroup?")) {
				Appl.DeleteCG.fire(parseInt(this.id.split("_")[1]));
			}
			return false;
		}	
	},
	'.addCG' : function () {
		element.onclick = function () {
			Appl.showAddCG.fire(parseInt(this.id.split("_")[1]));
			return false;
		}	
	},
	'.editCG' : function () {
		element.onclick = function () {
			Appl.showEditCG.fire(parseInt(this.id.split("_")[1]));
			return false;
		}	
	},
	'.add_save' : function () {
		element.onclick = function () {
			var ar = new Array();

			if ($('addCG0_name').value.length > 0 ) {
			var dmy = $('addCG0_comment');
				ar[0]=$('addCG0_name').value;
				ar[1]=$('addCG0_parent').value;
				ar[2]=dmy.value;
				ar[3]=$('addCG0_so').value;
				Appl.AddCG.fire(ar);	
			}
		}
	},
	'.edit_save' : function () {
		element.onclick = function () {
				if ($('editCG0_name').value.length > 0 ) {
					var dmy = $('editCG0_comment');			
					var ar = new Array();
					ar[0]=$('editCG0_name').value;
					ar[1]=dmy.value;
					ar[2]=$('editCG0').parentNode.getElementsByTagName("a")[0].id.split("_")[1];
					ar[3]=$('editCG0_so').value;
					Appl.EditCG.fire(ar);
				}		
		}
	},
	'.deletecollection' : function () {
		element.onclick=function() {
			if (window.confirm("do you really want to delete the collection with ID " + this.id.split("_")[3] + "?" )) {
				Appl.DeleteCollection.fire(this.id.split("_")[3],Appl);
			}
		}
	},
	'.editcollection': function () {
		element.onclick=function() {
			//if (Appl.currentcollection !=this.id.split("_")[3]) {
				Appl.currentcollection=this.id.split("_")[3];	
				Appl.GetCollection.fire(Appl.currentcollection.toString());
			//}
			//Appl.Showcollectiontab_d.fire();
			
		}
	},
	'.duplcollection': function () {
		element.onclick=function() {
			//if (Appl.currentcollection !=this.id.split("_")[3]) {
				Appl.duplCol.fire(this.id.split("_")[3]);
			//}
			//Appl.Showcollectiontab_d.fire();
			
		}
	},

	'.editslidecollection': function () {
		element.onclick=function() {
			//if (Appl.currentcollection !=this.id.split("_")[3]) {
				Appl.currentcollection=this.id.split("_")[3];	
				Appl.GetCollectionv.fire(Appl.currentcollection.toString());
			//}
			//Appl.Showcollectiontab_v.fire();
		}
	},
	'#addCG0_name' : function () {
		element.onkeypress = function (e) {
			if (e.which == 13 || e.keyCode == 13) {
			if ($('addCG0_name').value.length > 0 ) {
			var dmy = $('addCG0_comment');			
			var ar = new Array();
			ar[0]=$('addCG0_name').value;
			ar[1]=$('addCG0_parent').value;
			ar[2]=dmy.value;
			Appl.AddCG.fire(ar);
			}
			} 
			if (e.which == 27 || e.keyCode == 27) {
			Appl.CancelAddCG.fire();
			}
		}
	},
	'#editCG0_name' : function () {
		element.onkeypress = function (e) {
			if (e.which == 13 || e.keyCode == 13) {
				if ($('editCG0_name').value.length > 0 ) {
					var dmy = $('editCG0_comment');			
					var ar = new Array();
					ar[0]=$('editCG0_name').value;
					ar[1]=dmy.value;
					ar[2]=$('editCG0').parentNode.getElementsByTagName("a")[0].id.split("_")[1];
					//window.alert($('editCG0').parentNode.getElementsByTagName("a")[0].id.split("_")[1]);
					Appl.EditCG.fire(ar);
				}
			} 
			if (e.which == 27 || e.keyCode == 27) {
				Appl.CancelEditCG.fire();
			}
		}
	},

	'.cancelCGcreation' : function () {
		element.onclick = function () {
			Appl.CancelAddCG.fire();
		}
	},
	'.treenodeLink' : function () {
		element.onclick = function () {
			if (this.parentNode.parentNode.className.search(/root/) <=0) {
				var id = this.id.split("_")[1];
				Appl.getCollections.fire(id.toString());
				element.className="active";
			}
			return false;
		}
	},
	'.cgtree' : function () {
		element.onclick = function () {
			return false;
		}
	
	},
	'#navcollectiongroups' : function () {
		element.onclick = function () {
			Appl.getAllCGs.fire();
			return false;
		}
	},
	'.addcollection' : function () {
		element.onclick = function () {
			Appl.AddCollection.fire(Appl.CurrentCG);
			return false;
		}
	},
	'#savecollection1' :function () {
		element.onclick = function () {
			var params = $('c_editform1').elements;
			Appl.SaveCollection.fire(params);
			return false;
		}
	},
	'#collectionmenu': function() {
		element.onclick=function() {
			Appl.ShowCollections.fire(Appl);
		}
	},
	'#collectiongroupsmenu': function() {
		element.onclick = function () {
			Appl.getAllCGs.fire(Appl);
		}
	},
	'.cgc_grouping' : function () {
		element.onclick = function () {
			if (this.checked) {
				Appl.AddCGtoCol.fire(this.id.split("_"));
				this.parentNode.className="cgc_grouping_selected";
			} else {
				Appl.RemoveCGfromCol.fire(this.id.split("_"));
				this.parentNode.className="";
			}
			return true;
		};
	},	
	'#addslidescoll_a' : function () {
		element.onclick = function () {
			$('addslidescoll_input').value="";
			$('addslidescoll_form').className="visible";
			$('addslidescoll_text').className="hidden";
		};
	},	
	'#addslidescoll_button' : function () {
		element.onclick = function () {
			//$('addslidescoll_form').className="hidden";
			//$('addslidescoll_text').className="visible";
			if ($('addslidescoll_input').value.toString().search(/\./)>0) {
				var tstr = $('addslidescoll_input').value.split(".");
			} else {
				if ($('addslidescoll_input').value.toString().search(/,/)>0) {
					var tstr = $('addslidescoll_input').value.split(",");
				} else {
					tstr = $('addslidescoll_input').value;
				}	
			}
			
			var tar = "";
			var co_id =Appl.currentcollection;
			if (typeof(tstr)=="object") {
			for (i = 0, len = tstr.length; i < len; i++) {
				tstr[i] = tstr[i].replace(/ /,"");
				tstr[i]=parseInt(tstr[i]);
				if (!isNaN(tstr[i])) {
					tar+=","+tstr[i];
				}
			}
			} else {
				//window.alert(typeof(tstr));
				tar = tstr;
			}
			len = null;
			if (tar.length > 0 && co_id > 0) {
				$('addslidescoll_input').value="";
				addslidescoll(co_id, tar,Appl);
			} else {
				//window.alert(tar, co_id);
			}
			
			//window.alert(tar);
		};
	},
	'.ce_search': function () {
		element.onclick = function () {
			Appl.showSearchForm.fire(Appl);	
		}
	},
	'.cgtreeroot' : function () {
		element.onclick = function () {
			var tr = CGTree;
			tr.resetBranches();			
			for (var nde in tr.nodeRefs) {
				if (nde.split("_").length ==4) {
					tr.toggleBranch([nde],true);
				}
			}
		}
	},
	'.dropslide' : function () {
		element.onclick = function () {
			if (!Appl.editingcolslide) {
				var tmpslideid = this.parentNode.parentNode.id.split("_")[1];
				var pos = this.id.split("_")[1];
				pos ++;
				if (window.confirm("do you really want to drop vSlide " + tmpslideid + " on position "+ pos+" from this collection?")) {
					Appl.dropSlide.fire(this.id.split("_")[3],Appl);
				}
				return false;
			}
		}
	},
	'.editslide' : function () {
		element.onclick = function () {
			if (!Appl.editingcolslide) {
			Appl.editSlide.fire(this.id);
			}
			return false;	
		}
	},
	'.duplslide': function () {
		element.onclick = function () {
			if (!Appl.editingcolslide) {
				Appl.duplSlide.fire(this.id);
			}
			return false;	
		}
	},
	'.duplslide_notactive': function () {
		element.onclick = function (){
			return false;
		}
	},
	'.editslide_notactive': function () {
		element.onclick = function (){
			return false;
		}
	},
	'.dropslide_notactive': function () {
		element.onclick = function (){
			return false;
		}
	},
	'#csedit_save' : function () {
		element.onclick = function () {
			Appl.saveSlide.fire(Appl);
		}
	},
	'#cs_canceledit': function () {
		element.onclick = function () {
			Appl.cancelSlide.fire(Appl);
		}
	},
	'#topogroupremove': function () {
		element.onclick = function () {
			for (var i = 0; i <$('topogroupselected').length;i++) {
				if ($('topogroupselected')[i].selected == true) {
					$('topogroupselected')[i]=null;
				}
			}
		}
	},
	'#topogroupadd': function () {
		element.onclick = function () {
			for (var i = 0; i <$('topogroupavailable').length;i++) {
				if ($('topogroupavailable')[i].selected == true) {
					//$('topogroupavailable')[i]=null;
					var tmpo = new Option($('topogroupavailable')[i].text,$('topogroupavailable')[i].value);
					var enthalten=false;
					for (var j = 0;j<$('topogroupselected').length;j++) {
						if ($('topogroupavailable')[i].value==$('topogroupselected')[j].value) {
							enthalten=true;
						}
					}
					if (enthalten == false) {
						$('topogroupselected')[$('topogroupselected').length]=tmpo;
					}
				}
			}
		}
	},
	'#topogroupselected': function () {
		element.ondblclick = function () {
			for (var i = 0; i <$('topogroupselected').length;i++) {
				if ($('topogroupselected')[i].selected == true) {
					$('topogroupselected')[i]=null;
				}
			}
		}
	},
	'#topogroupavailable': function () {
		element.ondblclick = function () {
			for (var i = 0; i <$('topogroupavailable').length;i++) {
				if ($('topogroupavailable')[i].selected == true) {
					//$('topogroupavailable')[i]=null;
					var tmpo = new Option($('topogroupavailable')[i].text,$('topogroupavailable')[i].value);
					var enthalten=false;
					for (var j = 0;j<$('topogroupselected').length;j++) {
						if ($('topogroupavailable')[i].value==$('topogroupselected')[j].value) {
							enthalten=true;
						}
					}
					if (enthalten == false) {
						$('topogroupselected')[$('topogroupselected').length]=tmpo;
					}
				}
			}
		}
	}
};

Behaviour.register(pathoxrules);
