/*Carousel*/
jQuery(document).ready(function() {
	jQuery('.carousel').jcarousel({
	});
});
/*Placeholder*/
$(document).ready(function() {
	nmcFormHelper.init();
	nmcFormHelper.placeholder.styling = {'color':'#666666'};
});


/*Thumbs*/
$(document).ready(function() {
	$(".product_thumb_wrap").hover(
		function(){
			$(this).addClass("hover");
			$(this).parent(".product_thumbs li").css({'z-index' : '100'});
		},
		function(){
			$(this).removeClass("hover");
			$(this).parent(".product_thumbs li").css({'z-index' : '1'});
		}
	);
});
/*List*/
$(document).ready(function() {
	$(".name_list li").hover(
		function(){
			$(this).addClass("hover");
			$(this).css({'z-index' : '100'});
		},
		function(){
			$(this).removeClass("hover");
			$(this).css({'z-index' : '1'});
		}
	);
});
/*Add links*/
$(document).ready(function() {
	$('.add_links div.add_links_wrap').hide();
	$('a.ru_ask_q, a.ru_cons').toggle(
		function() {
			$(this).next("div.add_links_wrap").slideDown('fast');
			return false;
		},
		function() {
			$(this).next("div.add_links_wrap").slideUp('fast');
			return false;
		}
	);        
		

        $('a.en_ask_q, a.en_cons').toggle(
		function() {
			$(this).next("div.add_links_wrap").slideDown('fast');
			return false;
		},
		function() {
			$(this).next("div.add_links_wrap").slideUp('fast');
			return false;
		}
	);
});
/*Gallary*/
$(function() {
	$(".product_th").click(function() {
		var image = $(this).attr("rel");
		$('#product_photo').hide();
		$('#product_photo').fadeIn('fast');
		$('#product_photo').html('<img src="' + image + '" width="409" height="272"/>');
	return false;
	});
});

/*Selectbox*/
    $(document).ready(function() {
            $('.select_box').sSelect();
            $('.select_box').change(function(){
                var link = $(this).val();
                document.location.href = link;
            });
    });


/*Tooltop*/
function simple_tooltip(target_items, name){
    $(target_items).each(function(i){
    var href = $(this).attr("href");    
    if(containsChar(href, '#')){
        $("body").append("<div class='"+name+"' id='"+name+i+"'><center style='width:250px;'><img src='/images/loading.gif' width='30px' height='30px' /></center></div>");
        var my_tooltip = $("#"+name+i);
        var link_name = $(this).attr("title");
        var timeout;
        var delay = 700;
                                 
         my_tooltip.mouseleave(function(){
            if (timeout) window.clearTimeout(timeout);
                timeout = window.setTimeout(function(){
                    my_tooltip.fadeOut();
                }, delay);
         });

         my_tooltip.mouseover(function(){             
                if (timeout) window.clearTimeout(timeout);            
                timeout = window.setTimeout(function(){
                    my_tooltip.fadeIn();
                }, delay);
                
         });
                 
        $(this).removeAttr("title").mouseover(function(kmouse){
            if (timeout) window.clearTimeout(timeout);
            $("."+name+"").fadeOut();
                timeout = window.setTimeout(function(){
                    my_tooltip.fadeIn();
                }, delay);
            my_tooltip.css({left:kmouse.pageX-20, top:kmouse.pageY-15});
            $.post('/ajax/smartlink', {link:link_name}, function(data){
               my_tooltip.html(data);
            });                 
        }).mouseleave(function(){
            if (timeout) window.clearTimeout(timeout);
            
                timeout = window.setTimeout(function(){
                    my_tooltip.fadeOut();
                }, delay);
              my_tooltip.css({dysplay:"none"});
        });
         
        
           //check element for hover property
       
    }
  });
}
$(document).ready(function(){
    simple_tooltip("a","tooltip");
    $('.close_tooltip').click(function(){
        $(this).parent("div").fadeOut(400);
    });

    $('a#online').click(
		function() {
			$(this).next("div.add_links_wrap").slideUp('fast');
			return false;
	});
});


function containsChar(s, search) {
    result = false;
    for(var i=0; i<=s.length; i++) {
        if (s.charAt(i) == search) result = true;
    }
    return result;
}

