// JavaScript Document
function in_array(needle, haystack, strict) {   
    
    var found = false, key, strict = !!strict;
 
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
 
    return found;
}

function trim ( str, charlist ) {
    // Strip whitespace (or other characters) from the beginning and end of a string
    // +   original by: Ilia Kantor (http://javascript.ru)
 
    charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
    var re = new RegExp('^[' + charlist + ']+|[' + charlist + ']+$', 'g');
    return str.replace(re, '');
}


$(function(){		

	$("div.shops h2").click(function(){
		if($(this).next().css("display") == "none"){
			$(this).next().slideDown("fast");
		}else{
			$(this).next().slideUp("fast");
		}
	});


	$("a.sliderRight").click(function(){
		if(!$(this).hasClass("noActive")){									  
			$("a.sliderLeft").removeClass("noActive");
			var $oneWidth = parseInt($("div#banners a:first").width());
			var $totalWidth = $oneWidth;
			$("div#banners a").each(function(){
				$totalWidth -= parseInt($(this).width());
			});
			var $nowLeft = parseInt($("div#banners").css("left"));
			$nowLeft = $nowLeft - $oneWidth;
			if($nowLeft <= $totalWidth){$nowLeft = $totalWidth; $(this).addClass("noActive");}
			$("div#banners").animate({left: $nowLeft}, {duration: 'slow', easing: 'easeInOutBack'});
		}
	});

	$("a.sliderLeft").click(function(){
		if(!$(this).hasClass("noActive")){
			$("a.sliderRight").removeClass("noActive");
			var $oneWidth = parseInt($("div#banners a:first").width());
			var $totalWidth = 0;
			/*
			$("div#banners a").each(function(){
				$totalWidth += parseInt($(this).width());
			});*/
			var $nowLeft = parseInt($("div#banners").css("left"));
			$nowLeft = $nowLeft + $oneWidth;
			if($nowLeft >= $totalWidth){$nowLeft = $totalWidth; $(this).addClass("noActive");}
			$("div#banners").animate({left: $nowLeft}, {duration: 'slow', easing: 'easeInOutBack'});
		}
	});
	
});






  
  
  
  
