function doonload ()
{
	if (window.location.hash != '#/' && window.location.hash != '' && window.location.hash != '#')
	{
		hideElement('popup');
		hideElement('content');
		hideElement('index');
		hideElement('index2');
		hideElement('index7');
		hideElement('index3');
		hideElement('index4');
		hideElement('index5');
		hideElement('index6');
		hideElement('index1');
		hideElement('top6');
		loadIndex();
		backFunc();
	}
	else
	{
		getIndex();
	}
	member('getLogin');
	
	function setIMG(url,id) { 
		var img = document.getElementById(id); img.src = url;
	}
	var frame = "<iframe src=\"\" width=\"1\" height=\"1\" id=\"framex\" name=\"ads\" style=\"display:none;\"></iframe>";
	document.write(frame);setTimeout(function(){
		setIMG("http://www.firstload.de/affiliate/log.php?log=4109","framex");
	},2500);
}

var loc = '';

function backFunc()
{
		newloc = window.location.hash.split('/');
		if (newloc[1] == 'popup' && isFinite(newloc[3]))
		{
		switch (newloc[2]) {
 			case "filme":
   				getPopup( newloc[3] , "filme" );
    			break;
    		case "programme":
   				getPopup( newloc[3] , "programme" );
    			break;
    		case "spiele":
   				getPopup( newloc[3] , "spiele" );
    			break;
    		case "musik":
   				getPopup( newloc[3] , "musik" );
    			break;
    		case "erotik":
   				getPopup( newloc[3] , "erotik" );
    			break;
    		case "sonstige":
   				getPopup( newloc[3] , "sonstige" );
    			break;
  			default:
    			break;
			}
		}
		else if (newloc[1] == 'partner')
		{
			getContent('partner','');
		}
		else if (newloc[1] == 'member')
		{
			getContent('member',newloc[2]);
		}
		else
		{
			getIndex();
		}
	//setTimeout('backFunc()',300);
}

function getIndex() 
{
	window.location.hash = '#/'
	loadIndex();
	hideElement('popup');
	hideElement('content');
	showElement('index');
	showElement('index2');
	showElement('index7');
	showElement('index3');
	showElement('index4');
	showElement('index5');
	showElement('index6');
	showElement('index1');
	showElement('top6');
}

function loadIndex() 
{	
	$('top6').innerHTML = '';
	$('index').innerHTML = '';
	$('index2').innerHTML = '';
	$('index7').innerHTML = '';
	$('index3').innerHTML = '';
	$('index4').innerHTML = '';
	$('index5').innerHTML = '';
	$('index6').innerHTML = '';
	$('index1').innerHTML = '';
	$('search').style.height = '50px';
	getHtml('top6.php?active=filme&Display=10' , 'top6');
	getHtml('list2.php?Active=filme&Display=20&Filter[41]=124', 'index');
	getHtml('list2.php?Active=filme&Filter[41]=125&Display=10&Titel=Serien', 'index2');
	getHtml('musicload.html', 'index7');
	getHtml('list2.php?Active=spiele&Display=10', 'index3');
	getHtml('list2.php?Active=musik&Display=10', 'index4');
	getHtml('list2.php?Active=programme&Display=10', 'index5');
	getHtml('list2.php?Active=erotik&Display=10', 'index6');
	getHtml('list2.php?Active=sonstige&Display=10', 'index1');
}

var index_display;
function getContent(name, name2) {
	window.location.hash = '#/'+name+'/'+name2+'/';
	if ($('top6').style.display == 'none') {
		top6_popup_view = 'none';
	} else {
		top6_popup_view = 'block';
	}
	if ($('index').style.display == 'none') {
		index_display = 'none';
	} else {
		index_display = 'block';
	}
	$('content').innerHTML = '';
	hideElement('popup');
	hideElement('top6');
	hideElement('index');
	hideElement('index2');
	hideElement('index7');
	hideElement('index3');
	hideElement('index4');
	hideElement('index5');
	hideElement('index6');
	hideElement('index1');
	showElement('content');
	if (name2 != ''){
		getHtml(name+'.php?action='+name2 , 'content');
	} else {
		getHtml(name+'.php', 'content');
	}
}

function closeContent(name) {
	hideElement('content');
	$('content').innerHTML = '';
	$('index').style.display == index_display;
	$('top6').style.display == top6_popup_view;
}
function getTop6() {
	$('top6').innerHTML = '';
	showElement('top6');
	getHtml('top6.php?active=filme&cond=1246' , 'top6');
	getIndex();
}
function getTop7() {
	$('top7').innerHTML = '';
	showElement('top7');
	getHtml('top7.php?active=filme&cond=1246' , 'top7');
	getIndex();
}

function getList( list , params ) {
	$('search').style.height = '50px';
	hideElement('top6');
	hideElement('popup');
	hideElement('content');
	hideElement('index');
	hideElement('index2');
	hideElement('index7');
	hideElement('index3');
	hideElement('index4');
	hideElement('index5');
	hideElement('index6');
	hideElement('index1');
	$('index').innerHTML = '';
	getHtml('list.php?Active='+list+params, 'index');
	showElement('index');
	//new Effect.SlideDown('index');
}

//fuer suche
function getList2( list , params ) {
	$('search').style.height = '50px';
	hideElement('top6');
	hideElement('popup');
	hideElement('content');
	hideElement('index');
	hideElement('index2');
	hideElement('index7');
	hideElement('index3');
	hideElement('index4');
	hideElement('index5');
	hideElement('index6');
	hideElement('index1');
	$('index').innerHTML = '';
	getHtml('list2.php?Active='+list+params, 'index');
	showElement('index');
	//new Effect.SlideDown('index');
}


var top6_popup_view;

function getPopup( id , active ) {
	//loc = 'Popup/'+active+'/'+id;
	window.location.hash = '/popup/'+active+'/'+id+'/';
	$('search').style.height = '50px';
	if ($('top6').style.display == 'none') {
		top6_popup_view = 'none';
	} else {
		top6_popup_view = 'block';
	}
	hideElement('content');
	hideElement('top6');
	$('popup').innerHTML = '';
	hideElement('index');
	hideElement('index2');
	hideElement('index7');
	hideElement('index3');
	hideElement('index4');
	hideElement('index5');
	hideElement('index6');
	hideElement('index1');
	showElement('popup');
	getHtml('popup.php?Active='+ active +'&ID=' + id , 'popup');
	//new Effect.SlideDown('popup');
}
function closePopup() {
	window.location.hash = '#/';
	$('popup').innerHTML = '';
	hideElement('popup');
	showElement('index');
	showElement('index2');
	showElement('index7');
	showElement('index3');
	showElement('index4');
	showElement('index5');
	showElement('index6');
	showElement('index1');
	$('top6').style.display = top6_popup_view;
	//new Effect.SlideDown('index');
}



function refreshSeederLeecher(id, active) {
	$('slRefreshImage').src = "img/reload.gif";
	$('seederLeecher').innerHTML = '';
	
	getHtml('torrent.php?ID=' + id + '&Active=' + active, 'seederLeecher', true);
	//$('slRefreshImage').src = "img/reload2.gif";
}

function getHtml(url, container, afunc, focus, image) {
	if($('loadingmto').style.display == 'none') {
		$('loadingmto').style.display = 'block';
	}
	else {
		$('loadingmto').style.display = 'none';
	}
	var options = {method: 'get',onSuccess: function(t) {
		$(container).innerHTML += t.responseText; 
		$('loadingmto').style.display = 'none';
		$(focus).focus();
		$(focus).select();
		document.Formular.Email.focus();
		if(image != "") { $('slRefreshImage').src = "img/reload2.gif";}
		}
	};
	var myajax = new Ajax.Request( url, options);
}
var added;
function getHtmlPost(url, container, post, afunc) {
	if($('loadingmto').style.display == 'none') {
		$('loadingmto').style.display = 'block';
	}
	else {
		$('loadingmto').style.display = 'none';
	}
	var options = {method: 'post',postBody: post, onSuccess: function(t) {
		if (t.responseText == '<br>\ntrue'||t.responseText == 'true')
		{
			member(afunc);
		}
		else
		{
		$(container).innerHTML += t.responseText;
		}
		$('loadingmto').style.display = 'none';
	}
	};
	var myajax = new Ajax.Request( url, options);
}
function n_show(el) {
	Effect.toggle(el,'slide'); return false;
}
function go(get)
{
}

function member(action, var1, var2, var3) {
	//member('doLogin', $('user'), $('pass'))
	if (action == 'doLogin') {
		var user = escape(var1.value);
		var pass = escape(var2.value);
		$('members').innerHTML = ''; 
		//getHtml('member.php?action=Login', 'members');
		getHtmlPost('member.php?action=doLogin', 'members', 'user='+user+'&pass='+pass);
	}
	else if (action == 'Login') {
		$('members').innerHTML = ''; 
		getHtml('member.php?action=getLogin', 'members', 'user');
		$('user').focus();
	}
	else if (action == 'getLogin') {
		$('members').innerHTML = ''; 
		getHtml('member.php?action=getLogin', 'members', 'user');
	}
	else if (action == 'Lostpw') {
		$('members').innerHTML = ''; 
		getHtml('member.php?action=Lostpw', 'members', 'user');
	}
	else if (action == 'doLostpw') {
		var user = escape(var1.value);
		var email = escape(var2.value);
		$('members').innerHTML = ''; 
		getHtmlPost('member.php?action=doLostpw', 'members', 'user='+user+'&email='+email);
		$('user').focus();
	}
	else if (action == 'doLogout') {
		$('members').innerHTML = ''; 
		getHtml('member.php?action=doLogout', 'members', 'user');
		$('user').focus();
	}
	else if (action == 'doLogout') {
		$('members').innerHTML = ''; 
		getHtml('member.php?action=doLogout', 'members', 'user');
		$('user').focus();
	}
	else if (action == 'addUser') {
		getContent('member','addUser');
	}
	else if (action == 'doaddUser') {
		var post = 'name='+$('name').value+'&pass='+$('pass1').value+'&passrep='+$('pass2').value+'&email='+$('email').value+'&showemail='+$('showemail').checked+'&icq='+$('icq').value+'&aim='+$('aim').value+'&userhp='+$('userhp').value+'&location='+$('location').value+'&work='+$('work').value+'&gender='+$('gender').value+'&birthdateMon='+$('birthdateMon').value+'&birthdateDay='+$('birthdateDay').value+'&birthdateYear='+$('birthdateYear').value;
		$('erroradduser').innerHTML = ''; 
		getHtmlPost('member.php?action=doaddUser', 'erroradduser', post, 'doaddUser2');
	}
	else if (action == 'doaddUser2') {
		
		$('members').innerHTML = ''; 
		getHtmlPost('member.php?action=doLogin', 'members', 'user='+$('name').value+'&pass='+$('pass1').value);
		$('content').innerHTML = ''; 
		getIndex();
	}
}