function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function imageLink(image, linkto, alt){
	this.image = image;
	this.linkto = linkto;
	this.alt = alt;
	this.showStatic = showStatic;
	this.showSwf = showSwf;
	this.show = show;

	function show(){	
		didShow = true;
		if (this.image.match(/.*.swf/) && (navigator.appName != "Microsoft Internet Explorer" || (navigator.userAgent.indexOf("Opera")!=-1))){
			didShow = false;
		}
		else if (this.image.match(/.*.swf/) && (navigator.appName == "Microsoft Internet Explorer" || (navigator.userAgent.indexOf("Opera")=-1))){
			this.showSwf();
		}
		else{
			this.showStatic();
		}
		return didShow;
	}
		
	function showStatic(){
		document.write("<a href=\"" + this.linkto + "\"><img src=\"" + this.image + "\" width=\"365\" height=\"254\" border=\"0\" alt=\"" + this.alt +"\"></a>");
	}

	function showSwf(){
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="365" height="254">');
		document.write('<param name=movie value="'+this.image+'?hrefLoc='+URLEncode(this.linkto)+'">');
		document.write('<param name=quality value=high>');
		document.write('<param name="WMode" value="Transparent">');
		document.write('<param name="allowScriptAccess" value="always" />');
		document.write('<embed src="'+this.image+'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="356" height="254">');
		document.write('</embed>');
		document.write('</object>');
	}
}