// JavaScript Document
window.addEvent('domready', function(){	
	$$('#items div.item').addEvent('mouseenter',function(e){ this.addClass('hover'); });
	$$('#items div.item').addEvent('mouseleave',function(e){ this.removeClass('hover'); });	
	
	$$('#items div.textitem').addEvent('mouseenter',function(e){ this.addClass('texthover'); });
	$$('#items div.textitem').addEvent('mouseleave',function(e){ this.removeClass('texthover'); });	
	
	$$('#items div.item').addEvent('click',function(e){
		window.open(this.getChildren('a.title'));												
	});
	
	var slider = new Slider('slider','slidethumb',{
		steps:4, range:[2,6], snap:true, 
		onChange:function(step){ $('fpr').set('html',step);	},
		onComplete:function(step){
			$$('div.item').each(function(el,index){
				var temp = el.getChildren('div.pr');
				temp = temp[0].getChildren('span.pagerank');
				var pr = temp[0].get('html');
				if(pr<step) el.setStyle('display','none'); else el.setStyle('display','block');
			});	
		}
	}).set(0);
	
	$('formcauta').addEvent('submit',function(e){
		new Event(e).stop();										  
	});
	
	$('contact').addEvent('submit',function(e){
		// stop wordpress and blogspot		
		var url = $('url').value;
		if(url.indexOf(".blogspot.com") != "-1" || url.indexOf(".wordpress.com") != "-1") {
			alert(url);
			alert("Nu acceptam bloguri de pe .blogspot.com sau .wordpress.com fiindca sunt nofollow");
			return false;
		}
	});
	
	$('cauta').addEvent('keyup',function(e){
		var cauta = $('cauta').value.toLowerCase();
		$$('div.item').each(function(el,index){
			var temp = el.getChildren('a.title');
			var title = temp[0];
			var name = title.getProperty('title').toLowerCase();
			var url = title.getProperty('href').toLowerCase();
			if(!cauta) el.setStyle('display','block'); else {
				if(url.contains(cauta) || name.contains(cauta)) 
					el.setStyle('display','block'); else el.setStyle('display','none');
			}
		});								  
	});

	$$('#banners img').addEvent('click',function(e){
		$('copy').set('text','<a href="http://www.dofollow.ro/" title="Bloguri dofollow"><img style="border:none" src="http://www.dofollow.ro/'+this.get('src')+'" alt="Dofollow Banner" /></a>');
		if(this.get('src') == "banners/coltalb.png"){
			$('copy').set('text','<a href="http://www.dofollow.ro/" title="Bloguri dofollow"><img style="border:none; position: absolute; top: 0; right:0" src="http://www.dofollow.ro/'+this.get('src')+'" alt="Dofollow Blog" /></a>');
		}
		if(this.get('src') == "banners/coltnegru.png"){
			$('copy').set('text','<a href="http://www.dofollow.ro/" title="Bloguri dofollow"><img style="border:none; position: absolute; top: 0; right:0" src="http://www.dofollow.ro/'+this.get('src')+'" alt="Dofollow Blog" /></a>');
		}			
		$('codimg').set('src',this.get('src'));	
		$('codimg').set({'width':this.get('width'),'height':this.get('height')});
		$('code').setStyle('display','block');
	});
	$('codeclose').addEvent('click',function(e){ $('code').setStyle('display','none'); })
	
	$$('.report').addEvent('click',function(e){
		var temp = this.getParent().getChildren('a.title');
		var title = temp[0];
		title = title.getProperty('title');
		if(confirm('Esti sigur ca blogul "'+title+'" are nofollow ?')){
			window.open('http://www.dofollow.ro/report.php?action=report&blog='+title);
		}
		e.stopPropagation();
	});
});
