$(document).ready(function(){
    $("a#form1_title").click(function(){
	$(".form_order").fadeOut("slow");
	return false;
	});

    $("a.order12").click(function(){
        var str=$(this).attr("href");
	var i=str.indexOf("item-")+5;
        var training_id=str.substr(i,str.indexOf("#")-i-1);
	$("#tr_id").attr("value",training_id);

	$("#form_order").css("left",$(this).offset().left-50);
	$("#form_order").css("top", $(this).offset().top-100);
	$("#form1_title").text("запрос на проведение");
	$(".form1_theme").hide();
	$("#form_order").fadeIn("slow");
        $("#otype").val("order");

	return false;
	});
    $("a.order15").click(function(){
        var str=$(this).attr("href");
	var i=str.indexOf("item-")+5;
        var training_id=str.substr(i,str.indexOf("#")-i-1);
	$("#tr_id").attr("value",training_id);

	$("#form_order").css("left",$(this).offset().left-50);
	$("#form_order").css("top", $(this).offset().top-100);
	$("#form1_title").text("заказать в корпоративном формате");
	$("span.form1_theme2").text("Ваши пожелания");
	$("span.form1_theme").text("Контактная информация");
	$(".form1_theme").show();
	$("#form_order").fadeIn("slow");
        $("#otype").val("corp");

	return false;
	});
    $("#form1").submit(function(){

    	var form1=document.getElementById("form1");
        if(form1.email.value)
	  {
	  str=location.href;
	  str_host=location.hostname;
	  pos=str.indexOf(str_host)+str_host.length;
	  url=str.slice(pos);
	  $("#form_accepted").css("visibility","visible");
//          $.post(url,jQuery.makeArray($("#form1").children("input,textarea")));
          $.post(url,jQuery.makeArray(form1.elements));
//          $(".form_order").fadeOut("slow");
	  }
          return false;
	});
    $("#form_accepted_close").click(function(){
        $("#form_accepted").css("visibility","hidden");
        $(".form_order").fadeOut("slow");
        return false;
        });
    $("a#lookingfor").click(function(){
	$("#form_order").css("left",$(this).offset().left-65);
	$("#form_order").css("top", $(this).offset().top-260);
	$("#form1_title").text("не нашли тематику?");
	$("#tr_id").attr("value",0);
	$(".form1_theme").show();
	$("span.form1_theme").text("Интересующая тематика");
	$("span.form1_theme1").text("Контактная информация");
	$("#otype").val("look");
	$("#form_order").fadeIn("slow");
	return false;
	});
    $("input[id^='check']").change(function(){if($(this).attr("checked"))$(this).val(1);else $(this).val(0);});

    $("a.order13").click(function(){
	$("#form_order13").fadeIn("slow");

	return false;
	});

    $("#reg-link").click(function(){
    	var form2=document.getElementById("form2");
        if(form2.email.value && form2.phone.value && form2.name.value && form2.memb.value)
	  {
	  $str=location.href;
	  $str_host=location.hostname;
	  $pos=$str.indexOf($str_host)+$str_host.length;
	  $url=$str.slice($pos);
	  $("#reg_form_accepted").css("visibility","visible");
          $.post($url,jQuery.makeArray(form2.elements));
	  }
          return false;
	});
    $("#reg_form_accepted_close").click(function(){
        $("#reg_form_accepted").css("visibility","hidden");
        $("#reg").slideUp("slow");
        return false;
        });

/*
    $("[href='#registration']").toggle(
	function(){
	    $("#reg").slideDown("slow");
	},
	function(){
	    $("#reg").slideUp("fast");
	}
    );
*/
    if(location.hash)
	{
	$("a[href="+location.hash+"]").parent().next("#reg").show();
	}
    
    $(".order14").click(function(){$(this).parent().next("#reg").slideToggle("slow")});
    
/*    
function ShowReg(){
if (document.getElementById("reg").style.display=='none')
{
//	alert("fdsfds");
	$("#reg").slideDown("fast");
}
}
*/
});
