function stype_1(){
    $('input[name=form_type_value]').val('1');
    $('.type_2').hide();
    $('.type_2 input[type=text]').each( function(){
        $(this).attr('disabled', 'disabled');
        $(this).removeAttr('id');
    });

    $('.type_1').show();
    $('.type_1 input[type=text]').each( function(){
        $(this).attr('disabled', '');
        $(this).attr('id', $(this).attr('xid'));
    });
}

function stype_2(){
    $('input[name=form_type_value]').val('2');
    $('.type_1').hide();
    $('.type_1 input[type=text]').each( function(){
        $(this).attr('disabled', 'disabled');
        $(this).removeAttr('id');
    });

    $('.type_2').show();
    $('.type_2 input[type=text]').each( function(){
        $(this).attr('disabled', '');
        $(this).attr('id', $(this).attr('xid'));
    });
}
function imgz(imgss, old, f) {
	var maxx = 6;
	if (f == 1) {
		var prev = new Array();
		for (var o=0; o<maxx; o++) {
			prev[o] = new Image();
			prev[o].src= '/musor/i/partners/left/'+o+'.jpg';
		}
		
		$('<img src="/musor/i/partners/left/'+0+'.jpg" class="inPartImg num_'+0+'" />')
		.css({"height":"280px", "width":"175px", opacity: 1})
		.prependTo('#inPart');
		
		
	}
	imgss = imgss==old?(imgss+1)==maxx?imgss-1:imgss+1:imgss;
	$('<img src="/musor/i/partners/left/'+imgss+'.jpg" class="inPartImg num_'+imgss+'" />')
		.css({"height":"0px", "width":"0px", opacity: 0})
		.prependTo('#inPart');
		
	$('img.num_'+imgss).animate({"height":"280px", "width":"175px", opacity: 1}, 3000, function(){
		imgz(imgss==(maxx-1)?0:imgss+1, imgss, '');
	});
	
	$('img.num_'+old).animate({"height":"0px", "width":"0px", opacity: 0}, 3000, function () {
	$(this).remove();
	});
	
}

$(document).ready( function(){
		
imgz(1, 0, 1);
	$('#block_perere').click(function (){
		$('#perere_form').css({'display': 'block'});
		return false;
	});
	
	
	$('#pere_list_comp').click (function () {
		$('#pere_firm_select').css({'display':'block'});
		return false;
	});
	
	$('#pere_firm_select a')
	.click(function () {
	
		var htm_ = '<p style="font-size:11px">'+$(this).html() + $(this).attr('desc') + ' <a href="#" onClick="$(\'#p_pere_firm\').attr(\'value\',\''+$(this).html()+'\'); $(\'#pere_firm_select\').attr(\'style\',\'display:none\'); return false;">Выбрать эту компанию</a></p>';
		
		$('#desc_pere_firm')
		.html(htm_);
		
		return false;
	})   
		           
			
            $('<table id="our_tooltip"><tr><td class="t1"></td><td class="t2"></td><td class="t3"></td></tr><tr><td class="t4"></td><td class="t5"></td><td class="t6"></td></tr><tr><td class="t7"></td><td class="t8"></td><td class="t9"></td></tr></table>').appendTo('body');


            $('.otd').each( function(){
                $(this)
                    .mouseover( function(){
                        $('#our_tooltip').show();
                        if($(this).attr('ot_html') != undefined){
                            $('#our_tooltip td.t5').html($(this).attr('ot_html'));
                        }
                            
                    })
                    .mousemove( function(e){
                        $('#our_tooltip')
                            .css('left', eval(e.pageX - 20))
                            .css('top', eval(e.pageY - 80));
                    })
                    .mouseout( function(e){
                        $('#our_tooltip').hide();
                        $('#our_tooltip td.t5').html('');
                            
                    });

            });
            
            $('.ot').each( function(){
                $(this)
                    .mouseover( function(){
                        $('#our_tooltip').show();
                        if($(this).attr('ot_html') != undefined){
                            $('#our_tooltip td.t5').html('<img src="/musor/_i/tooltip/s/' + $(this).attr('ot_logo') + '" /><br />' + $(this).attr('ot_html'));
                        } else {
                            $('#our_tooltip td.t5').html('<img src="/musor/_i/tooltip/s/' + $(this).attr('ot_logo') + '" />');
                        }
                            
                    })
                    .mousemove( function(e){
                        $('#our_tooltip')
                            .css('left', eval(e.pageX - 20))
                            .css('top', eval(e.pageY - 160));
                    })
                    .mouseout( function(e){
                        $('#our_tooltip').hide();
                        $('#our_tooltip td.t5').html('');
                            
                    });

            });
            


           jQuery.easing.def = 'easeOutSine';
            jQuery.ifixpng('/musor/i/spacer.gif');
            jQuery('img, .bgPng').ifixpng();
            init_hovers();
			
			/*
            $("input[type=file]").filestyle({ 
                image: "/musor/i/resume.gif",
                imageheight : 17,
                imagewidth : 42,
                width : 335
            });
			*/
			/*
            $('div.hide>a').click( function(){
                if($(this).parent().find('div:visible').length > 0){
                    $(this).parent().find('div').hide();
                } else {
                    $('div.hide div:visible').hide();
                    $(this).parent().find('div').show();
                }
                $(this).blur();
                return false;
            });
			*/
            runIt();
            runIt2();
            runIt3();
            runIt4();
            runIt5();
            runIt6();

            fp = new Array();
            fp['type1_input1'] = 'Наименование компании';
            fp['type2_input1'] = 'Должность';
            fp['type3_input1'] = 'Фамилия';
            fp['type3_input2'] = 'Имя';
            fp['type3_input3'] = 'Отчество';
            fp['type4_input1'] = '000';
            fp['type4_input2'] = '0000000';
            fp['type4_input3'] = 'ваш@адрес.ru';
            fp['type5_input1'] = 'Тема обращения';
            fp['type7_input1'] = 'Фамилия Имя Отчество';
            fp['t11i1'] = '000';
            fp['t11i2'] = '0000000';
            fp['t11i3'] = 'ваш@адрес.ru';
            fp['t11i4'] = 'http://адрес.сайта';
            fp['t12i1'] = 'Должность';
            fp['t12i2'] = 'Кол-во лет';

            prf();

            if($('#type8_input1').length == 1){
                $.each(sm,function(index, item){
                    $('#type8_input1').append($( "<option value='"+ index + "'>" + item + "</li>" ));
                });

                $('#type8_input1').change( function(){
                    if($('#type8_input1').val() == 0){
                        $('#type9_input1').find('option').remove();
                    } else {
                        if($('#type8_input1').val() > 0 && $('#type8_input1').val() < 14){
                            $('#type9_input1').find('option').remove();
                            $.each(eval('sm'+$('#type8_input1').val()), function(index, item){
                                $('#type9_input1').append($('<option value="' + index + '">' + item + '</option>'));
                            });
                        } else {
                            $('#type9_input1').find('option').remove();
                        }
                    }
                });
            }
});
