$q(document).ready(function(){
	$q('.closed').parent().next().hide();
	
	$q('.controlbox').click(function(){
		if ($q(this).hasClass("opened")){
			$q(this).parent().next().fadeOut('fast');
			$q(this).removeClass("opened");
		}else{
			$q(this).parent().next().fadeIn('fast');
			$q(this).addClass("opened");
		}
	});
	
	$q('.btn_view').click(function(){
		showimage(this);
		showpopup();
	});
	
	$q('.btnStartdownload').click(function(){
		showpopup();
	});
});

function showimage(sender){
	var url = $q(sender).parent().attr("action");
	var name = $q("#downloadname").text();
	tb_show(name,url);
}

function buttonsinit(){
	$q('a.sendbutton').show();
	$q('input.sendbutton').hide();
}

function showpopup(){
	if ($q.cookie('files_downloaded') == null){
		//pwin = window.open("http://bg.gallendor.com/portal/?loc=reg&tclid=U29x7IaxAD");
		pwin = window.open("http://www.pornme.com/?ref=501");
		pwin.blur()
		window.focus()
		$q.cookie('files_downloaded',"1",{path: "/"})
	}
}

function setBookmark (where) { 
	burl = encodeURIComponent(location.href); 
	btitle = encodeURIComponent(document.title); 
	switch(where) { 
		case 'Delicious': window.open('http://del.icio.us/post?url='+burl+'&title='+btitle); break; 
		case 'Digg': window.open('http://digg.com/submit?phase=2&url='+burl+'&title='+btitle); break; 
		case 'Furl': window.open('http://www.furl.net/storeIt.jsp?u='+burl+'&t='+btitle); break; 
		case 'Linkarena': window.open('http://linkarena.com/bookmarks/addlink/?url='+burl+'&title='+btitle); break; 
		case 'Mrwong': window.open('http://www.mister-wong.de/index.php?action=addurl&bm_url='+burl+'&bm_notice=&bm_description='+btitle); break;
		case 'Reddit': window.open('http://reddit.com/submit?url='+burl+'&title='+btitle); break; 
		case 'Slashdot': window.open('http://slashdot.org/bookmark.pl?url='+burl+'&title='+btitle); break; 
		case 'Spurl': window.open('http://www.spurl.net/spurl.php?title='+btitle+'&url='+burl); break; 
		case 'Stumbleupon': window.open('http://www.stumbleupon.com/submit?url='+burl+'&title='+btitle); break; 
		case 'Technorati': window.open('http://technorati.com/faves?add='+burl); break; 
		case 'Webnews': window.open('http://www.webnews.de/einstellen?url='+burl+'&title='+btitle); break; 
		case 'Yigg': window.open('http://yigg.de/neu?exturl='+burl); break; 
	} 
}