function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

// An adapxation of Dorcht's function for deleting a cookie.
function delCookie (name,path,domain) {
  if (readCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
function delAllCookie() {
if (document.cookie != "")
    {
        var cookieInfo, cookieData;
        var expireDate = new Date();
       // if (confirm("Are you sure you want to delete the cookies?"))
        //{
            cookieInfo = document.cookie.split("; ");
            // Set the expiration date to yesterday
            expireDate.setDate(expireDate.getDate() - 1);
            for (counter=0; counter<cookieInfo.length; counter++)
            {
                // Get the cookie name
                cookieData = cookieInfo[counter].split("=")[0];
                // Add a null value and the expiration date
                cookieData += "=;expires=" + expireDate.toGMTString();
                // Expire the cookie
                document.cookie = cookieData; 
           // }
        }
    }
  }   
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
 
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}
function check(someArray, someValue) {
 for (var j = 0; j < someArray.length; j++) {  
      if (someArray[j] == someValue.toLowerCase() ) 
	 //alert(someArray[j]+ someValue.toLowerCase());
	     return true; 
     } return false; 
 }
  
function increase(fontIncrease, orig){ 
var currentElement, currentFontSize, newFontSize, orig;  

if (document.getElementsByTagName)  
   {  
      tags1 =   new Array ('div','h2' ,'p', 'a','span','td', "ul");  
      tags2 =  new Array ('h1');
	  tags = tags1.concat(tags2);
      for (j = 0; j < tags.length; j ++)  
      {  

        var tagElements = document.getElementById('maintextcontainer').getElementsByTagName(tags[j]);  
        
         for (i = 0; i < tagElements.length; i ++)  
         {  
            currentElement = tagElements[i]; 
		
            if(check(tags2,currentElement.tagName)){				
		    if (parseInt(orig)) currentFontSize = (parseInt(11))+ 'px'; 
		else{
			   if(parseInt(readCookie(currentElement.tagName))>0){ 			    
			    currentFontSize=(parseInt(readCookie(currentElement.tagName))) + 'px';			 
			   } else{
			   if(parseInt(currentElement.style.fontSize)>0)
			   currentFontSize = parseInt(currentElement.style.fontSize); 
			   else
			    currentFontSize = (parseInt(11))+ 'px'; 
			  }
			 } 
			 
			}else{
             // currentFontSize = parseInt(currentElement.style.fontSize); 
              if (parseInt(orig)) currentFontSize = (parseInt(11)); 
		else{
  //  alert(parseInt(fontIncrease));
if(parseInt(readCookie(currentElement.tagName))>0 && parseInt(fontIncrease)==0 ){ 
			//alert(readCookie(currentElement.tagName));
				currentFontSize=(parseInt(readCookie(currentElement.tagName))) + 'px';			
				} else{
			    if(parseInt(currentElement.style.fontSize)>0)
			     currentFontSize = parseInt(currentElement.style.fontSize); 
			   else
			    currentFontSize = (parseInt(11))+ 'px'; 
				}
			}
if ( parseInt(currentFontSize)<=11 && parseInt(fontIncrease)!=0){
fontIncrease ="+3";
changeImages('fontTool', 'dsg/toolbar_07_minus.html') ;
}
if ( parseInt(currentFontSize)>=14 && parseInt(fontIncrease)!=0){
 fontIncrease ="-3";  
 changeImages('fontTool', 'dsg/toolbar_07.html') ;
 }
			 }

//alert(readCookie(currentElement.tagName));
//   alert(currentFontSize);      
   
            newFontSize = parseInt(currentFontSize) + parseInt(fontIncrease); // alert(newFontSize); 
			//alert(parseInt(currentElement.style.fontSize));
          if (!parseInt(currentElement.style.fontSize)) currentElement.style.fontSize ='11px'; 
 if (parseInt(currentElement.style.fontSize)>11 && parseInt(fontIncrease)==parseInt('-3') ) {
            currentElement.style.fontSize = newFontSize + 'px'; 
		    setCookie(currentElement.tagName, newFontSize);  
}
 if (parseInt(currentElement.style.fontSize)<15 && parseInt(fontIncrease)==parseInt('3') ) {
            currentElement.style.fontSize = newFontSize + 'px'; 
		    setCookie(currentElement.tagName, newFontSize);  
}
if(parseInt(fontIncrease)==0) {
currentElement.style.fontSize = newFontSize + 'px'; 
		    setCookie(currentElement.tagName, newFontSize);  
}
         }  
      } 
       
   }
   if ( parseInt(readCookie(currentElement.tagName))<=11){
       changeImages('fontTool', 'dsg/toolbar_07.html') ;
   }
  // alert( document.images['fontTool'].src)
   if (parseInt(readCookie(currentElement.tagName))>=14){
       changeImages('fontTool', 'dsg/toolbar_07_minus.html') ;
   }
}
 
 
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}


function P7_JumpMenu(selObj,restore){ //v1.4 by Project Seven
	var theFullString = selObj.options[selObj.selectedIndex].value;
	if (restore) selObj.selectedIndex=0;
	var theLength = theFullString.length;
	var endPos = theFullString.lastIndexOf("~");
	var theUrl, theTarget, theParent;
	if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
	else {theUrl = theFullString;}
	endPos++
	if (endPos < theLength) {theTarget = theFullString.substring(endPos,theLength)}
	else {theTarget = "window:Main";}
	if (theTarget == "window:New") {window.open(theUrl);}
	else if (theTarget == "window:Main") {eval("parent.location='"+theUrl+"'");}
	else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}

// mouseover  function
// param imgName   string  image name/id  
//param imgSrc  string image url
//Example: changeImages('img1','dsg/img_y.gif')
function changeImages(imgName, imgSrc) 
{
 var imgName;
 var imgSrc;
  if (document.images)
  {
    if (imgSrc != "none")
    {
  if ( document.images[imgName])
      document.images[imgName].src = imgSrc;
    }
  }
}

