/**
 * Jquery actions for job list pages
 */

jQuery(document).ready(function() {
	// Handler for .ready() called.
	
	jQuery("DIV.topJobsListItem").easyMorphingBgColor({color:"ffffff",originalColor:"ffffff"});
	jQuery("DIV.topJobsListItem").mouseover(function() {
		jQuery(this).css( "opacity", "0.9");}).mouseout(function(){jQuery(this).css( "opacity", "1.0");
	});
	
	jQuery("DIV.jobFilterButtons").mouseover(function() {
		jQuery(this).css({'background-color': '#ffffff', 'border': '1px solid #85c7eb'});
		jQuery("INPUT#jobFilterSubmitButton").css({'color': '#000000'});	
	}).mouseout(function(){
		jQuery(this).css({'background-color': '#85c7eb', 'border': '1px solid #ffffff'});
		jQuery("INPUT#jobFilterSubmitButton").css({'color': '#ffffff'});
	});
	
	jQuery("INPUT.joblistFilterItemChboxAll").click(function() {
		if (jQuery(this).attr("checked")) {
			// Lösche alle anderen Checkboxes
			jQuery.each("INPUT.joblistFilterItemChbox", function(index) {
				jQuery("INPUT#chckbox_"+index).attr('checked', false);
			});
		}
		//fire form
		jQuery('#jobfilterForm').submit();
	});
	
	jQuery("INPUT.joblistFilterItemChbox").click(function() {
		var b_isFilterSet = false;
		jQuery.each("INPUT.joblistFilterItemChbox", function(index) {
			var buttonID = "chckbox_"+index;
			if (jQuery("INPUT#"+buttonID).attr("checked")) {
				b_isFilterSet = true;
			}
		});
		
		if (b_isFilterSet == true) {
			jQuery("INPUT.joblistFilterItemChboxAll").attr('checked', false);
		} else {
			jQuery("INPUT.joblistFilterItemChboxAll").attr('checked', true);
		}
		
		//fire form
		jQuery('#jobfilterForm').submit();
		
	});
	
	
	var iHelper = 0;
	
	jQuery('.highlightField').css('opacity','0.95');
	
	jQuery('.topJobsListItem').each(function(index) {
		var heighlightsOpenFieldID = jQuery(this).children(".highlightField").attr("id");
			
		var jobTitleID = jQuery(this).children(".topJobsListItemTitleWrapper");
		
		var heighlightsOpenFieldIDHeight = 	jQuery("#"+heighlightsOpenFieldID).outerHeight();
		
		
		var totalItemBarHeight =  jQuery("#"+jQuery(this).attr("id")).outerHeight();
		iHelper += totalItemBarHeight;
		
//		jQuery("#"+heighlightsOpenFieldID).css("margin-top", "-" + (heighlightsOpenFieldIDHeight - totalItemBarHeight) - 2 + "px");
		jQuery("#"+heighlightsOpenFieldID).css("margin-top", "-1px");
		
		jQuery(jobTitleID).mouseover(function() {
			jQuery("#"+heighlightsOpenFieldID).stop(true, true);
			jQuery("#"+heighlightsOpenFieldID).fadeIn();
		}).mouseout(function(){
			jQuery("#"+heighlightsOpenFieldID).stop(true, true);
			jQuery("#"+heighlightsOpenFieldID).fadeOut();
		});
		
	});
	
	jQuery("#mainContainerWrapper").css( "height", (iHelper + 500) + "px");
	
	/**
	PDF
	**/
	jQuery("DIV#pdfButton").mouseover(function() {
		jQuery(this).css("color","black");
	}).mouseout(function(){
		jQuery(this).css("color","#33a2dd");
	});
});

function openDetails(page) {
//	alert('http://cb.p3b.local/'+page);
	window.open(page,"_self");
}
