	
var SEARCH_TEXT = 'Suchbegriff oder Buchungs-Nr.';

function handleSearchInputTitle(obj, mode) {
	if (mode == 'hide' && obj.value == SEARCH_TEXT) {
		obj.value = ''
		obj.style.color = '#000000'
	} else if (obj.value == '') {
		obj.value = SEARCH_TEXT
		obj.style.color = '#999999'
	}
}


/* PERSONAL AREA */
function openPastEvents() {
	$j('#paTableFooter').hide();
	$j('.past').show();
}

function closePastEvents() {
	$j('.past').hide();
	$j('#paTableFooter').show();
}

function loadAllPastEvents(contextPath) {
//	alert(contextPath);
	$j(document).ready(function() {
		var url = "/personalarea/includes/dynamicBody/startpage/include-past-events.jsp";
		var layer = $j("<div>&nbsp;</div>");
		layer.addClass("transparentLayer");
		
		$j.ajax({
			type: 		"post",
			url: 		contextPath + url,
			data: 		"showAllPastEvents=true",
			beforeSend: function (xhr) {
				$j("#ajaxLoad").show();
				if ($j.browser.msie) {
					$j("#contentPastEvents").append(layer);
					layer.animate({opacity: 0.75},"slow");				
				} else {
					$j("#contentPastEvents .paEvents").append(layer);
					$j("#contentPastEvents .paEvents .transparentLayer").animate({opacity: 0.75},"slow");
				}
//				alert('start');
			},
			success: function (data, status, request) {
//				alert('success ' + status);
//				alert(data);
				$j("#ajaxLoad").hide();
				$j("#contentPastEvents").html(data);

				layer.animate({opacity: 0.0},"slow", function () {
					if ($j.browser.msie) {
						$j("#contentPastEvents").remove(layer);
					} else {
						$j("#contentPastEvents .paEvents").remove(layer);
					}					
				});				
				
				$j('.last').bind('mouseenter', doHoverInLast);
				$j('.last').bind('mouseleave', doHoverOutLast);
			},
		    error: function (request, status, error) {
//		    	alert('error');
//		        alert(request.responseText);
		    	$j("#ajaxLoad").hide();
		        $j("#contentPastEvents").html(request.responseText).fadeIn("slow");
		    }			
		});

		return false;
	});	
}

//Startseite Lehrgang events open/close
function processButton(button, id, isPast) {
	$j(document).ready(function() {
		var self = $j(button);
		var c = self.attr('class');
		if (c == 'courseCloseButton') {
			closeWrapper(id);
			self.removeClass('courseCloseButton');
			self.addClass('courseOpenButton');
		} else {
			openWrapper(id, isPast);
			self.removeClass('courseOpenButton');
			self.addClass('courseCloseButton');
		}
	});
}

//Startseite Lehrgang events
function openWrapper(id, isPast) {
	var offset = 0;
//	var offset = 11;
//	var offset = 76;
	var size = $j('#'+id).children().size();
	var i = 1;
	var index = 0;
	var isNextEventFirst = false;
	var existsNextEvent = false;
	$j('#'+id).children().each(function() {
		
//		alert($j(this).attr('class'));
		
		if ($j(this).attr('class') != 'paStandardCourseTable nextEvent') {
			$j(this).show();
		} else { // das ist die naechste veranstaltung
			existsNextEvent = true;
//			alert('nextEvent');
			var sep = $j('#'+id+' .separatorLarge');
//			alert(sep);
			if (sep != null) {
//				sep.removeClass('separatorLarge');
//				alert('removing');
				sep.remove();
			}
			
			if (i != 2) {
//				alert('nextEvent');
				$j(this).css('border-top', '1px solid #D8D8D8'); // table paStandardCourseTable top border
				$j(this).css('border-bottom', '1px solid #D8D8D8'); // table paStandardCourseTable top border
				if (size != i) {
					$j(this).css('margin-bottom', '0px');
				}
			} 
			
			if (i == 2) {// i == 1 ist separator
//				alert('first');
				isNextEventFirst = true;
				$j(this).css('border-bottom', '1px solid #D8D8D8'); // table paStandardCourseTable top border
			}
			
			if (i+1 == size) {
				$j(this).css('border-bottom', '0px'); // table paStandardCourseTable top border
			}
        }
		
//		alert(i+"/"+size);
		index = i+1; 
		if (isPast) {
			index = i; //bei abgelaufenen kein separatorLarge
		}
		
		if (index == size) { 
			offset += $j(this).height();
		}
		i++;
	});
	// vertical line height setzten
	
	
//	alert(offset);
	if (existsNextEvent || isPast) {
		$j('#'+id+' .vertLine:first').height($j('#'+id).height()-offset); 
	}
	
	if (!isNextEventFirst) {
		$j('#'+id).css('border-top', '1px solid #DADADA'); // div wrapper top border
	}
	$j('#'+id).css('margin-bottom', '5px');	// div wrapper 
	
	doHover('.last', '0px -29px');
	$j('div.last .courseWrapper').css('margin-bottom', '1px');
}

//Startseite Lehrgang events
function closeWrapper(id) {
	var i = 1;
	var sep;
	var size = $j('#'+id).children().size();
	$j('#'+id).children().each(function() {
        if ($j(this).attr('class') != 'paStandardCourseTable nextEvent') {
    		$j(this).hide();
        } else { // das ist die naechste veranstaltung
//        	sep = $j('#'+id+' .separator:first');
//        	if (sep != null) {
//        		sep.addClass('separatorLarge');
//        	}
        	
        	sep = $j('<div class="separator separatorLarge"></div>')
        	$j('#'+id).append(sep);
        	
        	$j(this).css('border-top', '0'); // table paStandardCourseTable top border
//        	$j(this).css('border-bottom', '0'); // table paStandardCourseTable bottom border
        	$j('div.lastFutureCourse #'+id).find('.nextEvent').css('border-bottom', '0'); // table paStandardCourseTable bottom border
        	if (size != i && i != 1) {
//        		$j(this).css('margin-bottom', '-1px');  
        		$j(this).css('border-bottom', '0'); // table paStandardCourseTable bottom border
        	}
        }
//        alert(i);
		if (i == size && sep != null) {
			sep.show();
		}
        
        i++;
	});	
	$j('#'+id).css('border-top', '0');	// div wrapper top border
	$j('#'+id).css('margin-bottom', '0px');	// div wrapper 
	$j('div.last .courseWrapper').css('margin-bottom', '0px');
}
//Startseite Lehrgang events
function setVertLineHeight(id) {
//	alert('drin');
//	var offsetL = 14;
//	var offsetL = -10;
	var offsetL = -7;
	var size = $j('#'+id).children().size();
	var i = 1;
	$j('#'+id).children().each(function() {
		if (i == size) {
			offsetL += $j(this).height();
		}
		i++;
	});	
	// vertical line height setzten
	$j('#'+id+' .vertLine:first').height($j('#'+id).height()-offsetL); 
}

//Detailseite portlet
function processPortlet() {
	if ($j(this).attr('class') == 'headerText opened') {
		$j(this).parent().find('.content:first').hide();
		$j(this).removeClass('opened');
		$j(this).addClass('closed');
	} else {
		$j(this).parent().find('.content:first').show();
		$j(this).removeClass('closed');
		$j(this).addClass('opened');
	}
}



function loadItemContent(contextPath, itemUrl) {
//	alert(contextPath + " / " + itemUrl);
	$j(document).ready(function() {
		var url = "/" + itemUrl;
		var layer = $j("<div>&nbsp;</div>");
		layer.addClass("transparentLayer");
		var loader = $j('<img alt="" src="images/pa/content/indicator.gif" id="ajaxLoad" />');
		
		$j.ajax({
			type: 		"post",
			url: 		contextPath + url,
			beforeSend: function (xhr) {
				layer.css('height',$j("#paDetailHeaderItems").height());
				layer.css('width',$j("#paDetailHeaderItems").width());
				layer.css('z-index','9998');
				
				loader.css('top','6px');
				loader.css('right','5px');
				loader.css('z-index','9999');
				loader.css('position','absolute');
				$j("#paDetailHeaderItems").append(loader);
				loader.show();
				$j("#paDetailHeaderItems").append(layer);
				layer.animate({opacity: 0.75},"slow");
//				alert('start');
			},
			success: function (data, status, request) {
//				alert('success ' + status);
//				alert(data);
				var response = $j(data).find('#paDetailHeaderItems').html();
//				alert(response);
				$j("#ajaxLoad").hide();
				$j("#paDetailHeaderItems").html(response);
				
				layer.animate({opacity: 0.0},"slow", function () {
					$j("#paDetailHeaderItems").remove(layer);
				});
			},
		    error: function (request, status, error) {
//		    	alert('error');
//		        alert(request.responseText);
		    	$j("#ajaxLoad").hide();
		        $j("#paDetailHeaderItems").html(request.responseText).fadeIn("slow");
		    }			
		});

		return false;
	});	
}





/* HOVER EFFECTS */
function doHoverInLast() {
	doHover('.last', '0px -196px');
}

function doHoverOutLast() {
	doHover('.last', '0px -29px');
}

function doHoverInLastFuture() {
	doHover('.lastFuture', '0px -196px');
}

function doHoverOutLastFuture() {
	doHover('.lastFuture', '0px -29px');
}

function doHoverInFooter(e) {
	doHoverFooter('.last', '0px -196px', '#e6e8f0');
	doHoverFooter('.lastFuture', '0px -196px', '#e6e8f0');
}

function doHoverOutFooter() {
	doHoverFooter('.last', '0px -29px', '#ffffff');
	doHoverFooter('.lastFuture', '0px -29px', '#ffffff');
}

function doHover(c, v) {
	$j(document).ready(function() {
		if ($j('.linkFurtherEvents').length > 0) {
			return;
		}
		
		if ($j('.last .courseCloseButton').length > 0) { // falls course events aufgeklappt sind kein hover
			return;
		}		
		
		var obj = $j(c).closest('.paTable').find('.footer:first');
		
		if (obj != null) {
			obj.css('background-position',v);
		}
	});
}

function doHoverFooter(c, v1, v2) {
	$j(document).ready(function() {
		if ($j('.linkFurtherEvents').length > 0) {
			return;
		}
		
		if ($j('.last .courseCloseButton').length > 0) { // falls course events aufgeklappt sind kein hover
			return;
		}
		
		var obj = $j('.footer').closest('.paTable').find(c+':first');
		if (obj != null) {
			obj.css('background-color',v2);
//			$j('div.last .courseWrapper').css('margin-bottom','0');
			obj.closest('.paTable').find('.footer').css('background-position',v1);
		}
	});
}



function openLMSPopUpOnlineService(transferLinkToLms) {
	lms=window.open(''+transferLinkToLms+'', 'LMS','width=972,height=675,toolbar=0,directories=0,menubar=0,status=0,resizable=0')
	return false;
}
//Event.observe(window, 'load', function() { openLMSPopUp() });





