


/**
 * pk_public class - used for public pages
 *
 * @author	DKone <bokonet GmbH & Co. KG>
 */
pk_publicClass=Class.create({
	conf:{
	},

	/**
	 * make ajax-request for code "get_account" + mgm return-messages
	 *
	 * @return	void
	 */
	get_account:function() {
		new Ajax.Request('index.php?eID=pk_get_account',{
			parameters:{action:'get_account',institute_name:$F('institute_name'),institute_number:$F('institute_number'),institute_email:$F('institute_email'),captcha:$F('captcha')},
			onCreate:function() {
				$('lv_overlay').wasabi_loading.show();
			}.bind(this),
			onSuccess:function(transport) {
				if(!transport.responseJSON) {this.ajaxError(transport,'pk_public.get_account');}
				$('institute_name').clear();
				$('institute_number').clear();
				$('institute_email').clear();
				$('captcha').clear();
			}.bind(this),
			onFailure:function(transport) {
				if(!transport.responseJSON) {this.ajaxError(transport,'pk_public.get_account');}
			}.bind(this),
			onComplete:function() {
				$('lv_overlay').wasabi_loading.hide();
				this.showMessage(transport.responseJSON['returnMessage']);
			}.bind(this)
		});
	},

	/**
	 * make ajax-request for code "password_remind" + mgm return-messages
	 *
	 * @return	void
	 */
	password_remind:function() {
		new Ajax.Request('index.php?eID=pk_password_remind',{
			parameters:{action:'password_remind',institute_number:$F('institute_number'),institute_email:$F('institute_email'),captcha:$F('captcha')},
			onCreate:function() {
				$('lv_overlay').wasabi_loading.show();
			}.bind(this),
			onSuccess:function(transport) {
				if(!transport.responseJSON) {this.ajaxError(transport,'pk_public.password_remind');}
				$('institute_number').clear();
				$('institute_email').clear();
				$('captcha').clear();
			}.bind(this),
			onFailure:function(transport) {
				if(!transport.responseJSON) {this.ajaxError(transport,'pk_public.password_remind');}
			}.bind(this),
			onComplete:function() {
				$('lv_overlay').wasabi_loading.hide();
				this.showMessage(transport.responseJSON['returnMessage']);
			}.bind(this)
		});
	},

	/**
	 * if transport is no JSON report this as error
	 *
	 * @param	object		transport: the ajax-transportObj
	 * @param	string		funcName: the func-name where the error occures
	 * @return	void
	 */
	ajaxError:function(transport,funcName) {
		var message='ERROR! Something went wrong. Sorry, please try again!\n\nError in '+funcName+'() while Ajax.Request: no JSON! transport:\n'+transport.responseText.trim();
		alert(message);
		throw new Error(message);
	},

	/**
	 * mgm the returnMessage(s) in messageContainer-DIV element
	 *
	 * @param	string		content: html-content of messages
	 * @return	void
	 */
	showMessage:function(content) {
		Effect.Fade('messageContent',{duration:0.5,afterFinish:function(){
			$('messageContent').update(content);
			Effect.Appear('messageContent');
		}});
	}
});



//make object
pk_public=new pk_publicClass();
document.observe('dom:loaded',function(){document.observe('lightview:loaded',function(){
	new wasabi_loadingItem('lv_overlay',{content:'<div class="loadingBackground222"><div class="loadingBig222"></div></div>',zIndex:9999});//init lightview loading
});});



document.observe('dom:loaded', function() {
	$$('a[rel]').each(function(element) {
		new Tip(element, element.rel, {style:'tooltip', title:element.title});
	});
});
Prototip.Styles.tooltip={
	className:'helpTooltip',
	delay:0,
	fixed:true,
	hideOn:'mouseout',
	hook:{target:'topRight',tip:'bottomRight'},
	images:'styles/default/',
	stem:{position:'bottomRight',height:12,width:20},
	offset:{x:45,y:5},
	width:300
};

