/* COPYRIGHT 2000-10, EARTHGAZER LTD. ALL RIGHTS RESERVED */
/* Lovingly crafted for Kisami */

$(document).ready(function() {
  mva('#globalDept','#footer')
  tts()
  tt('.view_product_tip','Click to view','bottomMiddle','topMiddle','tool_tip','mouse')
  tt('.view_more_tip','Click to view more','bottomMiddle','topMiddle','tool_tip','mouse')
  st('.view_search_tip','Enter search keyword',$('.view_search_tip'))
  tt('.view_next_tip','Next','bottomMiddle','topMiddle','tool_tip','mouse')
  tt('.view_previous_tip','Previous','bottomMiddle','topMiddle','tool_tip','mouse')
  tt('.view_look_tip','Shop this look','bottomMiddle','topMiddle','tool_tip','mouse')
  vt('.non_left','Size not in stock',$('.non_left'))
  ss('.select_search')
  ro('.view_product')
  ro('.view_more')
  cy('.view_product_detail','#viewer')
  ht('input')
  vr()
  dn()
  ed()
});

function mva(a,b) {
  $(a).appendTo(b)
}

function ht(a){
  $(a).inputHint();
}

function tts() {
  $.fn.qtip.styles.tool_tip = {
     background: '#131313',
     color: '#FFFFFF',
     textAlign: 'center',
     fontSize: '9px',
     fontFamily: 'Helvetica,Arial,Sans-Serif',
     fontWeight: '600',
     textTransform: 'uppercase',
     border: { width: 0 }
  }
  $.fn.qtip.styles.search_tip = {
     background: '#ACACAC',
     color: '#FFFFFF',
     textAlign: 'center',
     fontSize: '9px',
     fontFamily: 'Helvetica,Arial,Sans-Serif',
     fontWeight: '600',
     textTransform: 'uppercase',
     border: { width: 0 }
  }
  
}

function tt(a,b,c,d,e,f) {
  $(a).qtip({
     content: b,
     show: { when: {event: 'mouseenter'}, delay: 0, solo: true, effect: { type: 'none' , length: 0 } },
     hide: { when: {event: 'mouseleave'}, delay: 0, solo: true, effect: { type: 'none' , length: 0 } },
     position:
     {
       corner: { target: c, tooltip: d },
       target: f,
       adjust: { mouse: true, x: 0, y: 20 }
     },
     style: { name: e  }
  })
}

function st(a,b,c,d,e,f) {
  $(a).qtip({
     content: b,
     show: { when: {event: 'mouseenter'}, delay: 0, solo: true, effect: { type: 'none' , length: 0 } },
     hide: { when: {event: 'mouseleave'}, delay: 0, solo: true, effect: { type: 'none' , length: 0 } },
     position:
     {
       corner: { target: 'bottomMiddle', tooltip: 'topMiddle' },
       target: f,
       adjust: { mouse: false, x: 0, y: 0 }
     },
     style: { name: 'search_tip', tip: { corner: 'topLeft', color: '#ACACAC', size: { x: 7, y: 7 } } }
  })
}

function vt(a,b,c,d,e,f) {
  $(a).qtip({
     content: b,
     show: { when: {event: 'mouseenter'}, delay: 0, solo: true, effect: { type: 'none' , length: 0 } },
     hide: { when: {event: 'mouseleave'}, delay: 0, solo: true, effect: { type: 'none' , length: 0 } },
     position:
     {
       corner: { target: 'topMiddle', tooltip: 'bottomLeft' },
       target: f,
       adjust: { mouse: false, x: 0, y: 0 }
     },
     style: { name: 'search_tip', tip: { corner: 'bottomLeft', color: '#ACACAC', size: { x: 7, y: 7 } } }
  })
}

function ss(a) {
  $(a).mouseenter(function() { $(this).focus() });
  $(a).mouseleave(function() { if ($(this).val() == '') { $(this).blur() }});
}

function ro(a) {
  $(a).hover(function() {
      $(this).find('.less_info').hide();
      $(this).find('.more_info').show();
      if($(this).find('img').length > 1) {
        $(this).find('img:eq(0)').hide();
        $(this).find('img:eq(1)').show();
      }
    },
    function() {
      $(this).find('.more_info').hide();
      $(this).find('.less_info').show();
      if($(this).find('img').length > 1) {
        $(this).find('img:eq(1)').hide();
        $(this).find('img:eq(0)').show();
      }
    })
}

function cy(a,b) {
  $(a).click(function() {
      $(b).find('.large').hide();
      $(b).find('#'+this.id+'_large').show();
    })
}

function vr() {
  $('#matrix').find('input:radio').hide();
  var a = $('#matrix').find('input[type=submit]');
  var b = $('#matrix').find('.error_message');
  var c = $('#matrix').find('form');
  var d = $('#matrix').find('.size.stock');
  var e = $('#matrix').find('.size');
  
  c.submit(function() {
    if($(this).find('input:radio[name=id]:checked').val()) { return true; }
    b.show();
    return false;
    });
  
  d.click(function() {
      $(this).find('input:radio[name=id]').attr("checked","checked");
      if ($(this).find('input:radio[name=id]:checked').val()) {
        b.hide();
        e.removeClass('selected_size');
        $(this).addClass('selected_size');
      }
    });
}

function dn() {
  $('.dept_open').click(function() {
    $('.all_depts').hide();
    $('.'+this.id+'group').show();
    return false;
    });
    
  $('.dept_close').click(function() {
    $('.all_depts').hide();
    return false;
    });
}

function ed() {
  $('#gallery').cycle({
    fx: 'scrollHorz',
    prev: '#view_previous',
    next: '#view_next',
    slideExpr: $('.slide'),
    height: '500',
    timeout: 0
    });
}

/* COPYRIGHT 2000-10, EARTHGAZER LTD. ALL RIGHTS RESERVED */