//Название 

//===========================================================================================

// Для настройки хайслайда

hs.graphicsDir = 'images/';
hs.restoreCursor="zoomout.cur";
hs.expandSteps=10;
hs.expandDuration=250;
hs.restoreSteps=10;
hs.restoreDuration=250;
hs.allowMultipleInstances=false;
hs.hideThumbOnExpand=false;
hs.captionSlideSpeed=1;
hs.outlineWhileAnimating=false;
hs.outlineStartOffset=3;
hs.marginLeft=10;
hs.marginRight=35;
hs.marginTop=10;
hs.marginBottom=35;
hs.numberOfImagesToPreload=0;
hs.zIndexCounter=1001;
hs.fullExpandIcon='fullexpand.gif';
hs.fullExpandTitle='Увеличить до реального размера';
hs.restoreTitle='Нажмите, чтобы закрыть изображение.';
hs.focusTitle='Нажмите, чтобы перенести на передний план';
hs.loadingText='Загрузка...';
hs.loadingTitle='Нажмите, чтобы отменить';
hs.loadingOpacity=0.75; hs.showCredits=false;
hs.creditsText='';
hs.creditsHref='';
hs.creditsTitle='';
hs.enableKeyListener=true;
hs.anchor='auto';
hs.align='auto';
hs.targetX=null;
hs.targetY=null;
hs.captionId=null;
hs.captionTemplateId=null;
hs.slideshowGroup=null;
hs.spaceForCaption=30;
hs.minWidth=200;
hs.minHeight=200;
hs.allowSizeReduction=true;
hs.outlineType='rounded-white';
hs.wrapperClassName=null;

//===========================================================================================



//===========================================================================================



//===========================================================================================



//===========================================================================================

// Тянем таблицу для IE 

$(document).ready(function() {													 
if($.browser.msie) { $( function() {
	
	var h_header= $("#header").height();
	if($("#footer")) {var h_footer= $("#footer").height();}
	else {var h_footer= 0;}
	var pr_height= h_header + h_footer
	
	var userheight= document.documentElement.clientHeight;
	var middleheight = userheight - pr_height;// alert(middleheight);
	$("#content").css( "height", middleheight+"px" );	

 $(window).resize( function() {
	
	var userheight= document.documentElement.clientHeight;
	var middleheight = userheight - pr_height;// alert(middleheight);
	$("#content").css( "height", middleheight+"px" );	
	
					     } );		
				             } ); }
                              } );
//===========================================================================================



//===========================================================================================

// PNG для IE6

function fixPNG(element)
{	//Если браузер IE версии 5.5-6
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;
	//alert('opera');
    if (element.tagName=='IMG') //Если текущий элемент картинка (тэг IMG)
    {
      if (/\.png$/.test(element.src)) //Если файл картинки имеет расширение PNG
      {
        src = element.src;
        element.src = "images/1g.gif"; //заменяем изображение прозрачным gif-ом
      }
    }
    else //иначе, если это не картинка а другой элемент
    {
	  //если у элемента задана фоновая картинка, то присваеваем значение свойства background-шmage переменной src
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1]; //берем из значения свойства background-шmage только адрес картинки
        element.runtimeStyle.backgroundImage="none"; //убираем фоновое изображение
      }
    }
    //если, src не пуст, то нужно загрузить изображение с помощью фильтра AlphaImageLoader
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
  }
}

//===========================================================================================



//===========================================================================================

/** 
 * Happy Form Checker
 * @author wiz - wiz@kerpc.ru
 * @version 1.2
 *
 */
	$( function() {
		//
		$("form.happyform").submit( function() {
			errors = '';
			firstfound = null;
			$("form.happyform .required").each( function(i) {
				if (this.value == '') {
					//alert($("form.happyform label[for='"+this.id+"']").text());
					//label = $("form.happyform label[for='"+this.id+"']").text();
					errors += '<br />'+$("form.happyform label[for='"+this.id+"']").text();
					if (!firstfound) firstfound = this;
				}
			});
			if (errors) {
				$("div.error").html('<strong>Заполните следующие поля:</strong>'+errors);
				$("div.error").fadeIn("slow");
				firstfound.focus();
				return false;
			}
		});

		//фильтр нажатий кнопок в полях digits
		$("form.happyform .digits").bind("keypress", function(e) {
			var key = (typeof e.charCode == 'undefined' ? e.keyCode : e.charCode);
			if (e.ctrlKey || e.altKey || key < 32)
				return true;
			key = String.fromCharCode(key);
			return /\d/.test(key);
		});
	});
//===========================================================================================



//===========================================================================================

// Границы для TH 

$(document).ready(function() {
  $("th:first-child").addClass("brhl");
	$("th:last-child").addClass("brhr");
                             } );

//===========================================================================================


//===========================================================================================

//  Верхняя горизонтальная менюшка

$(document).ready(function() { 
$("ul#menu-top > li > a").hover(													 
function(){
	$(this).parent("li").addClass("opened");	
	},	 
function(){$(this).parent("li").removeClass("opened");});
});

$(document).ready(function() { 
$("ul#menu-top > li > div.vpm").hover(													 
function(){
	$(this).parent("li").addClass("opened");	
	},	 
function(){$(this).parent("li").removeClass("opened");});
});


//===========================================================================================


//===========================================================================================

// Для полей ввода

$(document).ready(function() { 
$("input, textarea").focus( function() {$(this).addClass("onFocus"); } );
$("input, textarea").blur( function() {$(this).removeClass("onFocus");} );
});
//===========================================================================================


//===========================================================================================

//  Для кнопок

$(document).ready(function() { 
$("button").mouseover( function() {$(this).addClass("buho");} );
$("button").mouseout( function()  {$(this).removeClass("buho");} );
});

$(document).ready(function() { 
$(".button").mouseover( function() {$(this).addClass("buho");} );
$(".button").mouseout( function()  {$(this).removeClass("buho");} );
});

//===========================================================================================



//===========================================================================================

//  Вертикальное выравнивание по центру

$(document).ready(function() {
	$("div.valign").children().each(function(){
	
		hthis = $(this).height();
		hparent = $(this).parent().height();
		$(this).parent().css("padding-top", (hparent - hthis)/2);
		//alert(hthis);
		//alert(hparent);
		//alert((hparent - hthis)/2);
		$(this).parent().css("height", hparent-(hparent-hthis)/2);
	});
});

//===========================================================================================

//нихренаська

//===========================================================================================

//классы для всех inputов

//input-checkbox
$(document).ready(function() {													 
	$("input").each(function(){$(this).addClass("input-"+ $(this).attr("type"));});													 
  $("input[@type=checkbox]").each( function(){
	  $(this).after("<div class='check0'>&nbsp;</div>");			 
		$("input[@checked] ~ div.check0").addClass("check1");	 
	  $(this).css( "display", "none" );	 
	});	
	$("input[@type=checkbox] ~ div").click(function(){ //alert("Ты чё чувак");
		$(this).toggleClass("check1");
		if ($(this).hasClass("check1")) $(this).siblings("input").attr("checked", "checked");
		else $(this).siblings("input").removeAttr("checked");	
	});
	
	//input-radiobutton
	$("input[@type=radio]").not(".radio").each( function(){
		$(this).after("<div class='radio0'>&nbsp;</div>");			 
		$("input[@checked] + div.radio0").addClass("radio1");
	});
	$("input[@type=radio] ~ div").click(function(){ //alert("Ты чё чувак");																													
		$("div.radio1").removeClass("radio1");																										
		$(this).toggleClass("radio1");
		if ($(this).hasClass("radio1")) $(this).siblings("input").attr("checked", "checked");
		else $(this).siblings("input").removeAttr("checked");	
	});	
	
});

//===========================================================================================



//===========================================================================================

//классы для всех основных браузеров

$(document).ready(function() {
	
 if($.browser.msie)  $("body").addClass("ie");	
 if($.browser.msie && $.browser.version == 6) $("body").addClass("ie6");
 if($.browser.msie && $.browser.version == 7) $("body").addClass("ie7");
 if($.browser.opera ) $("body").addClass("opera");
 if($.browser.mozilla) $("body").addClass("ffox");
 if($.browser.safari) $("body").addClass("safari");   							 
													 
});


