jQuery( function($) {

  // Hover effect for the header menu
  $("#categories > ul > li").not("#menu_home").hover(
    function() {
      $(this).find("a:first").stop().animate({
          color: '#ffffff',
          backgroundColor: $("#secondary_color").val()
        },300
      );
    }
    ,
    function() {
      $(this).find("a:first").stop().animate({
          color: $("#secondary_color").val(),
          backgroundColor: '#ffffff'
        },300
      );
    }
  );

  if (!$.browser.msie || parseInt($.browser.version, 10) > 8) {
      var onMouseOutOpacity = 1;
      $('div.s_listing > div.s_item').css('opacity', onMouseOutOpacity)
        .hover(
          function () {
            $(this).prevAll().stop().fadeTo('slow', 0.60);
            $(this).nextAll().stop().fadeTo('slow', 0.60);
          },
          function () {
            $(this).prevAll().stop().fadeTo('slow', onMouseOutOpacity);
            $(this).nextAll().stop().fadeTo('slow', onMouseOutOpacity);
          }
      );
  }

  // Hover effect for the shoppica cart
  $("#cart_menu").hover(
    function() {
      $(this).find(".s_grand_total").stop().animate({
          color: '#ffffff',
          backgroundColor: $("#main_color").val()
        },300
      );
    }
    ,
    function() {
      $(this).find(".s_grand_total").stop().animate({
          color: $("#main_color").val(),
          backgroundColor: '#ffffff'
        },300
      );
    }
  );

  // Animation for the languages and currency dropdown
  $('.s_switcher').hover(function() {
    $(this).find('.s_options').stop(true, true).slideDown('fast');
  },function() {
    $(this).find('.s_options').stop(true, true).slideUp('fast');
  });

  //
  $(".s_server_msg").live("click", function() {
    $(this).fadeOut(200, function(){
      $(this).remove();
    });
  });

  var search_visibility = 0;
  // Animation for the search button
  $("#show_search").bind("click", function(){
    if (search_visibility == 0) {
      $("#search_bar").fadeIn();
      search_visibility = 1;
    } else {
      $("#search_bar").fadeOut();
      search_visibility = 0;
    }
  });


});


function kontrol_siparis(theForm)
{  
   if (theForm.ad.value == "")
  {
    alert("Lütfen Adınız Soyadınız bölümünü doldurun.");
    theForm.ad.focus();
    return (false);
  } 
   if (theForm.gsm.value == "")
  {
    alert("Lütfen Cep Telefonunuz bölümünü doldurun.");
    theForm.gsm.focus();
    return (false);
  }   
   if (theForm.iller.value == 0)
  {
    alert("Lütfen Bulunduğunuz İli Seçiniz.");
    theForm.iller.focus();
    return (false);
  }  
   if (theForm.ilce.value == "")
  {
    alert("Lütfen Bulunduğunuz İlçeyi Giriniz.");
    theForm.ilce.focus();
    return (false);
  } 
   if (theForm.adres.value == "")
  {
    alert("Lütfen Adresiniz bölümünü doldurun.");
    theForm.adres.focus();
    return (false);
  } 
  return (true);
}

function kontrol_siparis_havale(theForm)
{  
   if ((theForm.banka[0].checked == false) && (theForm.banka[1].checked == false) && (theForm.banka[2].checked == false) && (theForm.banka[3].checked == false))
  {
    alert("Lütfen Havale Yapacağınız Hesap Numarasını Seçiniz.");
    return (false);
  } 
   if (theForm.ad.value == "")
  {
    alert("Lütfen Adınız Soyadınız bölümünü doldurun.");
    theForm.ad.focus();
    return (false);
  }   
   if (theForm.gsm.value == "")
  {
    alert("Lütfen Cep Telefonunuz bölümünü doldurun.");
    theForm.gsm.focus();
    return (false);
  }   
   if (theForm.iller.value == 0)
  {
    alert("Lütfen Bulunduğunuz İli Seçiniz.");
    theForm.iller.focus();
    return (false);
  }  
   if (theForm.ilce.value == "")
  {
    alert("Lütfen Bulunduğunuz İlçeyi Giriniz.");
    theForm.ilce.focus();
    return (false);
  }    
   if (theForm.adres.value == "")
  {
    alert("Lütfen Adresiniz bölümünü doldurun.");
    theForm.adres.focus();
    return (false);
  } 
  return (true);
}

function isTELNO(obj) {
	var rgpxp = new RegExp(/[-\( \/]*(0{1})?[-\)\( \/]*([\d]{3})[-\) \/]*([1-9]{1})([\d]{2})[- \/]*([\d]{2})[- \/]*([\d]{2})+$/);	
	if (obj.value.search(rgpxp) == -1) {
	alert ("Lütfen doğru bir telefon numarası giriniz!")
	obj.value = "";
	} else {
	obj.value=obj.value.replace(rgpxp,"$1($2) $3$4 $5 $6")
	}
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-20415105-16']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
