(function ($) {
    $.fn.searchForm = function () {
        var $this = $(this);
        var label = $this.find('.serch_label');
        var input = $this.find('.search_input');
        if (input.val() != '') {
            label.hide().animate({ opacity: 0 });
        }
        label.bind('click', function () {
            label.hide().animate({ opacity: 0 });
            input.focus();
        });
        input.bind('focus', function () {
            label.hide().animate({ opacity: 0 });
        });
        input.bind('blur', function () {
            if (input.val() == '') {
                label.show().animate({ opacity: 1 });
            }
        });
    }
})(jQuery);

$(document).ready(function () {
    $('#search').searchForm();
    $("#account").mouseenter(function () {
        $('#account_menu').slideDown(300);
        $("#account").css('color', '#000');
        $("#account").css('background-color', '#fff');
    }).mouseleave(function () {
        $('#account_menu').slideUp(300);
        $("#account").css('color', '#c7c8ca');
        $("#account").css('background-color', '#000');
    });
});

(function($){
     $.fn.extend({
          center: function (options) {
               var options =  $.extend({ // Default values
                    inside:window, // element, center into window
                    transition: 0, // millisecond, transition time
                    minX:0, // pixel, minimum left element value
                    minY:0, // pixel, minimum top element value
                    withScrolling:true, // booleen, take care of the scrollbar (scrollTop)
                    vertical:true, // booleen, center vertical
                    horizontal:true // booleen, center horizontal
               }, options);
               return this.each(function() {
                    var props = {position:'absolute'};
                    if (options.vertical) {
                         var top = ($(options.inside).height() - $(this).outerHeight()) / 2;
                         if (options.withScrolling) top += $(options.inside).scrollTop() || 0;
                         top = (top > options.minY ? top : options.minY);
                         $.extend(props, {top: top+'px'});
                    }
                    if (options.horizontal) {
                          var left = ($(options.inside).width() - $(this).outerWidth()) / 2;
                          if (options.withScrolling) left += $(options.inside).scrollLeft() || 0;
                          left = (left > options.minX ? left : options.minX);
                          $.extend(props, {left: left+'px'});
                    }
                    if (options.transition > 0) $(this).animate(props, options.transition);
                    else $(this).css(props);
                    return $(this);
               });
          }
     });
})(jQuery);


//function showModal(obj) {
//	obj.show('fade', 300);
//	$("#ContentHolder").append("<div class='modal_wrapper'>&nbsp;</div>");
//	obj.css('z-index', $('.modal_wrapper').css('z-index')+1)
//	if ( $.browser.msie ) {
//		$('.modal_wrapper').show();
//	} else {
//		$('.modal_wrapper').show('fade',300);
//	}
//	obj.center();
//}
function showModal(obj, contentHolder) {
    obj.show('fade', 300);
    $(contentHolder).append("<div class='modal_wrapper'>&nbsp;</div>");
    obj.css('z-index', $('.modal_wrapper').css('z-index') + 1)
    if ($.browser.msie) {
        $('.modal_wrapper').show();
    } else {
        $('.modal_wrapper').show('fade', 300);
    }
    obj.center();
}

function hideModal(obj) {
	obj.hide('fade', 300);
	if ( $.browser.msie ) {
		$('.modal_wrapper').hide();
	} else {
		$('.modal_wrapper').hide('fade',300);
	}
	$('.modal_wrapper').remove();
}

/*function deleteWrapper() {
	$('.modal_wrapper').css('display', 'none');
	$('.modal_wrapper').remove();
}*/
