$(function() {

	$('.customselect').sSelect();

	/*
	$('#content table').each(function() {
		$('th:last', this).css('border-right','2px Solid Black');
		$('tr', this).each(function() {
			$('td:last', this).css('border-right','0px');
		});
	});
        */
	
	var tabs_links = $('#header_tabs p a');
	tabs_links.click(function() {
		if ($(this).attr('class') == '') {
			tabs_links.attr('class','');
			$(this).attr('class','active');
			
			var tab_class = $(this).parent().attr('class');
			$('#header_tabs').attr('class',tab_class);
			
			var index = tabs_links.index(this);
			$('#header_banners .photos a').hide();
			$('#header_banners .photos a').eq(index).show();
		}
	});
	
	$('#header_menu li#drpdwn_about, #header_menu li#drpdwn_countries').hover(
		function() {
			$(this).attr('class','active');
			$('ul',this).fadeIn(150);
			$('.dropdown_b',this).fadeIn(150);
		},
		function() {
			$(this).attr('class','');
			$('ul',this).fadeOut(150);
			$('.dropdown_b',this).fadeOut(150);		
		}		
	);
	
	$('#left_col .left_menu li.dropdown').children('a').toggle(
		function() {
			//$(this).attr('class','active');
			$('ul.left_menu li.dropdown a.active').parent().find('ul').slideUp(200);
			$('ul.left_menu li.dropdown a.active').removeClass('active');

			$(this).attr('class','active');				
			$(this).parent().find('ul').slideDown(200);
		},
		function() {
			$(this).attr('class','');
			$(this).parent().find('ul').slideUp(200);			
		}		
	);
	
	$('form#feedback input').focus(function() {
		if ($(this).attr('class') == 'field_m' || $(this).attr('class') == 'field_s') {
			if ($(this).val() == 'Контактное лицо' || $(this).val() == 'Электронная почта' || $(this).val() == 'Телефон' || $(this).val() == 'Сопроводительный текст' || $(this).val() == 'Цифры с картинки') {
				$(this).attr('value','');
			}
		}
	});
	
	$('form#feedback input').blur(function() {
		if ($(this).attr('class') == 'field_m' || $(this).attr('class') == 'field_s') {	
			if ($(this).val() == '') {
				switch ($('form#feedback input').index(this)) {
				case 0:
					$(this).attr('value','Контактное лицо');
					break;
				case 1:
					$(this).attr('value','Электронная почта');
					break;
				case 2:
					$(this).attr('value','Телефон');
					break;
				case 3:
					$(this).attr('value','Цифры с картинки');
					break;
				}				
			}
		}
	});
	
	$('form#feedback textarea').focus(function() {
		if ($(this).html() == 'Сопроводительный текст') $(this).html('');		
	});
	$('form#feedback textarea').blur(function() {
		if ($(this).html() == '') $(this).html('Сопроводительный текст');		
	});	

	$("a.zoom").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300, 
		'overlayOpacity': 0
	});
	
	$('form#feedback').attr('action', '/sendform/');
	
	/*
	$('#searchform form select').bind('change', function(){
		var a = this.value;
		var b = $(this).attr('id');
		var c = b;
		
		var vals = $('#searchform form').serialize();
		
		$.post('/ajax/options.php', vals, function(data){
			var data2 = data.split('::');
			$('select#1').html(data2[0]);
			$('select#2').html(data2[1]);
			$('select#3').html(data2[2]);
			$('select#4').html(data2[3]);
			$('select#5').html(data2[4]);
		});
		
		// , 'json'
		
	});*/
 	
});


function zf_submit() {

	var error = false;

	if ($('input#name').val() == 'Контактное лицо') {
		error = true;
	}
	if ($('input#email').val() == 'Электронная почта') {
		error = true;
	}
	if ($('input#phone').val() == 'Телефон') {
		error = true;
	}
	
	$('form#feedback input.field_m').each(function(){
		if ($(this).val() == '') {
			error = true;
		}
	});
	if ($('form#feedback textarea').val() == '') {
		error = true;
	}
	
	if (error) {
		alert('В форме все поля обязательны для заполнения');
		return false;
	} else {
		return true;
	}
}

function sf_changed() {
	
	
}

