//  Sleight. Image can't be an anchor, but there is a hack/update at www.youngpup.net if desperate.







if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
	window.attachEvent("onload", fnLoadPngs);
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			var src = img.src;
			img.style.width = img.width + "px";
			img.style.height = img.height + "px";
			img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
			img.src = "/g/transparent.gif";
		}
		img.style.visibility = "visible";
	}
}







//  Sleight adapted for the backgrounds. PNG needs to be small--1px--otherwise it renders links inoperable. Also, elements using this need an explicit height and width! http://www.allinthehead.com/retro/69/







if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	window.attachEvent("onload", alphaBackgrounds);
}

function alphaBackgrounds(){
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
	for (i=0; i<document.all.length; i++){
		var bg = document.all[i].currentStyle.backgroundImage;
		if (itsAllGood && bg){
			if (bg.match(/\.png/i) != null){
				var mypng = bg.substring(5,bg.length-2);
				document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
				document.all[i].style.backgroundImage = "url('/g/transparent.gif')";
			}
		}
	}
}







//  This one's to help IE/Win cope with the drop-down menus.







function sfHover()

{
var nav =  document.getElementById("nav");

if (nav != null)
{
    var sfEls = nav.getElementsByTagName("li");
   
   if (sfEls.length)
    {
        var fnMouseOver = function() { this.className += " sfHover"; };
        var re = / sfHover\b/;
        var fnMouseOut = function() { this.className = this.className.replace(re, ""); };
        for (i = 0; (i < sfEls.length); ++i)
        {
            sfEls[i].onmouseover = fnMouseOver;
            sfEls[i].onmouseout = fnMouseOut;
        }
    }
}

}

if (window.attachEvent)
{ window.attachEvent("onload", sfHover); }







// Character Limitation







function limittext(limitfield, limitnum) {

    var messageDiv = document.getElementById(limitfield.id + "_div");
    
    if (messageDiv != null)
        messageDiv.style.display='block';

    //var messageSpan = document.getElementById(limitfield.id + "_span");

    if (messageDiv != null)
        {
	    if (limitfield.value.length > limitnum) 
	        {
		    limitfield.value = limitfield.value.substring(0, limitnum);
	        } 
	    else 
	        {
	        //do what we did with innerHTML the DOM way
	        //get rid off all child elements
            while (messageDiv.childNodes.length > 0) {

                    messageDiv.removeChild(messageDiv.childNodes[0]);

                }


                  	        
	        //create a string to go back in
	        var strMessage = "You have " + parseInt(limitnum - limitfield.value.length) + " characters left (Max: " + limitnum + ").";
	        
	        var message_span = document.createTextNode(strMessage)
	       
	        var myNode = messageDiv.appendChild(message_span);
	        }
	    }
}







// Show and Hide 







function showhide(id) {


			if (document.getElementById) { 
				obj = document.getElementById(id);

  if (obj.style.display == "none") {
    obj.style.display = "block";
  }
  else {
    obj.style.display = "none";
  }
}

_SaveViewState();

}

//view state for the damn thing

function _SaveViewState()
{

//gets all the divs of class forums
var my_array = document.getElementsByTagName("ul");

var strViewstate = '';

//now look and see if it's the right type
for (i = 0; i < my_array.length; i++)

  {

    //test to see if its the right type
    if (my_array[i].className == "forums")
    {
    var myVis = my_array[i].style.display;
    //alert(my_array[i].id + " is " + myVis);
    
    if (myVis != "none")
        {
        strViewstate = strViewstate + my_array[i].id + "," ;
        }
    }
  }


//save the thing in a cookie
   
document.cookie = "viewstate=" + strViewstate;

}

function _RestoreViewState()
{

var strViewstate = "";

strViewstate = document.cookie;


//get the value
var myCookie = strViewstate.split("=");


//only if we have a cookie
if (myCookie.length >= 2)
{

    //split the array by ,
    var myBits = myCookie[1].split(",");

    //loop each element
    for (i = 0; i < myBits.length; i++)

    {    
        //examine the state and set it
     
        if (myBits[i] != "")
        { 

        var myItem =  document.getElementById(myBits[i]);
        if (myItem != null)
        {
        myItem.style.display = 'block';
        }                      
        }       
        }
}
return true
}







// external links







function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;






