$(document).ready(function(){

 $('#ico_w img').mouseover(function(e) {
 $(e.target).animate({
      opacity: .6
    }, { duration: 100, queue:false }); 
 });	

 $('#ico_w img').mouseout(function(e) {
 $(e.target).animate({
      opacity: 1
    }, { duration: 100, queue:false }); 
 }); 
 
/*if ($('#gall img').attr('src'))
{
grayscale( $('#gall img') );
}
	
 $('#gall img').mouseover(function(e) {
 
 grayscale.reset( $(e.target) );
 
 });	
 
  $('#gall img').mouseout(function(e) {
 
 grayscale( $(e.target) );
 
 });*/


$('#m3_b1').mouseover(function(){
wdth=$('#m3_b1').width();
$.b_m3or_off(onor);
       $("#m_button").animate({
      top: 0,left:0 ,height: 25,width: wdth, opacity: 1
    }, { duration: 500, queue:false });  

},
function(){

});

$('#m3_b1').mouseout(function(){
wdth=$('#m3_b1').width();
$('#m3_b'+onor).attr("class","or_on");
       $("#m_button").animate({
      top: 0,left:0 ,height: 25,width: 0, opacity: 1
    }, { duration: 500, queue:false });  

},
function(){

});

$('#m3_b2').mouseover(function(){
wdth=$('#m3_b2').width();
$.b_m3or_off(onor);
       $("#m_button").animate({
      top: 0,left:135 ,height: 25,width: wdth, opacity: 1
    }, { duration: 500, queue:false });  

},
function(){

});

$('#m3_b2').mouseout(function(){
wdth=$('#m3_b2').width();
$('#m3_b'+onor).attr("class","or_on");
       $("#m_button").animate({
      top: 0,left:0 ,height: 25,width: 0, opacity: 1
    }, { duration: 500, queue:false });  

},
function(){

});

$('#m3_b3').mouseover(function(){
wdth=$('#m3_b3').width();
$.b_m3or_off(onor);
       $("#m_button").animate({
      top: 0,left:270 ,height: 25,width: wdth, opacity: 1
    }, { duration: 500, queue:false });  

},
function(){

});

$('#m3_b3').mouseout(function(){
wdth=$('#m3_b3').width();
$('#m3_b'+onor).attr("class","or_on");
       $("#m_button").animate({
      top: 0,left:0 ,height: 25,width: 0, opacity: 1
    }, { duration: 500, queue:false });  

},
function(){

});

$('#m3_b4').mouseover(function(){
wdth=$('#m3_b4').width();
$.b_m3or_off(onor);
       $("#m_button").animate({
      top: 0,left:405 ,height: 25,width: wdth, opacity: 1
    }, { duration: 500, queue:false });  

},
function(){

});

$('#m3_b4').mouseout(function(){
wdth=$('#m3_b4').width();
$('#m3_b'+onor).attr("class","or_on");
       $("#m_button").animate({
      top: 0,left:0 ,height: 25,width: 0, opacity: 1
    }, { duration: 500, queue:false });  

},
function(){

});

$('#m2_b1').click(function(){
window.location.href="aerography.php";
});

$('#m2_b2').click(function(){
window.location.href="tuning.php";
});

$('#m2_b3').click(function(){
window.location.href="autocenter.php";
});

$('#m2_b4').click(function(){
window.location.href="school.php";
});

$('#m2_b5').click(function(){
window.location.href="shop.php";
});


$('#m2_b1').mouseover(function(){
$.b_cl(1);
});

$('#m2_b2').mouseover(function(){
$.b_cl(2);
});

$('#m2_b3').mouseover(function(){
$.b_cl(3);
});

$('#m2_b4').mouseover(function(){
$.b_cl(4);
});

$('#m2_b5').mouseover(function(){
$.b_cl(5);
});

$('#m2_b1').mouseout(function(){
$.b_cl_o(on);
});

$('#m2_b2').mouseout(function(){
$.b_cl_o(on);
});

$('#m2_b3').mouseout(function(){
$.b_cl_o(on);
});

$('#m2_b4').mouseout(function(){
$.b_cl_o(on);
});

$('#m2_b5').mouseout(function(){
$.b_cl_o(on);
});


$.b_cl = function(numb) {
$.b_cl_off();
$.allback();
$("#ph"+numb).hide();
$("#ph"+numb).css("z-index","2000");
$("#ph"+numb).fadeIn("fast");
};

$.b_cl_off = function(num) {
$('#m2_b1').css("background","");
$('#m2_b2').css("background","");
$('#m2_b3').css("background","");
$('#m2_b4').css("background","");
$('#m2_b5').css("background","");
	};
	
$.allback = function() {
	$('#ph1').css("z-index","1005");
	$('#ph2').css("z-index","1004");
	$('#ph3').css("z-index","1003");
	$('#ph4').css("z-index","1001");
	$('#ph5').css("z-index","1002");
	};

$.b_cl_o = function(nn) 
{
if(nn!=0)
{
$('#m2_b'+nn).css("background","transparent url(../tmpl/images/m2_"+nn+"o.png) top left no-repeat");
$.allback();
$("#ph"+nn).hide();
$("#ph"+nn).css("z-index","2000");
$("#ph"+nn).fadeIn("slow");
}
if(nn==0)
{
//$('#m2_b'+nn).css("background","");
$.allback();
}
};

$.b_m3or_off = function(numor) {
//alert('');
$('#m3_b1').attr("class","");
$('#m3_b2').attr("class","");
$('#m3_b3').attr("class","");
$('#m3_b4').attr("class","");
};

});
