/*
 Externer Javascript-Code
 Code & Skripting: PoMan, www.paradiseresort.de
*/

// Globale Variablen
var ua = navigator.userAgent.toLowerCase(), uv = parseInt(navigator.appVersion);

if(ua.indexOf("opera") != -1 && uv >= 4) {brwsr = "OP";} 
 else if(ua.indexOf("msie") != -1 && uv >= 4) {brwsr = "IE";}
 else if(uv >= 5) {brwsr = "NN6";}

// Namenserkennung
function setLink(pm_string)
{var tcharset=" &+;.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÄÖÜäöüß";
 if (tcharset.indexOf(pm_string.charAt(0)) == -1) {pm_string = pm_string.substr(1);} 
 var cpos=0, spchar=0, mchar=0, mpos=0, cchar = "", ttname="", ttlnk=""; 
 var tclen=tcharset.length, ttlen=pm_string.length; 
 while (cpos <= ttlen)
 {spos=0; tchar = pm_string.charAt(cpos);
  while (spos <= tclen) {if (tchar == tcharset.charAt(spos)) {spos=-1; break;} spos++;}
  if (spos != -1) {ttname = pm_string.substr(0,cpos);
  if (tchar != "-") {break;} else {if (pm_string.charAt(cpos-1) == " ") {break;} mchar++;mpos=cpos;}
   if (tchar == "-" && (spchar > 1 || mchar > 1)) {break;}}
   else {if (tchar == " ") {spchar++; if (mpos > 1 &&  (cpos < mpos+5)) {break;}}} 
  cpos++;}
 if (cpos >= ttlen) {ttname = pm_string;}
 ttleft = ttname.replace(/^(\s*)(.*)$/,'$2');
 ttname = ttleft.replace(/^(.*?)(\s*)$/,'$1');
 ttgnam = ttname.replace(/ /g,"+");
 if (ttlen >= 1) 
 {
  ttpr1 = "<a href='celeblist.php?celeb="+ttname+"' style='text-decoration:none;'><b class='smallfont'>PR Celeb-Liste</b></a>";
  ttpr2 = "<a href='javascript:bsearch()' style='text-decoration:none;'><b class='smallfont'>weitere Beitr&auml;ge</b></a>";
  ttwpde = "<a class='xwpde' href='redir.php?url=http://de.wikipedia.org/wiki/"+ttname+"' target='_blank'><b class='smallfont'>Wikipedia</b></a>";
  ttwpen = "<a class='xwpen' href='redir.php?url=http://en.wikipedia.org/wiki/"+ttname+"' target='_blank'><b class='smallfont'>Wikipedia</b></a>";
  ttimdb = "<a class='ximdb' href='redir.php?url=http://german.imdb.com/find?q="+ttname+"&s=all' target='_blank'><b class='smallfont'>Starinfo</b></a>";
  ttgimg = "<a class='xgo' href='redir.php?url=http://images.google.de/images?q="+ttgnam+"' target='_blank'><b class='smallfont'>Google-Bildsuche</b></a>";
  ttcp = "<a class='xcp' href='redir.php?url=http://www.chickipedia.com/"+ttname+"' target='_blank'><b class='smallfont'>Chickipedia</b></a>";
  ttlnk = "<img src='images/cyberhype/search1.gif' border='0' style='float:left;padding-right:8px;'><b class='smallfont'>Mehr von " + ttname + ": </span>";
  ttlnk += ttpr1 + " | " + ttwpde + " | " + ttwpen + " | " + ttimdb + " | " + ttgimg + " | " + ttcp;
  document.formsearch.searchstring.value = ttname;
 }
document.getElementById('getimdb').innerHTML = ttlnk;
document.getElementById('pminfo').style.display = "block";
}
function bsearch() {document.formsearch.submit();}



// Threadbewertung per Mouseover-Grafik
var usrrate=0, usrrateok=0, ratetxt="", preImg = new Array();
var tp = new Array("","Sinnlos","Grauenhaft","Schlecht","Geht so","Mittelmässig","Recht gut","Gut","Sehr gut","Klasse","Sensationell");
function pm_rate(e)
{
 if(brwsr == "IE") {rx=window.event.offsetX;} 
 else if(brwsr == "OP") {rx = e.x;} 
 else if(brwsr == "NN6") {rx = e.layerX;}
 usrrate = parseInt(rx/12); 
 if(usrrate<=1) {n2=" Punkt";usrrate=1;} 
 else {n2=" Punkte"; if(usrrate>10) {usrrate=10;}}
 ratepkt = usrrate+n2+" - " + tp[usrrate];
 n1 = usrrate+100;
 document.getElementById("rategfx").src= "images/cyberhype/rt"+n1+".gif";
 document.getElementById("rateinfo").innerHTML=ratepkt;
}
function pm_rate0()
{
 document.getElementById("rategfx").src= "images/cyberhype/rt100.gif";
 document.getElementById("rateinfo").innerHTML="Noch nicht bewertet";
 document.getElementById("rategfx").onmousemove=pm_rate;
 document.getElementById("ratebox").onmouseout=pm_rate0;
 document.getElementById("ratechk").innerHTML=ratetxt;
 usrrate = 0; usrrateok = 0;
}
function pm_rateit()
{
 if(usrrate!=0) 
 {
  if (usrrateok==0)
  {usrrateok = 1;
   document.getElementById("ratebox").onmouseout="";
   document.getElementById("rategfx").onmousemove="";
   n2 = "<span class='normalfont tcol1' onclick='pm_rate0()' onmouseover='this.style.cursor=\"pointer\"'>";
   n2 += "<b>Klicke auf diesen Hinweistext um deine Bewertung zu annullieren.";
   n2 += "<br />Klicke zum absenden deiner Bewertung nochmals auf die Bewertungsbox.</b></span>";
   document.getElementById("ratechk").innerHTML=n2;
   document.getElementById("rateinfo").innerHTML=ratepkt;
  } 
  else 
  {
   document.getElementById("ratechk").innerHTML="";
   document.getElementById("rateinfo").innerHTML="Danke für deine Bewertung!";
   document.ratethread.rating.value=usrrate;document.ratethread.submit();
  }
 }
}
function pm_init_rateit()
{
 for(n=0;n<11;n++) {preImg[n] = new Image(); n1=100+n; preImg[n].src = "images/cyberhype/rt"+n1+".gif";}
 ratetxt = document.getElementById("ratechk").innerHTML;
 document.getElementById("ratebox").style.display="block";
 pm_rate0();
}



// Bereich ein- und ausblenden mit BBCode HIDE
function pm_hide(id)
{
 htxt = id.innerHTML; 
 if (id.nextSibling.style.display == "none")
 {
  ntxt = htxt.replace(/einblenden/, "ausblenden");
  id.innerHTML = ntxt;
  id.previousSibling.src = "images/cyberhype/minus.gif";
  $(id).next().slideDown(1000);
 //id.nextSibling.style.display = "block";
 }
 else
 {
  ntxt = htxt.replace(/ausblenden/, "einblenden");
  id.innerHTML = ntxt;
  id.previousSibling.src = "images/cyberhype/plus.gif";
  $(id).next().slideUp(1000);
 //id.nextSibling.style.display = "none";
 }
}



// Imagemover, bewegt IMG-BBCodes
var iMovx=40, iMovy=8, iPosx=0, iPosy=0;
var x1=.1, x2=.50, x3=3.2;
var y1=.5, y2=.36, y3=.28;
var pm_mImg=new Array(), pm_iTag=0, pm_iMax=0, pm_iNum=0, pm_mNum=0, pm_icnt=0;

function pm_rotimg()
{
 for(n=0; n<=pm_iNum; n++)
 {n1=pm_mImg[n];
  pm_iTagS=pm_iTag[n1].style; 
  pm_iTagS.position='relative';
  pm_iTagS.left=Math.sin(pm_icnt*x1+n*x2+x3)*iMovx+iPosx+'px';
  pm_iTagS.top=Math.cos(pm_icnt*y1+n*y2+y3)*iMovy+iPosy+'px';} 
 pm_icnt++;
}
function pm_rotstart(nti)
{
 if(nti==-1) 
 {pm_icnt=0; clearInterval(pm_roti); pm_shwism();
  for(n=0; n<=pm_iNum; n++)
  {n1=pm_mImg[n]; pm_iTag[n1].style.left="0px"; pm_iTag[n1].style.top="0px";}
 }
 else 
 {
  pm_iTag=document.images; 
  pm_iMax=pm_iTag.length; 
  pm_iNum=200; pm_mNum=0;
  for(n=0; n<pm_iMax; n++)
  {thmb=document.getElementsByTagName("img")[n];
   if (thmb.className =="rI" && pm_mNum<pm_iNum) {pm_mImg[pm_mNum]=n;pm_mNum++;}
  }
  pm_iNum=pm_mNum-1;
  if(pm_iNum>0)
  {
   document.getElementById('pm_rotinfo').innerHTML="<span style='cursor:pointer;' onclick='pm_rotstart(-1)'><img src='images/sm/2tanz3.gif' border='0' /></span>";
   if(nti<50) {nti=50;}
   pm_roti=setInterval('pm_rotimg()',nti);
  }
  else
  {document.getElementById('pm_rotinfo').innerHTML="<span><img src='images/sm/4sorry1.gif' border='0' title='Leider keine Bilder gefunden!' /></span>";
   setTimeout("pm_shwism()", 10000);    
  }
 }
}
function pm_shwism()
{document.getElementById('pm_rotinfo').innerHTML="<span style='cursor:pointer;' onclick='pm_rotstart(50)'><img src='images/sm/4ka2.gif' border='0' title='Lass die Bilder tanzen!' /></span>";}



// Image-Resizer
function rI()
{
 for (i=0;i < document.images.length;i++)
 {
  i2=0; imgI = document.images[i];
  iclassname = imgI.className;
  if (iclassname == 'rI') {i2=1; imaxX=imageMaxWidth; imaxY=imageMaxHeight;}
  if (iclassname == 'sImg') {i2=2; imaxX=600; imaxY=150;}
  if (i2!=0)
  {i1=0; imageWidth= imgI.width; imageHeight= imgI.height;
   if (imageHeight == 0 || imageWidth == 0)
   {imgI.alt=imgI.src; imgI.src="images/altimg.gif"; imgI.title="Bildadresse ungültig!";}
//   else {if (i2==1) {imgI.id="imgid"+i;}}

   if ((imaxX != 0 && imageWidth > imaxX) || (imaxY != 0 && imageHeight > imaxY))
   {if (imaxX != 0) {div1=imaxX/imageWidth;} else {div1=1;}
		if (imaxY != 0) {div2=imaxY/imageHeight;} else {div2=1;}
    if (div1 < div2)
    {i1=1; document.images[i].width=imaxX; document.images[i].height=Math.round(imageHeight*div1);}
		else {i1=1; document.images[i].height=imaxY; document.images[i].width=Math.round(imageWidth*div2);}
    if (i1==1) {document.images[i].title="Verkleinerte Darstellung";}
    if (!isLinked(document.images[i]))
    {if (i1==1) {document.images[i].title="Verkleinerte Darstellung, für Vollbildansicht("+imageWidth+"x"+imageHeight+" Pixel) bitte anklicken";}
     popupLink=document.createElement("a");
     popupLink.setAttribute('href', document.images[i].src);
     popupLink.setAttribute('target', '_blank');
     popupLink.appendChild(document.images[i].cloneNode(true));
     document.images[i].parentNode.replaceChild(popupLink, document.images[i]);
    }
   }
  }
 }
}
function isLinked(node)
{do {node=node.parentNode;if (node.nodeName == 'A') return true;}
 while (node.nodeName != 'TD' && node.nodeName != 'BODY');
 return false;
}

// Image-MouseoverFX
function pm_overimg()
{
 if (this.parentNode.nodeName=="A") {this.style.border="1px dashed #999999";}
}
function pm_outimg()
{
 if (this.parentNode.nodeName=="A") {this.style.border="1px solid transparent";}
}


// PR-Banner
var pm_wms=8, pm_bymax=120, pm_bposy=1, pm_bmov=1;
function banpos1() {document.getElementById('top_banner').style.backgroundPosition = "0px -"+pm_bymax+"px";}
function banpos2() {document.getElementById('top_banner').style.backgroundPosition = "0px 0px";}
function prban(wbbid)
{
 pm_scrw = screen.width;
 if (wbbid == 0) {bcm="bw";} else {bcm="";}
 if (pm_scrw >1024) 
 {if (pm_scrw >1280) 
  {document.getElementById('top_banner').style.backgroundImage="url(images/head/pr07v2a1600"+bcm+".jpg)";
   document.getElementById('top_banner').style.height="188px"; pm_bymax=188;}
  else
  {document.getElementById('top_banner').style.backgroundImage="url(images/head/pr07v2a1280"+bcm+".jpg)";
   document.getElementById('top_banner').style.height="150px"; pm_bymax=150;}
 }
 if (wbbid == 2) {window.setTimeout('ban_chg()',4000);}
 if (wbbid == 1)
 {document.getElementById('top_banner').onmouseover=banpos1;
  document.getElementById('top_banner').onmouseout=banpos2;
 }
}
function ban_chg()
{if (pm_bmov!=0) 
 {if (pm_bposy>=pm_bymax) {pm_bposy=pm_bymax; pm_bmov=0;}
  if (pm_bposy<=0) {pm_bposy=0; pm_bmov=0;}
  document.getElementById('top_banner').style.backgroundPosition = "0px -" + pm_bposy + "px";}
 if (pm_bmov==0) 
 {if (pm_bposy==0) {pm_bmov=1; pm_bposy=1;waitms=8000}
  else {pm_bmov=-1;pm_bposy=pm_bymax-1; waitms=6000}
  window.setTimeout('ban_chg()', waitms);}
 else
 {pm_bposy = pm_bposy + pm_bmov;
  window.setTimeout('ban_chg()', pm_wms);}
}
function prban_indx() {var pm_showindx=1;}

// Fenster öffnen
function winOpen(wadr,wsix,wsiy)
{
 wopt = "scrollbars=yes,resizeable=yes,width="+wsix+",height="+wsiy+",status=no,toolbar=no,location=no,menubar=no";
 xwin = window.open(wadr,"_blank",wopt);
 return false
}
