
/* ---------------------------- =Popup Window -------------------------------*/

function popupWindow (url, name, width, height, properties) {
	if (!name) name = "popWin";
	if (!width) width = "700";
	if (!height) height = "480";
	
	var features = "width=" + width + ",height=" + height;

	//	-- properties --
	//	not set or false    : standard clean window with no address bar, etc.
	//	some string         : use the string
	
	if (!properties || properties == false) {
		features += ",left=100,top=100,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1";
	} else {
		features += properties;
	}
	
	var popWin = window.open(url, name, features);	
	checkPopped(popWin);
	return popWin;
}

function checkPopped (winName) {
	if (winName)
		winName.focus();
	else {
	    var popupWarning = 'Pop-up blocking software in your browser has prevented us from opening a new window. In order for this site to function properly please disable your Pop-up blocking software for this site.';
		alert(popupWarning);
		return;
	}
}


/* ---------------------------- =Toggle Display -------------------------------*/

// elmID          : ID of element to toggle
// defaultDisplay : Overides the default display for an element (block, inline, none)
// force          : If set to true, forces the element to use the defaultDisplay (overides toggling)

function toggleDisplay (elmID, defaultDisplay, force) {
	// Get the style property of our element
	if (document.getElementById) {
		// standards way
		var elmStyle = document.getElementById(elmID).style;
	} else if (document.all) {
		// old msie version way
		var elmStyle = document.all[elmID].style;
	} else if (document.layers) {
		// nn4 way
		var elmStyle = document.layers[elmID].style;
	}
	
	// Force display to defaultDisplay if force is set
	if (force)
	{
		elmStyle.display = defaultDisplay; return;
	}
	// If there is no defaultDisplay set check the default state for the element
	else if (!defaultDisplay)
	{
		var elmType = document.getElementById(elmID).tagName.toLowerCase();
		if (elmType == 'a' || elmType == 'span' || elmType == 'strong' || elmType == 'em')
			var defaultDisplay = 'inline';
		else
			var defaultDisplay = 'block';
	}
	
	// If not forced toggle it's display
	if (elmStyle.display == 'none') {
		// if set to 'none' toggle to whatever the default for this element is
		elmStyle.display = defaultDisplay;
	} else {
		// if set to 'block' or default (which can't be read but is 'block')
		// toggle to 'none'
		elmStyle.display = 'none';
	}
}



/* ---------------------------- =Social Bookmarks -------------------------------*/

function socialBookmark(service, url, title)
{
	var newLocation;

	if (service == "digg")
		newLocation = 'http://digg.com/submit?phase=2&url=' + escape(url);
	else if (service == "delicious")
		newLocation = 'http://del.icio.us/post?v=2&url=' + escape(url) + '&title=' + escape(title);
	else if (service == "reddit")
		newLocation = 'http://reddit.com/submit?title=' + escape(title) + '&url=' + escape(url);
	else if (service == "technorati")
		newLocation = 'http://technorati.com/faves?sub=favthis&add=' + escape(url);
	else if (service == "stumbleupon")
		newLocation = 'http://www.stumbleupon.com/submit?title=' + escape(title) + '&url=' + escape(url);

	//alert(newLocation);

	location.href = newLocation;
}

function selectedIndexChangedSetHidden(ddl, hid){
	if (ddl.options && typeof(ddl.selectedIndex) == "number" && ddl.options.length > ddl.selectedIndex){
		hid.value = ddl.options[ddl.selectedIndex].value;
		
		var frm = document.forms[0];
		frm.submit();
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function selectedIndexChangedSetCookie(ddl, cookiename, controlToPage){
	if (ddl.options && typeof(ddl.selectedIndex) == "number" && ddl.options.length > ddl.selectedIndex){
		createCookie(cookiename, ddl.options[ddl.selectedIndex].value, 1);

		var regex = new RegExp("(" + controlToPage + "=[0-9]+)", "");
		var frm = document.forms[0];
		var newUrl = frm.attributes["action"].nodeValue.replace(regex, controlToPage + "=0");
		frm.attributes["action"].nodeValue = newUrl;
		
		// var frm = document.forms[0];
		// frm.submit();
	}
}

/* ---------------------------- Suckerfish Dropdowns -------------------------*/

sfHover = function() {
    if(document.getElementById("navlist") != null)
    {
	    var sfEls = document.getElementById("navlist").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"), "");
		    }
	    }
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// Mail To

function mailTo(username, domain)
{
	document.location = 'mailto: ' + username + '@' + domain + '?subject=Web Site Contact';
}


