function popwin(URL,name,width,height) {
	HorizPos = 0;
	VertPos = 0;
	if(screen) {
		HorizPos = (screen.width-width) / 2;
		VertPos = (screen.height-height) / 2;
	}
	varPopupWin=window.open(URL, name,'width='+width+',height='+height+',left='+HorizPos+',top='+VertPos+',scrollbars=yes,toolbar=no,menubar=no,resizable=yes');
	varPopupWin.focus(); 
}

//create an alias for popwin called popup
function popup(URL,name,width,height) {
	popwin(URL,name,width,height);
}
function Revelate(theContainer) {
	this._objectId;
	this.theContainerID = theContainer;
	this._containerObj = false;
	this.closeAll = true;
	this.tagSwap = "<ul>";
	this.openTracker = new Array();
	this._debug = true;
	this._execute = true;
	this.hideClass = "hidden";
	this.showClass = "block";

	this._constructor = function() { 
		if((this._containerObj = document.getElementById(this.theContainerID))==false) {
			this._execute = false;
			if(this._debug) {
				alert('could not detect the container in which you have instantiated this class!');
			}
		}
	}
	
	this.show = function(theOpen) {
		
		this._objectId = theOpen;
		if(this._execute) {
			//if(this.openTracker[theOpen]) {
				//this.hide(theOpen);
			//} else {
				if(theObj == document.getElementById(this._objectId)) {
					this.closeAll();
					this.trackOpen(theObj.className);

					tempS = theObj.className;
					tempS = tempS.replace(this.hideClass,"")
					theObj.className = this._trim(tempS);
					
					if(theObj.className == "labs"){
						document.getElementById("head_labs").className = this.showClass;
						document.getElementById("head_regions").className = this.hideClass;
					}else if(theObj.className == "sales"){
						document.getElementById("head_labs").className = this.hideClass;
						document.getElementById("head_regions").className = this.showClass;
					}

					

				} else if(this._debug) {
					alert('could not detect the object in which you wish to show!');
				}
			//}
		}
	}
	
	
	this.trackOpen = function(theClassName) {
		this.openTracker[this._objectId] = theClassName;
	}
	
	
	this.closeAll = function() {
		for(openJ in this.openTracker) {
			if(theTempO = document.getElementById(openJ)) {
				theTempO.className += " " + this.hideClass;
				delete this.openTracker[openJ];
			}
			
		}
	}
	
	this.hide = function(theClose) {
		if(this.closeAll==true) {
			this.closeAll();
		}
		if(theTempO = document.getElementById(theClose)) {
			theTempO.className += " " + this.hideClass;
			delete this.openTracker[theClose];
		}
	}
	
	this._trim = function(sInString) {
	  sInString = sInString.replace( /^\s+/g, "" );// strip leading
	  return sInString.replace( /\s+$/g, "" );// strip trailing
	}
	
}

myRevelation = new Revelate("labloc_right");


sfHover = function() {
	if(document.getElementById("admin_menu")){
	var sfEls = document.getElementById("admin_menu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
		
	}
	}
}


var dynamic_menus = true; // a value of true enables the menus, false disables them

var clock='';

var navitems  = new Array('aboutvlct', 'insuranceriskservices', 'resourcelibrary', 'municipalassistancecenter', 'eventscalendar', 'advocacy', 'marketplace', 'vermontlocalgovernment');
var navoffset = new Array('8',         '66',                    '171',             '248',                       '381',            '454',      '533',         '628');

function startTimer(divID) {
	clock = setTimeout( 'toggle("", "hide")', 350 );
}

function toggleObj(targetId, dowhat){
 
  	if (document.getElementById){
    	target = document.getElementById( targetId );
    
  		if (target.style.display == "none" && dowhat != 'hide' ){    
    		target.style.display = "";	
    	} else {
			if ( dowhat != 'show' ) {
      			target.style.display = "none";
			}
   		}
 	}

	return(false);

}

function toggle(targetId, how, offset){
 
  var dadivID = 'dd' + targetId;
 if(how == "show") {
	  
   }
  if (document.getElementById ){
   
	  switch ( how ) {
	  	case 'show' : 

			target = document.getElementById( dadivID );
	  		target.innerHTML = navA[targetId];

			target.style.display = "";

		    btntarget = document.getElementById( targetId );
			btntarget.style.background = "transparent url(/i/nav.gif) -" + offset + "px -66px no-repeat";
	  		break;

 		case 'hide' :
			for (var i=0; i<navitems.length; i++) {
	 			
	 			if ( navitems[i] != targetId ) {
	 			
		 			target = document.getElementById( 'dd' + navitems[i] );
					target.style.display = "none";
		  			if(document.getElementById( navitems[i] )) {
			  	    	btntarget = document.getElementById( navitems[i] );
						btntarget.style.background = "transparent url(/i/nav.gif) -" + navoffset[i] + "px 0 no-repeat";
					}
				}
			}
			
 			break;
	  }
	  
  }
}

function deleteProduct(prodID)
{
	new Ajax.Updater('product' + prodID, '/administration/bookstore.php?mode=delete&product=' + prodID, {onComplete: function() { new Effect.Fade('product' + prodID) }, asynchronous:true});
}

if (window.attachEvent) window.attachEvent("onload", sfHover);