//KLEINES USERPROFIL
var showShortProfile = {

	init : function() {
		showShortProfile.setEvents();
	},
	setEvents : function() {
		$("a.showShortProfile").bind("click keypress", showShortProfile.openShortProfile);
	},
	openShortProfile : function(event) {
		showShortProfile.u_UID = this.id.replace('profile_', "");
		showShortProfile.htmlRequest();
		return false;
	},
	resizeShortProfile : function() {
		// &&& TO DO: Mal sch�n in jQuery schreiben
		c = document.getElementById("TB_ajaxContent");
		d = document.getElementById("TB_window");
		e = document.getElementById("shortProfileContent");
		f = document.getElementById("shortProfile_userName_float");
		if(f.offsetWidth > 142){
			c.style.width = (f.offsetWidth+35) +"px";
			d.style.width = (f.offsetWidth+35) +"px";
			e.style.width = (f.offsetWidth+32) +"px";
		}else{
			c.style.width = (145) +"px";
			d.style.width = (145) +"px";
			e.style.width = (142) +"px";
		}
	},
	htmlRequest : function() {
		$.ajax({
		  url: "/user/shortprofilelayer?u_UID=" + showShortProfile.u_UID,
		  cache: false,
		  dataType: "html",
		  success: function(html){
			$("#TB_shortProfileLayer").html(html);
			tb_show('','#TB_inline?TB_null=null&amp;TB_height=300&amp;TB_width=145&amp;inlineId=TB_shortProfileLayer&amp;modal=false','');
			showShortProfile.resizeShortProfile();
		  }
		});
	}
}


//STANDARD LIGHTBOX - CONFIRM, FEHLERMELDUNGEN, CONTACT, LOGIN NOTICE
var showStandardLayer = {

	init : function() {
		showStandardLayer.setEvents();
	},
	setEvents : function() {
		$(".showLoginNotice").bind("click keypress", function(){ showStandardLayer.openStandardLayer('914','',''); return false; });
		$(".showContact").bind("click keypress", function(){ showStandardLayer.openStandardLayer('920','',''); return false; });
		$(".showRetrievePassword").bind("click keypress", function(event){showStandardLayer.openStandardLayer('917',$(this).attr('value'),''); return false; });
		$("#newGuestbookEntry").bind("click keypress", function(){ showStandardLayer.openStandardLayer('936','','',true); return false; });
	},

	/**
	 * @var {integer}p_id
	 * @var {integer}from_p_ID
	 * @var {object}error
	 * @var {boolean}checkUserStatus
	 * @var {object}args: Additional request parameters
	 * @var {object}attr: Attributes for thickbox
	 */
	openStandardLayer : function(p_ID,from_p_ID,error,checkUserStatus,args,attr)
	{
		if(checkUserStatus)
		{
			user_status = returnUserStatus();
			if(user_status===false)
			{
				showStandardLayer.htmlRequest('914','','', args, attr);
			}else
			{
				showStandardLayer.htmlRequest(p_ID,from_p_ID,error, args, attr);
			}
		}else
		{
			showStandardLayer.htmlRequest(p_ID,from_p_ID,error, args, attr);
		}
		return false;
	},
	htmlRequest : function(p_ID,from_p_ID,error, args, attr)
	{
		if(from_p_ID != 0){
			showStandardLayer.params = "?p_ID=" + p_ID + "&from_p_ID=" + from_p_ID + "&error=" + error;
		}else{
			showStandardLayer.params = "?p_ID=" + p_ID;
		}

		args = jQuery.extend({}, args);

		attr = jQuery.extend({
			tb_height: 300,
			tb_width: 350
		}, attr);

		$.ajax({
		  url: "/index/index/" + showStandardLayer.params,
			type: 'POST',
			data: args,
		  cache: false,
		  dataType: "html",
		  success: function(html)
			{
				// REMOVE OLD CONTENT...
				$("#TB_ajaxContent").empty();
				$("#TB_standardLayer").html(html);
				tb_show('','#TB_inline?TB_null=null&amp;TB_height='+attr.tb_height+'&amp;TB_width='+attr.tb_width+'&amp;inlineId=TB_standardLayer&amp;modal=false','');
				//initLogin();
				//Cufon.now();
		  }
		});
	}

}

//STANDARD LIGHTBOX - OHNE SUBREQUEST - FUER HINTS
var showInlineLayer = {
    display : function(layerContent,args,attr) {
        args = jQuery.extend({}, args);

        attr = jQuery.extend({
            tb_height: 300,
            tb_width: 350
        }, attr);

        $("#TB_ajaxContent").empty();
        $(layerContent).remove().appendTo('#TB_standardLayer');

        tb_show('','#TB_inline?TB_null=null&amp;TB_height='+attr.tb_height+'&amp;TB_width='+attr.tb_width+'&amp;inlineId=TB_standardLayer&amp;modal=false','');

    }
}

