//	Copyright NetCore 1997-2005, Licenced to SB2K.
//	http://www.netcore.com
//	http://www.sarahbrightman.co.uk

window.onerror=stopError;
function stopError(){return true;}
var MyURL = document.location.href;
var SophieErrorMessage="ERROR!\n\nIf you are accessing this website using the web address:\n\t'www.ilovesb2k.co.uk'\n\nPlease trying again but using the following address instead:\n\t\'www.sarahbrightman.co.uk/forum.php'\n\n\nIf you have this website in your Favourites Menu, it is recommended that\nyou removed this website from your Favourites menu and add it again.\n\n If you need help or advice, please contact Ash whoes eMail is:\n\nashman&#64;mail.com\n\nThank you.";
if (MyURL.toUpperCase().match("ILOVESB2K.CO.UK")){alert(SophieErrorMessage);}

var bV=parseInt(navigator.appVersion);
var NS4=(document.layers) ? true : false;
var IE4=((document.all)&&(bV>=4))?true:false;
var ver4 = (NS4 || IE4) ? true : false;
var VerMinor = parseFloat(navigator.appVersion);	// ex. 3.01
var HighlightForumAliasBoolean = 0;

function SwapImgRestore(){
 if (document.SwapImgData != null)
 for (var i=0; i<(document.SwapImgData.length-1); i+=2)
  document.SwapImgData[i].src = document.SwapImgData[i+1];
}

function SwapImage(){
 var i,theObj,j=0,swapArray=new Array,oldArray=document.SwapImgData;
 for (i=0; i < (SwapImage.arguments.length-2); i+=3) {
  theObj = eval(SwapImage.arguments[(navigator.appName == 'Netscape')?i:i+1])
  if (theObj != null) { // NetCore 2000
   swapArray[j++] = theObj;
   swapArray[j++] = (oldArray==null || oldArray[j-1]!=theObj)?theObj.src:oldArray[j];
   theObj.src = SwapImage.arguments[i+2];
  }
 }
 document.SwapImgData = swapArray;
}

function findObj(n,d){
 var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){
 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=findObj(n,d.layers[i].document);
 if(!x && document.getElementById) x=document.getElementById(n);return x;
}

function showHideLayers(){
 var i,p,v,obj,args=showHideLayers.arguments;
 for(i=0;i<(args.length-2);i+=3) if((obj=findObj(args[i]))!=null){v=args[i+2];
 if(obj.style){obj=obj.style;v=(v=='show')?'visible':(v='hide')?'hidden':v;}
  obj.visibility=v;
 }
}

function PreloadImages(){
 if(document.images){
  var imgFiles = PreloadImages.arguments;
  if (document.preloadArray==null) document.preloadArray = new Array();
  var i = document.preloadArray.length;
  with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
   preloadArray[i] = new Image;
   preloadArray[i++].src = imgFiles[j];
  }
 }
}

function GetCookie(byname){
 byname=byname+"=";
 nlen = byname.length;
 fromN = document.cookie.indexOf(byname)+0;
 if((fromN) != -1){
  fromN +=nlen
  toN=document.cookie.indexOf(";",fromN)+0;
  if(toN == -1){toN=document.cookie.length;}
  return unescape(document.cookie.substring(fromN,toN));
 } return "";
}

function SetCookie(name,value,time){
 exp = new Date();
 if((name==null)||(value==null)) return false;
 if(time==null) time=365*86400000;
 exp.setTime(exp.getTime()+time);
 document.cookie =escape(name)+"="+escape(value)+"; expires="+exp.toGMTString()+"; path=/; domain=www.sarahbrightman.co.uk";
 return true;
}

function DeleteCookie(name){
 exp=new Date();
 exp.setTime (exp.getTime() - 1);
 var cval = GetCookie ("name");
 document.cookie = name + "=" + cval +"; expires=" + exp.toGMTString()+"; path=/; domain=www.sarahbrightman.co.uk";
}

function TDClick(src){
 if(IE4){if(event.srcElement.tagName=='TD') src.children.tags('A')[0].click();}
}

function ChangeTableColor(X){
 if (!document.all) return;
  var source=event.srcElement
  if (source.tagName=="TR"||source.tagName=="TABLE") return;
  while(source.tagName!="TABLE")
   var source=source.parentElement
   if (source.style.backgroundColor!=X&&source.id!="ignore")
    source.style.backgroundColor=X;
}

function ChangeRowColor(X){
 if (!document.all) return;
  var source=event.srcElement;
  if (source.tagName=="TR"||source.tagName=="TABLE") return;
  while(source.tagName!="TR") var source=source.parentElement;
   if (source.style.backgroundColor!=X&&source.id!="ignore") source.style.backgroundColor=X;
}

function ChangeCellColor(X){
 if (!document.all) return;
 var source=event.srcElement;
 if (source.tagName=="TR"||source.tagName=="TABLE") return;
 while(source.tagName!="TD") var source=source.parentElement;
 if (source.style.backgroundColor!=X&&source.id!="ignore") source.style.backgroundColor=X;
}

function RestoreTableColor(X){
 if (!document.all) return;
 var source=event.srcElement;
 if (source.tagName=="TR"||source.tagName=="TABLE") return;
 while(source.tagName!="TABLE") var source=source.parentElement;
 if (source.style.backgroundColor!=X&&source.id!="ignore") source.style.backgroundColor=X;
}

function RestoreRowColor(X){
 if (!document.all) return;
 var source=event.srcElement;
 if (source.tagName=="TR"||source.tagName=="TABLE") return;
 while(source.tagName!="TR") var source=source.parentElement;
 if (source.style.backgroundColor!=X&&source.id!="ignore") source.style.backgroundColor=X;
}

function RestoreCellColor(X){
 if (!document.all) return;
 var source=event.srcElement;
 if (source.tagName=="TR"||source.tagName=="TABLE") return;
 while(source.tagName!="TD") var source=source.parentElement;
 if (source.style.backgroundColor!=X&&source.id!="ignore") source.style.backgroundColor=X;
}

var str_in;
var str_out="";
var num_in;
var num_out="";

function Tab(x){
var DataMissing="ERROR\n\nTab Data Missing\n\nPease report this error to info&#64;netcore.com";
 num_out="";
 if(x=="")alert(DataMissing);
 else{
  str_in=escape(x);
  for(i=0;i<str_in.length;i++)num_out+=str_in.charCodeAt(i)-23;
  return num_out;
 }
}

function UnTab(x){
var DataMissing="ERROR\n\nTab Data Missing\n\nPease report this error to info&#64;netcore.com";
var NumbersOnly="ERROR\n\nTab Data was not an Integer\n\nPease report this error to info&#64;netcore.com";
var e="ERROR\n\nTab Data was too small\n\nPease report this error to info&#64;netcore.com"
 str_out="";var flag=0;
 if(x=="")return ("0");
 num_out=x;  
 for(i=0;i<num_out.length;i++){
  if((num_out.charAt(i)>=0)||(num_out.charAt(i)<=9))flag=0;
  else{flag=1;break}
 }
 if(flag)alert(NumbersOnly);
 else{
  num_out=x;  
  for(i=0;i<num_out.length;i+=2){
   num_in=parseInt(num_out.substr(i,[2]))+23;
   num_in=unescape('%'+num_in.toString(16));
   str_out+=num_in;
  }
  return unescape(str_out);
 }
}

function PersonalMessenger(X){
 self.focus();
 CenterWindow("/forum/messenger/index.php","SB2KPM","260","500","0","1","0","0","0","0","0");
 if (X == "new"){
  document.PersnalMessenger.src = "/pic/PersonalMessenger.gif";
  document.NewPersnalMessage.src = "/pic/blank.gif";
  document.getElementById('NewPersnalMessage').style.width="0";
 }
}

function Load(URL){
 PopUpWindow = window.open(URL,"SB2KChildWindow","top=0,left=300,height=470,width=650,toolbar=yes,scrollbars=yes,location=no,status=no,menubar=Yes,resizable=Yes")
}

function SB2KLink(URL){
 PopUpWindow = window.open(URL,"SB2KLink","top=1000,left=300,height=280,width=400,toolbar=no,scrollbars=no,location=no,status=no,menubar=no,resizable=no")
}

function ArchivedBirthdayMessages2000(){
 PopUpWindow = window.open("../ArchivedBirthdayMessages2000/index.html","bDay","top=50,left=50,height=530,width=560,toolbar=no,scrollbars=no,location=no,status=no,menubar=no,resizable=yes")
}

function ShowPhoto(IMAGE,TEXT){
 SetCookie('TMPpic',IMAGE);
 SetCookie('TMPtext',TEXT);
 document.location="ShowPhoto.html";
}

function ShowSketch(IMAGE,TEXT){
 SetCookie('TMPpic',IMAGE);
 SetCookie('TMPtext',TEXT);
 document.location="ShowSketch.html";
}

function ShowFunPhoto(IMAGE,TEXT){
 SetCookie('TMPpic',IMAGE);
 SetCookie('TMPtext',TEXT);
 document.location="ShowFunPhoto.html";
}

function ShowRAH2(IMAGE,TEXT){
 SetCookie('TMPpic',IMAGE);
 SetCookie('TMPtext',TEXT);
 document.location="ShowRAH2.html";
}

function ShowFansMeetingSB(IMAGE,TEXT){
 SetCookie('TMPpic',IMAGE);
 SetCookie('TMPtext',TEXT);
 document.location="ShowFansMeetingSB.html";
}

function ShowPicVoice(IMAGE,TEXT){
 SetCookie('TMPpic',IMAGE);
 SetCookie('TMPtext',TEXT);
 document.location="ShowAlbumPhoto.html";
}

function CenterWindow(URL,WindowName,Width,Height,ScrollBars,Resizable,MenuBar,ToolBar,Location,Directories,Status){
 if (!WindowName) {var WindowName='SB2K_Child_Window'}
 if (!Width) {var Width=550}
 if (!Height) {var Height=350}
 if (!ScrollBars) {var ScrollBars=0}
 if (!Resizable) {var Resizable=0}
 if (!MenuBar) {var MenuBar=0}
 if (!ToolBar) {var ToolBar=0}
 if (!Location) {var Location=0}
 if (!Directories) {var Directories=0}
 if (!Status) {var Status=0}
  var winl = (screen.width - Width) / 2;
  var wint = (screen.height - Height) / 2;
  winprops = 'height='+Height+',width='+Width+',top='+wint+',left='+winl+',toolbar='+ToolBar+',location='+Location+',status='+Status+',menubar='+MenuBar+',scrollbars='+ScrollBars+',resizable='+Resizable+'';
  win = window.open(URL, WindowName, winprops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function LoadIconsWindow(){
 CenterWindow('/pic/SB2KIcons/icons.html','IconsWindow','390','220');
 //CenterWindow('/pic/SB2KIcons/icons.html','IconsWindow','390','330');
}

FadeObjects = new Object();
FadeTimers = new Object();

function Fade(object, destOp, rate, delta){
  // object - image to be faded (actual object, not name);
  // destOp - destination transparency level (ie 80, for mostly solid)
  // rate   - time in milliseconds between trasparency changes (best under 100)
  // delta  - amount of change each time (ie 5, for 5% change in transparency)
 if (!document.all)
  return
 if (object != "[object]"){  //do this so I can take a string too
  setTimeout("Fade("+object+","+destOp+","+rate+","+delta+")",0);
  return;
 }
 clearTimeout(FadeTimers[object.sourceIndex]);
 diff = destOp-object.filters.alpha.opacity;
 direction = 1;
 if (object.filters.alpha.opacity > destOp){
   direction = -1;
 }
 delta=Math.min(direction*diff,delta);
 object.filters.alpha.opacity+=direction*delta;
 if (object.filters.alpha.opacity != destOp){
  FadeObjects[object.sourceIndex]=object;
  FadeTimers[object.sourceIndex]=setTimeout("Fade(FadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
 }
}

function UpLoad(NoAlert){
 if(!NoAlert){alert("SB2K IMAGE UPLOAD NOTICE\n\nPlease do not upload images to SB2K that you have just downloaded from another website. Why not directly link to the image on the other website?\nTo do this follow these steps:\n  1) Right click on the image (on the other site) and click on Properties.\n  2) Highlight the Address (URL) of the image, and right click on the highlighted text and select copy.\n  3) Now back on the SB2K message page, paste in the URL that you have just copied in to the Picture URL feild.\n\nThe Upload tool will now load if you are genuinely uploading images that are not on the internet.\nThank you.");}
 CenterWindow("upload.php",'UploadWindow','390','180');
}

function Validate_eMail(DOM){
 var TestResults
 var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})$/
 if (filter.test(DOM))
  TestResults=true
 else{
  TestResults=false
 }
 return (TestResults)
}

function LoadTellAFriend(){
 CenterWindow("TellAFriend.php",'TellAFriend','470','365')
}

function HighlightButton(StyleClass){
 if (IE4){
  if ("INPUT"==event.srcElement.tagName)
  event.srcElement.className=StyleClass
 }
}

function HighlightForumAlias() {
 if (HighlightForumAliasBoolean==1){
  alert("You've already clicked me!");
  HighlightForumAliasBoolean++
  self.focus();
  return
 }
 if (HighlightForumAliasBoolean==2){
  alert("Come on, stop clicking me.!");
  HighlightForumAliasBoolean++
  self.focus();
  return
 }
 if (HighlightForumAliasBoolean==3){
  alert("Stop it!")
  HighlightForumAliasBoolean++
  self.focus();
  return
 }
 if (HighlightForumAliasBoolean==4){
  alert("Stop it NOW I say!!!")
  HighlightForumAliasBoolean++
  self.focus();
  return
 }
 if (HighlightForumAliasBoolean==5){
  alert("That's it, I'm ignoring you now.\n\n:-P");
  HighlightForumAliasBoolean++
  self.focus();
  return
 }
 if (HighlightForumAliasBoolean==6){
  self.focus();
  return
 }
 var Alias = document.body.createTextRange();
 if (document.Form1.Alias.value != ''){
  while (Alias.findText(document.Form1.Alias.value))
   Alias.pasteHTML('<FONT Class=HighlightForumAlias><I>&nbsp' + document.Form1.Alias.value + '&nbsp;</I></FONT>');
   HighlightForumAliasBoolean++;
 }else{
  alert("ERROR!\n\nYour name cannot be highlighted as you have not saved it.\nTo save your name, use the Settings tab on the left.")
 }
 self.focus()
}

function TrimLeadingAndTrailingChars(X,Y){
 while(X.value.charAt(X.value.length-1)==' '){
  X.value=X.value.substring(0,X.value.length-1);
 }
 while(X.value.charAt(0)==' '){
  X.value=X.value.substring(1,X.value.length);
 }
 if (Y != "DontStripHTML"){
  X.value=StripHTML(X.value);
 }
 X.value=ChangeLessThan(X.value);
 X.value=ChangeGreaterThan(X.value);
 X.value=StripDoubleSpaces(X.value);
}

function StripHTML(string){
 var strip = new RegExp();
 strip = /[<][^>]*[>]/gi;
 return string.replace(strip, "");
}


function ChangeLessThan(string){
 return string.replace("<", "[");
}

function ChangeGreaterThan(string){
 return string.replace(">", "]");
}

function StripDoubleSpaces(string){
 return string.replace("  ", " ");
}

/* Window.Scroll */
function JumpToPageTop(){
 if((ver4)&&window.scrollTo){
 //if(!MacIE3&&!MacIE4&&!NN&&window.scrollTo||NN&&(VerMinor>=4.75)&&window.scrollTo){
  PageScroll(0,0,0,0);
 }else{
  location.hash = "top";
 }
 self.focus();
}
var PageScrollTimer;
function PageScroll(toX,toY,frms,cuX,cuY){
 if(PageScrollTimer) clearTimeout(PageScrollTimer);
 if(!toX || toX < 0) toX = 0;
 if(!toY || toY < 0) toY = 0;
 if(!cuX) cuX = 0 + GetScrollLeft();
 if(!cuY) cuY = 0 + GetScrollTop();
 if(!frms) frms = 6;
 cuX += (toX - GetScrollLeft()) / frms; if (cuX < 0) cuX = 0;
 cuY += (toY - GetScrollTop()) / frms;  if (cuY < 0) cuY = 0;
 var posX = Math.floor(cuX);
 var posY = Math.floor(cuY);
 window.scrollTo(posX, posY);
 if(posX != toX || posY != toY){
  PageScrollTimer = setTimeout("PageScroll("+toX+","+toY+","+frms+","+cuX+","+cuY+")",16);
 }
}
function GetScrollLeft(){
 if((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)){
  return document.body.scrollLeft;
 }else if(window.pageXOffset){
  return window.pageXOffset;
 }else{
  return 0;
 }
}
function GetScrollTop(){
 if((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)){
  return document.body.scrollTop;
 }else if(window.pageYOffset){
  return window.pageYOffset;
 }else{
  return 0;
 }
}
function GetScrollWidth(){
 if((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)){
  return document.body.scrollWidth;
 }else if(window.innerWidth){
  return window.innerWidth;
 }
 return 0;
}
function GetScrollHeight(){
 if((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)){
  return document.body.scrollHeight;
 }else if(window.innerHeight){
  return window.innerHeight;
 }
 return 0;
}
/* Window.Scroll */
