﻿
		    function MM_findObj(n, d) { //v4.0
              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=MM_findObj(n,d.layers[i].document);
              if(!x && document.getElementById) x=document.getElementById(n); return x;
            }
            
            function MM_showHideLayers() { //v6.0
              var i,p,v,obj,args=MM_showHideLayers.arguments;
              for (i=0; i<(args.length-2); i+=3) if ((obj=MM_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; }
            }
            
            /* font size change 
            ------------------- */

            var curFontSize = 1; 	
            var fontModifier = 0.1; 	

            function getCookieVal(offset) {
                var endstr = document.cookie.indexOf (";", offset);
                if (endstr == -1) {
                    endstr = document.cookie.length;
                }
                return unescape(document.cookie.substring(offset, endstr));
            }

            function FixCookieDate(date) {
                var base = new Date(0);
                var skew = base.getTime();
                if (skew > 0)  {
	                date.setTime (date.getTime() - skew);
                }
            }

            function GetCookie(name) {
                var arg = name + "=";
                var alen = arg.length;
                var clen = document.cookie.length;
                var i=0;
                while (i < clen) {	
	                var j = i + alen;
	                if (document.cookie.substring(i, j) == arg) {
	                    return getCookieVal (j);
	                }
	                i = document.cookie.indexOf(" ", i) + 1;
	                if (i === 0) {
	                    break;
	                }
                }
                return null;
            }

            function SetCookie(name,value,expires,path,domain,secure) {
                document.cookie = name + "=" + escape (value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "");
            }

            /* insert hi-res logo and call window print */
            function printStoryPage() {
                     window.print();
            }

            function fontSize(act) {
                if (document.getElementById) {
                    storyBody = document.getElementById("article_content");
                    if (act === 1) {
                        curFontSize += fontModifier;
                        curFontSize = Math.min(curFontSize, 1.4);
                    } else if (act === 0) {
                        curFontSize -= fontModifier;
                        curFontSize = Math.max(curFontSize, 1);
                    }
                    storyBody.style.fontSize = curFontSize + "em";


					if (storyBody != null)
					{
	                    for (v = 0; v < storyBody.getElementsByTagName("blockquote").length; v++) {
	                       storyBody.getElementsByTagName("blockquote")[v].style.fontSize = curFontSize + "em";
						}
	                    for (v = 0; v < storyBody.getElementsByTagName("p").length; v++) {
	                       storyBody.getElementsByTagName("p")[v].style.fontSize = curFontSize + "em";
						}
	                    for (v = 0; v < storyBody.getElementsByTagName("span").length; v++) {
	                       storyBody.getElementsByTagName("span")[v].style.fontSize = curFontSize + "em";
						}

					}

                }
            	
                // set cookie with font size
                var expdate = new Date();
                FixCookieDate (expdate);
                expdate.setTime (expdate.getTime() + (672*60*60*1000)); // 4 weeks
                SetCookie("userfontc",curFontSize,expdate);		
            	
                return(false);
            }

function addOption(selectObject,optionValue,optionText) {
    var optionObject = new Option(optionText,optionValue)
    var optionRank = selectObject.options.length
    selectObject.options[optionRank]=optionObject
}

function deleteOption(selectObject) {
    optionRank = 0
    if (selectObject.options.length!=0) { selectObject.options[optionRank]=null }
}


/*
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
var NSX = (navigator.appName == "Netscape");
var IE4 = (document.all) ? true : false;

  function addOption(selObject,value,text) {
	if (NSX) {
		addOptionNS(selObject,value,text);
	} else if (IE4) {
		addOptionIE(selObject,value,text);
	}
  }

// (1) addOptionNS(theForm)
  function addOptionNS(selObject,value,text) {
	var newOpt  = new Option(text, value);
	selObject.options[value] = newOpt;
	if (NS4) history.go(0);
  }

// (2) addOptionIE(theForm)
  function addOptionIE(selObject,value,text) {
	var newOpt = document.createElement("OPTION");
	newOpt.text=text;
	newOpt.value=value;
	selObject.add(newOpt);
  }

  function deleteOption(selObject,pos) {
	if (NSX) {
		deleteOptionNS(selObject,pos);
	} else if (IE4) {
		deleteOptionIE(selObject,pos);
	}	
  }

// (3) deleteOptionNS(theForm)
  function deleteOptionNS(selObject,pos) {
	selObject.options[pos]=null;
  }

// (4) deleteOptionIE(theForm)
  function deleteOptionIE(selObject,pos) {
	selObject.remove(pos);
  }
//-->
*/
function URLEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
    return encoded;
};

function URLDecode(encoded)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
};
