site1 = new Image();site1.src = "/images/bg-flowers.jpg";
site2 = new Image();site2.src = "/images/content-bg.png";
nav1 = new Image();nav1.src = "/images/nav2-home-over.gif";
nav2 = new Image();nav2.src = "/images/nav2-about-over.gif";
nav3 = new Image();nav3.src = "/images/nav2-portfolio-over.gif";
nav4 = new Image();nav4.src = "/images/nav2-details-over.gif";
nav5 = new Image();nav5.src = "/images/nav2-clients-over.gif";
nav6 = new Image();nav6.src = "/images/nav2-blog-over.gif";
nav7 = new Image();nav7.src = "/images/nav2-contact-over.gif";
nav8 = new Image();nav8.src = "/images/nav2-search-over.gif";
footer1 = new Image();footer1.src = "/images/footer2-email-over.gif";
footer2 = new Image();footer2.src = "/images/footer2-facebook-over.gif";
footer3 = new Image();footer3.src = "/images/footer2-twitter-over.gif";
footer4 = new Image();footer4.src = "/images/footer2-subscribe-over.gif";

function nav(imgName, state) {
	document.images[imgName].src = "/images/nav2-" + imgName + "-" + state + ".gif";
}
var siteWidth = 970;
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(timeout_id != null)
		self.clearTimeout(timeout_id);
}
function popupon(index, leftPx) {
	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 = 71;
		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(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) {
	var commentWin = window.open("/comments_add.cfm?postID=" + postID, "commentWin", "width=650,height=450,scrollbars=yes,resizable=yes");
	commentWin.focus();
}
function emailList() {
	var emailWin = window.open("/email_list.cfm", "emailWin", "width=650,height=450,scrollbars=yes,resizable=yes");
	emailWin.focus();
}
function viewVideo() {
	var videoWin = window.open("/tira-in-action-video.cfm", "videoWin", "width=700,height=450,scrollbars=yes,resizable=yes");
	videoWin.focus();
}
function viewGallery(galleryID) {
	var galleryWin = window.open("/galleries.cfm?galleryID=" + galleryID, "galleryWin", "width=940,height=670,scrollbars=no,resizable=no");
	galleryWin.focus();
}
function postFacebook(u,t) {
	var shareWin = window.open("http://www.facebook.com/sharer.php?u=" + u + "&t=" + t, "shareWin", "width=650,height=450,toolbar=0,status=0");
	shareWin.focus();
}
function postTwitter(u,t) {
	var shareWin = window.open("http://twitter.com/share?url=" + u + "&title=" + t, "shareWin", "width=650,height=450,toolbar=0,status=0");
	shareWin.focus();
}

$(function() {
	$('.btnbar a img, .rollover').hover(
		function () {
			$(this).attr('src', $(this).attr('src').replace(/-off.gif/, '-over.gif'));
		},
		function () {
			$(this).attr('src', $(this).attr('src').replace(/-over.gif/, '-off.gif'));
		}
	);
});

