/* Author: Ilker Ergun

*/
var showEffect;
showEffect="true";

function addEmail(){
    
    var lang = $("#newsletter_lang").val();
    var uname = $("#newsletter_name").val();
    var email = $("#newsletter_email").val();

    var messages = new Array();
    messages['tr'] = 'Lütfen adınızı ve e-posta adresinizi giriniz.';
    messages['en'] = 'Please enter your name and e-mail address.';

    if(uname.length == 0 || email.length == 0){
        $.jGrowl(messages[lang], {
            life: 10000
        });
    }else{
        $.ajax({
            type: "POST",
            url: jQuery.url.attr("protocol")+'://'+jQuery.url.attr("host")+'/'+lang+'/newsletter',
            data: "uname=" + uname +
                  "&email=" + email,
            success: function(html){
                $.jGrowl(html, {
                    life: 10000
                });
                $("#newsletter_name, #newsletter_email").val('');
            }
        });
    }
}


function initMenu() {
  $('#menu ul').hide();
  $('#menu ul.selected').show();
  $('#menu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#menu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }

/* Bootstrap */
$(function() {

    initMenu();
    Cufon.replace('.parentmenu');
    
    
    $('.more').click(function()
    {
        $('.productdetails').toggle('slow');
    });
	$("#featured").kricordion({
			slides: '.featured',
			animationSpeed: 900,
			autorotation: true,
			autorotationSpeed:5,
			event: 'mouseover',
			imageShadow:true,
			imageShadowStrength:0.5
	});
    $("#name,#email").click(function () {$("input", this).focus();});
    $(".pf a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});
    $(".scrollable").scrollable(
    {
        next        : '.next',
        prev        : '.prev',
        keyboard    : false,
        circular    : true
    }).autoscroll(
    {
        interval    : 4000,
        autopause   : true
    });

    var scroller = $('.scrollable').scrollable();
    scroller.onSeek = function()
    {
        var index = this.getIndex() + 1;
        var total = this.getSize();
        $('.scrollcontrols .current').text(index);
    };
    if(scroller.length > 0) scroller.move(0, 0);
    
        $(window).load(function() {
                $('#headmenu a').css('display', 'block');
                var ml = ($('#headmenuwrp').width() - $('#headmenu').width()) / 2;
                $('#headmenu').css('margin-left', ml);
                
                $('#headmenu li').each(function(){
                    var width = $(this).width() + 60;
                    var subwidth = $(this).find('.submenu').width();
                    var left = (width - subwidth) / 2; 
                    $(this).find('.submenu').css('left', left + 'px');
                });
            
            
            
                  var portfolio_item=jQuery("a.imgeffect");

                  portfolio_item.each(function(){

                           var img_width = $(this).find('img').width();
                           var img_height = $(this).find('img').innerHeight();
                           var imageClass = $(this).attr("class");
                           $(this).prepend('<span class="imagemask '+imageClass+'"></span>');

                           var p = $(this).find('img');
                           var position = p.position();
                           var PosTop= parseInt(p.css("margin-top"))+position.top;
                           var PosLeft= parseInt(p.css("margin-left"))+position.left;
               if (!PosLeft) {PosLeft= position.left};

                           $(this).find('.imagemask').css({top: PosTop});
               $(this).find('.imagemask').css({left: PosLeft});

                           $('.imagemask', this).css({width:img_width,height:img_height,backgroundPosition:'center center'});

                           if($.browser.msie){$('.imagemask', this).css({display:'none'});}

                  });

         });


         var image_e= $("a.imgeffect");

        if($.browser.msie){

                image_e.mouseover(function(){

                $(this).find('.imagemask').stop().css({
                          display:"block"
                          });

                }).mouseout(function(){
                    $(this).find('.imagemask').stop().css({
                         display:"none"
                        } );
                });

        }else{
             image_e.mouseover(function(){

             $(this).find('.imagemask').stop().animate({
                       display:"block",
                       opacity:1
                       }, 500);

             }).mouseout(function(){
                 $(this).find('.imagemask').stop().animate({
                       display:"none",
                       opacity:0
                     }, 400 );
             });
        }



    



    $('#wishlist_wrp>div:even').css('background-color', '#f1f1f1');
    $('#wishlist_wrp>div:odd').css('background-color', '#c1c1c1');
});

