var tClockTmr=0;
var jji=0;
function OpenPage(dataArray) {
   for (x=0;x<10;x++) {
      document.getElementById('data'+x).value=dataArray[x];
   };
   doit();
   for (x=0;x<10;x++) {
      document.getElementById('data'+x).value='';
   };
};
function ClockBlink() {
   if (document.getElementById('dClock').style.visibility=='visible') {
      document.getElementById('dClock').style.visibility='hidden';
   } else {
      document.getElementById('dClock').style.visibility='visible';
   };
   clearTimeout(tClockTmr);
   tClockTmr = setTimeout('ClockBlink();',1000);
};
function ClockUpdate() {
   clearTimeout(tClockTmr);
   OpenPage(Array('Fn_Update_Clock'));
   tClockTmr = setTimeout('ClockBlink();',1000);
   setTimeout('ClockUpdate();',5000);
};
function TestConnA() {
   var d=new Date();
   var f=d.getSeconds();
   var g=d.getMilliseconds();
   jji=setTimeout('var e = document.getElementById(\'tmrConnect1\'); e.className=\'tG0\'; e.title=\'Offline!\';',3000);
   OpenPage(Array('Fn_Do_TestConn',f,g));
   setTimeout('TestConnA();', 3000);
};
function TestConnB(dA, dB) {
   clearTimeout(jji);
   var d=new Date();
   var f=d.getSeconds()-dA;
   var g=d.getMilliseconds()-dB;
   var h=(f*1000)+g;
   if (h>=0) {
      h=Math.floor(h/300);
      if (h>10) h=10; h=10-h;
		var e=document.getElementById('tmrConnect1');
		e.className='tG'+h;
		switch (h) {
			case 1: e.title='Deplorable'; break;
			case 2: e.title='Very Weak'; break;
			case 3: e.title='Weak'; break;
			case 4: e.title='Poor'; break;
			case 5: e.title='Fair'; break;
			case 6: e.title='Moderate'; break;
			case 7: e.title='Good'; break;
			case 8: e.title='Very Good'; break;
			case 9: e.title='Excellent'; break;
			case 10: e.title='Exceptional'; break;
			default: e.title='Level '+h;
		};
   };
};
function TabOff(tabHwnds) {
   document.getElementById('tabHwnd'+tabHwnds).style.fontWeight='normal';
   document.getElementById('tabHwnd'+tabHwnds).style.color='#888';
   document.getElementById('tabHwnd'+tabHwnds).style.backgroundColor='#200';
   document.getElementById('tabHwnd'+tabHwnds).style.borderTop='1px solid #400';
   document.getElementById('tabHwnd'+tabHwnds).style.borderBottom='1px solid #100';
   document.getElementById('tabHwnd'+tabHwnds).style.borderLeft='1px solid #400';
   document.getElementById('tabHwnd'+tabHwnds).style.borderRight='1px solid #100';
   document.getElementById('Tab'+tabHwnds).style.display='none';
};
function MenuOff(menuName) {
   document.getElementById('muBtn'+menuName).style.color='#888';
   document.getElementById('muBtn'+menuName).style.backgroundColor='#400';
   document.getElementById('muBtn'+menuName).style.borderTop='1px solid #600';
   document.getElementById('muBtn'+menuName).style.borderBottom='1px solid #200';
   document.getElementById('muBtn'+menuName).style.borderLeft='1px solid #600';
   document.getElementById('muBtn'+menuName).style.borderRight='1px solid #200';
   document.getElementById('mu'+menuName).style.display='none';
};
function TabOn(tabHwnds) {
   document.getElementById('tabHwnd'+tabHwnds).style.fontWeight='bold';
   document.getElementById('tabHwnd'+tabHwnds).style.color='#FFF';
   document.getElementById('tabHwnd'+tabHwnds).style.backgroundColor='#600';
   document.getElementById('tabHwnd'+tabHwnds).style.borderTop='1px solid #900';
   document.getElementById('tabHwnd'+tabHwnds).style.borderBottom='1px solid #300';
   document.getElementById('tabHwnd'+tabHwnds).style.borderLeft='1px solid #900';
   document.getElementById('tabHwnd'+tabHwnds).style.borderRight='1px solid #300';
   document.getElementById('Tab'+tabHwnds).style.display='block';
};
function MenuOn(menuName) {
   document.getElementById('muBtn'+menuName).style.color='#FFF';
   document.getElementById('muBtn'+menuName).style.backgroundColor='#600';
   document.getElementById('muBtn'+menuName).style.borderTop='1px solid #900';
   document.getElementById('muBtn'+menuName).style.borderBottom='1px solid #300';
   document.getElementById('muBtn'+menuName).style.borderLeft='1px solid #900';
   document.getElementById('muBtn'+menuName).style.borderRight='1px solid #300';
   document.getElementById('mu'+menuName).style.display='inline';
};
function MenuOver(menuItem) {
   menuItem.style.color='#FF0';
};
function MenuOut(menuItem) {
   menuItem.style.color='#FFF';
};
function ChooseTab(tabHwnd) {
   for (x=0;x<10;x++) {
      TabOff(x);
   };
   TabOn(tabHwnd);
};
function CloseTab(tabHwnd) {
   document.getElementById('tabX'+tabHwnd).style.backgroundColor='#F00';
   document.getElementById('tabX'+tabHwnd).style.color='#000';
   if (confirm('Are you sure you want to close this tab?')) {
      CloseTab2(tabHwnd);
   } else {
      document.getElementById('tabX'+tabHwnd).style.backgroundColor='#000';
      document.getElementById('tabX'+tabHwnd).style.color='#F00';
   };
};
function CloseTab2(tabHwnd) {
   document.getElementById('Tab'+tabHwnd).innerHTML='&nbsp;';
   document.getElementById('tabHwnd'+tabHwnd).innerHTML='&nbsp; &nbsp; '+String.fromCharCode(60)+'br>&nbsp; &nbsp; ';
};
function NextEmptyTab() {
   for (iNET=0;iNET<10;iNET++) {
      if ((document.getElementById('Tab'+iNET).innerHTML=='&nbsp;' || document.getElementById('Tab'+iNET).innerHTML==String.fromCharCode(160)) && document.getElementById('tabHwnd'+iNET).style.visibility!='hidden') break;
   };
   return (iNET);
};
function DrawCloseTabBtn(tabHwnd) {
   strRet = String.fromCharCode(60)+'input type="button" class="btnX" id="tabX'+tabHwnd+'" value="X" onMouseOver="window.status=\'Close Tab\';" onMouseOut="window.status=\'Done\';" onClick="CloseTab(\''+tabHwnd+'\');">';
   return (strRet);
};
function OPNT(pageID) {
   return OpenPageNewTab(pageID);
};
function OpenPageNewTab(pageID) {
   varInTab = NextEmptyTab();
   if (varInTab<10) {
      ChooseTab(varInTab);
      document.getElementById('tabHwnd'+varInTab).innerHTML=String.fromCharCode(60)+'div class="tabHwnd">'+DrawCloseTabBtn(varInTab)+' <br>&nbsp; &nbsp; </div>';
      OpenPage(Array(pageID,varInTab));
      return true;
   } else {
      alert('You do not have any empty tabs! Click the red X to close a tab, and try again.');
      return false;
   };
};

// FORUM Specific Scripts //
function blinkWatch(iid) {
   if (document.getElementById('watch_'+iid).style.color=='rgb(255, 255, 153)') {
      document.getElementById('watch_'+iid).style.color='rgb(153, 153, 153)';
      setTimeout('blinkWatch(\''+iid+'\');',100);
   } else {
      document.getElementById('watch_'+iid).style.color='rgb(255, 255, 153)';
      setTimeout('blinkWatch(\''+iid+'\');',400);
   };
};

// EMBLEM CREATION SCRIPT
var penColor='rgb(255, 255, 255)';
var penState=0;
var locnD;
var locnV;

function embMove(locn) {
   if (penState==1) embChange(locn);
}
function embClick(locn) {
   if (penState==2) {
      embChange(locn);
   } else if (penState==0) {
      penState=1;
	  document.getElementById('paint').value='Mode: Paint On';
   } else {
	  penState=0;
	  document.getElementById('paint').value='Mode: Paint Off';
   };
}
function embChange(locn) {
   locnD="b" + locn + "d";
   locnV="b" + locn + "v";
   document.getElementById(locnD).style.backgroundColor=penColor;
   document.getElementById(locnV).style.backgroundColor=penColor;
}
function embColor(bID) {
   penColor=document.getElementById(bID).style.backgroundColor;
   document.getElementById('pencolor').style.backgroundColor=penColor;
   if (penState==1) {penState=0; document.getElementById('paint').value='Mode: Paint Off';};
}
function embPenCh() {
   if (penState==2)
      {penState=0;}
   else
      {penState=2;};
   if (penState==0) document.getElementById('paint').value='Mode: Paint Off';
   if (penState==1) document.getElementById('paint').value='Mode: Paint On';
   if (penState==2) document.getElementById('paint').value='Mode: Paint One';
   return true;
}
function embGetCode() {
   var embI;
   var embJ;
   var embC='';
   var embD;
   var embE;
   for (embI=1; embI<26; embI++) {
      for (embJ=1; embJ<26; embJ++) {
         embD='b'+embI+'x'+embJ+'v';
         embE=document.getElementById(embD).style.backgroundColor;
         embC+=embGetColorCode(embE);
      }
   }
   document.getElementById('txtGetCode').value=embC;
}
function DrawEmblem(tCode) {
   tCode+='0';
   embRet='<table border=0 cellpadding=0 cellspacing=0>';
   for (embX=0;embX<625;embX+=25) {
      embRet+='<tr>';
      for (embY=0;embY<25;embY++) {
         embRet+='<td class="emb emb'+tCode.charAt(embX+embY)+'"></td>';
      };
      embRet+='</tr>';
   };
   embRet+='</table>';
   return (embRet);
};
function embGetColorCode(tCode) {
   switch (tCode) {
      case 'transparent': return '0'; break;
      case 'rgb(0, 0, 0)': return 'A'; break;
      case 'rgb(102, 102, 102)': return 'B'; break;
      case 'rgb(136, 136, 136)': return 'C'; break;
      case 'rgb(187, 187, 187)': return 'D'; break;
      case 'rgb(255, 255, 255)': return 'E'; break;
      case 'rgb(102, 0, 0)': return 'F'; break;
      case 'rgb(136, 0, 0)': return 'G'; break;
      case 'rgb(187, 0, 0)': return 'H'; break;
      case 'rgb(255, 0, 0)': return 'I'; break;
      case 'rgb(255, 136, 136)': return 'J'; break;
      case 'rgb(255, 187, 187)': return 'K'; break;
      case 'rgb(187, 102, 0)': return 'L'; break;
      case 'rgb(255, 136, 34)': return 'M'; break;
      case 'rgb(255, 187, 68)': return 'N'; break;
      case 'rgb(136, 136, 0)': return 'O'; break;
      case 'rgb(187, 187, 0)': return 'P'; break;
      case 'rgb(255, 255, 0)': return 'Q'; break;
      case 'rgb(0, 136, 0)': return 'R'; break;
      case 'rgb(0, 187, 0)': return 'S'; break;
      case 'rgb(0, 255, 0)': return 'T'; break;
      case 'rgb(0, 136, 136)': return 'U'; break;
      case 'rgb(0, 187, 187)': return 'V'; break;
      case 'rgb(0, 255, 255)': return 'W'; break;
      case 'rgb(0, 0, 102)': return 'X'; break;
      case 'rgb(0, 0, 136)': return 'Y'; break;
      case 'rgb(0, 0, 187)': return 'Z'; break;
      case 'rgb(0, 0, 255)': return '1'; break;
      case 'rgb(0, 136, 255)': return '2'; break;
      case 'rgb(0, 187, 255)': return '3'; break;
      case 'rgb(136, 0, 136)': return '4'; break;
      case 'rgb(187, 0, 187)': return '5'; break;
      case 'rgb(255, 0, 255)': return '6'; break;
      case 'rgb(136, 102, 68)': return '7'; break;
      case 'rgb(187, 136, 85)': return '8'; break;
      case 'rgb(187, 170, 102)': return '9'; break;
      default: return '+'; break;
   }
}
function embLoadCode() {
   var embX=0; var embI; var embJ;
   var embP=prompt('Please paste your saved Emblem Code:', '');
   for (embI=1; embI<26; embI++) {
      for (embJ=1; embJ<26; embJ++) {
         embP+='0'
         locnD='b'+embI+'x'+embJ+'d';
         locnV='b'+embI+'x'+embJ+'v';
         if (embGetCodeColor(embP.charAt(embX))!=false) {
            document.getElementById(locnD).style.backgroundColor=embGetCodeColor(embP.charAt(embX));
            document.getElementById(locnV).style.backgroundColor=embGetCodeColor(embP.charAt(embX));
         };
         embX++;
      };
   };
}
function embGetCodeColor(cCode) {
   switch (cCode.toUpperCase()) {
      case '0': return 'transparent'; break;
      case 'A': return 'rgb(0, 0, 0)'; break;
      case 'B': return 'rgb(102, 102, 102)'; break;
      case 'C': return 'rgb(136, 136, 136)'; break;
      case 'D': return 'rgb(187, 187, 187)'; break;
      case 'E': return 'rgb(255, 255, 255)'; break;
      case 'F': return 'rgb(102, 0, 0)'; break;
      case 'G': return 'rgb(136, 0, 0)'; break;
      case 'H': return 'rgb(187, 0, 0)'; break;
      case 'I': return 'rgb(255, 0, 0)'; break;
      case 'J': return 'rgb(255, 136, 136)'; break;
      case 'K': return 'rgb(255, 187, 187)'; break;
      case 'L': return 'rgb(187, 102, 0)'; break;
      case 'M': return 'rgb(255, 136, 34)'; break;
      case 'N': return 'rgb(255, 187, 68)'; break;
      case 'O': return 'rgb(136, 136, 0)'; break;
      case 'P': return 'rgb(187, 187, 0)'; break;
      case 'Q': return 'rgb(255, 255, 0)'; break;
      case 'R': return 'rgb(0, 136, 0)'; break;
      case 'S': return 'rgb(0, 187, 0)'; break;
      case 'T': return 'rgb(0, 255, 0)'; break;
      case 'U': return 'rgb(0, 136, 136)'; break;
      case 'V': return 'rgb(0, 187, 187)'; break;
      case 'W': return 'rgb(0, 255, 255)'; break;
      case 'X': return 'rgb(0, 0, 102)'; break;
      case 'Y': return 'rgb(0, 0, 136)'; break;
      case 'Z': return 'rgb(0, 0, 187)'; break;
      case '1': return 'rgb(0, 0, 255)'; break;
      case '2': return 'rgb(0, 136, 255)'; break;
      case '3': return 'rgb(0, 187, 255)'; break;
      case '4': return 'rgb(136, 0, 136)'; break;
      case '5': return 'rgb(187, 0, 187)'; break;
      case '6': return 'rgb(255, 0, 255)'; break;
      case '7': return 'rgb(136, 102, 68)'; break;
      case '8': return 'rgb(187, 136, 85)'; break;
      case '9': return 'rgb(187, 170, 102)'; break;
      default: return false; break;
   }
}
function embReset() {
   var embI; var embJ;
   for (embI=1; embI<26; embI++) {
      for (embJ=1; embJ<26; embJ++) {
         locnD='b'+embI+'x'+embJ+'d';
         locnV='b'+embI+'x'+embJ+'v';
         document.getElementById(locnD).style.backgroundColor=penColor;
         document.getElementById(locnV).style.backgroundColor=penColor;
      };
   };
}
// END EMBLEM CREATION

// PROFILE COLOR SCHEME SCRIPT
function profTextChange(tBtn) {
   document.getElementById('CSTextColor').style.backgroundColor=document.getElementById(tBtn).style.backgroundColor;
   document.getElementById('TextColor').style.display='none';
   document.getElementById('ColorScheme').style.display='block';
   document.getElementById('pColor1').value=embGetColorCode(document.getElementById('CSTextColor').style.backgroundColor);
   return true;
}
function profBackChange(tBtn) {
   document.getElementById('CSBackColor').style.backgroundColor=document.getElementById(tBtn).style.backgroundColor;
   document.getElementById('BackColor').style.display='none';
   document.getElementById('ColorScheme').style.display='block';
   document.getElementById('pColor2').value=embGetColorCode(document.getElementById('CSBackColor').style.backgroundColor);
   return true;
}
// END PROFILE COLOR SCHEME

// MOUSE POSITION SCRIPT
var xMousePos=0; // Horizontal position of the mouse on the screen
var yMousePos=0; // Vertical position of the mouse on the screen
var xMousePosMax=0; // Width of the page
var yMousePosMax=0; // Height of the page

function getMousePos(e) {
   var posx = 0;
   var posy = 0;
   if (!e) var e = window.event;
   if (e.pageX || e.pageY) {
      posx = e.pageX;
      posy = e.pageY;
   } else if (e.clientX || e.clientY) {
      posx = e.clientX + document.body.scrollLeft;
      posy = e.clientY + document.body.scrollTop;
   };
   // posx and posy contain the mouse position relative to the document
   xMousePos = posx;
   yMousePos = posy;
}
// END MOUSE POSITION

// BEGIN GROUP MANAGEMENT SCRIPT
function jsGOrder(jOrder) {
   document.getElementById('GroupOrder').value=document.getElementById('GOrder').value;
   document.getElementById('GroupForm').submit();
   return true;
}
function jsFriend(jName, jGroup) {
   var jText='Adding a user to your Friend Group will send a System Message notifying him or her of the addition';
   if (jGroup>0) jText+=', and will remove the user from his or her current Group';
   if (jGroup==3) jText+='. This means that he or she will no longer be blocked';
   if (confirm(jText+'. Do you want to continue?')) {
      document.getElementById('UserName').value=jName;
      document.getElementById('GroupAction').value='1';
      document.getElementById('GroupForm').submit();
      return true;
   };
   return true;
}
function jsEnemy(jName, jGroup) {
   var jText='Adding a user to your Enemy Group will remove the user from his or her current Group';
   if (jGroup==3) jText+='. This means that he or she will no longer be blocked';
   if (jGroup==0||confirm(jText+'. Do you want to continue?')) {
      document.getElementById('UserName').value=jName;
      document.getElementById('GroupAction').value='2';
      document.getElementById('GroupForm').submit();
      return true;
   };
   return true;
}
function jsBlock(jName, jGroup) {
   var jText='Adding a user to your Block Group will delete all message you\'ve received from him or her, and block all future contact.';
   if (jGroup>0) jText+=' This will also remove the user from his or her current Group.';
   if (confirm(jText+' Do you want to continue?')) {
      document.getElementById('UserName').value=jName;
      document.getElementById('GroupAction').value='3';
      document.getElementById('GroupForm').submit();
      return true;
   };
   return true;
}
function jsErase(jName, jGroup) {
   var jText='Erasing a user will remove that user from his or her current Group.';
   if (jGroup==3) jText+=' This means that he or she will no longer be blocked.';
   if (confirm(jText+' Do you want to continue?')) {
      document.getElementById('UserName').value=jName;
      document.getElementById('GroupAction').value='0';
      document.getElementById('GroupForm').submit();
      return true;
   };
   return true;
}
// END GROUP MANAGEMENT

function jsCtChange(jId) {
   var jImg=document.getElementById(jId).src;
   switch (jImg) {
      case 'http://www.mobculture.com/images/aim.gif': document.getElementById(jId).src='http://www.mobculture.com/images/msn.gif'; break;
      case 'http://www.mobculture.com/images/msn.gif': document.getElementById(jId).src='http://www.mobculture.com/images/yim.gif'; break;
      case 'http://www.mobculture.com/images/yim.gif': document.getElementById(jId).src='http://www.mobculture.com/images/icq.gif'; break;
      case 'http://www.mobculture.com/images/icq.gif': document.getElementById(jId).src='http://www.mobculture.com/images/eml.gif'; break;
      case 'http://www.mobculture.com/images/eml.gif': document.getElementById(jId).src='http://www.mobculture.com/images/aim.gif'; break;
   };
};

//TEST SCRIPTS
function CopLight(tpattern) {
   switch (tpattern) {
      case 1:
         setTimeout('CopRed(\'dCopL\');', 0);
         setTimeout('CopRed(\'dCopL\');', 250);
         setTimeout('CopBlue(\'dCopR\');', 500);
         setTimeout('CopBlue(\'dCopR\');', 750);
         setTimeout('CopLight(1);', 1000);
         break;
      case 2:
         setTimeout('CopRed(\'dCopL\');', 0);
         setTimeout('CopBlue(\'dCopR\');', 250);
         setTimeout('CopRed(\'dCopL\');', 500);
         setTimeout('CopBlue(\'dCopR\');', 750);
         setTimeout('CopLight(2);', 1000);
         break;
   };
};
function CopRed(tdivid) {
   document.getElementById(tdivid).style.backgroundColor='white';
   setTimeout('document.getElementById(\''+tdivid+'\').style.backgroundColor=\'red\';', 10);
   setTimeout('document.getElementById(\''+tdivid+'\').style.backgroundColor=\'transparent\';', 110);
};
function CopBlue(tdivid) {
   document.getElementById(tdivid).style.backgroundColor='white';
   setTimeout('document.getElementById(\''+tdivid+'\').style.backgroundColor=\'blue\';', 10);
   setTimeout('document.getElementById(\''+tdivid+'\').style.backgroundColor=\'transparent\';', 110);
};