$(function() //document is loaded
{
//png fix 
$("#header-left").pngFix();
	
//button hover
$(".button").hover(
function()
{ $(this).addClass("ui-state-hover"); },
	function(){ 
		$(this).removeClass("ui-state-hover"); 
		})	;

	

	
		//all hover and click logic for buttons
		$(".fg-button:not(.ui-state-disabled)")
		.hover(
			function(){ 
				$(this).addClass("ui-state-hover"); 
			},
			function(){ 
				$(this).removeClass("ui-state-hover"); 
			}
		);
		

		
			$(".h_deal").hover(
			function(){ 
				$(this).addClass("ui-state-active").removeClass("ui-state-default");
			},
			function(){ 
				$(this).removeClass("ui-state-active").addClass("ui-state-default");
			}
		);
		

$(".footer-box").hover(
function(){ $(this).find('.footer-box-header').addClass("ui-state-active").removeClass("ui-state-default");$(this).fadeTo("fast", 1);},
function(){ $(this).find('.footer-box-header').removeClass("ui-state-active").addClass("ui-state-default");$(this).fadeTo("fast", 0.8); });	


		

			
		$.widget("ui.combobox", {
			_create: function() {
				var self = this;
				var select = this.element.hide();
				var name = select.attr("name");

		
				
				var input = $("<input>").attr("name",name).addClass("jsd").insertAfter(select);
				if(undefined===window.values){
				window.values = [];
				}
				else
				{
					input.val(values[name]);
				}
				select.remove();
					input.autocomplete({
						source: function(request, response) {
							var matcher = new RegExp(request.term, "i");
							response(select.children("option").map(function() {
								var text = $(this).text();
								if (!request.term || matcher.test(text))
									return {
										id: $(this).val(),
										label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + request.term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
										value: text
									};
							}));
						},
						delay: 0,
						select: function(e, ui) {
							if (!ui.item) {
								// remove invalid value, as it didn't match anything
								$(this).val("");
								return false;
							}
							$(this).focus();
							select.val(ui.item.id);
							self._trigger("selected", null, {
								item: select.find("[value='" + ui.item.id + "']")
							});
							
						},
						minLength: 0
					})
					.css("border","1px solid #DDD").addClass("search_text_input ui-widget ui-widget-content ui-corner-left");
				$("<button type='button'></button>")
				.insertAfter(input)
				.button({
					icons: {
						primary: "ui-icon-triangle-1-s"
					},
					text: false
				}).removeClass("ui-corner-all")
				.addClass("ui-corner-right ui-button-icon auto-button")
				.position({
					my: "left top",
					at: "right top",
					of: input,
					offset: "-1 0"
				})
				.click(function() {
					// close if already visible
					if (input.autocomplete("widget").is(":visible")) {
						input.autocomplete("close");
						return;
					}
					// pass empty string as value to search for, displaying all results
					input.autocomplete("search", "");
					input.focus();
				});
			}
		});

	});