var o_serv;
$(document).ready(function(){


if(document.location.hash!='') {
        //get the index from URL hash
      	var tabSelect = document.location.hash.substr(4)-1;
		$.tabs = function(options){
		var defaults = {
			tabContainers: 'div.tabs-wrap > div',
			tabButtons: 'ul.tabs-buttons li a',
			loadTabActive: tabSelect,
			classAdd:'active'
		};
		var options = $.extend({},defaults, options);
		$(options.tabContainers).hide().eq(options.loadTabActive).show();
		$(options.tabButtons).click(function(){
			$(options.tabContainers).hide().filter(this.hash).show();
			$(options.tabButtons).removeClass(options.classAdd);
			$(this).addClass(options.classAdd);
			return false;
		}).eq(options.loadTabActive).click();
	}

}



var len = $('ul.vacancy-list li').length;
                $('ul.vacancy-list li').each(function(){
                    $(this).css('z-index',len--);
                });


options = {
		reject : { // Rejection flags for specific browsers
			all: false, // Covers Everything (Nothing blocked)
			msie5: true,msie6: true // Covers MSIE 5-6 (Blocked by default)
		},
		display: ['firefox','chrome','msie','safari','opera','gcf'], // What browsers to display and their order
		browserInfo: { // Settings for which browsers to display
			firefox: {
				text: 'Firefox 3.5+', // Text below the icon
				url: 'http://www.mozilla.com/firefox/' // URL For icon/text link
			},
			safari: {
				text: 'Safari 4',
				url: 'http://www.apple.com/safari/download/'
			},
			opera: {
				text: 'Opera 10.5',
				url: 'http://www.opera.com/download/'
			},
			chrome: {
				text: 'Chrome 5',
				url: 'http://www.google.com/chrome/'
			},
			msie: {
				text: 'Internet Explorer 8',
				url: 'http://www.microsoft.com/windows/Internet-explorer/'
			},
			gcf: {
				text: 'Google Chrome Frame',
				url: 'http://code.google.com/chrome/chromeframe/',
				allow: { all: false, msie: true } // This browser option will only be displayed for MSIE
			}
		},
		header: 'Ваш браузер устарел!', // Header of pop-up window
		paragraph1: 'К сожалению, ваш браузер слишком старой версии, чтобы просматривать этот сайт. Пожалуйста, обновите его до современной версии и повторите попытку.', // Paragraph 1
		paragraph2: 'Нажмите на иконку для перехода по ссылке.', // Paragraph 2
		close: true, // Allow closing of window
		closeMessage: '', // Message displayed below closing link
		closeLink: 'Закрыть окно', // Text for closing link
		closeURL: '#', // Close URL
		closeESC: true, // Allow closing of window with esc key
		closeCookie: false, // If cookies should be used to remmember if the window was closed (see cookieSettings for more options)
		// Cookie settings are only used if closeCookie is true
		cookieSettings: {
			path: '/', // Path for the cookie to be saved on (should be root domain in most cases)
			expires: 0 // Expiration Date (in seconds), 0 (default) means it ends with the current session
		},
		imagePath: '/images/', // Path where images are located
		overlayBgColor: '#000', // Background color for overlay
		overlayOpacity: 0.8, // Background transparency (0-1)
		fadeInTime: 'fast', // Fade in time on open ('slow','medium','fast' or integer in ms)
		fadeOutTime: 'fast' // Fade out time on close ('slow','medium','fast' or integer in ms)
	}
            
$.reject(options);




$('#callback_sub').click(function(){

	$('#callback').validate({
			errorClass: 'err-block',
			errorElement: 'div',
			rules:{
					f_Name: {
						required: true
					},
					f_Subject: {
						required: true
					},f_Phone: {
						required: true
					}
				},
		 submitHandler: function(form) {
			$('#callback').ajaxSubmit({
				clearForm : true,
				success: function() {
					done('callback');
						}		  		
				});
		 }

				
	});
	$('#callback').submit();

});




$('#feedback_sub').click(function(){
	$('#feedback').validate({
			errorClass: 'err-block',
			errorElement: 'div',
			rules:{
					f_Name: {
						required: true
					},
					f_Email: {
						email: true
					},
					f_Phone: {
						required: true
					},
					f_Quest: {
						required: true
					}

				},
			messages:{
				f_Name: {
					required: 'Введите имя'
				},
				f_Email: {
					required: 'Введите электронный ящик',
					email: 'Неверно введен электронный ящик'

				},
				f_Phone:{
					required: 'Введите телефон'
					},
				f_Quest:{
					required: 'Введите вопрос'
					}
			},
		 submitHandler: function(form) {
			$('#feedback').ajaxSubmit({
				clearForm : true,
				success: function() {
					done('feedback');
					}		  		
				});
		 }

				
	});
		$('#feedback').submit();


});





 o_serv={
			errorClass: 'err-block',
			errorElement: 'div',
			rules:{
					f_Name: {
						required: true
					},
					f_Email: {
						email: true
					},
					f_Phone: {
						required: true
					},
					f_Service: {
						onecheck: true,inlength: 1
					}

				},
			messages:{
				f_Name: {
					required: 'Введите имя'
				},
				f_Email: {
					required: 'Введите электронный ящик',
					email: 'Неверно введен электронный ящик'

				},
				f_Phone:{
					required: 'Введите телефон'
					},
				f_Service:{
					required: 'Выберите услугу'
					}
			},
		 submitHandler: function(form) {
			$('#service').ajaxSubmit({
				clearForm : true,
				resetForm:true,
				success: function() {
					done('service');
					$('.niceCheck').css('background-position', '0 0');
				}		  		
				});
		 }

				
	}


$('#service_sub').click(function(){
		 
	 $('#service').validate(o_serv);
		$('#service').submit();


});






				$('.contacts ul li a').click(function(){
					$(this).parent().toggleClass('open').next().slideToggle(0);
					$('ul li a.left').click(function(){
						$(this).parents('.drop_').slideUp(0).prev('div').removeClass('open');
						return false;
					});
					return false;
				});
				
//				$('.main-link').click(function(){
//					$('.top-nav li').removeClass('open');
//					$('.subnav').hide();
//					$(this).parent().addClass('open').children('.subnav').show();
//					return false;
//				});
				
				$('.calc .top a').click(function(){
					$(this).parent().toggleClass('open').next().slideToggle(0);
					$('.done').hide();

					$('.calc-drop a.blue-dashed').click(function(){
						$(this).parents('.calc-drop').slideUp(0).prev('div').removeClass('open');
						return false;
					});
					return false;
				});
				
				$('.order-service .top a').click(function(){
					$(this).parent().toggleClass('open').next().slideToggle(0);
					$('.order-service a.blue-dashed').click(function(){
						$(this).parents('.os-drop').slideUp(0).prev('div').removeClass('open');
						return false;
					});
					return false;
				});
			});


function done(id){
	$('#'+id+' .done').toggle();
	if(id=='service') $('.rez_serv').toggle(); else 
	$('#'+id+' #rez').toggle();
}


function plus(id){
num = parseInt($('#'+id).val())+1;
if(id=='period' && num >36) num=36;
$('#'+id).val(num);

}

function minus(id){
num = parseInt($('#'+id).val())-1;
if(num<0) num=0;
$('#'+id).val(num);

}

function send_v(id) {


	if($('#vacancy_'+id).validate({
			errorClass: 'err-block',
			errorElement: 'div',

			rules:{
					f_Name: {
						required: true
					},
					f_Email: {
						email: true
					},
					f_Phone: {
						required: true
					},
					f_Resume: {
						required: true
					}

				},
			messages:{
				f_Name: {
					required: 'Введите имя'
				},
				f_Email: {
					required: 'Введите электронный ящик',
					email: 'Неверно введен электронный ящик'

				},
				f_Phone:{
					required: 'Введите телефон'
					},
				f_Resume:{
					required: 'Вставьте резюме'
					}
			}

				
	}).form()) {
$('#vacancy_'+id).ajaxSubmit({
				clearForm : true,
					resetForm:true,
				success: function() {
					done('vacancy_'+id);
				}	
						  		
				});
}		


}


function help(id){
	window.open('/help/help_'+id+'.html','LIST','top=50, left=100,directories=no,height=395,location=no,menubar=no,resizable=no,scrollbars=yes,status=yes,toolbar=no,width=395');
}
