$(document).ready(function(){
	$("a[class=reveal]").hover(
		function(){ 
			sMenu = $(this).attr('data');
			position = $(this).position();
			iHeight = 9;
			iWidth = 0;
			if($.browser.msie) {
				iHeight = 7;
				iWidth = -4;
			}
			$('div[id='+sMenu+']').css('top', position.top+$(this).height()+iHeight);
			$('div[id='+sMenu+']').css('left', position.left);
			
			iWidth = $(this).width() + 17;
			$('div[id='+sMenu+'] div[class=menu-top]').css('width', iWidth+'px');
			iWidth += 15
			$('div[id='+sMenu+']').css('min-width', iWidth+'px');
			$('div[id='+sMenu+']').css('width', iWidth+'px');

			$('div[id='+sMenu+']').show();
		},
		function() {
			sMenu = $(this).attr('data');
			$('div[id='+sMenu+']').hide();
		}
	);
	$("div[class=menu]").hoverMenu();
});

$.fn.hoverMenu = function() {
	return this.each(function() {
		$(this).hover(
			function() {
				sMenu = $(this).attr('id');
				$('div[id='+sMenu+']').show();
			},
			function() {
				sMenu = $(this).attr('id');
 				$('div[id='+sMenu+']').hide();
			}
		);
	});
};

function randomStringForUrl(string_length) {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
function ucwords( str ) {
    return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase ( ); } );
}
function searchInput(event) {
	$('#search-input').css('background-color', '');
	if(event!=null) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if(keyCode == 13) 
			searchSubmit();
	}
}
function searchButton() {
	searchSubmit();
}
function searchSubmit() {
	sSearch = $('#search-input').val();
	if(sSearch)
		window.location = 'products.php?search='+sSearch;
	else
		$('#search-input').css('background-color', 'red');
}
