$(function(){
	
	// Все страницы
	$('.fb-like').hide();
	$('.fb').mouseover(function(){
		$('.fb-like').toggle(500).delay(5000).hide(500);	
	});
	
	// Главная страница
	if ($('#vypuskniki_buttom').size()>0){
		var imgVypusk = new Image(), imgWn = new Image(), imgWh = new Image(), imgWl = new Image(), imgNews = new Image(), imgNewsOn = new Image(), imgEvents = new Image(), imgEventsOn = new Image();
		var imgVypuskOn = new Image(), imgWnOn = new Image(), imgWhOn = new Image(), imgWlOn = new Image();
		
		if ($('#hide_eng').size()>0) {	
			imgWn.src = "/img/know_eng.gif";
			imgWnOn.src = "/img/know_eng_on.gif";
			imgWl.src = "/img/studying_eng.gif";
			imgWlOn.src = "/img/studying_eng_on.gif";
			imgWh.src = "/img/help_eng.gif";
			imgWhOn.src = "/img/help_eng_on.gif";
			
			imgNews.src = "/img/news_bg.gif";
			imgNewsOn.src = "/img/news_bg_on.gif";
			imgEvents.src = "/img/events_bg.gif";
			imgEventsOn.src = "/img/events_bg_on.gif";

			
		} else {
			imgVypusk.src = "/uplImages/static_304/582_vipusk_copy1.png";
			imgVypuskOn.src = "/uplImages/static_304/582_vipusk_copy0.png";
			imgWn.src = "/img/wont_know.gif";
			imgWnOn.src = "/img/wont_know_on.gif";
			imgWl.src = "/img/wont_learn.gif";
			imgWlOn.src = "/img/wont_learn_on.gif";
			imgWh.src = "/img/wont_help.gif";
			imgWhOn.src = "/img/wont_help_on.gif";

			imgNews.src = "/img/news_bg_ru.gif";
			imgNewsOn.src = "/img/news_bg_ru_on.gif";
			imgEvents.src = "/img/events_bg_ru.gif";
			imgEventsOn.src = "/img/events_bg_ru_on.gif";
			
			$('#vypuskniki_buttom').mouseover(function(){
				$('#vypuskniki_buttom').attr("src", imgVypuskOn.src);	
			}).mouseout(function(){
				$('#vypuskniki_buttom').attr("src", imgVypusk.src);
			}).click(function(){
				$('#vypuskniki_buttom').unbind('mouseout');
			});
		}
		
		$('#want_help').mouseover(function(){
			$('#want_help').attr("src", imgWhOn.src);	
		}).mouseout(function(){
			$('#want_help').attr("src", imgWh.src);
		}).click(function(){
			$('#want_help').unbind('mouseout');
		});
		
		$('#want_learn').mouseover(function(){
			$('#want_learn').attr("src", imgWlOn.src);	
		}).mouseout(function(){
			$('#want_learn').attr("src", imgWl.src);
		}).click(function(){
			$('#want_learn').unbind('mouseout');
		});
		
		$('#want_know').mouseover(function(){
			$('#want_know').attr("src", imgWnOn.src);	
		}).mouseout(function(){
			$('#want_know').attr("src", imgWn.src);
		}).click(function(){
			$('#want_know').unbind('mouseout');
		});
		
							
		$('#b_news').mouseover(function(){
			$('#b_news').attr("src", imgNewsOn.src);	
		}).mouseout(function(){
			$('#b_news').attr("src", imgNews.src);
		}).click(function(){
			$('#b_news').unbind('mouseout');
		});
		
		$('#b_events').mouseover(function(){
			$('#b_events').attr("src", imgEventsOn.src);	
		}).mouseout(function(){
			$('#b_events').attr("src", imgEvents.src);
		}).click(function(){
			$('#b_events').unbind('mouseout');
		});
	}
	
	// Как помочь
	if ($('#mat_help').size()>0){
		var vol = new Image(), mat = new Image();
		vol.src="/uplImages/custom/volonter1.png";
		mat.src="/uplImages/custom/mat_help1.png";
	
		$('#mat_help').mouseover(function(){
			$('#mat_help_text').css("color", "#438BB8");
			$('#mat_help_img').attr("src", mat.src);
			$('#mat_help').css("cursor", "pointer");
			
			
		}).mouseout(function(){
			$('#mat_help_text').css("color", "gray");
			$('#mat_help_img').attr("src", "/uplImages/custom/mat_help0.png");
		}).click(function(){
			if ($('#hide_eng').size()>0) {	
				window.location.href = "/en/how-to-help/help-with-goods-and-services/";
			} else {
				window.location.href = "/help/pomoch-tovarami-i-uslugami/";
			}
		});
		
		$('#volonter').mouseover(function(){
			$('#volonter_text').css("color", "#438BB8");
			$('#volonter_img').attr("src", vol.src);
			$('#volonter').css("cursor", "pointer");
				
		}).mouseout(function(){
			$('#volonter_text').css("color", "gray");
			$('#volonter_img').attr("src", "/uplImages/custom/volonter0.png");
		}).click(function(){
			if ($('#hide_eng').size()>0) {
				window.location.href = "/en/how-to-help/become-a-volunteer/";
			} else {
				window.location.href = "/help/stat-volonterom/";
			}
		});
	}
		
	
	// Ассист
	if ($('#assist-frame').size()){
		var option, alert;
		if((location.href).indexOf('/en/') + 1){
			option = "&OrderCurrency=RUR"+"&Delay=0"+"&Language=EN"+"&OrderComment=Donation for Big Change Charity Foundation";
			option += "&CardPayment=1"+"&WMPayment=1"+"&YMPayment=1"+"&AssistIDPayment=1"+"&QIWIPayment=1";
			option += "&URL_RETURN_OK=http://bigchange.ru/custom/assist_success_en.php";
			option += "&URL_RETURN_NO=http://bigchange.ru/custom/assist_failure_en.php";
			alert = " <font style='font-weight: bold; color: #7d0000'></font>";
		}
		else {
			option = "&OrderCurrency=RUR"+"&Delay=0"+"&Language=RU"+"&OrderComment=Donation for Big Change Charity Foundation";
			option += "&CardPayment=1"+"&WMPayment=1"+"&YMPayment=1"+"&AssistIDPayment=1"+"&QIWIPayment=1";
			option += "&URL_RETURN_OK=http://bigchange.ru/custom/assist_success_ru.php";
			option += "&URL_RETURN_NO=http://bigchange.ru/custom/assist_failure_ru.php";
			alert = " <font style='font-weight: bold; color: #7d0000'></font>";			
		}
		
		$('#donate').click(function(){
			$('#donate').attr("disabled","disabled").after(alert);
			$('#donate_summa').attr("disabled","disabled")
			var change = 0;
			$('div.cb').css("height", "670px");
			$('div.lb').css("height", "670px");
			$('div.rb').css("height", "670px");
			$('#assist-frame').attr("src", "https://payments123.paysecure.ru/pay/order.cfm?Merchant_ID=572522&OrderNumber=SAIT.PAYMENT."+(new Date()).getTime()+"&OrderAmount="+$('#donate_summa').val()+option);
			$('#assist_text').fadeOut(500);
			$('#assist-frame').show(500, function(){
				$('#assist-frame').load(function(){
					if (change){
						$('#assist-frame').attr("height", "900px");
						$('div.cb').css("height", "1050px");
						$('div.lb').css("height", "1050px");
						$('div.rb').css("height", "1050px");
					}
					change = 1;
				});
			});
		});
		$('#donate_summa').click(function(){
				$('#donate_summa').val("");
		});
		$('#donate_summa').focusout(function(){
				if ($('#donate_summa').val()==""){
					$('#donate_summa').val("100");
				}
		});
	}
});

