//Resizes the iframes in the window to the appropriate height
function redraw(frameID)
{
	var frame = $('#'+frameID);
	var height = frame.contents().find('html body').height();

	if ($.browser.msie == true || $.browser.opera == true)
	{
		height = document.frames(frameID).document.body.scrollHeight;
	}

	if ( ($.browser.opera == true || $.browser.chrome == true || $.browser.safari == true) && frameID == 'navig')
	{
		height = height - 70;
	}
	
	if ( ($.browser.chrome == true || $.browser.safari == true)	&& frameID != 'navig')
	{
		height = height + 20;
	}

	frame.height(height);
}

function sendToAFriend()
{
	if ($.browser.msie == true)
	{
		sendToAFriendURL(window.location.href);
	}
	else
	{
		var win=window.open('/Contact/SendToFriend.aspx', 'sendtoafriend', 'directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=0,toolbar=no,width=550,height=400');
		win.focus();
	}
}

function sendToAFriendURL(url)
{
	var win=window.open('/Contact/SendToFriend.aspx?url='+url, 'sendtoafriend', 'directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=0,toolbar=no,width=550,height=400');
	win.focus();
}

function fixMenuBorders()
{
	// removes extra border from last menu items
	$('.topMenu li ul li:last-child > a, .catalog li ul li:last-child > a').each(function()
	{
		$(this).addClass('noBorder');
	});
}

function fixSearchBoxEnterButton()
{
	// add functionality for pressing the enter button when in the search box in IE
	$('.searchTextBox').keypress(function(e)
	{
		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
		{
			$('.searchButton').click();
			return false;
		}
		else
		{
			return true;
		}
	});
}

$(function()
{
	$('#catalogSidebar a.sendToAFriend, #literatureWrapper a.sendToAFriend')
	.attr('href', '/Contact/SendToFriend.aspx?url=' + window.location.href)
	.attr('rev',"width:550 height:400 scrolling:no controlPos:tr");
});

String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function()
{
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function()
{
	return this.replace(/\s+$/,"");
}
