/* * * * * * * * * * * * *
 * Passport
 */
 
function blaettern(thiss,keyword) {
	a = thiss.parentNode.getAttribute("class",false);
	b = a.substr(-1);

	
	//ProfilSeite sichern
	if(document.getElementById("seite_profil").innerHTML == "")
		document.getElementById("seite_profil").innerHTML = document.getElementById("seite").innerHTML; 
			
			
	if(b == 3 || b==9) {			
		inhalt_neu = document.getElementById("seite_"+ keyword).innerHTML;
		
		//Inhalt noch leer (Ajax nachladen)
		if(!inhalt_neu) {			
			blaettern_ajax(keyword);
			document.getElementById("seite").innerHTML = "<div class=loading>wird geladen</div>";
		}
		else
			document.getElementById("seite").innerHTML = inhalt_neu; 		
	}
	else if(b == 1 || b==7) {
		document.getElementById("seite").innerHTML = document.getElementById("seite_profil").innerHTML; 		
	}
	
	
	//andere Ecken beim Umblättern ausblenden
	if(b == 3)
		document.getElementById("blaettern_"+ "egoman").style.display="none";
	else if(b==1)
		document.getElementById("blaettern_"+ "egoman").style.display="";
	
	if(b == 9)
		document.getElementById("blaettern_"+ "stamps").style.display="none";
	else if(b==7)
		document.getElementById("blaettern_"+ "stamps").style.display="";
	
	
	//Pad (knickEcke)
	switch(b) {
		case "3":	var b_neu=1;	break;
		case "9":	var b_neu=7;	break;
		case "1":	var b_neu=3;	break;
		case "7":	var b_neu=9;	break;
	}	
	document.getElementById("blaettern_"+ keyword).setAttribute("class","blaettern pad"+ b_neu);
	
}


function blaettern_ajax(keyword) {
		new Ajax.Updater('seite', 'ajax.php', {
			asynchronous:true, 
			evalScripts:true, 
			/*
			onComplete:function(request){
				Element.hide('indicator')
			},
			onLoading:function(request){
				Element.show('indicator')
			},
			*/
			onSuccess: function(transport) {
				document.getElementById("seite_"+ keyword).innerHTML = transport.responseText;				
				LoadWait_ready();
			},
			parameters: 'rs=blaettern&page=kabine_profil,_profil&rsargs[]='+ uc +'&rsargs[]='+ keyword});	

}


/* * * * * * * * * * * * *
 * Dynamisches Nachladen
 */		
function dyn_klick(count) {
	var text = count;
	var zahl = parseInt(count.replace(".",""));
	
	var e = $('dyn_klicks');
	
	e.innerHTML = text;
	
	
	if(zahl>=100000) {
		e.style.fontFamily="Geneva";
		e.style.fontSize="20px";
		e.style.fontWeight="bold";
		e.style.color="#9c2c26";		
		e.style.paddingBottom="2px";
		e.style.letterSpacing="2px";
	}
	else if(zahl>=75000) {
		e.style.fontFamily="Geneva";
		e.style.fontSize="18px";
		e.style.fontWeight="bold";
		e.style.color="#864542";		
		e.style.paddingBottom="2px";
		e.style.letterSpacing="2px";
	}
	else if(zahl>=50000) {
		e.style.fontFamily="Geneva";
		e.style.fontSize="16px";
		e.style.fontWeight="bold";
		e.style.color="#9c2c26";		
		e.style.paddingBottom="1px";
		e.style.letterSpacing="1px";
	}
	else if(zahl>=25000) {
		e.style.fontFamily="Geneva";
		e.style.fontSize="16px";
		e.style.fontWeight="bold";
		e.style.color="#465d5f";			
		e.style.paddingBottom="2px";	
	}	
	else if(zahl>=10000) {
		e.style.fontFamily="Geneva";
		e.style.fontSize="14px";
		e.style.fontWeight="bold";
		e.style.color="#465d5f";		
		e.style.paddingBottom="2px";
		
	}		
	else if(zahl>=5000) {
		e.style.fontSize="13px";
		e.style.fontWeight="bold";
		e.style.color="#465d5f";		
		e.style.paddingBottom="1px";
		
	}	
	else if(zahl>=1000) {
		e.style.fontWeight="bold";	
		e.style.fontSize="11px";
		e.style.color="#4f676a";
		e.style.paddingBottom="1px";
	}
	else if(zahl>=100) {				
		e.style.color="#4f676a";
	}
}
 
 

/* * * * * * * * * * * * *
 * SchnappSchuss
 */		
function change_fotogal_pic() {
	slideshow_akt = Math.round(Math.random() * slideshow_max);
	$('slideshow').style.backgroundImage = 'url('+ ar_url_pics[ slideshow_akt ] +')';	
}			

			
/* * * * * * * * * * * * *
 * Freunde & Crews
 */
 					
function zapp() {
	new Ajax.Updater('randomdampfies', 'ajax.php', {
	onComplete:function(request){Element.show('button_zapp');$('randomdampfies').fade({duration: 0.1 ,to:1.0})},
	onLoading:function(request){Element.hide('button_zapp');$('randomdampfies').fade({ duration: 0.1 ,to:0.1})},
	parameters:'rs=zapp&page=kabine_profil,_profil&rsargs[]='+ uc});
}	
var type_last="";
function AlleFreunde(open,typ) {
	var d=document.getElementById('allefreunde');
	var s=d.style;

	if(open==1) s.display='block';
	else {s.display='none';return;}
	
	if(!typ) typ = "freunde";
	
	if(!d.innerHTML || type_last!=typ) {
		LoadWait_Screen('allefreunde',480);
		AlleFreundePage(uc,1,typ);
	}
	
	if(open==1)
		type_last = typ;
}
					
function AlleFreundePage(uc,page,typ) {
	new Ajax.Updater('allefreunde', 'ajax.php', { 
		evalScripts:true, 
		onSuccess: function(transport) {
			LoadWait_ready();
		},
		parameters: 'rs=allefreunde&page=kabine_profil,_profil&rsargs[]='+ uc +'&rsargs[]='+ page +'&rsargs[]='+ typ});	
}
					
function AlleCrews(open) {
	var d=document.getElementById('allecrews');
	var s=d.style;

	if(open==1) s.display='block';
	else {s.display='none';return;}
		
	if(!d.innerHTML) {
		AlleCrewsPage(uc,1);
	}
}
					
function AlleCrewsPage(uc,page) {	
	new Ajax.Updater('allecrews', 'ajax.php', {
		evalScripts:true, 
		onSuccess: function(transport) {
			LoadWait_ready();
		},
		parameters: 'rs=allecrews&page=kabine_profil,_profil&rsargs[]='+ uc +'&rsargs[]='+ page});	
}


function BesucherBig(open) {

	var d=$('lastbesucher_big');
	var s=d.style;

	
	if(s.display=='none') s.display='block';
	else {s.display='none';return;}
	
	
	if(!d.innerHTML) {
		LoadWait_Screen('lastbesucher_big',400,400);
		
		new Ajax.Updater('lastbesucher_big', 'ajax.php', { 
			onSuccess: function(transport) {
				LoadWait_ready();
			},
			parameters: 'rs=lastbesucher_big&page=kabine_profil,_profil&rsargs[]='+ uc});	
	}


}



//Gemeinsame Freundes Tab
function LoadOnClick1() {
	var e=document.getElementById('tabcontent_1');
	if(e.innerHTML=="...") {
		e.innerHTML = "<small><i>- Gemeinsame Freunde wird geladen -</i></small>";
		GemeinsameFreundeLoad();
	}
}
function GemeinsameFreundeLoad() {
	new Ajax.Updater('tabcontent_1', 'ajax.php', {
		evalScripts:true, 
		onSuccess: function(transport) {
			LoadWait_ready();
		},
		parameters: 'rs=gemeinsamefreunde&page=kabine_profil,_profil&rsargs[]='+ uc});	
}
 
 
 /* * * * * * * * * * * * *
 * BUDDY PICS
 */
 var BuddysIsZapping = false;
function BuddyPicsZapp(user_uc) {	
	button = document.getElementById('zappButton');
	button.style.display = 'none';
	button.src = 'http://images.dampfer.net/buttons/zapp_deaktiv.jpg';
	
	LoadWait_MouseLoad();
	
	//ausblenden
	alphaFader('buddypicsContentDiv','out');
		
	if(!BuddysIsZapping) {
		BuddysIsZapping = true;
		x_BuddyPicsReload(user_uc,do_BuddyPicsReload_cb);
	}
 }
 
function do_BuddyPicsReload_cb(z) {	
	button = document.getElementById('zappButton');
	button.style.display = '';
	button.src = 'http://images.dampfer.net/buttons/zapp.jpg';	
	
	LoadWait_MouseNormal();
	
	//einblenden
	alphaFader('buddypicsContentDiv','in');
	
	document.getElementById('buddypicsContentDiv').innerHTML = unescape(z);
	BuddysIsZapping = false;
}

 
 

/* * * * * * * * * * * * *
 * GESCHENKE BOX
 */
var GeschenkBoxViewStatus=false;
var AjaxLoaded=false;
var EndAr = false;	
function geschenkBoxView(usermd5) {	
	if(!GeschenkBoxViewStatus) {
		document.getElementById("geschenkBox_flash").style.display = "";
		GeschenkBoxViewStatus = true;
		
		//RüttlnSpeicherKnopf weg wenn neu aufpoppn
		document.getElementById('ButtonSpeichern').style.display = 'none';
			
		if(!AjaxLoaded) {		
			new Ajax.Updater('geschenkBox_inhalt', 'ajax.php', {
				asynchronous:true, evalScripts:true, 
				onSuccess: function(transport) {			
					//LoadWait_ready();
				},parameters: 'rs=geschenkLoad&page=kabine_profil,_profil&rsargs[]='+ usermd5});			
		}

	}
	else {
		document.getElementById("geschenkBox_flash").style.display = "none";
		GeschenkBoxViewStatus = false;
	}
}
			
function do_geschenkLoad_cb(z) {				
	//document.getElementById('geschenkBoxInhalt').innerHTML = unescape(z);
	alphaFader('button_zapp','in');
}



function GeschenkeNewSet() {
	
	all = document.getElementById('geschenkBox_inhalt').childNodes.length;
	for(var i = 1 ; i <= all ; i++) {
		
		d = document.getElementById('geschenkNr_'+ i);		
		x = d.style.left = Math.round(Math.random() * 350) +"px";
		y = d.style.top = Math.round(Math.random() * 270) +"px";
		
		EndAr[i] = i +"_"+ x +"_"+ y;
	}
}

function AllesWackeln() { 
		
	GeschenkeNewSet();
	
	if (!self.moveBy) return;	
	for (var x = 10; x > 0; x--) { 
		for (var xx = 10; xx > 0; xx--) { 
			window.moveBy(0,x); 
			window.moveBy(x,0); 
			window.moveBy(0,-x); 
			window.moveBy(-x,0);							
		} 		
	} 
} 
function do_geschenkSpeichern_cb(z) {				
	alert(z);
	
	//Speichern wieder ausblenden
	if(z == "Alles gespeichert")
		document.getElementById('ButtonSpeichern').style.display = 'none';
		
	EndAr = false; //Ar leeren
}


function ButtonWackeln() {		

	EndAr = new Array();
	
	AllesWackeln();	
	
	if(selfUser)
		document.getElementById('ButtonSpeichern').style.display = '';
}
function ButtonSpeichern() {
	
		
	document.getElementById("ButtonSpeichern").style.display = 'none';
	
	if(EndAr === false) {
		alert("Das wurde doch gerade schon mal gespeichert!");
		return;
	}
	
	new Ajax.Request( 'ajax.php', {
		asynchronous:true, evalScripts:true, 
		onSuccess: function(transport) {		
			t = transport.responseText;		
			alert(t);
	
			//Speichern wieder ausblenden
			if(t == "Alles gespeichert")
				document.getElementById('ButtonSpeichern').style.display = 'none';
				
			EndAr = false; //Ar leeren
		},parameters: 'rs=geschenkSpeichern&page=kabine_profil,_profil&rsargs[]='+ uc +'&rsargs[]='+ EndAr});	

}



function malautomat(x) {
	url = "swf/kabine_profil/malautomat_2009.swf?malid="+ x;
	save_content=document.getElementById("play_"+ x).innerHTML;
	document.getElementById("play_"+ x).innerHTML= "<div class=img>"+ flash(url,"284","202")+"</div>";
}

