$(document).ready(function(){
	textInput($('form#newsletter #email'));
	/*$('form#newsletter').hide();
	$('#abonare').click(function(){
		$('form#newsletter').show();
		return false;
	});
	$('form#newsletter a#close').click(function(){
		$(this).parent().hide();
		return false;
	});*/
	
	$('li#cauti a, li#prieteni a').click(function(){
		return false;	
	});
	
	$('#lista_castigatori div.left:nth-child(4n)').css('margin-right','0px');
	
	$('.vraja').click(function(){
		var href = $('h2 a',$(this)).attr('href');
		//alert(href);
		window.location.replace(href);
		return false;	
	});
	$('#header_planse').click(function(){
		var href = $('h2 a',$(this)).attr('href');
		//alert(href);
		window.location.replace(href);
		return false;	
	});
	
	$('#agree').click(function(){
		//alert($(this).attr('checked'));
		if($(this).attr('checked')){
			$('#agree_form').submit();	
		}
		
		return;
	});
	$('#concurs').click(function(){
		var href = $('h3 a',$(this)).attr('href');
		//alert(href);
		window.location.replace(href);
		return false;	
	});
	$('#cumpara_aici').click(function(){
		var href = $('a',$(this)).attr('href');
		
		window.location.replace(href);
		return false;	
	});
	
	//counter pentru demo downloads
	$('a.demo_download').click(function(){
		var id = $(this).attr('rel');
		$.ajax({
			url: 'produse/mark_download/'+id,
			success: function(data) {
			  //$('.result').html(data);
			  //alert('Load was performed.');
			}
		      });
	});
	$('a.demo_download').css('text-decoration','blink');
	var blink = setInterval(function(){
		if(window.blink){
		$('a.demo_download').css('color','#F06300');
			window.blink=false;
		}
	        else{
		       $('a.demo_download').css('color','#F9F8CC');
		       window.blink = true;
	        }

		/*$('a.demo_download').animate({'visible':'hidden'},100,function(){
			$('a.demo_download').animate({'visible':'visible'},100);
			});*/
		
		},400);
	
});
//function for focus/blur on inputs
function textInput($element){
	var elementValue = $element.val();
	$element.focus(function(){
		var text  = $(this).val();		
		if (text == elementValue){
			$(this).val('');
		} 
	}).blur(function(){
		var text  = $(this).val();
		if (text == ''){
			$(this).val(elementValue);
		} 
		
	});
}


