// adds active flash object to the page
function loadFlash(flashMovie, width, height) {
	// document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" align="middle"><param name="allowScriptAccess" value="sameDomain"><param name="movie" value="' + flashMovie + '"><param name="quality" value="high"><embed src="' + flashMovie + '" quality="high" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>');
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" align="middle"><param name="allowScriptAccess" value="sameDomain"><param name="wmode" value="transparent"><param name="movie" value="' + flashMovie + '"><param name="quality" value="high"><embed src="' + flashMovie + '" quality="high" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>');
}

if(document.images) {
	// preload
	site1 = new Image();
	site1.src = "/images/bg-tile.jpg";
	site2 = new Image();
	site2.src = "/images/nav-bg.gif";
	site3 = new Image();
	site3.src = "/images/body-bg.gif";
	image1 = new Image();
	image1.src = "/images/nav-categories-over.gif";
	image2 = new Image();
	image2.src = "/images/nav-portfolio-over.gif";
	image3 = new Image();
	image3.src = "/images/nav-about-over.gif";
	image4 = new Image();
	image4.src = "/images/nav-links-over.gif";
	image5 = new Image();
	image5.src = "/images/nav-contact-over.gif";
	image6 = new Image();
	image6.src = "/images/nav-rss-over.gif";
	image7 = new Image();
	image7.src = "/images/nav-search-over.gif";
	image8 = new Image();
	image8.src = "/images/btn-view-comments-over.gif";
	image9 = new Image();
	image9.src = "/images/btn-hide-comments-off.gif";
	image10 = new Image();
	image10.src = "/images/btn-hide-comments-over.gif";
	image11 = new Image();
	image11.src = "/images/btn-add-comment-over.gif";
	image12 = new Image();
	image12.src = "/images/btn-link-over.gif";
	image13 = new Image();
	image13.src = "/images/btn-email-over.gif";
	image14 = new Image();
	image14.src = "/images/btn-older-over.gif";
	image15 = new Image();
	image15.src = "/images/btn-newer-over.gif";
}
function nav(imgName, state) {
	document.images[imgName].src = "/images/nav-" + imgName + "-" + state + ".gif";
}
var siteWidth = 974;
function getWidth() {
	var n_win = window.innerWidth ? window.innerWidth : 0;
	var n_docel = document.documentElement ? document.documentElement.clientWidth : 0;
	var n_body = document.body ? document.body.clientWidth : 0;
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	var currentWidth = n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
	if(currentWidth < siteWidth)
		return siteWidth;
	else
		return currentWidth;
}
var old_index = 0;
var timeout_id;
function clear_timeouts() {
	if(document.getElementById) {
		if(timeout_id != null)
			self.clearTimeout(timeout_id);
	}
}
function popupon(index, leftPx) {
	if(document.getElementById) {
		clear_timeouts();
		if(old_index != 0) {
			if(document.getElementById(old_index + "Sub"))
				document.getElementById(old_index + "Sub").style.display = "none";
			nav(old_index, "off");
		}
		if(document.getElementById(index + "Sub")) {
			document.getElementById(index + "Sub").style.top = 540;
			document.getElementById(index + "Sub").style.left = ((getWidth() - siteWidth) / 2) + leftPx; 
			document.getElementById(index + "Sub").style.display = "inline";
		}
		nav(index, "over");
		old_index = index;
	}
}
function popupoff() {
	if(document.getElementById) {
		if(old_index != 0)
			timeout_id = setTimeout("if(document.getElementById(old_index + 'Sub'))document.getElementById(old_index + 'Sub').style.display = 'none';nav(old_index, 'off');", 100);
	}
}

function addComment(postID) {
	if(document.getElementById("commentDiv" + postID).style.display == "none")
		viewComments(postID);
	var commentWin = window.open("/comments_add.cfm?postID=" + postID, "commentWin", "width=650,height=450,scrollbars=yes,resizable=yes");
	commentWin.focus();
}
function viewComments(postID) {
	if(document.getElementById("commentDiv" + postID).style.display == "none") {
		document.getElementById("commentDiv" + postID).style.display = "inline";
		document.getElementById("commentsShow" + postID).style.display = "none";
		document.getElementById("commentsHide" + postID).style.display = "inline";
	}
	else {
		document.getElementById("commentDiv" + postID).style.display = "none";
		document.getElementById("commentsShow" + postID).style.display = "inline";
		document.getElementById("commentsHide" + postID).style.display = "none";
	}
}

function viewGallery(galleryID) {
	var galleryWin = window.open("/portfolio.cfm?galleryID=" + galleryID, "galleryWin", "scrollbars=no,resizable=no");
	galleryWin.focus();
}


// Ondemand function to generate dynamic bit.ly urls
//function getBitlyUrl($url) {  
    // fill up this 2 lines below with your login and api key
  //  $bitlylogin = 'raebarnes';
    //$bitlyapikey= 'R_f89658d3b2bb85279d17dfe81c472921';
    
    
    // you dont need to change below this line
    //$bitlyurl = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl=".$url."&login=".$bitlylogin."&apiKey=".$bitlyapikey);  
     
    //$bitlycontent = json_decode($bitlyurl,true);

    //$bitlyerror = $bitlycontent["errorCode"];

    //if ($bitlyerror == 0){
    //    $bitlyurl = $bitlycontent["results"][$url]["shortUrl"];
    //}
    //else $bitlyurl = $url;

    //return $bitlyurl;
//}

