var width = $(window).width();
var height = $(window).height();
var raz = $('#pathway').text();

$(document).ready(function(){

/* Расположение кнопки */
if($.browser.msie && $.browser.version == 6){
	$(function(){
		hh = Math.round(height / 2) - 75;
		$('.knopka').css({'top':hh+'px',/* 'left':'-23px',*/ 'position':'absolute'});
		if(raz == ''){raz = 'Главная';}
		$('.razdel').val(raz);
	});
}else{
	$(function(){
		hh = Math.round(height / 2) - 75;
		$('.knopka').css({'top':hh+'px',/* 'left':'-23px',*/ 'position':'fixed'});
		if(raz == ''){raz = 'Главная';}
		$('.razdel').val(raz);
	});	
}

/* При изменении размера */
$(window).resize(function(){
	var width = $(window).width();
	var height = $(window).height();
	$('.op').css({'width':width+'px','height':height+'px'});
	ww = Math.round(width / 2) - 325;
	hh = Math.round(height / 2) - 140;
	$('.forma').css({'top':hh+'px','left':ww+'px'});
	$('.forma1').css({'top':hh+'px','left':ww+'px'}); // Forma 1
	$('.forma2').css({'top':hh+'px','left':ww+'px'}); // Forma 2
});

/* При навидении на кнопку */
/*if($.browser.msie && $.browser.version == 6){
	$('.knopka').hover(function(){
		$('.knopka').css({'left':'0px','position':'absolute'});
	/*},function(){
		$('.knopka').css({'margin-left':'-23px'});*/
	/*});
}else{
	$('.knopka').hover(function(){$('.knopka').css({'left':'0px','position':'fixed'});
	/*},function(){	$('.knopka').css({'margin-left':'-23px'});*//*});
};

/* При клите на кнопку */
if($.browser.msie && $.browser.version == 6){
	$('.knopka').click(function(){
		$('.op').css({'width':width+'px','height':height+'px'});
		ww = Math.round(width / 2) - 325;
		hh = Math.round(height / 2) - 140;
		$('.forma').fadeIn(500);
		$('.forma').css({'top':hh+'px','left':ww+'px','position':'absolute'});
		ww = Math.round(width / 2) - 235;// Forma 1 & Forma 2
		hh = Math.round(height / 2) - 140;// Forma 1 & Forma 2
		$('.forma1').fadeIn(500);// Forma 1
		$('.close').fadeIn(500);
		$('.forma1').css({'top':hh+'px','left':ww+'px','position':'absolute'});// Forma 1
		$('.forma2').fadeIn(500);// Forma 2
		$('.forma2').css({'top':hh+'px','left':ww+'px','position':'absolute'});// Forma 2
		$('.op').fadeTo(500, 0.25, function(){$(this).css({'position':'absolute','display':'block','left':'0px','top':'0px'});});
	});
}else{
	$('.knopka').click(function(){
		$('.op').css({'width':width+'px','height':height+'px'});
		ww = Math.round(width / 2) - 325;
		hh = Math.round(height / 2) - 140;
		$('.forma').fadeIn(500);
		$('.forma').css({'top':hh+'px','left':ww+'px','position':'fixed'});
		ww = Math.round(width / 2) - 235;// Forma 1 & Forma 2
		hh = Math.round(height / 2) - 140;// Forma 1 & Forma 2
		$('.forma1').fadeIn(500);// Forma 1
		$('.close').fadeIn(500);
		$('.forma1').css({'top':hh+'px','left':ww+'px','position':'fixed'});// Forma 1
		$('.forma2').fadeIn(500);// Forma 2
		$('.forma2').css({'top':hh+'px','left':ww+'px','position':'fixed'});// Forma 2
		$('.op').fadeTo(500, 0.25, function(){$(this).css({'position':'fixed','display':'block','left':'0px','top':'0px'});});
	});
};

/* При клите на кнопку закрыть */
$('.close').click(function(){
	$('.close').fadeOut(500);
	$('.forma').fadeOut(500);
	$('.op').fadeOut(500);
});

/* При клите на кнопку закрыть Forma1 & Forma 2 */
$('.close1').click(function(){
	$('.close1').fadeOut(500);
	$('.forma1').fadeOut(500);// Forma 1
	$('.forma2').fadeOut(500);// Forma 2
	$('.op').fadeOut(500);
});

/* При клите на затемненную область */
$('.op').click(function(){
	$('.close').fadeOut(500);
	$('.forma').fadeOut(500);
	$('.close1').fadeOut(500);// Forma 1 &  Forma 2
	$('.forma1').fadeOut(500);// Forma 1
	$('.forma2').fadeOut(500);// Forma 2
	$('.op').fadeOut(500);
});

/* При прокрутки для IE6 */
if($.browser.msie && $.browser.version == 6){
	$(window).scroll(function(){
		//hh = Math.round(height / 2) - 75;
		//alert(hh);
		//$('.knopka').css({'margin-top':hh+'px'});
		//$('.op').css({'position':'absolute','display':'block','left':'0px','top':'0px'});
	});
};

});
