
function resizeModuleGroup(moduleGroupElement) {
	var groupHeight = jQuery(moduleGroupElement).height();
	if (jQuery(moduleGroupElement).children('.module:not(.unframed)').size() > 1) {
		jQuery(moduleGroupElement).children('.module:not(.unframed)').each(function(){
			var moduleHeaderHeight = jQuery(this).children('.moduleHeader').outerHeight(true);
			var moduleFooterHeight = jQuery(this).children('.moduleFooter').outerHeight(true);
			var moduleBodyWrapHeight = groupHeight - moduleHeaderHeight - moduleFooterHeight;
			jQuery(this).children('.moduleBodyWrap').height(moduleBodyWrapHeight + 'px');
		});
	}
}

jQuery(document).ready(function(){
	jQuery('.moduleGroup').each(function(){
		resizeModuleGroup(this);
	});
});

function goToByScroll(id){
     $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

$(function(){
	
	/*
	------------------------------------------------------------------------------------------------------
	Online Catalog 
	------------------------------------------------------------------------------------------------------
	*/
	
	if($("#content").find('#flash_catalog').length ) {
		var swf_url = 'swf/online_catalog.swf';
	
		var params = {};
		params.allowfullscreen = "true";
		params.wmode = "transparent";
		
		var flashvars = {};
	
		swfobject.embedSWF(swf_url, "flash_catalog", 880, 663, "9", "swf/expressInstall.swf",flashvars,params );
	}
	
	/*
	------------------------------------------------------------------------------------------------------
	Forms 
	------------------------------------------------------------------------------------------------------
	*/
	
	$('#content').find('input[type=text]').each(function(i) {
		
		
		$(this).data('value', $(this).attr('title') );
		if($(this).val().length<1) {
			$(this).val($(this).attr('title'));
		}
		
		 $(this).blur(function () {
			if( $(this).val() == "") {
				$(this).val( $(this).data('value') );
			}
		});
		 
		$(this).focus(function () {
			if( $(this).val() == $(this).data('value') ) {
				$(this).val('');
			}
		});
		
	});
	
	if($('#content').find('.formmsg').length ) {
	 showOverlay( $('.formmsg').html() );
	}
	
});

/*
------------------------------------------------------------------------------------------------------
Overlay 
------------------------------------------------------------------------------------------------------
*/

function showOverlay(_msg) {
	
	var overlayHtml = '<div id="overlay">' +
	'<div class="background"></div>' +
	'<div class="container">' +
	'<p>' + _msg + '</p>' +
	'<a href="#">OK</a> </div>' +
	'</div>';
	
	$('body').append(overlayHtml);
	$('#overlay').css({opacity: 0}); 
	
	$('#overlay').animate({
		opacity: 1
	}, 300, 'easeOutQuad');
	
	$('#overlay .container').click(function() {
		
		$('#overlay').animate({
			opacity: 0
		}, 300, 'easeOutQuad', function() {
		  $(this).remove();
		});
		 
		 return false;
		
	});
	
}




