
function change_buttons() {
	// Автоматом меняем дизайн у <input type="submit" class="GraySubmit" и class="BlueSubmit"
	jQuery("input.GraySubmit, input.BlueSubmit").each( function() {
		onClick =	jQuery(this).attr('onClick');
		Val =		jQuery(this).attr('value');
		Type =		jQuery(this).attr('type');
		Class =		jQuery(this).attr('class');
		FontSize =	jQuery(this).css('font-size');
		FontWeight =	jQuery(this).css('font-weight');
		Width 	=	jQuery(this).css('width');

		PaddingTop = jQuery(this).css('padding-top');
		jQuery(this).css('padding-top', '');
		PaddingRight = jQuery(this).css('padding-right');
		jQuery(this).css('padding-right', '');
		PaddingBottom = jQuery(this).css('padding-bottom');
		jQuery(this).css('padding-bottom', '');
		PaddingLeft = jQuery(this).css('padding-left');
		jQuery(this).css('padding-left', '');

		MarginTop = jQuery(this).css('margin-top');
		jQuery(this).css('margin-top', '');
		MarginRight = jQuery(this).css('margin-right');
		jQuery(this).css('margin-right', '');
		MarginBottom = jQuery(this).css('margin-bottom');
		jQuery(this).css('margin-bottom', '');
		MarginLeft = jQuery(this).css('margin-left');
		jQuery(this).css('margin-left', '');

		tstyle = ' height: 24px; display: block; text-align: center; ';
		if ( Class == 'GraySubmit' ) {
			BorderColor = '#546d78';
			TextColor = '#FFFFFF';
			image1 = 'btn_gray_l.gif';
			image1_h = 'btn_gray_lh.gif';
			image2 = 'btn_gray_r.gif';
			image2_h = 'btn_gray_rh.gif';
		}
		if ( Class == 'BlueSubmit' ) {
			BorderColor = '#004f94';
			BorderLColor = '#68c1e8';
			TextColor = '#FFFFFF';
			image1 = 'btn_blue_l.gif';
			image1_h = 'btn_blue_lh.gif';
			image2 = 'btn_blue_r.gif';
			image2_h = 'btn_blue_rh.gif';
		}

		submitcode = '';
		if ( Type == 'submit' || Type == 'reset' ) {
			if ( Type == 'submit' ) { submitcode = ' onClick=" jQuery(this).parents(\'form\').submit(); " '; }
			if ( Type == 'reset' ) { submitcode = ' onClick=" jQuery(this).parents(\'form\').submit(); " '; }
		} else {
			var text = ''+onClick;
			var re = '/\n/mg';
			text = text.replace(re, "");
			var re = /\r/mg;
			text = text.replace(re, "");
			re = /function\sanonymous\(\)/mg;
			text = text.replace(re, "");
			re = /function\sanonymous(\s+)\(\)/mg;
			text = text.replace(re, "");
			re = /[\{\}]/mg;
			text = text.replace(re, "");
			onClick = text;
			submitcode = ' onClick=" '+onClick+' " ';
		}

		if ( parseInt(PaddingTop) == 0 ) {
			PaddingTop = '5px';
		}
	
		new_code = '<div style="position: relative; display: block; width: '+Width+'; height: 24px;'+
			'margin-top: '+MarginTop+'; '+
			'margin-right: '+MarginRight+'; '+
			'margin-bottom: '+MarginBottom+'; '+
			'margin-left: '+MarginLeft+'; '+
			' " ' +
			submitcode +
			' >'+
			'<div style=" background-image: url(\'/images/template/sp.gif\'); width: 100%; height: 24px; display: block; cursor: pointer; z-index: 10; position: absolute; "'+
		
			'><span>' +
			'</span></div>'+
			'<div class="innBack1" style="z-index: 5; display: block; width: 100%; height: 24px; position: absolute; background-position: top left; background-repeat: no-repeat; background-image: url(/images/template/'+image1+'); ">' +
			'<div class="innBack2" style="z-index: 5; display: block; width: 100%; height: 24px; position: absolute; background-position: top right; background-repeat: no-repeat; background-image: url(/images/template/'+image2+'); ">' +
				'<span style="display: table; vertical-align: middle; width: 100%; height: 20px; white-space: nowrap; width: 100%; z-index: 20; font-size: '+FontSize+'; font-weight: '+FontWeight+'; ">'+
				'<span style="white-space: nowrap; '+tstyle+' display: block; width: 100%; height: 20px; position: absolute; z-index: 10; top: '+PaddingTop+'; color: '+BorderColor+'; margin: 0px 0 0 1px; ">'+Val+'</span>'+
				'<span style="white-space: nowrap; '+tstyle+' display: block; width: 100%; height: 20px; position: absolute; z-index: 10; top: '+PaddingTop+'; color: '+BorderColor+'; margin: 0px 0 0 -1px; ">'+Val+'</span>'+
				'<span style="white-space: nowrap; '+tstyle+' display: block; width: 100%; height: 20px; position: absolute; z-index: 10; top: '+PaddingTop+'; color: '+BorderColor+'; margin: -1px 0 0 0px; ">'+Val+'</span>'+
//				'<span style="white-space: nowrap; '+tstyle+' display: block; width: 100%; height: 20px; position: absolute; z-index: 10; top: '+PaddingTop+'; color: '+BorderColor+'; margin: 1px 0 0 0px; ">'+Val+'</span>'+
//				'<span style="white-space: nowrap; '+tstyle+' display: block; width: 100%; height: 20px; position: absolute; z-index: 10; top: '+PaddingTop+'; color: '+BorderColor+'; margin: -1px 0 0 1px; ">'+Val+'</span>'+
//				'<span style="white-space: nowrap; '+tstyle+' display: block; width: 100%; height: 20px; position: absolute; z-index: 10; top: '+PaddingTop+'; color: '+BorderColor+'; margin: 1px 0 0 -1px; ">'+Val+'</span>'+
//				'<span style="white-space: nowrap; '+tstyle+' display: block; width: 100%; height: 20px; position: absolute; z-index: 10; top: '+PaddingTop+'; color: '+BorderColor+'; margin: -1px 0 0 -1px; ">'+Val+'</span>'+
//				'<span style="white-space: nowrap; '+tstyle+' display: block; width: 100%; height: 20px; position: absolute; z-index: 10; top: '+PaddingTop+'; color: '+BorderColor+'; margin: 1px 0 0 1px; ">'+Val+'</span>'+
				'<span style="white-space: nowrap; '+tstyle+' width: 100%; height: 20px; position: absolute; z-index: 21;  '+' top: '+PaddingTop+'; color: '+TextColor+' " >'+Val+'</span>'+
				'</span>'+
			'</div></div>'+
			'</div>';
			jQuery(this).replaceWith(new_code);

		});

		// tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
		// imgLoader = new Image();// preload image
		// imgLoader.src = tb_pathToImage;
}





























	var delta_left = new Array;
	var delta_top  = new Array;





function startall() {
	jQuery(document).ready(function(){
		jQuery(document).pngFix();
		change_buttons();
		bind();
	});
}

jQuery(document).ready(function(){
	startall();
});


	function show_tab(id, tab) {
		if ( document.getElementById('tab_'+id+'_1') && document.getElementById('tab_'+id+'_2') ) {
			document.getElementById('tab_'+id+'_1').style.display = 'none';
			document.getElementById('tab_'+id+'_2').style.display = 'none';
			document.getElementById('tabbtn_'+id+'_1_on').style.display = 'none';
			document.getElementById('tabbtn_'+id+'_2_on').style.display = 'none';
			document.getElementById('tabbtn_'+id+'_1_off').style.display = 'block';
			document.getElementById('tabbtn_'+id+'_2_off').style.display = 'block';
			document.getElementById('tabbtn_'+id+'_'+tab+'_off').style.display = 'none';
			document.getElementById('tabbtn_'+id+'_'+tab+'_on').style.display = 'block';
			document.getElementById('tab_'+id+'_'+tab).style.display = 'block';
		}
	}


	function bind() {
		$("table.MenuTop tr td").bind("mouseover", function(){
			$(this).find('.Shadow').show();
			$(this).find('.Popup').show();
			$(this).find('.Link').removeClass().addClass('LinkHover');
			$(this).find('.Current').removeClass().addClass('CurrentHover');
		});
		$("table.MenuTop tr td .Popup").bind("mouseover", function(){
			$(this).parent().find('.Shadow').show();
			$(this).show();
			$(this).parent().find('.Link').removeClass().addClass('LinkHover');
			$(this).parent().find('.Current').removeClass().addClass('CurrentHover');
		});
		$("table.MenuTop tr td").bind("mouseout", function(){
			$(this).find('.Shadow').hide();
			$(this).find('.Popup').hide();
			$(this).find('.LinkHover').removeClass().addClass('Link');
			$(this).find('.CurrentHover').removeClass().addClass('Current');
		});


	}



