﻿$(document).ready(function() {
  // initialise homepage flash

      
      $("a.img_link").fancybox({"overlayColor":"#000", "overlayOpacity":"0.6", "padding":"0px"}); 

      //init stylish selects
      $('#sidebar_panel01 select, #sidebar_panel02 select, #select_country').sSelect();


      $('#searchtext').val('搜索').focusin(function(){if ($(this).val() == "搜索")$(this).val('');}).focusout(function(){ if ($(this).val() == "")$(this).val('搜索');});

      //hack fix for top nav. ugh.
      $('<li class="filler"></li>').appendTo($('#header #header_sect02 ul li ul'));
      
      //fix for tyre search 
      $('.submit_tyresearch').click(function(){
         var model_txt = $('#c_vsearch_model .selectedTxt').text();
         var make_txt = $('#c_vsearch_make .selectedTxt').text();

         var abc = model_txt.replace('- ','|');
         var def = make_txt.replace(' ','+');

         var build_query = "/vehicle_search_results.asp?model="+abc+"&make=" +def;

         window.location = build_query;
         return;
       });
       
       $.fn.qtip.styles.mystyle = { // Last part is the name of the style
         width: 228,
         height:52,
         backgroundColor:'transparent',
         backgroundImage: 'url("/images/site/bg_tooltip.png")',
         backgroundRepeat:'no-repeat',
         border: {
                  width: 0,
                  radius: 0
         },
         color: '#fff',
         fontSize:'11px',
         padding: '15px 40px 15px 15px'
       };
       
       $('.tyre_details #prod_keypoints tr[title]').qtip({
          style: { 
            name:'mystyle'
          },
          
          position: {
             corner: {
                target: 'leftMiddle',
                tooltip: 'rightTop'
             }
          }
       });
       
       $('.tyre_compare .prod_keypoints li[title]').qtip({
          style: { 
            name:'mystyle'
          },
          
          position: {
             corner: {
                target: 'center',
                tooltip: 'rightTop'
             }
          }
       });
       
       $('#c_sel_country .newList li').click(function(){
         geturlfor($('#c_sel_country .selectedTxt').text());
       });
});
