$(document).ready(function(){

    $("a[rel^='viewgallery']").prettyPhoto();
	$('a.itemdel').livequery(function(){ $(this).qtip({	content: 'Click to remove this item from cart',	position: { corner: 'rightMiddle' , adjust: { x: -8, y: 2 } }, show: { solo: true }, style: {background: "#666", border: { width: 1, radius: 3, color: '#777'}, padding: 1, tip: 'rightMiddle', name: 'dark' } }); }, function() { $('.qtip').hide(); });
	$("a.itemadd").live("click", function() { xajax_add_to_cart(this.id);});
	$("a.itemdel, a.itemdelc").live("click", function() { xajax_del_from_cart(this.id);});
	$("#cart").bind("mouseover", function() {$('#cartfull:hidden').show('blind', { direction: 'vertical' }, 300);});
	$("#cart").bind("click", function() {$('#cartfull').toggle('blind', { direction: 'vertical' }, 300);});
	$("#cartclose").bind("click", function() {$('#cartfull').hide('blind', { direction: 'vertical' }, 200);});
	$("#qslink").bind("click", function() {$('#qsearch').toggle('slide', { direction: 'down' }, 200);});
	//$("#qllink a.title").bind("mouseenter", function() {$('#qletters').show('slide', { direction: 'up' }, 200);});
	//$("a.menuitem").bind("mouseleave", function() {$('#qletters:visible').hide('slide', { direction: 'up' }, 200);});
	$("input#qs").toggleVal();
	$('a.lostpwdlink').nyroModal({sizes: {initW: 600, w: 600, initH: 450, h: 450}});
	$('a.info').live("mouseover", function() {$('a.info').cluetip({clickThrough: true, width: 400, showTitle: false, fx: {open:"fadeIn"} });}).cluetip({clickThrough: true, width: 400, showTitle: false, fx: {open:"fadeIn"} });
	$('#qletters a[href="' + document.location.pathname + '"], #letters a[href$="' + document.location.pathname + '"],#menu a[href="' + document.location.pathname + '"]').addClass("selected").click(function() { return false; } );

  $('#qs').autocomplete({
    source: function(request, response) {
      $.ajax({
        url: "/tagbox/",
        dataType: 'json',
        data: { term: request.term, max: 20 },
        success: function(data) {
          response($.map(data, function(item) {
            return {value: item.value,
                    label: item.label,
                    id: item.id};

          }));
        }
      });
    },
    minLength: 2,
    select: function( event, ui ) {
        document.location.href =  "/info/" + (ui.item.id) + "/";
	}
 })
  .data( "autocomplete" )._renderItem = function( ul, item ) {
                return $( "<li></li>" )
                        .data( "item.autocomplete", item )
                        .append( $( "<a></a>" ).html(item.label) )
                        .appendTo( ul );
                };
});

function headcontrol()
{
	$('#header, #logo, #menu').toggleClass("min");
	$.cookies.set('hmin', $("#header").hasClass("min"), {hoursToLive: 17520});
}

