/* for the facebook share link */
function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}



function showMe(myTarget){
	if(!document.getElementById){
		return false;
	}
	if(document.getElementById(myTarget)){
		document.getElementById(myTarget).className = "showMe";
		return false; // keep my link from doing anything
	}
	return false;
}

function hideMe(myTarget){
	if(!document.getElementById){
		return false;
	}
	if(document.getElementById(myTarget)){
		document.getElementById(myTarget).className = "hideMe";
		return false; // keep my link from doing anything
	}
	return false;
}


/* open in new window code */
/* generic popup window function to act as an interface to window.open() 
* DOM Scripting (88) */
function popUp(winURL, title, w, h){
	d = "width=" + w + ",height=" + h;
	window.open(winURL, title, d);
}

/* function to handle thumbnails replacing main image in portfolio/project.php */
function prep_emailThisLinks(){
	if(!document.getElementsByTagName || !document.getElementById){
		return false;
	}
	if(document.getElementById("shell")){
		var box = document.getElementById("shell");
		if(document.getElementsByTagName("a")){
			var links = box.getElementsByTagName("a");
			for (var i=0; i<links.length; i++){
				if(links[i].className == "emailThisLink"){
					links[i].onclick = function(){
						popUp(this.getAttribute("href"), this.name, 550, 700);
						return false;
					}
				}
			}
		}
	}
}
addLoadEvent(prep_emailThisLinks);

/* function to look for links that will close a window
 * 
 */
function prep_windowCloseLinks(){
	if(!document.getElementsByTagName){
		return false;
	}
	if(document.getElementsByTagName("a")){
		var links = document.getElementsByTagName("a");
		for (var i=0; i<links.length; i++){
			if(links[i].className == "js_closeWindow"){
				links[i].onclick = function(){
					close();
					//return false;
				}
			}
		}
	}
}
addLoadEvent(prep_windowCloseLinks);

/* function to show the additional comment/account fields in the blog comment area */
function prep_createAccountCheckbox(){
	if(!document.getElementsByTagName || !document.getElementById){
		return false;
	}
	if(document.getElementById("createAccount")){
		var clicker = document.getElementById("createAccount");
		clicker.onclick = function(){
			var target = document.getElementById("comment_optional");
			var box = document.getElementById("shell");
			target.style.display = "block";
			box.style.minHeight = (box.scrollHeight + 200) + "px";
		}
	}
}
addLoadEvent(prep_createAccountCheckbox);

/* to resize height of #page_content in the event that a single blog post is too tall */
function prep_contentHeight(){
	if(!document.getElementsByTagName || !document.getElementById){
		return false;
	}
	if(document.getElementById("blog_post_content")){
		var ruler = document.getElementById("blog_post_content");
		if(document.getElementById("shell")){
			var target = document.getElementById("shell");
			var theH = ruler.scrollHeight;
				if(target.scrollHeight < ruler.scrollHeight){
					target.style.height = (ruler.scrollHeight + 60) + "px";
				}
			}
		}
		/* additional browser dependent stuff that may need to get used
		if(document.getElementById("indexContent") && navigator.appName != "Microsoft Internet Explorer"){
			var indexContent = document.getElementById("indexContent");
			var outershell = document.getElementById("outershell");
			outershell.style.height = (indexContent.scrollHeight + 295) + "px";
			} */
	}
addLoadEvent(prep_contentHeight);


/* global resources */

/* function to simply multiple functions in window.onload
* DOM Scripting (103) :: Simon Willison (http://simon.incution.com) */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}
	else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}
