



function fadeThis(el){
  el.fadeOut("slow");
  if ($(el).next().length == 0) {
    $("#plasma img:first-child").fadeIn("slow", function(){
      fadeTimeout($(this));
    });
  } else {
    fadeNext($(el));
  }
}
function fadeNext(el){
  el.next().fadeIn("slow", function(){
    fadeTimeout($(this));
  });
}
function fadeTimeout(el){
  setTimeout(function(){
    fadeThis($(el));
  }, 5000);
}


function GoToUrl(form){
  if ($("#url").length) 
  {
  	document.location = $("#url").val();
  }
  return false;
}


window.onload = function() {
  if ($.browser.msie) $("#plasma img").attr("galleryimg", "no");
  if ($("#plasma").length) fadeTimeout("#plasma img:not(.hide)");
}

$(document).ready(function() {
  
  $('.rnd').append('<span class="cn tl"></span><span class="cn tr"></span><span class="cn bl"></span><span class="cn br"></span>');
  
  $('#header .nav td div').each(function() {
    if ($(this).find('ul').length) {
      $(this).hover(function() {
        $(this)
          .find('ul')
          .show();
      }, function() {
        $(this)
          .find('ul')
          .hide();
      });
    };
  });


  //swfobject.embedSWF("/i/logo.swf", "logo", "231", "199", "9.0.0", false, false, {wmode: "transparent"});
  
  //swfobject.embedSWF("/i/vip.swf", "vip", "84", "54", "9.0.0", false, false, {wmode: "transparent"});

  
  if($("#search.index")) {
    $("#search.index form .toggler").click(function() {
      $("#search.index form.hide").removeClass("hide");
      $(this).parents("form").addClass("hide");
      return false;
    }) 
  }
  
  if ($('#plasma').length) {
    
    $('#search .phone .controls i').each(function() {
      $(this).click(function() {
        $(this).parents('.phone:first').find('.current').removeClass('current');
        $(this).parents('.phone:first').find('.phone_' + $(this).attr('class').replace(/[a-z_ ]+/g, '')).addClass('current');
      });
    });
    
  };

  if($("#vip").length) {
  	swfobject.embedSWF("/i/vip.swf", "vip", "84", "54", "9.0.0", false, false, {wmode: "transparent"});
	}
	
  if ($('#sidebar').length) {
    $('#sidebar .phone .controls i').each(function() {
      $(this).click(function() {
        $(this)
          .parents('.phone:first')
          .find('.current')
          .removeClass('current');
        $(this)
          .parents('.phone:first')
          .find('.phone_' + $(this).attr('class')
          .replace(/[a-z_ ]+/g, ''))
          .addClass('current');
      });
    });
  };
  
//  if ($('.thickbox').length)
//    $('.thickbox').each(function() {
//      $(this).slimbox();
//    });

    if ($('.thickbox').length) {
    $('.thickbox').lightBox();
  };
   
     
});



function myForm(e) {

	var error = 0;
	var form = $(e);
	if(!$('#o_name').val() && !$('#o_phone').val()) 
	{
		if(!$('#o_name').val())      { alert ("Заполните, пожалуйста, телефон или e-mail"); error = 1; }
		else if(!$('#o_phone').val()) { alert ("Заполните, пожалуйста, телефон или e-mail"); error = 1; }
	}
	if(error)
		return false;
	else
		form.submit();
};


