var stPage = {
	max_links:1000, 	
	navs:{}, 	
	msg:{},
	widgets:{},	
	triggers:[], 
	
	init:function(){
		var t=stPage, i, type, id, ids = {c:'container', d:'display'};
		t.containers = [];
		t.triggers = [];		
		for (type in ids) {
			for (i=0; i<t.max_links; i++){
				id = ids[type] + '_' + i;
				if ($(id)) {
					if (type == 'c') t.containers.push(id);
					t.triggers.push(id);	
				}
			}
		}
		
		//tip.init(t.triggers);
		act.init();
		
	}
	
};


var act = {	
		
		acts:{}, hidIDs:{}, idHids:{}, placeHolders:{},
		selectColor:'#900000',	actTag:'a',	actClass:'el_ah',
		hPattern:/act.show_h\([\"\']([^\"\']+)[\"\'][^\"\']+[\"\']([^\"\']+)[\"\']\)/, tPattern:/act.show_t\([\"\']([^\"\']+)[\"\']\)/,
		
		init:function(){
			act.makeActLists();
		},
		
		makeActLists:function(){
			
			var t=act, arr, args, i, id, str;
			
			t.acts = {};
			t.hidIDs = {};
			t.idHids = {};
			t.placeHolders = {};
			
			for (str in stPage.containers){
				arr = getElementsByClassName($(stPage.containers[str]), t.actTag, t.actClass);				
				for (i =0; i<arr.length; i++) {
					args = t.hArguments(arr[i]);
					if (args.d && args.h) {
						if (!t.acts[args.d]) {
							t.acts[args.d] = [];
							t.hidIDs[args.d] = {};
							t.idHids[args.d] = {};
							t.placeHolders[args.d] = $(args.d) && $('nav_' + args.d) ? $('nav_' + args.d) : null;
						}
						
						if (!t.hidIDs[args.d][args.h]){
							t.acts[args.d].push(arr[i]);
							id = t.acts[args.d].length - 1;
							t.hidIDs[args.d][args.h] = id ;
							t.idHids[args.d][id] = args.h;
						}
					}
				
				}
			}
			
			for (str in t.acts) {
				if (t.acts[str][0]) {				
					t.acts[str][0].onclick();
				}
				
			}
			
		},
		
		hArguments:function(act){
			var obj = {d:'', h:''}, matches;
			if (act.onclick) {				
				matches = act.onclick.toString().match(this.hPattern);
				if (matches[1] && matches[2]) {
					obj = {d:matches[1], h:matches[2]};		
				}
			}
			return obj;
		},
		
		tArguments:function(act){
			if (act.onmouseover) {
				var matches = act.onmouseover.toString().match(this.tPattern);
				if (matches[1]) return matches[1];
			}
			return '';
		},
		
		
		show_h:function(d, h){
			
			var t=this, str, display=$(d), hidden = $(h),  nav='', id=-1;
			
			if (display) {
				display.innerHTML = hidden ? hidden.innerHTML : '';
			}
			
			if (t.acts[d]){
				
				for (str in t.acts[d]){
					t.acts[d][str].style.color = '';
				}
				if (t.hidIDs[d][h] != null && t.acts[d].length > 1) {
					id=t.hidIDs[d][h];
					t.acts[d][id].style.color = t.selectColor;	
				}
			}
			
			if (t.placeHolders[d]) {
				if (t.acts[d].length>1 && id != -1) {
					if (id > 0) nav += '&lt;&lt; <a href="javascript:void(0);" onClick="act.show_h(\''+d+'\', \''+t.idHids[d][id-1]+'\');">'+stPage.msg['PREVIOUS_PAGE']+'</a>&nbsp;';
					if (id < t.acts[d].length - 1) nav += '<a href="javascript:void(0);" onClick="act.show_h(\''+d+'\',\''+t.idHids[d][id+1]+'\');">'+stPage.msg['NEXT_PAGE']+'</a> &gt;&gt;';
				}
				t.placeHolders[d].innerHTML = nav;
			}
		},
		
		show_t:function(tip){
			if (tip) startTip($(tip).innerHTML);
			else stopTip();
		},
		show_st:function(){
			startStatTip();
		}
		
};

addLoadEvent(stPage.init);
