
var angle = 0;
var timer;

$(function() {
	$('#mainLogoImg').rotate({ 
	   bind:{ 
			mouseover : function() { 
				timer = setInterval(function(){
					  angle+=-3;
					 $('#mainLogoImg').rotate(angle);
				},10);
			},
			mouseout : function() { 
				clearInterval(timer);
			}
		} 
	});
	$('.mainMenuHover').hover(
		function(){ids = $(this).attr('id').replace('mainMenuHover','');$('#mainMenu'+ids).animate({backgroundPosition: '0px 35px'});},
		function(){$('#mainMenu'+ids).animate({backgroundPosition: '-65px 100px'});
	});
	$('.mainStylesSquares').hover(
		function(){ids = $(this).attr('id');$('#'+ids+'Text').show();},
		function(){$('.mainStylesText').hide();}
	).click(
		function(){
			ids = $(this).attr('id');
			colorText = ids.replace('mainStyles','');
			sendStyle(colorText);
			$('.style').removeClass('Yellow').removeClass('Pink').removeClass('Blue').addClass(colorText);
		}
	);

	$('.stylesSquares').hover(
		function(){ids = $(this).attr('id');$('#'+ids+'Text').show();},
		function(){$('.stylesText').hide();}
	).click(
		function() {
			ids = $(this).attr('id');
			colorText = ids.replace('styles','');
			$('#color').val(colorText);
			sendStyle(colorText);
			$('.style').removeClass('Yellow').removeClass('Pink').removeClass('Blue').addClass(colorText);
			$('.menuImg').attr('src','images/circle'+colorText+'.gif');
		}
	);
	$('.menuLink').hover(
		function() {
			color = $('#color').val();
			if (color=='Pink') $(this).css('color','#ed2290');
			else if (color=='Blue') $(this).css('color','#4696be');
			else $(this).css('color','#fbdc1e');
			$(this).find('img').show();
		},
		function() {
			$(this).css('color','#ffffff');
			$(this).find('img').hide();
		}
	);
	$('.panelImg').hover(
		function() {
			$(this).css('background-position','0px 0px');
		},
		function() {
			$(this).css('background-position','0px -130px');
		}
	).click(function(){
		ids = $(this).attr('id');
		ids = ids.replace('panelImg','');
		$('.descr').hide();
		$('#descr'+ids).show();
	});
	$('#csCarousel').jcarousel({wrap:'circular'});
	$('#daretoaskSubmit').click(function(){
		name = $('#name').val();
		mail = $('#mail').val();
		message = $('#message').val();
		if (name && mail && message) {
			alert('Message send');
			$('#daretoaskForm').submit();
		} else {
			alert('Enter all fields');
		}
	});
	$('.descrThumbImg').click(function(){
	});
	$( "#dialog-modal" ).dialog({
			autoOpen: false,
			height: 450,
			width: 550,
			modal: true
	});
	
	$('.descrThumbs').each(function(index) {
		ids = $(this).attr('id');
		ids = ids.replace('descrThumb','');
		$("a[rel=example_group"+ids+"]").fancybox({
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'titlePosition' : 'over'
		}); 
	});
});
function sendStyle(style) {
	$.ajax({
		url: "index.php",
		type: "POST",
		data: "style="+style
	});
}
function showWorker(ids) {
	$('#workerTitle').text($('#title_'+ids).val());
	$('#workerPosition').text($('#position_'+ids).val());
	$('#workerDescr').text($('#descr_'+ids).val());
	$('#workerParam1').text($('#param1_'+ids).val());
	$('#workerParam2').text($('#param2_'+ids).val());
	$('#workerParam3').text($('#param3_'+ids).val());
	$('#workerParam4').text($('#param4_'+ids).val());
	$('#workerParam5').text($('#param5_'+ids).val());
	$('#workerParam6').text($('#param6_'+ids).val());
	$('#workerBlock').show();
}

 var _gaq = _gaq || [];  _gaq.push(['_setAccount', 'UA-28093254-1']);  _gaq.push(['_trackPageview']);  (function() {    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);  })();
