// frame buster  
if (self != top) {
   if (document.images) {
       top.location.replace(window.location.href);
   	} else {
       top.location.href = window.location.href;
	}
}

// virtual Earth
document.getElementById("vE").setAttribute("onmouseover","window.open('virtualEarth.php','mywin','width=450,height=450,resizable')" );

// home page set
var hpstr = "If you wish to make PreserveStaffnow.org your home page, drag the icon in the address area and drop it on the home icon";
document.getElementById("hp").setAttribute("onclick","alert('" + hpstr +"');this.blur()");

// gathering the flower buttons
var osaSection = document.getElementById("osa");
var theImages = osaSection.getElementsByTagName('img');
var theLength = theImages.length;

// note the flower images are not displayed in order so need each one's id
for (var i=0,num=0, max = theLength; i < max; i++) { 
 num = theImages[i].id.substr(4);
 theImages[i].setAttribute("onmouseover","Decorate('Text"  + num + "');hilite('"  + theImages[i].id  + "')" );
 theImages[i].setAttribute("onmouseout", "unDecorate('Text" + num + "');restore('" + theImages[i].id + "')" );
} 

// applet instructions
var strAppDirs = "Mouse over a headline and scrolling temporarily stops.  Click a link and a window will open with the news item.  You may also control this newsfeed by pressing either of the buttons below.";
var Para = null;
var tNode = null;
var ahref = null;

if(navigator.javaEnabled()) {

  Para = document.createElement("p");
  tNode = document.createTextNode( strAppDirs );
  Para.setAttribute("class","tiny");
  
  ahref = document.createElement("a");
  ahref.setAttribute("href","javascript: void(document.getElementById('botblock').style.display='none');");
  ahref.appendChild( document.createTextNode("[ Hide ]") );
  Para.appendChild( tNode );
  Para.appendChild( ahref );
  
  document.getElementById("botblock").appendChild( Para );
  
}

// seems to be a bug in using java with firefox on mac
/*
doesn't work with ffx 3.6+ b/c java now a plugin!
if ( !navigator.javaEnabled()  ) {
   Para = document.createElement("p");
   ahref = document.createElement("a");
   ahref.setAttribute("class","eightyFive");
   ahref.setAttribute("href","./newscacher.php?news=ns&amp;url=f4ns");
   ahref.appendChild( document.createTextNode("Read All About It") );
   Para.appendChild( ahref );
   document.getElementById("readAllDiv").appendChild( Para );
   document.getElementById("readAllDiv").style.display="block";
} 
*/



function Bye()
{
alert('Thank you for visiting. You are now going offsite; please hit the browser back button to return.');
}

function showVal(str)
{
document.getElementById('floval').innerHTML=str;

}

function noVal(str)
{
document.getElementById('floval').innerHTML=str;
}


// cookie stuff
var bo_stat=0;
var noshow=1;
function getCookie(name)
{

	var allcookies = document.cookie;
      var start='';
      var endpos='';
      var value='';

	if (document.cookie.length == 5){  // Bou=0/1
  		bo_stat = unescape(document.cookie.split("=")[1]);
	}
	else 	if (document.cookie.length > 5){
	      start = allcookies.indexOf(name+"=");
		if (start != -1){
		      start += name.length + 1;
			endpos = allcookies.indexOf(";",start);
			if (endpos == -1) endpos = document.cookie.length;  
			value = unescape(allcookies.substring(start,endpos));
			bo_stat = value;
		} else {
                  noshow=1;
                }//inner-if
                
	}//outer-if
     
         
}

function setCookie (name, value) {
// Set the cookie
		document.cookie = name + '=' + escape(value);
}



function BouquetToggle(){
   if (document.getElementById("osa").style.display=='none') {
			document.getElementById("flobut").style.display = 'none';
	       	window.focus();
 
            document.getElementById("osa").style.display='block';

			//document.getElementById("MyImage0").title = "Click to Collapse or Press Alt-O and ENTER";
      			if ( noshow == 1 ){   // execute light show once.
		  		        Domino(); // hi-lite each link of interest
                    	noshow=0;
			    }
			setCookie('Bou','1');
	} else {
	  //document.getElementById("MyImage0").title = "Click to Expand or Press Alt-O and ENTER";
      document.getElementById("osa").style.display='none';
      document.getElementById("flobut").style.display = 'block';
      window.focus();
	  setCookie('Bou','0');

   }
	getCookie('Bou'); // get new cookie values if any
}

function Decorate(str)
{
    eval("document.getElementById('" + str + "').style.textDecoration='underline'");
}

function unDecorate(str)
{
    eval("document.getElementById('" + str + "').style.textDecoration='none'");
}

function ChangeSign()
{
document.getElementById('MyImage0').textContent =  (document.getElementById('MyImage0').textContent==' [-] ')?  ' [+] ' : ' [-] ';
}        

getCookie('Bou');
if (bo_stat==0) {
 document.getElementById("flobut").style.display='block';
}



var TIMEDELAY=4.5;   
function WorkIt(usecode, d, j)
{
    setTimeout(usecode, d * j);
}

function hilite(theImg)
{
	var flower = eval( "document.getElementById('" + theImg + "')" ); 
	flower.src = document.getElementById("hilited").src;
}

function restore(theImg)
{
    var flower = eval( "document.getElementById('" + theImg + "')" );
	flower.src = document.getElementById("restored").src;
}

function HiSix(c,delay)
{
	WorkIt("hilite('BEC6')", delay, c);
	c += TIMEDELAY;
	WorkIt("restore('BEC6')", delay, c);
	c += TIMEDELAY;
	return c;
}
      
function counter_clockwise(c,delay)
{
	for (i=6,counter=c; i >= 1; i--,counter++)
	{
   		code = "hilite('BEC" + i  + "')";
   		WorkIt(code, delay, counter);
	   	code = "restore('BEC" + i + "')";
   		counter += TIMEDELAY;
   		WorkIt(code, delay, counter);
  	}
  	HiSix(counter,delay);
}

function clockwise(c,delay)
{
	c = HiSix(c,delay);
	for (var i=1,counter=c; i <= 6; i++,counter++) {
		code = "hilite('BEC" + i  + "')";
   		WorkIt(code, delay, counter);
	   	code = "restore('BEC" + i + "')";
   		counter += TIMEDELAY;
   		WorkIt(code, delay, counter);
	} //end for
	return counter;
}

function Domino()
{
	var delay=130;   // was 100
	var c=5;
	var today = new Date();
	var secs = today.getSeconds();

	if ( (secs/3) && (secs % 3 == 0) )
	{
		counter_clockwise(c,delay);
	} 
	else if ((secs/2) && (secs % 2 == 0)){
		clockwise(c,delay);
	}
	else 
	{
		c = clockwise(c,delay);
		counter_clockwise(c,delay);
	}// end else
}// end function

 
// version for non-MSIE browsers:
function CloseNGo()
{
     // check for popup whether max or fs.
     if (window.opener)
	 {
          window.opener.location.href = "b_opts.php";
          self.close();
     } 
	 else
	 {
	    location.href = "b_opts.php";
	 }
}//end CloseNGo()

function toggleFairPayWidget()
	{
	    var widget = document.getElementById('fairpay');
		var tog    = document.getElementById('wgcToggle');
		
		if (widget.style.display == 'block') {
		     tog.textContent = '+'; 
			 widget.style.display='none';
		}
		else
		if (widget.style.display == 'none') {
		    tog.textContent = '-';
			widget.style.display = 'block';
		}  
	}

 