// Suckerfish dropdown JS
function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}

sfHover = function(sfEls) {
	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"), "");
		}
	}
}
suckerfish(sfHover, "li", "nav");
suckerfish(sfHover, "li", "topnav");

//functions for admin section
function confirmDelete(whichOne) {
	var answer=confirm("Are you sure you want to delete the entire " + whichOne + " database?!"); 
	
	if (answer) {
		var url = "http://www.nyu.edu/bronfman/new/admin/?p=wipe&t="+ whichOne;  
		window.location = url;
	} else {
		alert("Database not wiped."); 
	}
	
}

function deleteAd(whichOne) {
	var answer=confirm("Are you sure you want to delete this ad?"); 
	
	if (answer) {
		var url = "http://www.nyu.edu/bronfman/new/admin/?p=wipe&ad=1&id="+ whichOne;  
		window.location = url;
	}
}

function deleteBio(whichOne) {
	var answer=confirm("Are you sure you want to delete this staff member's bio? There IS NO UNDO!!"); 
	
	if (answer) {
		var url = "http://www.nyu.edu/bronfman/new/admin/?p=wipe&staffbios=1&id="+ whichOne;  
		window.location = url;
	}
}


function deleteEvent(whichOne) {
	var answer=confirm("Are you sure you want to delete this calendar event?"); 
	
	if (answer) {
		var url = "http://www.nyu.edu/bronfman/new/admin/?p=wipe&calendar=1&id="+ whichOne;  
		window.location = url;
	}
}

function deleteRegForm(whichOne) {
	var answer=confirm("Are you sure you want to delete this registration form?"); 
	
	if (answer) {
		var url = "http://www.nyu.edu/bronfman/new/admin/?p=wipe&genreg=1&id="+ whichOne;  
		window.location = url;
	}
}



function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name, 
  'width=' + w + ', height=' + h + ', ' +
  'location=yes, menubar=yes, ' +
  'status=yes, toolbar=yes, scrollbars=yes, resizable=yes');
 win.resizeTo(w, h);
 win.focus();
}
