$(document).ready( function() {
//lightbox loading
	$('a[rel=lbox], a[rel=lightbox]').colorbox();

//css help
	$('#main #left ul.newmem li a').hover( function() {
		$(this).find('span').css('color', '#95b638');											
	}, function() {
		$(this).find('span').css('color', '#B256A1');											
	});
	
//new photos animate
	if($('#newph').css('display') == 'block')
	{
		$('#newph a.prev').click( function() {
			var	pos = $('#photos').css('left');
			pos = pos.substring(0, (pos.length-2));

			if(pos == -700 || pos == -1400)
			{
				pos = pos*1 + 700;

				$('#newph #photos').animate({
					left: pos + 'px'
				}, 1000);
			}
			
			if(pos < 0)
			{
				$('#newph a.prev').css('visibility', 'visible');
			}
			else
				$('#newph a.prev').css('visibility', 'hidden');
				
			if(pos > -1400)
			{
				$('#newph a.next').css('visibility', 'visible');
			}
			else
				$('#newph a.next').css('visibility', 'hidden');		
			
			return false;
		});
		
		$('#newph a.next').click( function() {
			var	pos = $('#newph #photos').css('left');
			pos = pos.substring(0, (pos.length-2));
			
			if(pos == 0 || pos == -700)
			{
				pos = pos - 700;
				
				$('#photos').animate({
					left: pos + 'px'
				}, 1000);		
			}
			
			if(pos < 0)
			{
				$('#newph a.prev').css('visibility', 'visible');
			}
			else
				$('#newph a.prev').css('visibility', 'hidden');
				
			if(pos > -1400)
			{
				$('#newph a.next').css('visibility', 'visible');
			}
			else
				$('#newph a.next').css('visibility', 'hidden');		

			return false;
		});
	}

//tooltip with photo
	if($('#main #left ul.newmem, div.title2 div.mb').css('display') == 'block')
	{
		$("#main #left ul.newmem li a.tooltipClass, div.title2 div.mb p a.tooltipClass").each(function (i) {
			$(this).qtip({
				content: $(this).attr("tip"),
				style: {name:'mystyle', width:126},
				position:{
					corner:{
						target:'rightTop',
						tooltip:'leftBottom'
					},
					adjust: {x:10, y:8}
					}
				});
		});
	}
	
	if($('#main #right #in_form, #main #right #out_form, #main #right #status, #main #right, #main #right_res #profil').css('display') == 'block')
	{
		$("#main #right .tab td a.tooltipClass").each(function (i) {
			$(this).qtip({
				content: $(this).attr("tip"),
				style: {name:'mystyle', width:126},
				position:{
					corner:{
						target:'rightTop',
						tooltip:'leftBottom'
					},
					adjust: {x:10, y:8}
					}
				});
		});
	}
	
	if($('#main #right_res #profil').css('display') == 'block')
	{
		$("#main #right_res .classicTable td a.tooltipClass").each(function (i) {
			$(this).qtip({
				content: $(this).attr("tip"),
				style: {name:'mystyle', width:126},
				position:{
					corner:{
						target:'rightTop',
						tooltip:'leftBottom'
					},
					adjust: {x:10, y:8}
					}
				});
		});
	}
	
//menu left number animation

	function Anim()
	{
		$('span.anim').css({
			position: 'relative'
		}).animate({
			top: '-5px'
		}, 200, function() {
			$(this).animate({
				top: '0'
			}, 500, function() {
				$(this).animate({
					top: '0'
				}, 2000, function() {
					Anim();
				});
			});
		});
	}
	
	//Anim();

//splash pretty photo animate
	if($('#splash_main').css('display') == 'block')
	{
		$('form[name=register]').submit( function() {
			sendEmail();
			return false;								
		});
		
		$('#access').click( function() {
			sendEmail();
			return false;
		});
	
	var temp = $('#members').find('div.foto');
	var py = 0;
	var px = 0;
	var zi = 1;

	for(var i=0; i<5; i++)
	{		
		$(temp[i]).css('zIndex', zi).animate({
			top: py + 'px',
			left: px + 'px'
		}, 500);
		
		if(i == 0)
		{
			py = 40;
			px = 92;
			zi = 2;
		}
		else if(i == 1)
		{
			py = 80;
			px = 184;
			zi = 3;
		}
		else if(i == 2)
		{
			py = 40;
			px = 276;
			zi = 2;
		}
		else 
		{
			py = 0;
			px = 368;
			zi = 1;
		}
	}
	
	var layer;
	var lt;
	var to;
	
	$('#members div.foto').hover(function() {
										  
		lt = $(this).stop().css('left');
		lt = lt.substring(0, lt.indexOf('px'))-15;
		
		to = $(this).css('top');
		to = to.substring(0, to.indexOf('px'))-20;
		
		layer = $(this).css('z-index');
				
		$(this).css('z-index', 10).stop().animate({
			width: '174px',
			height: '200px',
			left: lt+'px',
			top: to+'px',
			fontSize: '13px',
			lineHeight: '16px'
		}, 200);
			
		$(this).find('img').stop().animate({
			width: '146px',
			height: '146px',
			marginLeft: '13px'
		}, 200);
		
	} , function() {
		
		$(this).css('z-index', layer).stop().animate({
			width: '144px',
			height: '165px',
			left: lt+15+'px',
			top: to+20+'px',
			fontSize: '11px',
			lineHeight: '13px'
		}, 200);
		
		$(this).find('img').stop().animate({
			width: '120px',
			height: '120px',
			marginLeft: '11px'
		}, 200);

	});
	
	}
	
});

//AJAX request splash join email
function sendEmail()
{
	var string = document.getElementById('first_email').value.toLowerCase();		
	if(string.replace(RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"), '') != '')
	{
		alert('Please write correct email address');
	}
	else if(string == '')
	{
		alert('Please write correct email address');
	}
	else
	{
		$("#intro").fadeOut("fast", function() 
		{
			$("#loader").fadeIn("fast", function() {
			$.ajax({
				   type: "GET",
				   url: "ajax/splash2_joinform.cfm",
				   data: 'email='+string,
				   success: function(msg) {
					 $("#intro").html(msg).css({position: 'relative', top: '-10px'});
					 $("#loader").fadeOut("fast", function() {
						$("#intro").fadeIn("fast");
					 });					
		   		   }
		 		});
			});
		});
	}
}
