// 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(){		
	$("input.changeble").focus(function(){
		var $defValue = $(this).attr("defValue");
		var $curValue = $(this).val();
		if($curValue == $defValue){
			$(this).val("");
		}		
	}).blur(function(){
		var $defValue = $(this).attr("defValue");
		var $curValue = $(this).val();
		if($curValue == ""){
			$(this).val($defValue);
		}
	});
	
	$("ul.mainMenu li").mouseover(function(){
		$("ul.mainMenu li").removeClass("act");
		$(this).addClass("act");
	});
	
	$("div.subMenu div.items div").mouseover(function(){
		$("div.subMenu div.items div").removeClass("actIn");
		$(this).addClass("actIn");
	});
	
	$("ul.mainMenu").mouseout(function(){
		$("ul.mainMenu li").removeClass("act");
	});
	
	$("form#subscr a.submit").click(function(){
		var $die = 0;
		
		if($("input#FIO").val() == "" || $("input#FIO").val() == $("input#FIO").attr("defvalue")){
			$("input#FIO").css("background-color", "#DA1F53")
			$("input#FIO").val("We need your name");
			$("input#FIO").attr("defvalue","We need your name");
			$die = 1;
		}
		
		if($("input#email").val() == "" || $("input#email").val() == $("input#email").attr("defvalue")){
			$("input#email").css("background-color", "#DA1F53")
			$("input#email").val("We need your E-Mail");
			$("input#email").attr("defvalue","We need your E-Mail");
			$die = 1;
		}
		
		
		if($die == 0){
			$.get("/mail.php", { FIO: $("input#FIO").val(), email: $("input#email").val(), phone: $("input#phone").val() },
				function(data){
					$("form#subscr").slideUp("fast");
					$("div#subscrOk").slideDown("fast");
			});
		}else{
			return false;	
		}
	});
	
	$("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'});
		}
	});

	if($('#gall').html() != null){
//		$('#gall a').lightBox(); // Select all links in object with gallery ID
		$('#gall a').lightBox({
			overlayBgColor: '#000',
			overlayOpacity: 0.6,
			imageLoading: '/images/lightbox-btn-loading.gif',
			imageBtnClose: '/images/lightbox-btn-close.gif',
			imageBtnPrev: '/images/lightbox-btn-prev.gif',
			imageBtnNext: '/images/lightbox-btn-next.gif',
			imageBlank : '/images/lightbox-blank.gif',
			containerResizeSpeed: 200
  		}); 

	}
	

	
});






  
  
  
  
