
//alert("huhu");


/*****************************************************
*/ function __P___Language() {}
/******************************************************/
 
lang = 'de';
lang_show_failed_keys = '';

if(typeof INT != 'object') INT = new Object();
/*INT['firstname'] = new Object();
INT['firstname']['de'] = 'Vorname';
INT['firstname']['en'] = 'First Name';*/

function $L(key) {
	
	this.lang = lang;
	this.def_lang = 'en';
	
	if(!INT[key]) {
		return key+lang_show_failed_keys;
	} else if(INT[key]) {
		if(INT[key][this.lang]) return INT[key][this.lang];
		else if(INT[key][this.def_lang]) return INT[key][this.def_lang];
		else return key+lang_show_failed_keys;
	} else return key+lang_show_failed_keys;
}


function ShowAlert() {
	return false;
}

/* Menu Functions */

//---------------------------------------------------------------------------------------
//-- Menu Functions ---------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function Interface () {
	
	this.window = false;
	this.title = '';
	
	this.init = function() {
		// quicksearch, submit on return
		/*if(qs = document.getElementById('quicksearch')) {
			this.quicksearchEL = document.getElementById('quicksearch');
			this.addEvent(qs,'keydown',this.quicki = function(event) {this.quicksearch(event);}.bind(this));
		}*/ // done with submit button
		
		//this.setFooter();
		//this.linkExternalLinks();
		
		//if(!this.window) this.buildWindow();
		
		/*if($('search-q')) {
			$('search-q').focus();
		}*/
		
		this.overlays = 'ext'; //lightview / ext
		
	}

	this.setLang = function(lang) {
		// simple
		document.location.href = '/'+lang+myPlainPagePath;		
	}
	
	this.quicksearch = function(event) {
		if(event.keyCode != 13) return;
		this.do_search();
	}
	
	this.do_search = function() {
		document.location.href = '/suche/'+this.quicksearchEL.value;
	}
	
	this.donotinterruptsubmits = function() {
		this.coverbackground('visible',0.8);
		// get sid
		PA = new ProgressAnimation();
		PA.viewProgress(this.cover,false,'Bild wird geladen',false,0.5);
	}
	
	this.jumpTo = function(path) {
		window.open(path);
	}

	//---------------------------------------------------------------------------------------
	this.adjustSize = function(r) {
		sizeUnit = "%";
		defaultSize = 100;
		maxSize = 160;
		minSize = 98;	
	}


	//---------------------------------------------------------------------------------------
	this.loginOperation = function(operation,formname) {
		//alert();
		document.forms[0].operation.value = operation;
		document.forms[0].onsubmit(); // workaround browser bugs.
		document.forms[0].submit();
	}
	
	//---------------------------------------------------------------------------------------
	this.logout = function() {
		document.forms['iflogin'].operation.value = '[logout]';
		document.forms['iflogin'].action = '/';
		document.forms['iflogin'].onsubmit(); // workaround browser bugs.
		document.forms['iflogin'].submit();
	}	
	//---------------------------------------------------------------------------------------
	this.toggleMode = function() {
		if(mode) mode_value = mode;
		else if (document.getElementById('list_rdbms')) mode_value = "admin";
		else mode_value = "browse";
		//mode_el = document.getElementById("mymode");
		switch (mode_value) {
			case"admin":
				document.getElementById("mymode").value = 'browse';
				//mode_value = document.getElementById("mymode").value;
				break;
			case"browse":
				document.getElementById("mymode").value = 'admin';
				//mode_value = document.getElementById("mymode").value;
				break;			
		}
		//alert(document.getElementById("mymode").value);
		document.forms['iflogin'].onsubmit(); // workaround browser bugs.
		//DebugDump(document.forms['iflogin'],'document.forms ');
		document.forms['iflogin'].submit();
	}
	
//---------------------------------------------------------------------------------------
/*	this.toggleView = function(elId,force) {
		if(!$(elId)) return false;
		if($(elId).style.display == 'none') $(elId).style.display = '';
		else $(elId).style.display = 'none';
	}*/
	
	this.toggleView = function(elId,force) {
		if(!elId) return false;
		if(document.getElementById(elId).style.display == 'none') document.getElementById(elId).style.display = '';
		else document.getElementById(elId).style.display = 'none';
	}

	//---------------------------------------------------------------------------------------

	this.linkExternalLinks = function() {
		if(is_phpos_environment) return;
		//return;
		 var links = document.getElementsByTagName('A');
		 for (var i=0; i<links.length; i++) { 
		  // var anchor = anchors[i]; 
		  var v = links[i].getAttribute("href");
		  var c = links[i].getAttribute("onclick");
		  
		   if (!c
		   && v
		   && v.indexOf('http') != -1) {
			 //DebugDump(c,'external link found');
			 //DebugDump(v,'external link found');
			 //this.addEvent(document,'click',function() {return false;}.bind(this));
			 links[i].setAttribute('target',"_blank");
			}
			
			 
		 } 

		/*links = document.getElementsByTagName('A');
		for(i=0;i<links.length;i++) {
			var atts = links[i].attributes;//getAttribute('href');
			DebugDump(atts,'external link found');
			for(p=0;p<atts.length;p++) {
				DebugDump(atts[p],''+p);
			}		
		}*/
	}

	this.jumpToExternalLink = function(myUrl,myName,hitId,hitName) {
	
		var jumpPage = "/link/external";
		var path = myUrl;
		jumpPage = jumpPage+"?path="+path;
		if ((hitName && hitName.length > 0) && (hitName && hitName.length >0)) jumpPage = jumpPage+"&object_id="+hitId+"&object_name="+hitName;
		mywin = window.open(jumpPage,myName);
		mywin.focus();
		
	}

	// browser
	//---------------------------------------------------------------------------------------
	this.browserSubmit = function(v,i,eidb,formname) {
		//alert('huhu'); return;
		if(!formname) formname = 'contentform';
		document.getElementById(i).value = v;
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();
	}

	this.setDirPath = function(id,order_dir,eidb) {
		document.getElementById(eidb+'order').value = id;
		this.browserSubmit(order_dir,eidb+'order_dir');
	} 
		
	this.changeDirPath = function(id,order_dir,eidb) {
		img_path = '/images_admin/embedded_browser/';
		document.getElementById(eidb+'order').value = id;
		switch(order_dir) {
			case"desc":
				document.getElementById(id+'_order_dir_dot').src = img_path+"asc_blue_dot.gif";
				order_change = 'asc';
			break;
			case"asc":
				document.getElementById(id+'_order_dir_dot').src = img_path+"desc_blue_dot.gif";
				order_change = 'desc';
			break;	
		}	
		this.browserSubmit(order_change,eidb+'order_dir');
	} 
	
	// submit
	this.justSubmit = function(formname) {
		if(!formname) formname = 'contentform';
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();	
	}

	// submit
	this.setHiddenAndSubmit = function(hidden_value,hidden_id,formname) {
		if(!formname) formname = 'contentform';
		document.getElementById(hidden_id).value = hidden_value;
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();
	}

	// submit
	this.setHidden = function(hidden_value,hidden_id,formname) {
		if(!formname) formname = 'contentform';
		document.getElementById(hidden_id).value = hidden_value;
	}	
	//---------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------
	this.magnifier_is_visible = false;
	this.magnify = function(m) {
		var mtop, st, ww;
		
		if(this.magnifier_is_visible == true) {
			setTimeout(function(){ this.magnify(m); }.bind(this), 300);
			return;
		}
		
		
/*
.menuitemGNW {
	position: absolute;
	visibility: hidden;
}

.fllGN {
	background-image: url(/images_admin/icons/kr_hl.png);
	background-repeat: no-repeat;
	background-position: left top;
	width: 36px; 
	height:72px; 
	float:left;
}

.fllGNib {
	background-image: url(/images_admin/icons/kr_hr.png);
	background-repeat: no-repeat;
	background-position: right top;	
	height:72px; 
	width: 36px;
	float:left;
}

.fllGNCT {
	float:left;
	background-color: #000;
	margin: 1px 0 0 0;
	he

*/		
		st = PAGEdom.docScrollTop();
		mtop = (st+160)+'px';
		ww = GetWindowWidth();
		this.mag = document.createElement('div');
		this.mag.style.position = 'absolute';
		this.mag.style.zIndex = 10020;
		this.mag.style.left = 60+'px';
		this.mag.style.top = mtop;		
		this.mag.style.width = (ww-120)+'px';	
		this.mag.style.textAlign = 'center';
		//this.mag.style.height = '180px';
		this.mag.style.padding = '3px';
		this.mag.style.fontWeight = 'bold';
		//this.mag.style.fontSize = '400%';
		this.mag.style.fontSize = '60px';
		this.mag.style.lineHeight = '60px';
		this.mag.style.color = '#fff';
		//this.mag.style.border = '1px solid red';
		
		this.mag.innerHTML = m;
		document.getElementsByTagName('body')[0].appendChild(this.mag);
		
		this.mag_bg = document.createElement('div');
		this.mag_bg.style.position = 'absolute';
		this.mag_bg.style.zIndex = 10019;
		this.mag_bg.style.left = 60+'px';
		this.mag_bg.style.top = mtop;		
		this.mag_bg.style.width = (this.mag.offsetWidth)+'px';//(ww-60)+'px';
		this.mag_bg.style.height = this.mag.offsetHeight+'px';//'200px';
		
		op = 0.1;
		this.mag_bg.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
		this.mag_bg.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		
		
		rk = document.createElement('div');
		rk.className = 'fllGN';
		this.mag_bg.appendChild(rk);
		
		ct = document.createElement('div');
		ct.style.width = (this.mag.offsetWidth - 72)+'px';
		ct.className = 'fllGNCT';
		this.mag_bg.appendChild(ct);	
		
		lk = document.createElement('div');
		lk.className = 'fllGNib';
		this.mag_bg.appendChild(lk);		
		
		document.getElementsByTagName('body')[0].appendChild(this.mag_bg);
		
		new Effect.Opacity(this.mag_bg, {duration:0.3, from:0.1, to:0.7,afterFinish: function() {IF.magnifier_is_visible = true;}});
		
		//new Effect.Appear(this.mag_bg,{duration:0.5});
		//new Effect.Appear(this.mag,{duration:0.5});
		//new Effect.SlideDown(menuitems[i],{duration:0.8});
		//new Effect.BlindDown(menuitems[i],{duration:0.8});
		//new Effect.Grow(menuitems[i],{duration:0.8});		

		//this.mag.style.backgroundColor = '#ffffff';
		this.addEvent(document,'mousedown',this.hideme = function(event) {this.hideMagnifier(event);}.bind(this));
	}
	//---------------------------------------------------------------------------------------
	this.hideMagnifier = function(event) {
	
		var el;
		el = this.gettarget(event);
		
		// If the active button was clicked on, exit.
		if (el == this.mag) return;
		if (el == this.mag_bg) return;
	
		// If the element is not part of a menu, reset and clear the active
		// button.
		
		PAGEdom.removeNode(this.mag);
		mag_bg = this.mag_bg;
		new Effect.Opacity(this.mag_bg, {duration:0.3, from:0.7, to:0,afterFinish: this.sau_Effect_rmNode});
		//new Effect.Puff(this.mag_bg, {duration:0.5,afterFinish: rmNode});
		//PAGEdom.removeNode(this.mag_bg);
	}	
	
	this.sau_Effect_rmNode = function(obj) {
		PAGEdom.removeNode(obj.element);
		IF.magnifier_is_visible = false;
	}
	//---------------------------------------------------------------------------------------
	
	//---------------------------------------------------------------------------------------
	this.coverbackground = function(vs,op) {
		
		if(!op) op = 0;
		
		if(!this.cover) {
			this.cover = document.createElement('div');
			this.cover.style.position = 'absolute';
			this.cover.style.zIndex = 5;
			this.cover.style.left = 0+'px';
			this.cover.style.top = 0+'px';
			this.cover.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			this.cover.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
			this.cover.style.backgroundColor = "#fff";
			document.getElementsByTagName('body')[0].appendChild(this.cover);
		}
		
		if(!vs) {
			this.cover.style.visibility = 'hidden';
		} else {
			ww = GetWindowWidth();
			wh = GetWindowHeight();
			st = PAGEdom.docScrollTop();
			bodyheight = st+wh;
			bodyheight = document.body.offsetHeight;
			this.cover.style.width = (ww-15)+'px';
			this.cover.style.height = ((bodyheight-15))+'px';
			this.cover.style.visibility =  'visible';			
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.setField = function(sourcefield_id,targetfield_id,value,disable) {

		sourcefield = $(sourcefield_id);
		targetfield = $(targetfield_id);
		//DebugDump(sourcefield.value,'sourcefield.value');
		if(targetfield.value != value) {
			targetfield.value = value;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.getPHPOSContent = function(event,sid,conf) { //,{width:200,height:400,autosize:false}
		
		
		if(this.overlays == 'ext') {
			//DebugDump(conf,'conf');
			//DebugDump(sid,'sid '+sid);
			if(event) var evTarget = this.gettarget(event); //'.x-grid3-row'
			var win = Ext.getCmp('xcontentwindow');
			if(!win) {
				var d = {
					animateTarget: evTarget ? evTarget.id : false,
					modal:false,
					autoLoad:{
						url:'/ajax/getphposcontent/'+sid,
						callback: function() {
							Ext.addBehaviors({
							   // add a listener for click on all anchors in element with id foo
							   '#xcontentwindow h3.expandable-header@click' : function(e, t){
								   // do something
								   FNK.displayDown(e,t);
							   }					
							});
						}
					},//'/ajax/getphposcontent/'+sid,
					id:'xcontentwindow',
					//minWidth:350,
					stateful:false,
					shadow:true,
					shadowOffset:8,
					shim:false,		
					bodyStyle:'padding: 10px 7px 10px 7px;',
					autoScroll:true,
					//waitMsgTarget:evTarget.id,
					//iconCls:'x-content-ico',
					closable:false,
					defaultButton:0,
					//border:false,
					//modal:true,
					//plain:true,
					buttons:[{
						 text: $L('close')
						,scope:this
						,handler:function(button) {
							button.ownerCt.close();
						}							
					}],				
					bodyCfg: {
						//tag: 'center',
						cls: 'outercontent'
					},
					cls:'x-friendnik'
					
				};
				
				if(typeof conf != 'object') var conf = {};
				o = Ext.apply(conf,d);
				
				var win = new Ext.Window(o);
			} else {
				win.load({
					url:'/ajax/getphposcontent/'+sid,
					callback: function() {
						Ext.addBehaviors({
						   // add a listener for click on all anchors in element with id foo
						   '#xcontentwindow h3.expandable-header@click' : function(e, t){
							   // do something
							   //DebugDump(t,'t');
						   }
						});						
					}
				});
				if(conf && conf.width) win.setWidth(conf.width);
				if(conf && conf.height) win.setHeight(conf.height);
				win.center();
			}
			win.show.defer(50, win,evTarget.id);
		
		} else {
		
		if(typeof conf != 'object') conf = {};

			default_conf = {
				width:400,
				height:600,
				autosize: true,
				topclose: true,
				overflow: 'auto',
				fullscreen: false
			};		
			
			var conf = Ext.apply(default_conf,conf);
			//DebugDump(conf,'conf');
			if(event) Event.stop(event);
			
			Lightview.show({
				href: '/ajax/getphposcontent/'+sid,
				rel: 'ajax',
				options: {
					autosize: conf.autosize,
					width: conf.width,
					height: conf.height,
					topclose: conf.topclose,
					myOverflow: conf.overflow,
					sid:sid,
					ajax: {
						onSuccess: function(transport) {
							//DebugDump(transport.responseText,'transport.responseText');
						},
						onComplete: function(a){
							//DebugDump(this,'onComplete this');
							//DebugDump(a,'onComplete a');
							//DebugDump(Lightview,'Lightview');
							if(Lightview.view.options.myOverflow == 'auto') { // dunno, why lightview is not doing it by it self :(
								var ic = $('phposcontent_'+Lightview.view.options.sid);
								ic.style.width = ((Lightview.view.options.width)-5)+'px';
								ic.style.height = ((Lightview.view.options.height)-15)+'px';
								ic.style.overflow = 'auto';
							}
						},
						parameters: {sid:sid,noxml:true}
					}
				}
			});		
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.getContent = function(event,context,classname,sid) { // die hier is nich so dolle....
		
		switch(context) {
			case'contact':
				this.contactWindow(event,context,classname,sid);
				break;
			case'rqp':
				this.requestPasswordWindow(event,context,classname,sid);
				break;
			case'sendarticle':
			case'send':
				this.getAdviseWindow(event,context,classname,sid);
				break;
			default:
				// get ajax content
		}
	}

	this.contactWindow = function(event,t,c,sid) {
		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_contact.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitContactWindow);
						if($('aam_email') && $('aam_email').value.length == 0) $('aam_email').focus();
						BB.clearOnFocus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});	
	}
	
	// lightview submit callback
	this.submitContactWindow = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_contact.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitContactWindow);
				BB.clearOnFocus();
			}	
		  }
		}
	  });
	}	
	
	this.requestPasswordWindow = function(event,t,c,sid) {
		
		if(this.overlays == 'ext') {

			if(event) var evTarget = this.gettarget(event); //'.x-grid3-row'
			var win = Ext.getCmp('rqp');
			if(!win) {
				var d = {
					animateTarget: evTarget ? evTarget.id : false,
					modal:false,
					//autoLoad:'/php-os/app_local/scripts/ajax_request_password.php',
					id: 'rqp',
					//minWidth:350,
					stateful:false,
					shadow:true,
					shadowOffset:8,
					shim:false,		
					bodyStyle:'padding:10px;',
					autoScroll:true,
					title:$L('request_password'),
					//waitMsgTarget:evTarget.id,
					//iconCls:'x-content-ico',
					closable:false,
					defaultButton:0,
					width:400,
					height:200,
					//border:false,
					//modal:true,
					//plain:true,
					items:[{
						id: 'rqpform',
						url:'/php-os/app_local/scripts/ajax_request_password.php',
						waitMsgTarget:'rqp',
						xtype:'requestpassword'
					}],
					buttons:[{
						 text: $L('cancel')
						,scope:this
						,handler:function(button) {
							button.ownerCt.close();
						}							
					},{
						 text: $L('send')
						,scope:this
						,handler:function(button) {
							var rqpform = Ext.getCmp('rqpform');
							rqpform.getForm().submit({
								params:{
									triggers:'ajaxrqp',
									noxml:'1'
								},
								failure:function(form,action){
									FNK.showMessage({
										bt: false,
										height:150,
										width:300,
										modal:true,
										iconCls:'x-accept-ico',
										title:$L('warning'),
										html: (action.result && action.result['errorText']) ? '<p class="winmsg">'+action.result['errorText']+'</p>' : '<p class="winmsg">'+$L('An error occured! Please use a valid eMail address...')+'</p>',
										defaultButton:0,
										y:300,
										buttons:[{
											 text: $L('ok')
											,scope:this
											,handler:function(button) {
												button.ownerCt.close();
											}							
										}]
									});										
								},
								success:function(form,action) {
									if(action.result && action.result.success) {
										FNK.showMessage({
											bt: false,
											height:150,
											width:300,
											iconCls:'x-accept-ico',
											title:$L('hint'),
											html:'<p class="winmsg">'+action.result['msg']+'</p>',
											defaultButton:0,
											y:300,
											buttons:[{
												 text: $L('ok')
												,scope:this
												,handler:function(button) {
													button.ownerCt.close();
												}							
											}]
										});
										
										Ext.getCmp('rqp').close();
										
									} else {
										FNK.showMessage({
											bt: false,
											modal:true,
											height:150,
											width:300,
											iconCls:'x-accept-ico',
											title:$L('warning'),
											html: (action.result && action.result['errorText']) ? '<p class="winmsg">'+action.result['errorText']+'</p>' : '<p class="winmsg">'+action.result['msg']+'</p>',
											defaultButton:0,
											y:300,
											buttons:[{
												 text: $L('ok')
												,scope:this
												,handler:function(button) {
													button.ownerCt.close();
												}							
											}]
										});	
									}
								},
								waitMsg:'Saving...'
							});
							//this.getForm().submit({params:{triggers:'ajaxsaverecord',noxml:'1'},failure:function(form,action){Ext.Msg.alert("Error", action.result.msg);},success:function(form,action){ Ext.getCmp(form.p_id).has_been_submitted = true; Ext.getCmp(form.win_id).close();}});'
							//IF.submitAjaxRequestPassword();
							//button.ownerCt.close();
							
						}							
					}],				
					bodyCfg: {
						//tag: 'center',
						cls: 'outercontent'
					},
					cls:'x-friendnik'
					
				};
				
				if(typeof conf != 'object') var conf = {};
				o = Ext.apply(conf,d);
				
				var win = new Ext.Window(o);
			}
			win.show.defer(50, win,evTarget.id);
			
		} else {
		
			Event.stop(event);
			Lightview.show({
				href: '/php-os/app_local/scripts/ajax_request_password.php',
				rel: 'ajax',
				options: {
					autosize: true,
					topclose: true,
					ajax: {
						onSuccess: function(transport) {
							//DebugDump(transport.responseText,'transport.responseText');
							
						},
						onComplete: function(){
							// once the request is complete we observe the form for a submit
							$('adviseform').observe('submit', IF.submitAjaxRequestPassword);
							if($('aam_email') && $('aam_email').value.length == 0) $('aam_email').focus();
						},
						parameters: {t:t,c:c,sid:sid}
					}
				}
			});		
		}
	}
	
	// lightview submit callback
	this.submitAjaxRequestPassword = function(event) {
	  // block default form submit
	  
	  if(this.overlays == 'ext') {
			Ext.Ajax.request({
				url: '/php-os/app_local/scripts/ajax_request_password.php',
				scope: this,
				success: function(response,options){
				var rData = Ext.util.JSON.decode(response.responseText);//passed back from server

				if(rData && rData.success) {
					this.showMessage({
						bt: this.bt ? this.bt.id : false,
						sid:sid,
						height:150,
						width:300,
						iconCls:'x-accept-ico',
						title:$L('hint'),
						html:'<p class="winmsg">'+rData['msg']+'</p>',
						defaultButton:0,
						y:300,
						buttons:[{
							 text: $L('ok')
							,scope:this
							,handler:function(button) {
								button.ownerCt.close();
							}							
						}]
					});
					
				} else {
					this.showMessage({
						bt: this.bt ? this.bt.id : false,
						sid:sid,
						height:150,
						width:300,
						iconCls:'x-accept-ico',
						title:$L('warning'),
						html: (rData && rData['errorText']) ? '<p class="winmsg">'+rData['errorText']+'</p>' : '<p class="winmsg">'+$L('An error occured! Probably your session expired...')+'</p>',
						defaultButton:0,
						y:300,
						buttons:[{
							 text: $L('ok')
							,scope:this
							,handler:function(button) {
								button.ownerCt.close();
							}							
						}]
					});					
					this.enable(options.bt);
				}					
				},
				failure: function(){
					
				},
				params: {noxml:'1',email: Ext.get('rqp_email').dom.value}
			});
	  
	  } else {
		  
		  Event.stop(event);
		  Lightview.show({
			href: '/php-os/app_local/scripts/ajax_request_password.php',
			rel: 'ajax',
			options: {
			  title: 'results',
			  menubar: false,
			  topclose: true,
			  autosize: true,
			  ajax: {
				parameters: Form.serialize('adviseform'), // the parameters from the form
				onComplete: function(){
					// once the request is complete we observe the form for a submit
					if($('adviseform')) $('adviseform').observe('submit', IF.submitAjaxRequestPassword);
				}	
			  }
			}
		  });
	  }
	}	
	
	// lightview submit form
	this.getAdviseWindow = function(event,t,c,sid) {

		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_advise_mail.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitAjaxFormDemonstration);
						if($('aam_recipientmail') && $('aam_recipientmail').value.length == 0) $('aam_recipientmail').focus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});
	}

	// lightview submit callback
	this.submitAjaxFormDemonstration = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_advise_mail.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitAjaxFormDemonstration);
			}	
		  }
		}
	  });
	}
	
	
	
	//---------------------------------------------------------------------------------------
	
	this.windowPrint = function() {
		window.print();
	}
	
	this.printDonation = function(printform) {
		
		
		var firstformEL = false;
	//if (!def_printversion_available) return alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
		var contentEL = document.getElementById('content');
		var contentforms = contentEL.getElementsByTagName('FORM');
		for (var i=0; i<contentforms.length; i++) { 
			if(contentforms[i]) { firstformEL = contentforms[i]; break; }
		}	
		
		if(firstformEL) {
			//var o_target = firstformEL.target;
			var o_action = firstformEL.action;
			//firstformEL.target = printform;
			firstformEL.action = printform;
		}
		this.printVersion();
		//window.print();
		if(firstformEL) {
			//firstformEL.target = o_target;
			firstformEL.action = o_action;	
		}
	}

	this.printVersion = function() {
		var firstformEL = false;
	//if (!def_printversion_available) return alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
		var contentEL = document.getElementById('content');
		var contentforms = contentEL.getElementsByTagName('FORM');
		for (var i=0; i<contentforms.length; i++) { 
			if(contentforms[i]) { firstformEL = contentforms[i]; break; }
		}
		//firstformEL.submit();
		//alert(firstformEL.name);
		if(firstformEL) var Ppath = firstformEL.action;//parent.content.myPlainPagePath;
		else var Ppath = parent.content.myPlainPagePath;
		
		var Pname = "PrintVersion";
		var no_w = '/none';
		var no_w = checkUrl(no_w);
		var WHeight = GetWindowHeight()-100;
		mywin = window.open(no_w,Pname,"top=20,left=30,width=540,height="+WHeight+",scroll=yes,scrollbars=yes,titlebar=no,status=no,toolbar=no,location=no,directories=no,menubar=yes,resizable=yes");
		
		Ppath = Ppath+"?print=true";
		var Ppath = checkUrl(Ppath);		
		//spendenformulardrucken
		if(firstformEL) {
			
			var o_target = firstformEL.target;
			var o_action = firstformEL.action;
			//alert(o_target);
			firstformEL.target = Pname;
			firstformEL.action = Ppath;
			firstformEL.onsubmit(); // workaround browser bugs.
			firstformEL.submit();
			firstformEL.target = o_target;
			firstformEL.action = o_action;			
		} else {
			mywin.location.href =createUrl(Ppath);
		}
		
		
		
		/*if (document.forms[formname]) { // this part will be true from now on
			var createdTempHidden = false;
			if (document.createElement) {
				switch (SmartAgent){
					case "Netscape6":
					case "MSIE5.5":
					case "Opera5":
					case "Khtml":
						try {
							var tempFormObj;
							var tempHiddenObj;
							tempFormObj = parent.content.document.forms[0];
							var tempHidden = 	parent.content.document.createElement('input');
							tempHidden.setAttribute('type','hidden');
							tempHidden.setAttribute('name','print');
							tempHidden.setAttribute('value','true');
							tempHiddenObj = tempFormObj.appendChild(tempHidden);
							var createdTempHidden = true;
						} catch(e) {
							Ppath = Ppath+"?print=true";
						}
						break;
				case "Netscape4":
				case "MSIE5":
				default:
					var Ppath = Ppath+"?print=true";
					var Ppath = createUrl(Ppath);
					break;
				}
			} else {
				var Ppath = Ppath+"?print=true";
				var Ppath = createUrl(Ppath);
			}
			setActionAndSubmit(Pname,Ppath,'parent.content.document.forms[0]');
			if (createdTempHidden) tempFormObj.removeChild(tempHidden);
		} else {
			var Ppath = Ppath+"?print=true"; 
			mywin.location.href =createUrl(Ppath);
		}
		*/
		
		if(mywin) mywin.focus();
	}

	//---------------------------------------------------------------------------------------
	this.buildWindow = function() {
		
		// window
		//bodyroot = document.getElementsByTagName('form')[0];
		if(!document.getElementById('content')) return;
		bodyroot = document.getElementById('content');
		this.w_wrapper = document.createElement("div");	
		

		this.w_wrapper.id = 'window';
		this.w_wrapper.className = 'window';
		this.w_wrapper.style.position = 'absolute';
		//this.w_wrapper.style.display = 'none';
		this.w_wrapper.style.visibility = 'hidden';
		this.w_wrapper.width = 300;
		this.w_wrapper.height = 300;
		this.w_wrapper.style.width = this.w_wrapper.width+'px';
		this.w_wrapper.style.height = this.w_wrapper.height+'px';
		this.w_wrapper.style.overflow = 'auto';
		//this.w_wrapper.style.border = '1px solid black';
		//this.w_wrapper.style.backgroundColor = 'white';
		//this.w_wrapper.style.zIndex = 100000;
		WWidth = GetWindowWidth();
		WHeight = GetWindowHeight();
		dst = PAGEdom.docScrollTop();
		var topheight = (((WHeight+dst)/2)-(this.w_wrapper.height/2));
		if(topheight<133) topheight = 133;
		this.w_wrapper.style.top = topheight+'px';
		var leftwidth = ((WWidth/2)-(this.w_wrapper.width/2));
		if(leftwidth<250) leftwidth = 250;
		this.w_wrapper.style.left = leftwidth+'px';
		bodyroot.appendChild(this.w_wrapper);

		this.makeNewWndow();
				
	}
	
	this.makeNewWndow = function() {
		this.window = new ContentWindow(this.title,this.w_wrapper.id);
		this.window.client_area_id = 'windowclientarea';
		this.window.title_id = 'windowtitlearea';
		this.window.init(this.window);	
	}
	
	//---------------------------------------------------------------------------------------
	this.showMessage = function(o) {
		
		var d = {
			animEl: o.bt ? o.bt.id : false,
			modal:false,
			minWidth:350,
			stateful:false,
			shadow:true,
			shadowOffset:8,
			shim:false,
			closable:false,
			cls:'x-friendnik'
		};
		
		if(typeof o != 'object') var o = {};
		o = Ext.apply(o,d);
		
		var win = new Ext.Window(o);
		win.show.defer(50, win,[o.bt.id]);
		
	}	
	

	//---------------------------------------------------------------------------------------
	this.gettarget = function(event) {

		if(window
		&& (window.event)
		&& (window.event.srcElement)) {
			t = window.event.srcElement;
		} else {
			t = (event.target.tagName ? event.target : event.target.parentNode);
		}
		return t;
	}	
	

	//---------------------------------------------------------------------------------------
	this.addEvent = function(el,evname,func) {
	
		if (el.attachEvent) { // IE
			el.attachEvent("on" + evname, func);
		} else if (el.addEventListener) { // Gecko / W3C
			el.addEventListener(evname, func, true);
		} else {
			el["on" + evname] = func;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.removeEvent = function(el,evname,func) {
	
		if (el.detachEvent) { // IE
			el.detachEvent("on" + evname, func);
		} else if (el.removeEventListener) { // Gecko / W3C
			el.removeEventListener(evname, func, true);
		} else {
			el["on" + evname] = null;
		}
	
	}
}

IF = new Interface(); 
OnLoadFunctions[OnLoadFunctions.length] = "IF.init();";

var reg = 'phpos'; 
var is_phpos_environment = document.location.href.match(reg);
if(!is_phpos_environment) {
	browserSubmit = IF.browserSubmit;
	setDirPath = IF.setDirPath;
	changeDirPath = IF.changeDirPath;
}

//--------------------------------------------------------------------------------------- //
function checkSubmit() { // weiss nich, ob ich das brauche... ist der onsubmit gerade
	return true;
}
//--------------------------------------------------------------------------------------- //
function SmartBrowser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var SMbrowser = new SmartBrowser();
//--------------------------------------------------------------------------------------- //
function FLOETER () {
	
	this.init = function() {

	//	$("a.fancyview").fancybox();
	//	$(".photos a").fancybox();
		
		this.clearOnFocus();
		
		//FancyForm.start();
		/*
		$$('form label').each(function(e) {
			e.observe('click', switchSelectAll4Label);
		});
		
		// preload wait image
		Preloaded1 = new Image();
		Preloaded1.src = '/javascripts/ext/resources/images/default/grid/loading.gif';
		Preloaded2 = new Image();
		Preloaded2.src = '/local/media/images/loading/circle.gif';	
		Preloaded3 = new Image();
		Preloaded3.src = '/local/media/images/loading/run.png';			
		*/
		
	}
	
	// deny submit, on searches with less than 2 chars	
	this.checkFriendsFormLength = function(event) {
		
		if(typeof event == 'undefined' || !event) return true;

		var obj = event.target || event.srcElement;
		if((event.type == 'keypress' && event.keyCode == 13 ) || (event.type == 'submit')) {
			if($('xff') && $('xff').value.length < 2) {
				if ( event.preventDefault )
					event.preventDefault()
				else event.returnValue = false;		
			}
			else if($('ff') && $('ff').value.length < 2) {
				if ( event.preventDefault )
					event.preventDefault()
				else event.returnValue = false;		
			}
		}
		return true;
	}

	//---------------------------------------------------------------------------------------
	this.clearOnFocus = function() {
		/**
		* Clears all input/textareas with classname "clearonfocus"
		* on focus-Mouseevent.
		*/
		$$('.cof').each(function(input) {
			input._defaultValue = input.readAttribute('title');
			input.observe('focus', function(ev) {
				if(input.value == input._defaultValue) {
					input.value = '';
				}
				input.addClassName('on-focus');
			});
			input.observe('blur', function(ev) {
				if(input.value == '') {
					input.value = input._defaultValue;
				}
				input.removeClassName('on-focus');				
			});
			
		});	
	}
	
	//---------------------------------------------------------------------------------------
	this.inputValues = new Array();
	/*
	 * clearOnFocusSA = StandAlone - to be called in html onfocus 
	 */
	this.clearOnFocusSA = function(input) {
	  $(input).addClassName('on-focus');
	  if(this.inputValues[$(input).getAttribute('id')] == null) {
	  	var l_code = $(input).getAttribute('rel');
	  	var value = $(input).value;
	  	if(value != $L(l_code)) return false;
		this.inputValues[$(input).getAttribute('id')] = value;
		$(input).value = '';
	  }
	}
	
	/*
	 * fillOnBlurSA = StandAlone - to be called in html onblur
	 * fills the element with the value stored in Array inputValues[]
	 */
	this.fillOnBlurSA = function(input) {
	  $(input).removeClassName('on-focus');
	  if(input.value == '' && this.inputValues[$(input).getAttribute('id')] != null) {
		$(input).value = this.inputValues[$(input).getAttribute('id')];
		delete this.inputValues[$(input).getAttribute('id')];
	  }
	}

	this.order = function(s,t) {
		
		var active = $('order').value;
		if(s != active) {
			$('order_'+active).removeClassName('active');
			$('order_'+active).addClassName('inactive');
			$('order_'+s).removeClassName('inactive');
			$('order_'+s).addClassName('active');
			$('order').value = s;
			if($('order_'+s).hasClassName('sort-asc')) {
				$('order_dir').value = 'asc';
			} else {
				$('order_dir').value = 'desc';			
			}			
		} else {
			if($('order_'+s).hasClassName('sort-asc')) {
				$('order_'+s).removeClassName('sort-asc');
				$('order_'+s).addClassName('sort-desc');
				$('order_dir').value = 'desc';
			} else {
				$('order_'+s).removeClassName('sort-desc');
				$('order_'+s).addClassName('sort-asc');
				$('order_dir').value = 'asc';			
			}
		}
		
		IF.justSubmit('contentform');
	}	
	
	//---------------------------------------------------------------------------------------

	
	this.setMissionMessage = function(i,msg) {
		
		// mm1, mmessage1
		// hide 
		var mm = Ext.get('mm'+i);
		if(!mm) return false;
		if(mm.getStyle('display') == 'none') {
			mm.slideIn('t',{
				easing: 'easeOut',
				duration: .5,
				scope:this,
				useDisplay: true
			});	
		}
		$('mmessage'+i).innerHTML= msg;
		
	}
	
	//---------------------------------------------------------------------------------------
	this.hideGlobalMessage = function(id,sid) {
		this.hideMessage(id);
		//$('space-if-no-highlight').removeClassName('invisible');
		
		// save on blacklist
		var post = '';
		post += 'fields[sid]='+URLEncode(sid);
		post += '&control[method]=setread';
		post += '&control[class]=globalmessageblacklist';
		
		var url = '/php-os/app_local/scripts/update.php';		
		Ext.Ajax.request({
			scope:this,
			method:'post',
			sid:sid,
			url: url,
			success: function(response,options){
				//var rData = Ext.util.JSON.decode(response.responseText);//passed back from server
			},
			failure: function(response,options){ 
			},
			params: post
		});					
		
	}
	
	//---------------------------------------------------------------------------------------
	this.autocancel = function(e,sid,o) {
		if(e) {
			var el = Event.element(e);
			if(el.id == ('ieNik'+sid)) return;
			container = PAGEdom.getContainer(el, $('userservice'+sid));
			if(container != null) return;
		}
		if($('ieNik'+sid)) $('ieNik'+sid).style.display='none';
		Event.stopObserving($('ieNik'+sid), 'keydown');
		Event.stopObserving(document.body, 'click');
		if($('ieNikAccept'+sid)) $('ieNikAccept'+sid).style.display='none';
		if($('servicetitle'+sid)) $('servicetitle'+sid).style.display='';
		//this.bodycancel = 0;
	}
	
	//---------------------------------------------------------------------------------------
	this.checkAllByClassName = function(id,classname) {

	}
	
	//---------------------------------------------------------------------------------------
	this.hideMessage = function(id,context) {
		
		// hide 
		var mm = Ext.get(id);
		if(!mm) return false;
		mm.slideOut('t',{
			easing: 'easeOut',
			duration: .5,
			scope:this,
			//remove: true,
			useDisplay: true
		});
				
	}
	
	//---------------------------------------------------------------------------------------
	this.displayDown = function(e,t) {
		var l = Ext.get(t);
		var p = l.next(false,true);
		var pl = Ext.get(p);
		if(p && pl.hasClass('collapsed-content') && (pl.is('h3') != true)) {
			if(pl.getStyle('display') == 'none') pl.setStyle('display','block');
			else pl.setStyle('display','none');
			this.displayDown(e,p);
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.disable = function(obj) {

		//if(typeof console == 'object') console.log('x obj: %o',obj);
		for(id in obj) {
			//if(typeof console == 'object') console.log('x obj.id: %o',obj.id);
			if(obj && obj.id && obj.id.length >0 && $(obj.id)) {
				$(obj.id).addClassName('disabled');
				$(obj.id).disabled = true;
			}
		}			
	}
	
	this.enable = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if(obj && obj.id && obj.id.length >0 && $(obj.id)) {
				$(obj.id).removeClassName('disabled');
				$(obj.id).disabled = false;
			}
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.hideContainer = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if($(obj.id)) {
				$(obj.id).addClassName('hidden');
				//$(obj.id).disabled = true;
			}
		}			
	}
	
	this.showContainer = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if($(obj.id)) {
				$(obj.id).removeClassName('hidden');
				//$(obj.id).disabled = false;
			}
		}
	}	
	
	//---------------------------------------------------------------------------------------
	this.showMessage = function(o) {
		
		var d = {
			animEl: o.bt ? o.bt.id : false,
			modal: o.modal ? true : false,
			minWidth:350,
			stateful:false,
			shadow:true,
			shadowOffset:8,
			shim:false,	
			closable:false,
			cls:'x-friendnik'
		};
		
		if(typeof o != 'object') var o = {};
		o = Ext.apply(o,d);
		
		var win = new Ext.Window(o);
		if(o.bt) win.show.defer(50, win,[o.bt.id]);
		else win.show.defer(50, win);
	}	
	
	//---------------------------------------------------------------------------------------
	this.check4FileUpload = function(event) {
		
		if(typeof event == 'undefined' || !event) return true;
	
		var obj = event.target || event.srcElement;
			
		if ( obj.type != "textarea" && event && event.keyCode == 13 ){
			
			if ( event.preventDefault )
				event.preventDefault()
			else event.returnValue = false;
		};
		
		// check if file is going to be uploaded
		var inputs = $$('input[type=file]');
		var has_value = false;
		if(inputs) {
			for(i=0;i<inputs.length;i++) {
				if(inputs[i].value.length>0) has_value = true;
			}
		}
		if(has_value) { // mask background and show uploading file
			//var myMask = new Ext.LoadMask(Ext.getBody(), {msg:$L('Please wait, uploading file...')});
			//myMask.show();			
			this.mask($L('Please wait, uploading file...'));
		}

		return true;
	} 
	
	this.mask = function(msg) {
		if(!msg) var msg = $L('Loading...')
		var m = Ext.getBody().mask();

		var tpl = '';
		tpl += '<div id="maskmsg">';
		tpl += msg;
		tpl += '';
		tpl += '';
		tpl += '';
		tpl += '';
		tpl += '</div>';
		Ext.getBody().insertHtml('beforeEnd',tpl);
	}
	
}

var FNK = new FLOETER();

//--------------------------------------------------------------------------------------- //
if(typeof Ext == 'object') {

	// application main entry point
	Ext.onReady(function() {
		FNK.init();
	}); // eo function onReady



	
	/*****************************************************
	*/ function __P___RequestPasswordForm() {}
	/******************************************************/
	
	// Setup LoginForm
	IF.RequestPasswordForm = Ext.extend(Ext.form.FormPanel, {
	 initComponent:function() {
		 Ext.apply(this, {
			frame:true,
			url:'/php-os/app_local/scripts/ajax_request_password.php',
			method:'post',
			labelAlign: 'top',
			cls:'x-friendnik',
			iconCls:'x-mail-tab',
			//title: $L('login'),
			bodyStyle:'padding:5px',
			id: 'rqpform',
			defaultType: 'textfield',
			defaults: {width: 230},
			layoutConfig: {
				labelSeparator: ''
			},		
			items: [{
				xtype:'hidden',
				name: 'operation',
				value:'requestpassword'
			},{
				//xtype:'textfield',
				fieldLabel:$L('email'),
				hideLabel:true,
				name: 'email',
				id: 'rqp_email',
				anchor:'100%',
				allowBlank:false
			},{
				xtype: 'tbtext',
				text:$L('request_password_hint')
			}]
		}); // eo apply
	
		// call parent
		IF.RequestPasswordForm.superclass.initComponent.apply(this, arguments);
		
	} // eo function initComponent
	
	});
	// Register New Event Form
	Ext.reg('requestpassword', IF.RequestPasswordForm);

}
//--------------------------------------------------------------------------------------- //

function switchSelectAll4Label(event) {
var childNodes = Event.element(event).childNodes;
for(var i in childNodes) {
  if(childNodes[i].type == 'checkbox') {
	element = childNodes[i];
	// check / uncheck all when the "select all" checkbox is pressed
	if(element.hasClassName('switcher')) {
	  // unfortunately IE understands the checking exactly opposite than gecko or webkit browser :(
	  if(Prototype.Browser.IE) {
	  //  element.checked ? runThroughInputs4SelectAll(element, false) : runThroughInputs4SelectAll(element, true);
		if(element.checked) {
		  runThroughInputs4SelectAll(element, false);
		  setChecked(element, true);
		}else{
		  runThroughInputs4SelectAll(element, true);
		  setChecked(element, false);
		}
	  // webkit, opera and gecko browsers..
	  }else{
		element.checked ? runThroughInputs4SelectAll(element, true) : runThroughInputs4SelectAll(element, false);
	  }
	// if any other checkbox is clicked, the "select all" checkbox should be disabled if not
	// all other ones are checked and it should be enabled if all are checked
	}else{
	  var checkboxAmount = 0;
	  var checkedCheckboxes = 0;
	  // IE changes the Checked attribute to after finishing this script, so we must set it manually
	  if(Prototype.Browser.IE) {
		element.checked ? element.checked = 0 : element.checked = 1;
	  }
	  // run through every input checkbox field and change count checked ones and all checkboxes with the same name
	  $$('form input').each(function(e) {
		if(e.type == 'checkbox' && !e.hasClassName('switcher') &&  e.getAttribute('rel') == element.getAttribute('rel')) {
		  e.checked ? checkedCheckboxes++ : checkedCheckboxes;
		  checkboxAmount++;
		}
	  });

	  // set "select all" checkbox to true
	  if(checkedCheckboxes == checkboxAmount) {
		$$('form input').each(function(e) {		
		  if(e.type == 'checkbox' && e.hasClassName('switcher') &&  e.getAttribute('rel') == element.getAttribute('rel')) {
			setChecked(e, true);
		  }
		});
	  // set "select all" checkbox to false
	  }else{
		$$('form input').each(function(e) {	
		  if(e.type == 'checkbox' && e.hasClassName('switcher') &&  e.getAttribute('rel') == element.getAttribute('rel')) {
			setChecked(e, false);
		  }
		});
	  }
	}
  }
}
}

/**
* just to avoid code duplication...
* runs through all input checkboxes in form.select_all
*/ 
function runThroughInputs4SelectAll(element, bool) {
	$$('form input').each(function(e) {
	  if(e.type == 'checkbox'  && e.getAttribute('rel') == element.getAttribute('rel')) { //e.name.indexOf(element.name) >= 0
		setChecked(e, bool);
	  }
	});
}

/**
* sets the label class to checked and checks the input itself
*
* @var element Object
* @var bool Boolean for checking/unchecking the element
*/
function setChecked(element, bool) {
if(element.type == 'checkbox') {
  var label = element.parentNode;
  if(bool) {
	element.checked = 1;
	element.setAttribute('checked', 'checked');
	label.removeClassName('unchecked');
	label.addClassName('checked');
  }else{
	element.checked = 0;
	element.removeAttribute('checked');
	label.removeClassName('checked');
	label.addClassName('unchecked');
  }
}
}

