 /*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
	function toggleDisp() {
	    for (var i=0;i<arguments.length;i++){
		var d = $(arguments[i]);
		if (d.style.display == 'none')
		    d.style.display = 'block';
		else
		    d.style.display = 'none';
	    }
	}
	/*-----------------------------------------------------------
	    Toggles tabs - Closes any open tabs, and then opens current tab
	    Input:     1.The number of the current tab
			    2.The number of tabs
			    3.(optional)The number of the tab to leave open
			    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
	    Output: none 
	    ---------------------------------------------------------*/
	function toggleTab(num,numelems,opennum,animate) {
	    if ($('tabContent'+num).style.display == 'none'){
		for (var i=1;i<=numelems;i++){
		    if ((opennum == null) || (opennum != i)){
			var temph = 'tabHeader'+i;
			var h = $(temph);
			if (!h){
			    var h = $('tabHeaderActive');
			    h.id = temph;
			}
			var tempc = 'tabContent'+i;
			var c = $(tempc);
			if(c.style.display != 'none'){
			    if (animate || typeof animate == 'undefined')
				Effect.toggle(tempc,'blind',{duration:0.5, queue:{scope:'menus', limit: 3}});
			    else 
				toggleDisp(tempc);
			
			    //Element.toggle(tempc);
			}
		    }
		}
		var h = $('tabHeader'+num);
		if (h)
		    h.id = 'tabHeaderActive';
		h.blur();
		var c = $('tabContent'+num);
		c.style.marginTop = '2px';
		
		if (animate || typeof animate == 'undefined'){
		    Effect.toggle('tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
		}else{
		    toggleDisp('tabContent'+num);
		} 
		//Element.toggle('tabContent'+num);
	    }
	}
	
// variables
	imageDir = '/images/social/'
	theURL = encodeURIComponent(document.location.href)
	theTitle = encodeURIComponent(document.title)
	
	// preload
	var myImages = new Array (	);
	var myPreload = new Array ();
	for (var i = 0; i < myImages.length; i++ )
	{
		myPreload[ i ]= new Image();
		myPreload[ i ].src = myImages[ i ];
	}
	
	// rollovers
	function imageOver(theImage,imageName) {
		theImage.src = imageDir + imageName
	}
	function imageOut(theImage,imageName) {
		theImage.src = imageDir + "bw/" + imageName
	}
	
	// bookmark
	 function CreateBookmarkLink() {
		
			if (window.sidebar) { // Mozilla Firefox Bookmark
				window.sidebar.addPanel(document.title, document.location.href,"");
			} else if( window.external ) { // IE Favorite
				window.external.AddFavorite( document.location.href, document.title); }
			else if(window.opera && window.print) { // Opera Hotlist
				return true; 
			} else {
				alert("Bookmark our site using one of the many featured online social tools.");
			}
	 }

function addToMyFavorites(objectID) {
	
		$('favorite').innerHTML = "<a href=\"#\" id=\"loading\">&nbsp;</a>";
	
		var url = "/actions/add_to_favorites.php";
		var params = "ajax=1&objectID=" + objectID;
		var aj = new Ajax.Request(
						url,
						{
							method: 'post',
							parameters: params,
							onSuccess: updateFavorite
						});
		return false;
}
function removeFromMyFavorites(objectID) {
	
		$('favorite').innerHTML = "<a href=\"#\" id=\"loading\">&nbsp;</a>";
	
		var url = "/actions/remove_from_favorites.php";
		var params = "ajax=1&objectID=" + objectID;
		var aj = new Ajax.Request(
						url,
						{
							method: 'post',
							parameters: params,
							onSuccess: updateFavorite
						});
		return false;
}
function updateFavorite(response) {
	$('favorite').innerHTML = response.responseText;
}

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

sfHover = function() {
	var sfEls = document.getElementById("nav").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);


function submitComment() {
		$('addcommentspin').innerHTML = "<a href=\"#\" id=\"loading\">&nbsp;</a>";
		var aj = new Ajax.Request(
						"/actions/add_comment.php",
						{
							method: 'post',
							parameters: "ajax=1&"+$('commentform').serialize(),
							onSuccess: function (response) { $('ajaxcomment').innerHTML = response.responseText; $('addcommentspin').innerHTML = ""; $('comment_form_title').value = "Title"; $('comment_form_text').value=""; }
						});
		return false;
}