$(document).ready(function() {
	var settings = {
		tl: { radius: 10 },
        tr: { radius: 10 },
        bl: { radius: 10 },
        br: { radius: 10 },
        antiAlias: true
    };
	var settingsTop = {
		tl: { radius: 10 },
        tr: { radius: 10 },
        bl: { radius: 0 },
        br: { radius: 0 },
        antiAlias: true
    };
	//curvyCorners(settings, '.curved');
	//curvyCorners(settingsTop, '.topcurved');
	$('#newsletter-3rdparty').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - ",
		extraClass: "pretty",
		fixPNG: true
	});
	$('#product-dialog').dialog({
		modal: true,
		autoOpen: false,
		position: 'center',
		width: "40em",
		title: 'Product profile added to \'My Products\'',
		buttons: {
			'Request Information': function() {
				$(this).dialog("close");
				window.location.href = '/my-products/send';
			},
			'Continue Browsing': function() {
				$(this).dialog('close');
			}
		}
	});
	$('#welcome p:first').css({"height": "15em", "overflow": "hidden"});
	$('#welcome div').append('<a href="#" id="expand-welcome"><img src="/images/more.png" alt="More" /></a>');
	
	$('#expand-welcome').click(function(){
		if ($('#welcome p:first').height() == 162) {
			$('#welcome p:first').height(300);
		}
		else {
			$('#welcome p:first').height(162);
		}
	});
});

function submitSearch(href,id)
{
	if (document.getElementById(id).value != '') {
		window.location.href = href + escape(document.getElementById(id).value) + '/';
	}
}
function checkKey(href, id, e)
{ 
	var key;

    if(window.event) {
         key = window.event.keyCode;     //IE
    }
    else {
         key = e.which;     //firefox
    }
    if (key == 13)
    {
    	submitSearch(href,id);
    }
}

function wishlist(href)
{
	$.get(href, function(data) {
		$('#basket').replaceWith(data);
		$('#product-dialog').dialog("open");
	});
}

function checkSearch()
{
	if ($('#company').val() != 'Company')
	{
		submitSearch('/search/company/', 'company');
	}
	else if ($('#keyword').val() != 'Keyword')
	{
		submitSearch('/search/site/', 'keyword');
	}
}