/*add class=roll_image to a image for rollover effect*/
function roll_image() {
	jQuery('img.roll_image').hover(function() {
			var imageSrc = jQuery(this).attr("src");
			imageArr = imageSrc.split(".");
			var newImg = imageArr[0]+"_roll."+imageArr[1];
			jQuery(this).attr("src", newImg);
		}, function() {
			var imageSrc = jQuery(this).attr("src");
			imageArr = imageSrc.split(".");
			var newImageNamePart = imageArr[0].replace("_roll","");
			var newImg = newImageNamePart+"."+imageArr[1];
			jQuery(this).attr("src",newImg);
	});
}

/*rollover for buttons left/right fix and middle with a flexible width*/
function roll_button() {
	jQuery('.buttonbox,.buttonboxreader')
		.hover(
			function() {
				jQuery(this).addClass('button_roll');
			}, 
			function() {
				jQuery(this).removeClass('button_roll');
			})
		.mousedown(
			function() {
				jQuery(this).removeClass('button_roll').addClass('button_act');
			})
		.mouseup(
			function() {
				jQuery(this).removeClass('button_act');
			});
}

/*center a container horizontal*/
function centerElement(objId) {
	var myWidth =  jQuery('#'+objId).width();
	var parentWidth = jQuery('#'+objId).parent().width();
	var pos = Math.round(parentWidth/2)-Math.round(myWidth/2);
	jQuery('#'+objId).css({ left: pos+"px"});
	//alert ("parentwidth: "+parentWidth+"  Mywith: "+myWidth)
}

/*top navigation*/
function topNav() {
	//jQuery("#nav-global li:first").addClass('navleft');
	//jQuery("#nav-global li:last").addClass('navright');
	jQuery('#nav-global li')
		.mouseover(
			function() {
				jQuery(this).addClass('navroll');
			})
		.mouseout(
			function() {
				jQuery(this).removeClass('navroll'); 
			});
}




jQuery(document).ready(function() {
	roll_image();
	roll_button();
	topNav();
});