$(document).ready(function() {
	$('table').css({width:'100%'})
	
$(".captchaHref").click(function() { // перезагрузка каптчи
	$("#captchaPic"+$(this).attr("rel")).attr("src", $("#captchaPic"+$(this).attr("rel")).attr("src"))
	//$(".captchaPic").attr("src",$(".captchaPic").attr("src"));
	return false;
});

});



$(document).ready(init);

function init(){
		$("#questions a.closed, #questions a.open").click(
			function(){
				x=$(this).attr("id");
				x = x.replace("q","a");
				if($("#"+x).is(':hidden')){
					$("#"+x).slideDown(200);
					$(this).removeClass("closed");
					$(this).addClass("open");
				}else{
					$("#"+x).slideUp(200);
					$(this).removeClass("open");
					$(this).addClass("closed");

				}
				return false;
			}
		);
		$("#overlay").animate({opacity: 0}, 0 );

}

function togg(name) {
	c = (document.getElementById(name).clientHeight==0? "block":"none");
	document.getElementById(name).style.display = c;
}

function change_search(p){
	if(p==1){
		$("#tm1 div").hide();
		$("#tm1 a").show();
		$("#tm2 a").hide();
		$("#tm2 div").show();
		$("#tm1_f").fadeOut(300, function(){$("#tm2_f").fadeIn();});
		$("#form_search_submit").addClass("butt_personal_order");
		document.getElementById("form_search_submit").onclick = function() {document.forms.personalTour.submit();return false;};

	}else if(p==2){
		$("#tm1 a").hide();
		$("#tm1 div").show();
		$("#tm2 div").hide();
		$("#tm2 a").show();
		$("#tm2_f").fadeOut(300, function(){$("#tm1_f").fadeIn();});
		$("#form_search_submit").removeClass("butt_personal_order");
		document.getElementById("form_search_submit").onclick = function() {alert('Не тыкать. Не работает пока.');return false;};


	}
}

function change_u(p){
	if(p==1){
		$("#dot").hide();
		$("#aot").hide();
		$("#aoa").show();
		$("#doa").show();
                
	}else if(p==0){
		$("#dot").show();
		$("#aot").show();
		$("#aoa").hide();
		$("#doa").hide();
	}
        if (p==1) $("#u").val(1);
        if (p==0) $("#u").val(0); 
       
}

function togg_anim_up(name) {
	c = (document.getElementById(name).offsetHeight==0? "block":"none");
	if(c=="block"){$("#"+name).fadeIn(200);}else{$("#"+name).fadeOut(200);}
}

function togg_anim_slide(name, obj) {
	c = (document.getElementById(name).offsetHeight==0? "block":"none");
	if(c=="block"){$("#"+name).slideDown(200);$(obj).removeClass('close_bl');close=0;}else{$("#"+name).slideUp(400);$(obj).addClass('close_bl');close=1;}
	date=getDate();
	setCookie(name, close, date, "/");
	return false;
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getDate(dtDaysExpires){

   var dtExpires = new Date();
   var dtExpiryDate = "";

	dtExpires.setTime(dtExpires.getTime() + 
	dtDaysExpires * 24 * 60 * 60 * 1000);
	dtExpiryDate = dtExpires.toGMTString();
	return dtExpiryDate;
}

function show_des(bl_id){
	if(document.getElementById('up_'+bl_id).offsetHeight==0){
		$('#bl_'+bl_id).css("z-index", 500);
		$('#out_'+bl_id).css("z-index", 500);
		document.getElementById('overlay').style.display="block";
		$("#overlay").animate({opacity: 0.6}, 500 );
		$('#up_'+bl_id).fadeIn(200);
		$('#bl_'+bl_id).css("position", "absolute");
	}else{
		$('#up_'+bl_id).fadeOut(50);
		$("#overlay").animate({opacity: 0}, 500 );
		document.getElementById('overlay').style.display="none";
		$('#bl_'+bl_id).css("z-index", 10);
		$('#out_'+bl_id).css("z-index", 10);
	}
}

function change_memt(mid){
	c=$("#"+mid).val();
	c = c.split('///');
	$("#mbl_"+mid).fadeOut(300,function(){
		$("#link_"+mid).attr("href", c[1]);
		$("#size_"+mid).empty();
		$("#size_"+mid).append(c[0]+" Kb");
		$("#mbl_"+mid).fadeIn(300);
	});

}

function change_viza(mid){
	c=$("#"+mid).val();
	$("#mbl_"+mid).fadeOut(300,function(){
		$("#link_"+mid).attr("href", c);
		$("#mbl_"+mid).fadeIn(300);
	});

}

