var tOut;
var locker = false;

function hider () {
    $('#alert').empty().hide();
    clearTimeout(tOut);
}


function show_note (obj, kit, pretext) {
	var obj, pretext;
	var kit = parseInt(kit);
	if (pretext == '' && kit == 0) return;
	var Notes = new Array ('');
	var separator = '<hr style="width:175px;">';
	var text = (pretext ? pretext + (kit != 0 ? separator : '') : '') + Notes[kit];
	if (!locker) {
		$(obj).mousemove( function (e) {
			if ( e.pageY && e.pageX ) {
				$('#floating').css('top', e.pageY + 20);
				$('#floating').css('left', e.pageX + 15);
			} else {
				$('#floating').css('top', e.clientY + 20);
				$('#floating').css('left', e.clientX + 15);
			}
		});
    }
	$('#floating').html(text).show(50);
	window.setTimeout('hide_note()', 10000);
}

function hide_note () {
	$('#floating').hide();
}

function default_search (field, searchDef) {
	var field, searchDef;
    var curVal = $.trim( $('#' + field).val() );
    if (curVal == '' || curVal == searchDef) $('#' + field).val(searchDef).css('color', '#999999');
}

$(document).resize( function () {
	$('#top_holder').height($(this).height());
});

$(document).ready( function () {

    tOut = window.setTimeout('hider()', 8000);
    default_search('phone', 'xxxxxxxxxx');

	if (location.pathname.indexOf('admin') == -1) $(function() { $('.gallery a').lightBox(); });

    $('#menu a img').hover( function() {
        var src = $(this).attr('src');
        $(this).attr('src', src.replace('.png', '_h.png'));
    }, function() {
        var src = $(this).attr('src');
        $(this).attr('src', src.replace('_h.png', '.png'));
    });

    $('.gal_photo img, .del_photo img, .download, .show, .edit, .del').hover( function() {
    	show_note($(this), 0, $(this).attr('alt'));
    }, function() {
    	hide_note();
    });

    $('#phone').focus( function () {
        $(this).css('color', '#000000');
        if ($(this).val() == 'xxxxxxxxxx') $(this).val('');
    });
    $('#phone').blur( function () {
        default_search('phone', 'xxxxxxxxxx');
    });

    $('.type a').click( function () {
    	$('.type div').hide();
    	$('.type').css('background', 'none').css('color', '#000000');
    	$('.type a').css('color', '#000000');
    	$(this).parent('.type').css('background', 'url(/img/dot.png) no-repeat 15px 15px').children('div').show();
    	$(this).parent('.type').children('a').css('color', '#004760');
    	$(this).blur();
    });

});