




function MM_preloadImages() { //v3.0
	var d=document; if(d.images){
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++) if(a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i]; }
	}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
  for(i=0;i<(a.length-2);i+=3) if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}





function resizeimg(img,mw,mh) {
	if(typeof(img)=='string') img=document.getElementById(img); if(!img) return;
	var osrc=img.src;
	eleaddevent('load',function(){resizeimgonload(img,mw,mh);},img);
	if(img.style){ img.style.width='auto'; img.style.height='auto'; }
	img.src=''; img.src=osrc;
}
function resizeimgonload(img,mw,mh) {
	if(typeof(img)=='string') img=document.getElementById(img); if(!img) return;
	eleremoveevent('load',function(){resizeimgonload(img,mw,mh);},img);
	if(img.height>=img.width) img.height=mh; else img.width=mw;
}





function setimgbutton(imgid,normalimg,onimg,downimg,action) {
	var img=document.getElementById(imgid);
	img.src=normalimg;
	eleaddevent('mouseover',function(){this.style.cursor='pointer';document.getElementById(imgid).src=onimg;},img);
	eleaddevent('mouseout',function(){document.getElementById(imgid).src=normalimg;},img);
	eleaddevent('mousedown',function(){document.getElementById(imgid).src=downimg;},img);
	eleaddevent('mouseup',function(){document.getElementById(imgid).src=normalimg;},img);
	if(typeof(action)=='function') eleaddevent('click',action,img);
}





//SuperSleight, version 1.1.0
//version 1.1.0 by Jeffrey Barke <http://themechanism.com/> 20071218
//Essential (99% of the) code by Drew McLellan <http://24ways.org/2007/supersleight-transparent-png-in-ie6>
var supersleight = function() {
	var root = false; var applyPositioning = true; var shim = 'x.gif'; // path to a transparent GIF image
	var fnLoadPngs = function() {
		if (root) { root = document.getElementById(root); } else { root = document; } // if supersleight.limitTo called, limit to specified id
		for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
			if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) { bg_fnFixPng(obj); } // background pngs
			if (obj.tagName == 'IMG' && obj.src.match(/\.png$/i) !== null) { el_fnFixPng(obj); } // image elements
			if (applyPositioning && (obj.tagName=='A'||obj.tagName=='a'||obj.tagName=='INPUT'||obj.tagName=='input') && obj.style.position==='') { obj.style.position='relative'; } // apply position to 'active' elements
		}
	};
	var bg_fnFixPng = function(obj) {
		var mode = 'scale'; var bg = obj.currentStyle.backgroundImage; var src = bg.substring(5,bg.length-2);
		if (obj.currentStyle.backgroundRepeat == 'no-repeat') { mode = 'crop'; }
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
		obj.style.backgroundImage = 'url(' + shim + ')';
	};
	var el_fnFixPng = function(img) {
		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 = shim;
	};
	var addLoadEvent = function(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') { window.onload = func; }
		else { window.onload = function() { if (oldonload) { oldonload(); } func(); }; }
	};
	// supersleight object
	return {
		init: function(strPath, blnPos, strId) {
			if (document.getElementById) {
				if (typeof(strPath) != 'undefined' && null !== strPath) { shim = strPath; }
				if (typeof(blnPos) != 'undefined' && null !== blnPos) { applyPositioning = blnPos; }
				if (typeof(strId) != 'undefined' && null !== strId) { root = strId; }
				addLoadEvent(fnLoadPngs);
			} else { return false; }
		},
		limitTo: function(el) { root = el; },
		run: function(strPath, blnPos, strId) {
			if (document.getElementById) {
				if (typeof(strPath) != 'undefined' && null !== strPath) { shim = strPath; }
				if (typeof(blnPos) != 'undefined' && null !== blnPos) { applyPositioning = blnPos; }
				if (typeof(strId) != 'undefined' && null !== strId) { root = strId; }
				fnLoadPngs();
			} else { return false; }
		}
	};
}();
//limit to part of the page ... pass an ID to limitTo:
//supersleight.limitTo('top');
//optional path to a transparent GIF image, apply positioning, limitTo
/*
The init method of the supersleight object takes three optional parameters:
1. String path to the transparent gif file. Note this path is relative to the actual document, not the JavaScript document.
2. Boolean value to apply relative positioning to anchor and input elements. Pass false to leave the elements as they are.
3. String ID of an element to limit SuperSleight's operations to.
To call SuperSleight from a script, use the run method of the supersleight object. This method takes the same three optional parameters as the init method.
*/
//supersleight.init('gfx/fixie6png.gif',false);
function fixiepng(relpos,scope) {
	if(isie()) supersleight.run('gfx/fixie6png.gif',relpos,scope);
}
//var fixpaVersion = navigator.appVersion.split("MSIE");
//var fixpbversion = parseFloat(fixpaVersion[1]);
function fixiepngv1(imgid) {
	if(!isie()) return;
//if((fixpbversion>=5.5)&&(document.body.filters)){
	var img=document.getElementById(imgid);
	if(img.tagName.toLowerCase()!='img') return;
	if(img.src.substring(img.src.length-3,img.src.length).toLowerCase()!="png") return;
	var cid=(img.id)?"id='"+img.id+"' ":"";
	var cclass=(img.className)?"class='"+img.className+"' ":"";
	var ctitle=(img.title)?"title='"+img.title+"' ":"title='"+img.alt+"' ";
	var cstyle=img.style.cssText+";";
	cstyle=cstyle+"display:inline-block;";
	cstyle=cstyle+"width:"+img.width+"px;";
	cstyle=cstyle+"height:"+img.height+"px;";
	if(img.align.toLowerCase()=="left") cstyle=cstyle+"float:left;";
	if(img.align.toLowerCase()=="right") cstyle=cstyle+"float:right;";
	if(img.parentElement.href) cstyle=cstyle+"cursor:hand;";
	cstyle=cstyle+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img.src+"', sizingMethod='scale');";
	var container="<span "+cid+cclass+ctitle+"style=\""+cstyle+"\"></span>";
	img.id=img.id+'pngfixed';
	img.outerHTML=container;
//}
}
function fixiepngupdatesrcv1(cid,src) {
	var container=document.getElementById(cid);
	container.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')";
}
function fixiepngallv1() {
	if(!isie()) return;
//if ((fixpbversion >= 5.5) && (document.body.filters)) {
	for(var i=0; i<document.images.length; i++) { fixiepngv1(document.images[i].id); }
//}
}
function fixie6bgimg() {
	if(isie()==6){ try{ document.execCommand("BackgroundImageCache",false,true); } catch(e){ /* just in case this fails .. ? */ }}
}





