//onpageload
	window.addEvent('domready', function(){
	     document.getElementById('noscript').style.display='none';
	     loadSubmenu(1);
	});

//checkwars
beforecat=0;
beforecont=0;
var aktiv='aktiv';
var inaktiv='nix';

// load content
/* to do: 
// Immer nur 10 weitere Kommentare anzeigen
// commentfield unter alle Seiten ausser Kategorie 1
// 0 == kein Kommentarfeld
//18 == Blog (Kommentarfeld)
*/
	function showComment()
	{
		
		 var el=document.getElementById('entrycomment')

		if(el.style.display=='none')
		{
			el.style.display='inline-block'
		}
		else
		{
			el.style.display='none';
		}
	}
	
	
		
//load Submenue
	function loadSubmenu(tcat,start)
	{
	      cat=tcat;
	      beforecont=0;
	   
	      
	      if(beforecat!=0)
	      {
		document.getElementById('menu'+beforecat).className=inaktiv;
	      }
	      
	      document.getElementById('menu'+cat).className=aktiv;
	      beforecat=cat;

	      loadOverview(cat);
	      
	      new Request.HTML({
	      url: 'submenu.php',
	      onFailure: function() {
	     },
	      onComplete: function(response) {
		$('navigation').empty().adopt(response);
	      },
	      data: {
		'cat': cat
	      }
	    }).send();
	}
	
	
function loadSitemapContent(url,i, entryid, tcat)
	{
	      cat=tcat;
	      beforecont=0;
	   
	      
	      if(beforecat!=0)
	      {
		document.getElementById('menu'+beforecat).className=inaktiv;
	      }
	      
	      document.getElementById('menu'+cat).className=aktiv;
	      beforecat=cat;

	      new Request.HTML({
	      url: 'submenu.php',
	      onFailure: function() {
	     },
	      onComplete: function(response) {
		$('navigation').empty().adopt(response);
	      },
	      data: {
		'cat': cat
	      }
	    }).send();
	    
	    loadContent(url,i, entryid, cat);
	    
	}
	
//load overview in ctx
	function loadOverview(tcat)
	{
		document.getElementById('ctxcomment').style.display='none';
		 cat=tcat;
		 if(cat==1)
		 {
			turl='start.php'
		 }
		 else
		 {
			turl='overview.php'
		 }
		  new Request.HTML({
		      url: turl,
		      onFailure: function() {
		     },
		      onComplete: function(response) {
			$('ctx').empty().adopt(response);
		      },
		      data: {
			'cat': cat
		      }
		    }).send();
	}
	
	function loadContent(url,i, entryid, cat)
	{
		turl=url;	
		document.getElementById('sublink'+beforecont).className='notchosen';
		document.getElementById('sublink'+i).className='chosen';
		beforecont=i;
		
	      if(cat==1)
	      {
		 document.getElementById('ctxcomment').style.display='none';
	      }
	      else if(cat==undefined)
	      {
		 document.getElementById('ctxcomment').style.display='none';
	      }
	      else
	      {
		document.getElementById('ctxcomment').style.display='inline-block';
		loadEntryComment(entryid);
	      }
		
		eid=entryid;
		
		  new Request.HTML({
		      url: turl,
		      onFailure: function() {
		     },
		      onComplete: function(response) {
			$('ctx').empty().adopt(response);
		      },
		      data: {
			'eid': eid
		      }
		    }).send();
	}

function reLoadCharas(order,i, entryid, cat)
	{
		torder=order;	
		document.getElementById('sublink'+beforecont).className='notchosen';
		document.getElementById('sublink'+i).className='chosen';
		beforecont=i;
	
		document.getElementById('ctxcomment').style.display='inline-block';
		loadEntryComment(entryid);
		
		eid=entryid;
		
		  new Request.HTML({
		      url: 'ich/chars.php',
		      onFailure: function() {
		     },
		      onComplete: function(response) {
			$('ctx').empty().adopt(response);
		      },
		      data: {
			'eid': eid,
			'order':torder
		      }
		    }).send();
	}
	
function loadEntryComment(entryid)
	{
		var eid=entryid;
	     
	      new Request.HTML({
	      url: 'entrycomment.php',
	      onFailure: function() {
	     },
	      onComplete: function(response) {
		$('ctxcomment').empty().adopt(response);
	      },
	      data: {
		'entryid': eid
	      }
	    }).send();
	}

function loadComic(pre,url,nr)
	{
	      new Request.HTML({
	      url: 'comic.php',
	      onFailure: function() {
	     },
	      onComplete: function(response) {
		$('comic').empty().adopt(response);
	      },
	      data: {
		'pre': pre,
		'url': url,
		'nr':nr
	      }
	    }).send();
	    
		document.getElementById('tpbg').style.display='inline-block';
		document.getElementById('comic').style.display='inline-block';
		document.getElementById('container2').style.position='fixed';
		var viewportheight= window.innerHeight;
		
	}

function loadComicPage(pre,url,num,last)
	{
	

		document.getElementById('cpage').src=url+'/'+pre+num+'.jpg';
		
		
		
		if((num-1)<0)
		{
			var backnum=last;
		}
		else
		{
			var backnum=num-1;
		}
		
		if((num+1)>last)
		{
			var fornum=0;
		}
		else
		{
			var fornum=num+1;
		}
		
		document.getElementById('comicnav').innerHTML='<span class="norm3" style="cursor:pointer; width:100px; padding:0; margin:0; text-align:left !important; background-color:#191919;" onclick="loadComicPage(\''+pre+'\',\''+url+'\','+backnum+','+last+')">&laquo; backward</span><span class="norm3" style="cursor:pointer;  width:140px;padding:0; margin:0; background-color:#191919;" onclick="loadComicPage(\''+pre+'\',\''+url+'\','+fornum+','+last+')">forward &raquo;</span>'

	}


function closeComic() {
	document.getElementById('tpbg').style.display='none';
	document.getElementById('comic').style.display='none';
	document.getElementById('container2').style.position='absolute';
}


function showBlogEntrys(tid){
var el=document.getElementById(tid)

	if(el.style.display=='none')
	{
		el.style.display='inline-block'
	}
	else
	{
		el.style.display='none';
	}
}

//my tooltip Image stuff
function showImage(url,desc) {

 var viewportwidth = window.innerWidth;
 var viewportheight= window.innerHeight;
 
document.getElementById('tpimage').src=url;
document.getElementById('tpdescription').innerHTML=desc;
document.getElementById('container2').style.position='fixed';
document.getElementById('tpbg').style.display='inline-block';
document.getElementById('tp').style.display='inline-block';

var newImg = new Image();
newImg.src = url;
curHeight = newImg.height;
curWidth = newImg.width;

	if((((viewportheight/2)-(curHeight/2))-20)<0)
	{
		document.getElementById('tp').style.top  = 0+'px';
	}
	else
	{
		document.getElementById('tp').style.top  = ((viewportheight/2)-(curHeight/2))-20+'px';
	}
	
	if(((viewportwidth/2)-(curWidth/2))<0)
	{
		document.getElementById('tp').style.left  = 0+'px';
	}
	else
	{
		document.getElementById('tp').style.left  = ((viewportwidth/2)-(curWidth/2))+'px';
	}
	

	if((curWidth +10)<200)
	{
		document.getElementById('tp').style.width=200 +'px';
	}
	else
	{
		document.getElementById('tp').style.width=curWidth +10 +'px';
	}
}

function closeImage() {
	document.getElementById('tpbg').style.display='none';
	document.getElementById('tp').style.display='none';
	document.getElementById('container2').style.position='absolute';
}

//my tooltip Text stuff
function showText(url, name) {

	var turl=url;
	var tname=name;
	
	new Request.HTML({
	      url: turl,
	      onFailure: function() {
	     },
	      onComplete: function(response) {
		$('text').empty().adopt(response);
	      },
	      data: {
		'name': tname
	      }
	    }).send();
	    
	document.getElementById('tpbg').style.display='inline-block';
	document.getElementById('text').style.display='inline-block';
	document.getElementById('container2').style.position='fixed';
}

function closeText() {
	document.getElementById('tpbg').style.display='none';
	document.getElementById('text').style.display='none';
	document.getElementById('container2').style.position='absolute';
}

var details=new Array();

details["alex"]=new Array("29","7cm long scar left on his throat, right shoulder and arm","	openminded and direct in general but due to the events of the last years more withdrawn and sarcastic","-");
details["jadzi"]=new Array("29","-","Sometimes to impulsive and klingon. She can bear a grudge in minor cases if this really hurts her.Mostly companionable with a good humor.","united with the Jadzi-symbiote");
details["aliya"]=new Array("27","wears on her left shoulder a tattoo with the symbol of 'Om'. She also wears a nose and earpearcing.","Aliya never refuse a good drink. She loves to tinker and find alternative Posibilities to repair things. Unfortunatly she rather try things out than read a 'manual' which causes some accidents.Aliya is cheerfull, find always something positive and is good with improvisation but she is also Chaotic and stubborn","pointy ears, haircolor, nearly silver blood");
details["geordi"]=new Array("0","interactive Assistant holographic program. The role model was Geordi LaForge","Developed for the Panteraclass prototype as assistant hologram and should also help other engineers in the future. As role model every enginer can choose between starfleet greatest engineers: Zephram Cochrane, Trip Tucker, Montgomery Scott and Geordi LaForge. ","-");
details["jamary"]=new Array("25","3 scars on her chest","Jamary is very impulsive and got lot of temerament. She can handle a couple of martial arts styles. Its hard to provoke her because she learned in early years, that wrath and anger are useless in a battle.","was hurt badly by a cheetah at the age of 15. Therefore she had 3 scares on her left chest from the cheethas claws. slight resistence against natural venoms of terranian toxic animals because she was bitten several times from snakes and spiders.");
details["kaley"]=new Array("25","partly denobulan looking face","Open-minded and cheerfull person. Loves the easy way the denobulan culture deals with sexual and human relations. She would like to have a second man but only less non-denobulan can deal with the denobulan way of realtionships.","Kaley do not sleeps six days in a row like pure denobulan - but she didn't need to sleep every day. Once a month she sleeps for about two days.");
details["kay"]=new Array("25","-","Ambivalent character who is torn between his traditional raising and his own wishes. High expertise in his field but shows quite disrespectful behavior","Due to a lab accident with adaptive cloaking technologies with nanites his haircolor changes due to his emotional state");
details["kendara"]=new Array("27","karibian bulges on forehead dalris","Quite and frindly but can be really outspoken when something pisses her off","allergic to Jintel pollen");
details["maqtar"]=new Array("37","Scar on left shoulder","stayed with starfleet after joining an Starfleet - klingon exchange program. He is forthright and a fighter but not as impusive as other klingons","-");
details["reena"]=new Array("25","Tattoo of a dragon on right shoulder","outspoken and bubbly. Tight bonds with her brother","Was adhered at the head with her siamese brother. It was impossible to separate the two on a natural way with both surviving. A new method was tested in which the both where separated via tranporter. Duron this procedure Reenay Y chromosome was damaged and could only be replaced by doubeling the X chromosom. With this incident, an other problem was unseen: The separation worked too well and gave Reena all the asian characteristics while Reeno got all the african");
details["reeno"]=new Array("25","Tattoo of a dragon on left shoulder","	Tight bonds with his sister but quiter than her","Was adhered at the head with his siamese sister. It was impossible to separate the two on a natural way with both surviving. A new method was tested in which the both where separated via tranporter. Duron this procedure Reenay Y chromosome was damaged and could only be replaced by doubeling the X chromosom. With this incident, an other problem was unseen: The separation worked too well and gave Reena all the asian characteristics while Reeno got all the african");
details["robyn"]=new Array("30","can change her hairlength, haircolor, eyecolor an partly her skincolor","Cherfull and a bit crazy. Change her haircolor sometimes unknowingly if she is very emotional.","She is half changer but her ability is limited to hair, eyes and skin.");
details["samuel"]=new Array("53","-","-","-");

function showChar(name)
{
	var coord = document.getElementById(name).getCoordinates();
	var url="rpg/general/crew/char/"+name+".jpg";

	document.getElementById('char').style.display='inline-block';
	document.getElementById('char').style.width=600 +'px';
	document.getElementById('char').style.height=270 +'px';
	document.getElementById('char').style.top=coord.top+20 +'px';
	
	document.getElementById('charimage').src=url; 
	document.getElementById('age').innerHTML=details[name][0];
	document.getElementById('mark').innerHTML=details[name][1];
	document.getElementById('character').innerHTML=details[name][2];
	document.getElementById('record').innerHTML=details[name][3];
}

function hideChar(name)
{
	document.getElementById('char').style.display='none';
}


