jQuery.noConflict();
jQuery(document).ready(function(){


  //----------------------------------------------------------------------------
  // меню компании
  //
  jQuery(".n1").click(function () {

    if (jQuery(".company_menu").css("display")=="none")
     jQuery(".company_menu").show("fast");
    else
     jQuery(".company_menu").hide(500);

    return false;
  });

  //----------------------------------------------------------------------------
  // слайдер объектов
  //
  jQuery(".objects").jCarouselLite({
		  btnNext: "#objects_prev",
		  visible: 5,
		  scroll: 1,
		  speed: 500
	 });


	 //----------------------------------------------------------------------------
  // вспывающие подсказки
  //
  jQuery(".tooltip").easyTooltip();
	 //----------------------------------------------------------------------------
  // заказать обратный звонок
  //
  var options={
       target: '#order_call_dialog'   // target element(s) to be updated with server response
  };
  jQuery('#order_call').click(function()
  {
   	jQuery('#order_call_dialog').dialog('open');
   	return false;
  });
  jQuery('#order_call_dialog').dialog(
  {
  	autoOpen: false,
  	width: 400,
  	heght:400
  });
  //------------
  jQuery('#order_call_form').submit(function() {
    jQuery(this).ajaxSubmit(options);
    return false;
  });
  jQuery('#order_call_form').live("submit",  function(){
    jQuery(this).ajaxSubmit(options);
    return false;
  });

  //----------------------------------------------------------------------------
  // дом на странице "изготовление ангаров"
  //
  jQuery('.dr').hide();
 	jQuery('.opt p').click(function(){
 		jQuery('.opt').removeClass('zi');
 		jQuery('.dr').hide();
 		jQuery(this).parent('.opt').addClass('zi');
 		jQuery(this).next('.dr').animate({ opacity: 'show' }, "150");

 	});
 	jQuery('.close').click(function(){
 		jQuery(this).parent('.dr').hide();
 	});

 	//----------------------------------------------------------------------------
  // фак на страница обработка металла
  //
 	jQuery(".faq-cont").hide();
	 //jQuery(".faq-cont").eq(0).show();
 	jQuery(".faq-h").click(function(){
 		jQuery(this).next(".faq-cont").slideToggle("slow")
 		.siblings("div:visible").slideUp("slow");
	 });

	 //----------------------------------------------------------------------------
  // расчет стоимости здания - доп. информация
  //
  jQuery("#calculationrequest_sub_link").click(function () {

    if (jQuery("#calculationrequest_sub").css("display")=="none")
     jQuery("#calculationrequest_sub").show("fast");
    else
     jQuery("#calculationrequest_sub").hide(500);

    return false;
  });

});

function UnSelected(id)
{
	sel=document.getElementById(id);
	for(var i = 0; i<sel.length; i++){
		sel.elements[i].checked = false;
	}
	return false;
}

function Selected(id)
{
	sel=document.getElementById(id);
	for(var i = 0; i<sel.length; i++){
		sel.elements[i].checked = true;
	}
	return false;
}

//------------------------------------------------------------------------------
// для ajax
//

function order_call_success(responseText, statusText, xhr, $form)
{
 jQuery('#order_call_dialog form').clearForm();
 return false;
}
// pre-submit callback
function showRequest_test(formData, jqForm, options) {
    // formData is an array; here we use jQuery.param to convert it to a string to display it
    // but the form plugin does this for you automatically when it submits the data
    var queryString = jQuery.param(formData);

    // jqForm is a jQuery object encapsulating the form element.  To access the
    // DOM element for the form do this:
    // var formElement = jqForm[0];

    alert('About to submit: \n\n' + queryString);

    // here we could return false to prevent the form from being submitted;
    // returning anything other than false will allow the form submit to continue
    return true;
}

// post-submit callback
function showResponse_test(responseText, statusText, xhr, $form)  {
    // for normal html responses, the first argument to the success callback
    // is the XMLHttpRequest object's responseText property

    // if the ajaxSubmit method was passed an Options Object with the dataType
    // property set to 'xml' then the first argument to the success callback
    // is the XMLHttpRequest object's responseXML property

    // if the ajaxSubmit method was passed an Options Object with the dataType
    // property set to 'json' then the first argument to the success callback
    // is the json data object returned by the server

    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
        '\n\nThe output div should have already been updated with the responseText.');
}



function refreshLenght(wid,lid,coefficient)
{
 var weight=document.getElementById(wid).value;
 weight=weight.replace(',','.');
 document.getElementById(lid).value=(weight/coefficient).toFixed(1);
}
function refreshWidth(lid,wid,coefficient)
{
 var lenght=document.getElementById(lid).value+'';
 lenght=lenght.replace(',','.');
 document.getElementById(wid).value=(lenght*coefficient).toFixed(3);
}

