$('html').addClass('js');
$(document).ready(function() {
	$("#sf_result_table td.hotel .visible a, #sf_result_table td.hotel .hint").hover(function() {$(this).closest("td").find("span.hint").addClass("visible_hint")}, function() {$(this).closest("td").find("span.hint").removeClass("visible_hint")});
	$("#fam_trip div.button a").click(function() {
		$("#fam_trip_form").popup_window({
			width:"478px",
			onShow:function($elem) {
				$elem.find("div.tour :text").val($("h1").text()).end()
				.find("div.date .from :text").val($("#fam_trip_from").text()).end()
				.find("div.date .to :text").val($("#fam_trip_to").text());
			},
			onClose:function($elem) {
				$elem.find(":text, textarea").val("");
			}
		});
		return false;
	});
	$("#trips_list div.button a").click(function() {
		_gaq.push(['_trackEvent', 'Fam trips', 'Нажата кнопка Записаться']);
		var $trip = $(this).closest("div.item");
		$("#fam_trip_form").popup_window({
			width:"478px",
			onShow:function($elem) {
				$elem.find("div.tour :text").val($trip.find("h2").text()).end()
				.find("div.date .from :text").val($trip.find(".fam_trip_from").text()).end()
				.find("div.date .to :text").val($trip.find(".fam_trip_to").text());
			},
			onClose:function($elem) {
				$elem.find(":text, textarea").val("");
			}
		});
		return false;
	});
	//searchForm(jQuery);
	$("#trip_filter a.icon").click(function() {
		$(this).next("div.select").children("div").slideDown("middle");
		return false;
	});
	$("div.tours_list div.item div.filter a.show_filter").click(function(e) {
		$(this).closest("div.filter").find("div.hint").toggleClass("hint_visible");
		e.stopPropagation();
		return false;
	});
	if(window.about_tours) {$("#about_directions div.map").tours_map({obj:about_tours});}
	$("#about_directions div.bookmarks").delegate("a","click",function() {
		var $this = $(this), thisClass = $this.attr("class"), thisHTML = $this.html(), $span = $this.siblings(".bookmark"), spanClass = $span.attr("class"), spanHTML = $span.html(), newSpan = $('<span></span>'), newA = $('<a href="#"></a>');
		if($this.hasClass("map")){
			$("#about_map").show();
			$("#about_map_list").hide();
		}
		else if($this.hasClass("list")) {
			$("#about_map").hide();
			var mapType, mapClass = $("#about_directions div.map").attr("class").split(/\s*map\s*/);
			for(var a=0; a<mapClass.length; a++) {if(mapClass[a] !="") {mapType = mapClass[a];}}
			var countryList = '<ul>';
			for(var i=0; i<about_tours[mapType].length; i++) {
				countryList+='<li><a href="'+about_tours[mapType][i]["target"]+'">'+about_tours[mapType][i]["name"]+'</a></li>';
			}
			countryList+='</ul>';
			$("#about_map_list").show().html(countryList);
		}
		newSpan.attr({"class":thisClass}).html(thisHTML);
		$this.after(newSpan).remove();
		
		newA.attr({"class":spanClass}).html(spanHTML);
		$span.after(newA).remove();
		return false;
	});
	
	$.cookie("cash_flag", null, {expires:7, path:"/"});
	
	$(document).click(function() {
		$("#city_select div.list").slideUp("middle");
		$("#section_select ul").slideUp("middle");
		$("div.date_select div.select, div.other_select div.select div, #trip_filter .select div").slideUp("middle");
		$("div.tours_list div.item div.filter div.hint").removeClass("hint_visible");
		$("#e_ticket div.hints div.info").hide();
	}).keydown(function(e) {
		NavigateThrough(e);
	});
	
	$("#e_ticket div.hints a.icon").click(function(e) {
		$("#e_ticket div.hints div.info").each(function() {
			this.style.display = "none";
		});
		$(this).closest("div.item").find("div.info").show();
		e.preventDefault();
		e.stopPropagation();
	});
	$("#e_ticket div.hints a.close").click(function(e) {
		$(this).closest("div.info").hide();
		e.preventDefault();
	});
	$("#trip_filter .select div").click(function(e) {
		e.stopPropagation();
	});

	$("select").selectMac_dj();
	//cookies
	$("#agents_documents div.h2 div.date_select li a").click(function() {
		$("div.docs_city").hide();
		$("#docs_"+String($(this).attr("href")).substr(1)).show();
		$("#agents_documents div.h2 div.select").slideUp("middle");
		$("#agents_documents div.h2 a.frame_bg span.bg span").text($(this).text());
		return false;
	});
	if($.cookie("city_name")) {
		$("#city_select a.button span.bg span").text($("#city_select li." + $.cookie("city_name") + "").text());
		if($("div."+$.cookie("city_name")).is("div")) {
			$("#offices_list").find("div.group").hide().end().find("div."+$.cookie("city_name")).show();
			$("#offices_switch a.frame_bg span.bg span").text($("#offices_switch a[href=#"+$.cookie("city_name")+"]").text());
		} else {
			$("#offices_list").find("div.group").hide().end().find("div.7191").show();
			$("#offices_switch a.frame_bg span.bg span").text($("#offices_switch a[href=#7191]").text());
		}
		
		
		$("div.docs_city").hide();
		if($("#docs_"+$.cookie("city_name")).is("div")) {
			$("#docs_"+$.cookie("city_name")).show();
		}
		else {$("#docs_7191").show();}
		$("#agents_documents div.h2 div.date_select a").each(function() {
			if(String($(this).attr("href")).substr(1) == $.cookie("city_name")) {
				$(this).click();
			}
		});
	}
	else {
		$("div.docs_city").hide();
		$("#docs_7191").show();
	}
	$("#city_select div.list a").click(function() {
		$.cookie("cash_flag", "1", {expires:7, path:"/"});
		$.cookie("city_name", this.parentNode.className, {expires:30, path:"/"});
	});
	/*$("#filter")
		.find("a.all_checkbox").click(function() {
			$this = $(this);
			$this.toggleClass("checked");
			if($this.hasClass("checked")) {$("#filter input[type='checkbox']").attr({checked:"checked"});}
			else {$("#filter input[type='checkbox']").attr({checked:""});}
			return false;
		});*/
	//form
	$("form").validateForm();
	//banner panel
	$("div.banner_panel li a").click(function() {
		$(this).parent().siblings().removeClass("act").end().addClass("act").closest("div.banner_panel").children("a.banner").css({backgroundImage:"url(" + $(this).attr('rel') + ")"}).attr({href:$(this).attr('href')});
		return false;
	});
	var bannerIntervalID = window.setInterval(function() {var $li=$("div.banner_panel li.act"); var $next=$li.next("li"); if(!$next.is("li")){$next=$li.parent().children("li:first");};$next.children("a").click();}, 5000);
	$("div.banner_panel a.banner").click(function(e) {
		if($(this).attr('href')=="#") {
			e.preventDefault();
		}
	});
	//top panel
	$("#city_select a.button").click(function() {
		$("#city_select div.list").slideToggle("middle");
		return false;
	});
	$("#city_select div.list").click(function(e) {
		stopEvent(e);
	});
	//logo space
	$("#section_select a.button").click(function() {
		$("#section_select ul").slideToggle("middle");
		return false;
	});
	$("#section_select ul").click(function(e) {
		stopEvent(e);
	});
	$("a.show, a.hide").click(function() {
		var thisAnchor = $(this);
		thisAnchor.closest("div.item").children("div").slideToggle("middle", function() {
			if(thisAnchor.hasClass("show")) {
				$.scrollTo($(this).closest("div.item"), 500);
			}
		});
		return false;
	});
	$("#filter a.show, #filter a.hide, #filter div.pointer a").unbind("click").click(function() {
		var thisAnchor = $(this);
		$("#filter > div").slideToggle("middle", function() {
			if(thisAnchor.hasClass("show")) {
				$("#filter div.selectMac_dj").find("div.select div").width("60px").end().find("span.bg").width("50px");
				$.scrollTo($("#filter"), 500);
			}
		});
		return false;
	});
	$("#contest15years a.show, #contest15years a.hide").unbind("click");
	$("#contest15years")
	.delegate("div.stages a.show", "click", function(e) {
		e.preventDefault();
	})
	.delegate("div.visible", "click", function() {
		$(this).find("a.show").hide().closest("div.item").addClass("open").find("div.hidden:hidden").slideDown("middle");
	})
	.delegate("div.stages a.hide", "click", function(e) {
		var itemDiv = $(this).closest("div.item");
		itemDiv.find("div.hidden").slideUp("middle", function() {
			itemDiv.removeClass("open");
		});
		itemDiv.find("a.show").css({display:"inline-block"});
		e.preventDefault();
	});
	$(".region a.show, .region a.hide").unbind("click");
	$(".region").delegate("a.show", "click", function() {
		$(this).hide().closest("div.region").find("a.hide").css({display:"inline-block"});
		$(this).closest("div.region").find("div.hidden").slideToggle("middle", function() {
			$.scrollTo($(this).closest(".region"), 500);
		});
		return false;
	}).delegate("a.hide", "click", function() {
		var $a = $(this);
		$a.closest("div.region").find("div.hidden").slideToggle("middle", function() {$a.hide().closest("div.region").find("a.show").css({display:"inline-block"});});
		return false;
	});
	$("div.all_tours_list div.region td.text h3 a").click(function() {
		var $this = $(this), $region = $this.closest("div.region");
			
		if($region.find("div.hidden").is(":hidden")) {
			$region.find("a.show").hide().end().find("a.hide").css({display:"inline-block"}).end().find("div.hidden").slideToggle("middle", function() {
				$.scrollTo($region, 500);
			});
		}
		else {
			$region.find("div.hidden").slideToggle("middle", function() {$region.find("a.hide").hide().end().find("a.show").css({display:"inline-block"});});
			return false;
		}
		
		return false;
	});
	$("#offices_list div.visible h3 a, #offices_list div.hidden h2 a").click(function() {
		var thisAnchor = $(this);
		thisAnchor.closest("div.item").children("div").slideToggle("middle", function() {
			if(thisAnchor.closest("div").hasClass("visible")) {
				$.scrollTo($(this).closest("div.item"), 500);
			}
		});
		return false;
	});
	setTimeout(function() {$("#offices_list div.item:visible:first").find("a.show").click();},100);
	$("#offices_switch div.select a").click(function() {
		$("#offices_list").find("div.group").hide().end().find("div."+$(this).attr("href").substring(1)).show().find("div.visible").show().end().find("div.hidden").hide();
		$("#offices_list div.item:visible:first").find("a.show").click();
		$("div.date_select div.select, div.other_select div.select div").slideUp("middle");
		$("#offices_switch a.frame_bg span.bg span").text($(this).text());
		return false;
	});
	$("#offices_list a.show, #offices_list div.visible h3 a").click(function() {
		var $div = $(this).closest("div.item").find("div.map").find("div[class!=YMaps]:first");
		if($div.is("div")) {
			var id = /[0-9]*$/.exec($(this).closest("div.item").find("div.map").find("div[class!=YMaps]").attr("id"));
			setTimeout(function() {window["YMapsID"+id]();}, 1000);
		}
	});
	//resort
	$("div.description_block div.description div.more a").click(function() {
		$(this).closest("div.description").children("div").slideToggle("middle");
		$(this).parent().hide();
		return false;
	});
	$("div.photos_block div.list a").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over'/*,
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}*/
	});
	$("div.filter_block div.stars a").hover(function() {
		var starAnc = $(this).parent().children("a");
		var index = starAnc.index(this);
		for(var i=0; i < index; i++) {
			$(starAnc[i]).addClass("hover");
		}
	}, function() {
		$(this).parent().children("a").removeClass("hover");
	});
	$("div.filter_block div.pointer div, div.filter_block h3").click(function() {
														 
		$(this).closest("div.filter_block").find("form").slideToggle("middle", function() {
			$(this).closest("div.filter_block").find("div.pointer").show();
		}).end().find("div.pointer").hide().end().find("div.center").toggleClass("open").toggleClass("closed");
		if($(this).closest("div.filter_block").find("div.center").hasClass("open")) {
			$(this).attr({title:"Скрыть фильтр"});
		}
		else {$(this).attr({title:"Показать фильтр"});
		}
	});
	$("div.filter_block a.hide").click(function() {
														 
		$(this).closest("div.filter_block").find("form").slideUp("middle", function() {
			$(this).closest("div.filter_block").find("div.pointer").show();
		}).end().find("div.pointer").hide().end().find("div.center").toggleClass("open").toggleClass("closed");
		$("div.filter_block div.pointer div, div.filter_block h3").attr({title:"Показать фильтр"});
		return false;
	});
	//date_select
	$("div.date_select a.icon").click(function() {
		$("div.date_select div.select").slideUp("middle");
		$(this).siblings("div.select").slideToggle("middle");
		return false;
	});
	//other_select
	$("div.other_select a.icon").click(function() {
		$("div.other_select div.select div").slideUp("middle");
		$(this).siblings("div.select").children("div").slideToggle("middle");
		return false;
	});
	$("div.date_select a.icon, div.date_select div.select, div.other_select a.icon, div.other_select div.select").click(function(e) {
		stopEvent(e);
	});
	//feedback
	$("#contact_form div.form_field:first select").focus();
	//individual
	$("#right_menu_block a.show").click(function() {
		$(this).slideUp("middle").siblings("ul").slideToggle("middle");
		return false;
	});
	$("a.send").click(function() {
		$("#application").popup();
		return false;
	});
});

function checkForm(form_element) {
	var formElement = form_element;
	var form = $(formElement).closest("form");
	var flag = 0;
	var firstElement;
	if(form.parent().attr("id") == "forget_password") {
		if ($(form).find("input.text:eq(0)").attr("value") != "") {
			form.submit();
		}
		else if($(form).find("input.text:eq(1)").attr("value") != "") {
			var mail = $(form).find("input.text:eq(1)").attr("value");
			var mailRegex = /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i;
			if(!mail.match(mailRegex)){
				$(form).find("input.text:eq(1)").parent().addClass("attention");
				return false;
			}
			else {form.submit();
			}
		}
		else {
			$(form).find("input.text").each(function() {
				$(this).parent().addClass("attention");
			});
			return false;
		}
	}
	else {
		$(form).find("input.text").each(function() {

			if ($(this).attr("value") == "" && $(this).attr("type") != "password" && $(this).parent().find("span.important").text() != "") {
				$(this).parent().addClass("attention");
				if(flag == 0) {firstElement = this;
				}
				flag = 1;
			}
			else if ($(this).attr("name").toLowerCase().search("mail") != -1 && $(this).parent().find("span.important").text() != "") {
				var mail = $(this).attr("value");
				var mailRegex = /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i;
				if(!mail.match(mailRegex)){
					$(this).parent().addClass("attention");
					if(flag == 0) {firstElement = this;
					}
					flag = 1;
				}
				else {$(this).parent().removeClass("attention");
				}

			}
			else {
				$(this).parent().removeClass("attention");
			}
			
			var confirmPasswordField="";
			var passwordField;
			$(form).find("input:password").each(function() {
				if ($(this).attr("name").toLowerCase().search("confirm") != -1) {
					confirmPasswordField = this;
				}
				else {
					passwordField = this;
				}
			});
			if(confirmPasswordField == "") {
				if($(passwordField).attr("value") == "") {
					$(passwordField).parent().addClass("attention");
					if(flag == 0) {firstElement = passwordField;
					}
					flag = 1;
				}
			}
			else {
				if(form.parent().attr("id") == "new_password" && ($(passwordField).attr("value") == "" || $(passwordField).attr("value") != $(confirmPasswordField).attr("value"))) {
					$(passwordField).parent().removeClass("attention");
					$(confirmPasswordField).parent().addClass("attention");
					if(flag == 0) {firstElement = confirmPasswordField;
					}
					flag = 1;
				}
				else {
					if ($(passwordField).attr("value") == "") {
						$(passwordField).parent().removeClass("attention");
						$(confirmPasswordField).parent().removeClass("attention");
					}
					else if (($(passwordField).attr("value") != "" && $(confirmPasswordField).attr("value") == "") || ($(passwordField).attr("value") != "" && $(confirmPasswordField).attr("value") != "" && $(passwordField).attr("value") != $(confirmPasswordField).attr("value"))) {
						$(passwordField).parent().removeClass("attention");
						$(confirmPasswordField).parent().addClass("attention");
						if(flag == 0) {firstElement = confirmPasswordField;
						}
						flag = 1;
					}
				}
			}
		});
		$(form).find("textarea").each(function() {
			if (($(this).attr("value") == "" && $(this).html() == "" && $(this).text() == "") && $(this).parent().find("span.important").text() != "") {
				$(this).parent().addClass("attention");
				if(flag == 0) {firstElement = this;
				}
				flag = 1;
			}
			else {
				$(this).parent().removeClass("attention");
			}
		});
		if (flag == 0) {$(form).submit();
		}
		else {
			if(form.attr("id") == "personal_anketa" || form.parent().attr("id") == "registration_b2b" || form.parent().attr("id") == "registration_individual") {
				$.scrollTo(firstElement.parentNode, 500);
			}
			firstElement.focus();
			return false;
		}
	}
}

(function($) {
	var defaults = {
		forget:false
	};
	$.fn.validateForm = function(params) {
		var options = $.extend({}, params, defaults);
		$(this).each(function() {
			var $this = $(this),
				submitFlag = 0,
				firstElement = null,
				$confirm = "",
				$password = "",
			
				methods = {
					setAttention:function($elem) {
						$elem.closest("div.form_field").addClass("attention");
						if(submitFlag == 0) {firstElement = $elem;}
						submitFlag = 1;
					},
					removeAttention:function($elem) {$elem.closest("div.form_field").removeClass("attention");},
					check:function() {
						submitFlag = 0;
						firstElement = null;
						/*if(options.forget === true) {
							var $firstElem = $this.find("input.text:eq(1)");
							if ($this.find("input.text:eq(0)").val() != "") {form.submit();}
							else if($firstElem.val() != "") {
								var mail = $firstElem.val();
								var mailRegex = /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i;
								if(!mail.match(mailRegex)){
									$firstElem.parent().addClass("attention");
									return false;
								}
								else {form.submit();
								}
							}
							else {
								$(form).find("input.text").each(function() {
									$(this).parent().addClass("attention");
								});
								return false;
							}
						}
						else {*/
							methods.checkInput();
							methods.checkPassword();
							methods.checkTextarea();
							methods.checkSelect();
							/*if(tName) {
								$("#form_button_name").attr({name:tName});
							}*/
							//alert(submitFlag);
							if (submitFlag == 0) {
								if($this.parent().attr("id") == "fam_trip_form") {
									_gaq.push(['_trackEvent', 'Fam trips', 'Отправлена заявка']);
									submitAjax($this);
									return false;
								}
								else {
									return true;
								}
							}
							else {
								//$.scrollTo(firstElement.parentNode, 500);
								if(firstElement!=null) {firstElement.focus();}
								return false;
							}
						//}
					},
					checkInput:function() {
						$this.find("input.text[type!=password]").each(function() {
							var $input = $(this),
								$val = $input.val(),
								mailRegex = /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
								phoneRegex = /^([0-9-()\s]{5,})$/i,
								priceRegex = /^([0-9\s\.,]+)$/i,
								$noText = $input.closest("div.form_field").find("span.important");
							
							if ($val == "" && $noText.is("span")) {methods.setAttention($input);}
							else if ($input.attr("name").toLowerCase().search("mail") != -1 && $noText.is("span")) {
								if(!$val.match(mailRegex)){methods.setAttention($input);}
								else {methods.removeAttention($input);}
							}
							else if ($input.hasClass("phone") && $noText.is("span")) {
								if(!$val.match(phoneRegex)){methods.setAttention($input);}
								else {methods.removeAttention($input);}
							}
							else if ($input.hasClass("price") && $noText.is("span")) {
								if(!$val.match(priceRegex)){methods.setAttention($input);}
								else {methods.removeAttention($input);}
							}
							else {methods.removeAttention($input);}
						});
					},
					checkPassword:function() {
						$this.find(":password").each(function() {
							var $pass;
							if ($pass.attr("name").toLowerCase().search("confirm") != -1) {$confirm = $(this);}
							else {$password = $(this);}
						});
						if($confirm!="") {
							if($this.parent().attr("id") == "new_password" && ($password.val() == "" || $password.val() != $confirm.val())) {
								methods.removeAttention($password);
								methods.setAttention($confirm);
							}
							else {
								if ($password.val() == "") {
									methods.removeAttention($password);
									methods.removeAttention($confirm);
								}
								else if (($password.val() != "" && $confirm.val() == "") || ($password.val() != "" && $confirm.val() != "" && $password.val() != $confirm.val())) {
									methods.removeAttention($password);
									methods.setAttention($confirm);
								}
							}
						}
						else if($password != "" && $password.val() == "") {methods.setAttention($password);}
					},
					checkTextarea:function() {
						$this.find("textarea").each(function() {
							var $textarea = $(this),
								$val = $textarea.val(),
								$noText = $textarea.closest("div.form_field").find("span.important");
							
							if (($val == "") && $noText.is("span")) {methods.setAttention($textarea);}
							else {methods.removeAttention($textarea);}
						});
					},
					checkSelect:function() {
						$this.find("select").each(function() {
							var $select = $(this),
								$val = $select.val(),
								$noText = $select.closest("div.form_field").find("span.important");
							
							if (($val == "") && $noText.is("span")) {methods.setAttention($select);}
							else {methods.removeAttention($select);}
						});
					},
					submitForm:function(e) {
						$this.find(":submit").click();
						e.preventDefault();
						return false;
					}
				};
			
			$this.find(":submit").click(function() {
				if(!methods.check()) {return false;}
			}).end().find("input.text").each(function() {
				if(this.className.toLowerCase().search("ac_input")==-1) {
					$(this).keyup(function(e) {
						if(e.wich == 13) {
							methods.submitForm(e);
						}
					});
				}
			}).end().find("select").each(function() {
				$(this).keypress(function(e) {
					if(e.wich == 13) {
						methods.submitForm(e);
					}
				});
			}).end().find("textarea").keyup(function(e) {
				if(e.ctrlKey && e.keyCode == 13) {
					methods.submitForm(e);
				}
			});
		});
	};
})(jQuery);

function stopEvent(e) {
if(!e) e = window.event;
if(e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
}

function setCookie(name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "");
				 document.cookie = curCookie;
}

function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
			document.cookie = name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}

function NavigateThrough(event) {
	if (!document.getElementById) return;
	if (window.event) event = window.event;
	if (event.ctrlKey) {
		if(document.getElementById("index_prods_ideas")) {
			switch (event.keyCode ? event.keyCode : event.which ? event.which : null) {
				case 0x25: $("#index_prods_ideas a.prev").click(); break;
				case 0x27: $("#index_prods_ideas a.next").click(); break;
			}
		}
		else {
			var link = null;
			var href = null;
			switch (event.keyCode ? event.keyCode : event.which ? event.which : null) {
				case 0x25: link = document.getElementById ('PrevLink'); break;
				case 0x27: link = document.getElementById ('NextLink'); break;
				case 0x24: href = '/'; break;
			}
			if (link && link.href) document.location = link.href;
			if (href) document.location = href;
		}
	}
}

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);


//MouseWheel
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
*
* Requires: 1.2.2+
*/
(function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=
f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);





/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1

 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright - 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.A(x,t*2,0,c,d)*.5+b;6 h.i.v(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|sqrt||5625|asin|||undefined|easeOutBounce|abs||def|swing|easeInBounce|525|cos|easeOutQuad|easeOutBack|easeInBack|easeInSine|easeOutElastic|easeInOutQuint|easeOutQuint|easeInQuint|easeInOutQuart|easeOutQuart|easeInQuart|extend|easeInElastic|easeInOutCirc|easeInOutCubic|easeOutCirc|easeInOutElastic|easeOutCubic|easeInCirc|easeInOutExpo|easeInCubic|easeOutExpo|easeInExpo||9375|easeInOutSine|easeInOutQuad|25|easeOutSine|easeInOutBack|easeInQuad|625|984375|jswing|easeInOutBounce'.split('|'),0,{}))

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright - 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */



/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 * 
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 * 
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);

/*$("#button").click(function() {
	$("#win").popup(
		{
			closeElem:"#win a.close",
			after:function(elem) {$(elem).append("<span>fhjdsk<\/span>")}});
		}
	);
*/
(function($) {
	var defaults = {
		opaco:true,
		valign:"center",
		align:"center"
		//after:function(thisElem){}
		//closeElem:"a.close"
		//close:function(thisElem){} overwrites default function
	};
	
	$.fn.popup = function(params) {
		var options = $.extend({}, defaults, params);
		$(this).each(function() {
			var $this=$(this);
			if(!$this.is(":visible")) {
				var topPx="20px", leftPx="50%", marginLeft=0, outerHeight=$this.outerHeight(), winHeight=$(window).height();
				switch(options.valign) {
					case "top": topPx = $(window).scrollTop() + 20 + "px"; break;
					case "center":
						if (winHeight > outerHeight) {topPx = winHeight/2 + $(window).scrollTop() - outerHeight/2 - 20 + "px";}
						else {topPx = $(window).scrollTop() + 20 + "px";}
						break;
					case "bottom": topPx = $(window).scrollTop()+winHeight-outerHeight-20 + "px";break;
				}
				switch(options.align) {
					case "left": leftPx = "0px"; break;
					case "center":
						leftPx = "50%";
						marginLeft = -$this.outerWidth()/2+"px";
						break;
					case "right": leftPx = $(document).width()-$this.outerWidth()+"px";break;
				}
				if(options.opaco === true) {
					$this.before('<div id="opaco"></div>');
					$("#opaco, #opaco iframe").css({width:"100%", height:$(document).height()+"px"}).show();
					var closeElem = $("#opaco");
					if(options.closeElem){closeElem=$("#opaco, "+options.closeElem+"");}
					
					var closeFunc = function() {$this.popup(options);};
					if(options.close){closeFunc=function(){options.close(this);};}
					closeElem.click(function(e) {
						closeFunc();
						e.preventDefault();
					});
				}
				$this.show().css({marginLeft:marginLeft, left:leftPx}).animate({top:topPx}, 500, function() {
					if(options.after) {options.after(this);}
				});
			}
			else {
				$this.hide();
				$("#opaco").remove();
				if(options.closeElem){
					$(""+options.closeElem+"").unbind("click");}
			}
		});
		return this;
	};
})(jQuery);

/*$("#button").click(function() {
	$("#win").popup_window(
		{
			closeElem:"#win a.close",
			after:function(elem) {$(elem).append("<span>fhjdsk<\/span>")}});
		}
	);
*/
(function($) {
	var defaults = {
		opaco:true,
		valign:"center",
		align:"center",
		width:undefined,
		onShow:function($thisElem){},
		onClose:function($thisElem){},
		closeElem:"a.close"
		//close:function(thisElem){} overwrites default function
	};
	
	$.fn.popup_window = function(params) {
		var options = $.extend({}, defaults, params);
		$(this).each(function() {
			var $this=$(this), $window = $('<div id="popup_window"><a title="Закрыть" class="close" href="#">Закрыть</a><div class="pad"></div></div>');
			$("body").append($window);
			
			if(options.width) {
				$window.width(options.width);
			}
			
			if($this.is(":hidden")) {
				var topPx="20px", leftPx="50%", marginLeft=0, outerHeight=$this.outerHeight() + $window.outerHeight(), winHeight=$(window).height();
				switch(options.valign) {
					case "top": topPx = $(window).scrollTop() + 20 + "px"; break;
					case "center":
						if (winHeight > outerHeight) {topPx = winHeight/2 + $(window).scrollTop() - outerHeight/2 - 20 + "px";}
						else {topPx = $(window).scrollTop() + 20 + "px";}
						break;
					case "bottom": topPx = $(window).scrollTop()+winHeight-outerHeight-20 + "px";break;
				}
				switch(options.align) {
					case "left": leftPx = "0px"; break;
					case "center":
						leftPx = "50%";
						marginLeft = -$window.outerWidth()/2+"px";
						break;
					case "right": leftPx = $(document).width()-$window.outerWidth()+"px";break;
				}
				if(options.opaco === true) {
					$("body").append('<div id="opaco"></div>');
					$("#opaco, #opaco iframe").css({width:"100%", height:$(document).height()+"px"}).show();
					var closeElem = $("#opaco");
				}
				
				$window.find("div.pad").append($this.show());
				$window.show().css({marginLeft:marginLeft, left:leftPx}).animate({top:topPx}, 500, function() {
					if(options.onShow) {options.onShow($this);}
				});
				
				
				var closeFunc = function() {
					$this.popup_window(options);
					if(options.onClose) {options.onClose($this);}
				};
				if(options.close){closeFunc=function(){options.close(this);};}
				if(!closeElem && options.closeElem) {
					closeElem=$("#popup_window "+options.closeElem);
				}
				else if(options.closeElem){closeElem=$("#opaco, #popup_window " + options.closeElem);}
				closeElem.click(function(e) {
					closeFunc();
					e.preventDefault();
				});
			}
			else {
				$this.hide().appendTo('body');
				$("#opaco, #popup_window").remove();
				$("#popup_window").remove();//for IE
			}
		});
		return this;
	};
})(jQuery);


/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};




/*dj.selectMac - nice appearance of select element in each of broadly known browsers from IE6 to FF*/

(function($){
	var defaults = {
		selectClass:"selectMac_dj"
	};
	$.fn.selectMac_dj = function(params) {
		var options = $.extend({}, defaults, params);
		
		this.each(function() {
			var $this = $(this);
			//html
			var li="";
			for(var i=0; i<$this.find("option").size(); i++) {li+='<li rel="'+$this.find("option:eq("+i+")").val()+'">'+$this.find("option:eq("+i+")").text()+'</li>';}
			var $select=$('<div class="'+options.selectClass+'"><input type="hidden" name="'+$this.attr("name")+'" value="'+$this.find("option:selected").val()+'"><div class="select"><div><ul>'+li+'</ul></div></div><a href="#" class="frame_bg icon"><span class="left"><span class="right"><span class="bg"><span>'+$this.find("option:selected").text()+'</span></span></span></span></a></div>'),
			
			$selectDiv = $select.find("div.select > div"),
			$bg = $select.find("span.bg"),
			$ul = $select.find("ul"),
			$li = $select.find("li"),
			selectWidth = $this.outerWidth(),
			
			methods={
				numValue:function(value) {
					var string = new String(value);
					return parseInt(string.slice(0, string.length-2));
				},
				click:function(e) {
					$("."+options.selectClass).each(function() {
						if (this != $select[0]) {$(this).children("div.scroll").hide().end().find("div.body").slideUp("fast").end().children("div.pointer").children("div").removeClass("up");}
					});
					if($li.size() > options.visibleLi) {
						$body.css({height:"303px"});//!
						if($scroll.is(":hidden")) {
							$slider.css({top:"-3px"});//!
							$ul.css({marginTop:"0"});
							$body.slideDown("fast", function() {$scroll.show();});
						}
						else {
							$scroll.hide();
							$body.slideUp("fast");
						}
					}
					else {$body.slideToggle("fast");
					}
					$pointer.toggleClass("up");
					e.stopPropagation();
				}
			};
			$this.before($select).remove();
			$bg.css({width:$bg.outerWidth()-($select.find("a.icon").outerWidth()-selectWidth)});
			$selectDiv.css({width:$bg.outerWidth()});
			
			$li
			.hover(function() {$(this).addClass("hover");}, function() {$(this).removeClass("hover");})
			.click(function() {
				$select.find("span.bg").children("span").text($(this).text());
				$select.children("input").val($(this).attr("rel"));
			});
			//$select.click(methods.click);
			
			$select.find("a.icon").click(function(e) {
				$("div."+options.selectClass+" div.select div").slideUp("middle");
				$(this).siblings("div.select").children("div").stop().slideToggle("middle");
				e.stopPropagation();
				return false;
			});
			//$("div.date_select a.icon, div.date_select div.select, div.other_select a.icon, div.other_select div.select").click(function(e) {stopEvent(e);});
		});
		
		$(document).bind("click", function() {$("div."+options.selectClass+" div.select div").slideUp("middle");});
		
		return this;
	};
})(jQuery);

//google maps for the page about company
(function($){
	var defaults = {
		obj:{"summer":[{"name":"Франция", "target":"/france/"}]},
		image:"/images/map/icon.png",
		mapView:"ROADMAP",
		mapId:"about_map",
		types:{"summer":{
			"zoom":5,
			"centerLatLng":[48, 19]
		}, "winter":{
			"zoom":5,
			"centerLatLng":[49, 19]
		}},
		activeType:"summer"
	};
	$.fn.tours_map = function(params) {
		var options = $.extend({}, defaults, params);
		
		this.each(function() {
			var $this = $(this),
				$a = $this.find("div.switcher a"),
				countryOverlay,
				methods = {
					initialize:function() {
						var centerLatLng = new google.maps.LatLng(options.types[options.activeType].centerLatLng[0], options.types[options.activeType].centerLatLng[1]),
							myOptions = {
								scrollwheel: false,
								zoom: options.types[options.activeType].zoom,
								center: centerLatLng,
								mapTypeId: google.maps.MapTypeId[options.mapView]
							},
							map = new google.maps.Map(document.getElementById(options.mapId), myOptions),
							image = options.image,
							obj = options.obj,
							markers = {},
							countryOverlay = {};
						
						for(var i in options.types) {
							markers[i] = [];
							countryOverlay[i] = [];
						}
						for(var i in obj) {
							for(var j=0; j<obj[i].length; j++) {
								markers[i][j] = new google.maps.Marker({
									position: new google.maps.LatLng(obj[i][j].lat, obj[i][j].lng),
									map: map,
									title: obj[i][j].name,
									icon:image
								});
								countryOverlay[i][j] = new methods.COverlay(obj[i][j], map);
								markers[i][j].hint = countryOverlay[i][j];
								google.maps.event.addListener(markers[i][j], "click", function() {
									var mapType, mapClass = $this.attr("class").split(/\s*map\s*/);
									for(var a=0; a<mapClass.length; a++) {if(mapClass[a] !="") {mapType = mapClass[a];}}
									for(var b=0; b<markers[mapType].length; b++) {
										markers[mapType][b].hint.hide();
										markers[mapType][b].setVisible(true);
									}
									this.hint.show();
									this.setVisible(false);
								});
								if(i!=options.activeType) {markers[i][j].setVisible(false);}
							}
						}
						for(var k=0; k<$a.size(); k++) {
							google.maps.event.addDomListener($a[k], 'click', function() {
								map.setCenter(new google.maps.LatLng(options.types[options.activeType].centerLatLng[0], options.types[options.activeType].centerLatLng[1]));
								map.setZoom(options.types[options.activeType].zoom);
								for(var type in markers) {
									for(var i=0; i<markers[type].length; i++){
										var bool=true;
										if(type != options.activeType) {
											bool=false;
											markers[type][i].hint.hide();
										}
										markers[type][i].setVisible(bool);
									}
								}
							});
						}
					},
					COverlay:function(obj, map) {
						this.name_ = obj.name;
						this.target_ = obj.target;
						this.tours_ = obj.tours;
						this.lat_ = obj.lat;
						this.lng_ = obj.lng;
						this.map_ = map;
						
						this.div_ = null;
						
						this.setMap(map);
					}
				};
			
			
			$a.click(function() {
				$(this).closest("div.map").toggleClass("summer").toggleClass("winter");
				var mapType, mapClass = $(this).closest("div.map").attr("class").split(/\s*map\s*/);
				for(var a=0; a<mapClass.length; a++) {if(mapClass[a] !="") {mapType = mapClass[a];}}
				options.activeType = mapType;
				if(options.activeType == "summer") {$(this).closest("div.map").find("h3 span").text("Карта маршрутов летом");}
				else if(options.activeType == "winter") {$(this).closest("div.map").find("h3 span").text("Карта маршрутов зимой");}
				if($("#about_map_list").is(":visible")) {
					var countryList = '<ul>';
					for(var i=0; i<about_tours[mapType].length; i++) {countryList+='<li><a href="'+about_tours[mapType][i]["target"]+'">'+about_tours[mapType][i]["name"]+'</a></li>';}
					countryList+='</ul>';
					$("#about_map_list").html(countryList);
				}
				return false;
			});
			
			methods.COverlay.prototype = new google.maps.OverlayView();
			methods.COverlay.prototype.onAdd = function() {
				var div = document.createElement('DIV');
				div.style.position = "absolute";
				div.style.top = "0px";
				div.style.visibility = "hidden";
				div.innerHTML = '<div style="white-space:nowrap;box-shadow:0 0 10px #555555;-webkit-box-shadow:0 0 10px #555555;-moz-box-shadow:0 0 10px #555555;position:absolute;z-index:1000005;"><a href="'+this.target_+'" style="display:inline-block;background:url(/images/decor/h_bg.png) repeat-x 0 -98px;color:#ffffff;font-size:10pt;font-family:Arial, Helvetica, sans-serif;text-shadow:1px 0 0 #4974bb;padding:6px 12px 7px 12px;-moz-border-radius:2px 0 0 2px;-webkit-border-radius:2px 0 0 2px;-khtml-border-radius:2px 0 0 2px;border-radius:2px 0 0 2px;vertical-align:top;">'+this.name_+'<\/a><a href="'+this.tours_+'" style="display:inline-block;background:url(/images/decor/h_bg.png) repeat-x 0 -128px;color:#ffffff;font-size:8pt;font-family:Arial, Helvetica, sans-serif;text-shadow:1px 0 0 #630303;padding:7px 18px 8px 18px;-moz-border-radius:0 2px 2px 0;-webkit-border-radius:0 2px 2px 0;-khtml-border-radius:0 2px 2px 0;border-radius:0 2px 2px 0;vertical-align:top;">Туры<\/a><div style="width:17px;height:9px;background:url(/images/decor/pic.png) no-repeat -67px -10px;position:absolute;left:29px;bottom:-9px;"><\/div><\/div>';
				this.div_ = div;
				var panes = this.getPanes();
				panes.overlayLayer.appendChild(div);
				panes.overlayLayer.style.zIndex="107";
			}
			methods.COverlay.prototype.draw = function() {
				var overlayProjection = this.getProjection(),
					sw = overlayProjection.fromLatLngToDivPixel(new google.maps.LatLng(this.lat_, this.lng_)),
					div = this.div_;
				div.style.left = (sw.x-36) + 'px';
				div.style.top = (sw.y-45) + 'px';
			}
			methods.COverlay.prototype.onRemove = function() {
				this.div_.parentNode.removeChild(this.div_);
				this.div_ = null;
			}
			methods.COverlay.prototype.hide = function() {if (this.div_) {this.div_.style.visibility = "hidden";}}
			methods.COverlay.prototype.show = function() {if (this.div_) {this.div_.style.visibility = "visible";}}
			methods.COverlay.prototype.toggle = function() {if (this.div_) {if (this.div_.style.visibility == "hidden") {this.show();} else {this.hide();}}}
			methods.COverlay.prototype.toggleDOM = function() {if (this.getMap()) {this.setMap(null);} else {this.setMap(this.map_);}}
			
			
			var season = new Date();
			if(season.getMonth() >= 9 || season.getMonth() <3) {season = "winter";}
			else {season = "summer";}
			if(!$this.hasClass(season)) {$($a[0]).click();}
			
			methods.initialize();
		});
		return this;
	};
})(jQuery);

/*//search_form
function searchForm($){
	var availableDates = [
			new Date(2011, 8, 30).getTime(),
			new Date(2011, 9, 2).getTime(),
			new Date(2011, 9, 10).getTime(),
			new Date(2011, 9, 11).getTime(),
			new Date(2011, 9, 12).getTime(),
			new Date(2011, 9, 18).getTime(),
			new Date(2011, 9, 19).getTime(),
			new Date(2011, 9, 25).getTime(),
			new Date(2011, 9, 27).getTime(),
			new Date(2011, 9, 28).getTime(),
			new Date(2011, 10, 3).getTime(),
			new Date(2011, 10, 5).getTime()
		];
		availableDates.obj={};
		for(var i=0; i<availableDates.length; i++) {
			availableDates.obj[availableDates[i]] = "";
		}
		methods = {
		getRegions:function() {
			$.ajax({
				url:'/php/regions.php',
				dataType:"json",
				from:$("#sf_conditions div.from select").val(),
				type:$("#sf_conditions div.type select").val(),
				to:$("#sf_conditions div.to select").val(),
				action:"getRegions",
				success:function(data) {
					var html='';
					for(var i=0; i<data.regions.length; i++) {
						html+='<label><input type="checkbox" name="regions[]" value="'+data.regions[i].id+'" />&nbsp;<span class="item"><span class="hint"><span class="pad"><img src="'+data.regions[i].src+'" alt="" /><span class="text">'+data.regions[i].description+'</span><span class="pointer"><span></span></span></span></span><a href="#">'+data.regions[i].name+'</a></label>&nbsp;';
					}
					$("#sf_results").html(html).attr({"class":"regions"}).show();
				}
			});
			$("#sf_chosen").hide().find("div.list").remove();
		},
		getResorts:function() {
			$.ajax({
				url:'/php/resorts.php',
				dataType:"json",
				from:$("#sf_conditions div.from select").val(),
				type:$("#sf_conditions div.type select").val(),
				to:$("#sf_conditions div.to select").val(),
				action:"getResorts",
				success:function(data) {
					var html='';
					for(var i=0; i<data.regions.length; i++) {
						html+='<label><input type="checkbox" name="regions[]" value="'+data.regions[i].id+'" checked="checked" />&nbsp;<span class="item"><a href="#">'+data.regions[i].name+'</a><br />'+data.regions[i].brief+'</span></label>&nbsp;';
					}
					$("#sf_results").html(html).attr({"class":"resorts"}).show();
				}
			});
		},
		getNum:function(id) {
			var items = [];
			$("#sf_results :checked").each(function() {
				items.push($(this).val());
			});
			$.ajax({
				url:'/php/num.php',
				from:$("#sf_conditions div.from select").val(),
				type:$("#sf_conditions div.type select").val(),
				to:$("#sf_conditions div.to select").val(),
				items:items,
				action:"getResorts",
				success:function(data) {
					if(data.length!=0) {$("#"+id+" span.num").text("("+data+")");}
					else {$("#"+id+" span.num").text("");}
				}
			});
		},
		switchMenu:function(active) {
			$("#sf_place_menu .item").each(function() {
				var $menuItem = $(this);
				if($menuItem.attr("id") != active && !$menuItem.is("a")) {
					$menuItem.after($('<a href="#" class="'+$menuItem.attr("class")+'" id="'+$menuItem.attr("id")+'">'+$menuItem.html()+'</a>')).remove();
				}
				else if ($menuItem.attr("id") == active) {
					$menuItem.after($('<span href="#" class="'+$menuItem.attr("class")+'" id="'+$menuItem.attr("id")+'">'+$menuItem.html()+'</span>')).remove();
				}
			});
		}
	};
	methods.getRegions();
	$("#sf_place_menu")
		.delegate("a.item", "click", function() {
			switch(this.getAttribute("id")){
				case "sf_regions":methods.getRegions();break;
				case "sf_resorts":methods.getResorts();break;
				//case "sf_hotels":methods.getHotels();break;
			}
			methods.switchMenu(this.getAttribute("id"));
			$("#sf_place_menu a.none").removeClass("active");
			return false;
		})
		.delegate("a.none", "click", function() {
			$("#sf_place_menu a.item span.num").text("");
			$("#sf_results").empty().hide();
			$("#sf_chosen").hide().find("div.list").remove();
			methods.switchMenu("");
			$(this).addClass("active");
			return false;
		});
	$("#sf_results")
		.delegate("label", "click", function() {
			if($("#sf_results").hasClass("regions")) {
				setTimeout(function() {
					methods.getNum("sf_resorts");
					if($("#sf_results :checked").size()>20) {
						$("#sf_chosen").show().find("div.regions").remove().end().find("h5").after('<div class="list regions"><strong>Регионы:</strong> Вы выбрали больше 20 регионов.</div>');
					}
					else if($("#sf_results :checked").size()!=0) {
						var chosen="";
						$("#sf_results :checked").each(function() {chosen+=$(this).closest("label").find(".item a").text()+", ";});
						$("#sf_chosen").show().find("div.regions").remove().end().find("h5").after('<div class="list regions"><strong>Регионы:</strong> '+chosen.slice(0, chosen.length-2)+'</div>');
					}
					else {
						$("#sf_chosen div.regions").remove();
						if(!$("#sf_chosen div.resorts").is("div")) {$("#sf_chosen").hide();}
					}
				}, 100);
			}
			else if($("#sf_results").hasClass("resorts")) {
				setTimeout(function() {
					//methods.getNum("sf_hotels");
					if($("#sf_results :checked").size()>20) {
						$("#sf_chosen").show().find("div.resorts").remove().end().find("a.reset").before('<div class="list resorts"><strong>Курорты:</strong> Вы выбрали больше 20 курортов.</div>');
					}
					else if($("#sf_results :checked").size()!=0) {
						var chosen="";
						$("#sf_results :checked").each(function() {chosen+=$(this).closest("label").find(".item a").text()+", ";});
						$("#sf_chosen").show().find("div.resorts").remove().end().find("a.reset").before('<div class="list resorts"><strong>Курорты:</strong> '+chosen.slice(0, chosen.length-2)+'</div>');
					}
					else {
						$("#sf_chosen div.resorts").remove();
						if(!$("#sf_chosen div.regions").is("div")) {$("#sf_chosen").hide();}
					}
				}, 100);
			}
		})
		.delegate("label a", "mouseenter", function(e) {
			$(this).siblings("span.hint").addClass("visible_hint");
		})
		.delegate("label a", "mouseleave", function(e) {
			$(this).siblings("span.hint").removeClass("visible_hint");
		})
		.delegate("label a", "click", function(e) {
			e.stopPropagation();
			e.preventDefault();
		});
	$("#sf_conditions")
		.delegate("div.from div.select li", "click", function() {
			methods.getRegions();
			methods.switchMenu("sf_regions");
			$("#sf_chosen").hide().find("div.list").remove();})
		.delegate("div.type div.select li", "click", function() {
			methods.getRegions();
			methods.switchMenu("sf_regions");
			$("#sf_chosen").hide().find("div.list").remove();})
		.delegate("div.to div.select li", "click", function() {
			methods.getRegions();
			methods.switchMenu("sf_regions");
			$("#sf_chosen").hide().find("div.list").remove();});
	$("#sf_date input.text").datePickerMultiMonth({
		numMonths:2,
		showYearNavigation:false,
		displayClose:true,
		clickInput:true,
		renderCallback:function($td, date, month, year) {
			if(availableDates.obj[date.getTime()]=="") {
				$td.addClass("active");
			}
		},
		autoCompleteNextInput:true
	});
	$("#search_form form").submit(function(e) {
		var flag = true;
		$("#sf_date input.text").each(function() {
			if(!/\d{2}.\d{2}.\d{4}/.test($(this).val())) {
				$("#sf_date label").addClass("attention");
				flag = false;
			}
		});
		if(flag) {return true;}
		else {return false;}
	});
};*/
