jQuery( function() {
  // Disable dragging on certain portlets
  jQuery('#layout-column_portlet\\:71_INSTANCE_0001').removeClass('lfr-portlet-column');
  jQuery('#layout-column_portlet\\:73_INSTANCE_0001').removeClass('lfr-portlet-column');
  jQuery('#layout-column_portlet\\:N5SecondaryContentEditor_INSTANCE_0001').removeClass('lfr-portlet-column');
  jQuery('#personResponsibleForContentPortlet_WAR_stmpersonresponsibleforcontent .lfr-portlet-column').removeClass('lfr-portlet-column');
  
  // Hide private links from Dock's My Places
  jQuery("h3:contains('fi'),h3:contains('sv'),h3:contains('en')").parent().next().find(".private").addClass("hide-private")
  ;  
});


jQuery(document).ready( function() {
	// Topnavi dropdown
	jQuery("#top-navi li").hover(
		function () {
			jQuery(this).addClass('hover');
			jQuery(this).find('.child-menu').fadeIn('fast');
		}, 
		function () {
			jQuery(this).removeClass('hover');
			jQuery(this).find('.child-menu').fadeOut('fast');
		}
	);

	// Ticket 8783: remove borders from first-child. IE6 does not support the pseudo-class :first-child
	jQuery('.frontpage #layout-column_column-5 .portlet:first').addClass('hide-border');

	// If page has subpage(s) which is hidden from navi it shows anyway an empty UL in navigation.
	// We hide the empty ul with JS. This isssue is fixed in Liferay 5.x 
	// - mileht
	
	jQuery('#left .nav-menu ul').each(function() {
		if (jQuery(this).children().length == 0) {
			jQuery(this).remove();
		}
	});

	
	// JavaScript text modifications for Blog and comments
	jQuery('#portlet-wrapper-33 #_33_messageScroll0 td a:contains("Vastaa")').each(function(){
		jQuery(this).html( 
			jQuery(this).html().replace(/Vastaa/,'Kommentoi blogia')
		);
	});
	
	jQuery('#portlet-wrapper-33 #_33_postReplyButton0:contains("Vastaa")').each(function(){
		jQuery(this).html( 
			jQuery(this).html().replace(/Vastaa/,'Kommentoi')
		);
	});
	
	if ( jQuery('#portlet-wrapper-33 #_33_postReplyButton0').val() == "Vastaa" ){
		jQuery('#portlet-wrapper-33 #_33_postReplyButton0').val('Kommentoi');
	}
	
	jQuery('#portlet-wrapper-33 .comments:contains("Kommentit")').each(function(){
		jQuery(this).html( 
			jQuery(this).html().replace(/Kommentit/,'Kommenttia')
		);
	});
	
	
	
	/* Frontpages should not be edited.. Function disables all inputs for those pages 
	   that are listed in disableEditingOnPages array
	*/
	
	var disableEditingOnPages = new Array();
	
	// List of pages that should be disabled (groupId-layoutId)
	disableEditingOnPages['10854-1350'] = true; // fi
	disableEditingOnPages['10857-524'] = true; // sv
	disableEditingOnPages['10860-205'] = true; // en
	
	// Check if input field exists ... Manage Pages portlet's id is 88
	if ( jQuery('input[@name=_88_layoutId]').size() > 0 ) {
		
		var pageid = jQuery('input[@name=_88_groupId]')[0].value + "-" + jQuery('input[@name=_88_layoutId]')[0].value;
		
		if ( disableEditingOnPages[pageid] ) {
			// Disable inputs and selects ...
			jQuery('#p_p_id_88_ input').attr("disabled", "disabled");
			jQuery('#p_p_id_88_ select').attr("disabled", "disabled");
		}
		
	}
});

