function imgFit_Onload (context)
{
	var context = context || 'body';
	var $img = $('img.postImg', $(context));
	if ($.browser.msie || context == 'body') {
		$img.each(function(){ imgFit(this); });
	} else {
		$img.load(function(){ imgFit(this); });
	}
	$img.click(function(){ return imgFit(this); });
}

function imgFit (img, maxW)
{
	if (typeof(img.naturalWidth) == 'undefined') {
		img.naturalHeight = img.height;
		img.naturalWidth  = img.width;
	}
	if (!maxW) {
		var id = img.getAttribute('id');
		var wd = img.width;

		if (id && wd) {
			if (id == 'postImg' && wd >= postImg_MaxWidth) {
				maxW = postImg_MaxWidth;
			}
			else if (id == 'postImgAligned' && wd >= postImgAligned_MaxWidth) {
				maxW = postImgAligned_MaxWidth;
			}
			else if (id == 'attachImg' && wd >= attachImg_MaxWidth) {
				maxW = attachImg_MaxWidth;
			}
		}
		else {
			return false;
		}
	}

	if (img.width > maxW) {
		img.height = Math.round((maxW/img.width)*img.height);
		img.width  = maxW;
		img.title  = 'Click image to view full size';
		img.style.cursor = 'move';
		return false;
	}
	else if (img.width == maxW && img.width < img.naturalWidth) {
		img.height = img.naturalHeight;
		img.width  = img.naturalWidth;
		img.title  = 'Click to fit in the browser window';
		return false;
	}

	return true;
}



function _hideBBCode() 
{ 
   this.objs = []; 
   return this; 
} 
_hideBBCode.prototype.IsDisplaySupported = function() 
{ 
   // Opera: Only v7+ supports write access to display attribute ! 
   if( window.opera && !document.childNodes ) return false; 
   // Other DOM browsers and MSIE4+ support it as well. 
   if( document.getElementById || document.all ) return true; 
   // This is where legacy browsers fall. NS4, Hotjava, etc. 
   return false; 
} 
_hideBBCode.prototype.getObj = function(obj) 
{ 
   return ( document.getElementById ? document.getElementById(obj) : 
         ( document.all ? document.all[obj] : 
         ( document.layers ? document.layers[obj] : null ) ) ); 
} 
_hideBBCode.prototype.displayObj = function(obj, status) 
{ 
   var x = this.getObj(obj); 
   if(!x) return; 
   var css = ( document.layers ? x : x.style ); 
   if( this.IsDisplaySupported() ) 
   { 
      css.display = status; 
   } 
   else 
   { 
      css.visibility = ( status == 'none' ? 'hidden' : 'visible' ); 
   } 
} 
_hideBBCode.prototype.open = function(l_title, l_hide) 
{ 
   var s='', randomId = 'slide' + Math.floor(Math.random() * 15000); 
   var style = ( this.IsDisplaySupported() ? 'display:none;' : 'visibility:hidden;' ); 
   if( document.layers ) { style = 'position:relative;' + style; } 
   s += '<div class="hideblock"><div class="hidetitle clickable" onClick="javascript:hideBBCode.showHide(\'' + randomId + '\');"> ' + l_hide + l_title + '</div>'; 
   s += '<div class="hidecont" id="' + randomId + '" style="'+style+'">'; 
   document.write(s); 
   this.objs[randomId] = 'none'; 
} 
_hideBBCode.prototype.close = function() 
{ 
   document.write('</div></div>'); 
} 
_hideBBCode.prototype.showHide = function(obj) 
{ 
   if( !this.objs[obj] ) return; 
   this.objs[obj] = ((this.objs[obj]=='none') ? 'block':'none'); 
   this.displayObj(obj, this.objs[obj]); 
} 
var hideBBCode = new _hideBBCode();



function toggle_block (block_id) {
	displaystyle = document.getElementById(block_id).style;
	if (displaystyle.display == 'none') {
		displaystyle.display = 'block';
	} else {
		displaystyle.display = 'none';
	}
	return false;
}

function toggle_TR (tr_id) {
	var tr = document.getElementById(tr_id);
	if (tr.className == 'hiddenRow') {
		tr.className = '';
	} else {
		tr.className = 'hiddenRow';
	}
	return false;
}

// Flashing Links START (from http://www.dynamicdrive.com/dynamicindex5/flashlink.htm)
var flashlinks=new Array()

function changelinkcolor(){
for (i=0; i< flashlinks.length; i++){
var flashtype=document.getElementById? flashlinks[i].getAttribute("flashtype")*1 : flashlinks[i].flashtype*1
var flashcolor=document.getElementById? flashlinks[i].getAttribute("flashcolor") : flashlinks[i].flashcolor
if (flashtype==0){
if (flashlinks[i].style.color!=flashcolor)
flashlinks[i].style.color=flashcolor
else
flashlinks[i].style.color=''
}
else if (flashtype==1){
if (flashlinks[i].style.backgroundColor!=flashcolor)
flashlinks[i].style.backgroundColor=flashcolor
else
flashlinks[i].style.backgroundColor=''
}
}
}

function init(){
var i=0
if (document.all){
while (eval("document.all.flashlink"+i)!=null){
flashlinks[i]= eval("document.all.flashlink"+i)
i++
}
}
else if (document.getElementById){
while (document.getElementById("flashlink"+i)!=null){
flashlinks[i]= document.getElementById("flashlink"+i)
i++
}
}
setInterval("changelinkcolor()", 1000)
}

if (window.addEventListener)
window.addEventListener("load", init, false)
else if (window.attachEvent)
window.attachEvent("onload", init)
else if (document.all)
window.onload=init
// Flashing Links END


