/* FW100.091027 */
/* (c)2009 SugarHill Works LLC - http://www.sugarhillworks.com */

var newWin, rootPath='';

function getRootPath() {
	// set the linkHome variable which is used to create rootPath
	var fullUrl = window.location.toString();
	if(fullUrl.search(/localhost|\.local\/\~|http\:\/\/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/\~[a-zA-Z0-9_-]+\/?/) > -1) {
		var tmpUrl = fullUrl.replace(/.*\/\~[a-zA-Z0-9_-]+\/?/, '');
		var urlChunks = tmpUrl.split(/\//);
		rootPath = (fullUrl.match(/.*\/\~[a-zA-Z0-9_-]+\/?/)) + urlChunks[0] + '/';
	}
	else if (fullUrl.search(/clientsites/) > -1) {
		rootPath = (fullUrl.match(/(?:.*clientsites.sugarhillworks.com\/[a-zA-Z0-9_-]+\/?)|(?:.*sugarhillworks\.com\/clientsites\/[a-zA-Z0-9_-]+\/?)/)).toString();// + urlChunks[0] + '/';
	}
	else {
		rootPath = fullUrl.match(/http\:\/\/(?:[a-zA-Z0-9_-]+\.{1})*[a-zA-Z0-9_-]+\.{1}[a-zA-Z]{2,4}/).toString() +'/';
	}
	return rootPath;
}

var isitIE = false;
var isitIE8 = false;
var isitIE7 = false;
var isitIE6 = false;
if (window.attachEvent && !window.opera) { //object-detect IE5+, exclude opera
	isitIE = true;
	if(navigator.appVersion.match(/MSIE 8/)) { isitIE8 = true; }
	if(navigator.appVersion.match(/MSIE 7/)) { isitIE7 = true; }
	if(navigator.appVersion.match(/MSIE 6/)) { isitIE6 = true; }
	document.write("<meta HTTP-EQUIV=\"imagetoolbar\" content=\"no\">");
}

var isitFF2 = false;
var isitFF2mac = false;
var userAgent = navigator.userAgent.toLowerCase();
if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
	var ffversion = new Number(RegExp.$1);
	if (ffversion < 3){
		isitFF2 = true;
	}
}
if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
	var ffversion = new Number(RegExp.$1);
	if ((ffversion < 3) && (userAgent.indexOf('mac') != -1)) {
		isitFF2mac = true;
	}
}

if (!window.Node) {
	var Node = {
		ELEMENT_NODE: 1,
		ATTRIBUTE_NODE: 2,
		TEXT_NODE: 3,
		COMMENT_NODE: 8,
		DOCUMENT_NODE: 9,
		DOCUMENT_FRAGMENT_NODE: 11
	};
}

function randOrd(){
	return (Math.round(Math.random())-0.5);
}

$(window).ready(function(){
	getRootPath();
	// set up  menu
	if ($('#menu_cntr').length > 0) {
		ddsmoothmenu.init({
			mainmenuid: "smoothmenu1", //menu DIV id
			orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
			classname: 'ddsmoothmenu', //class added to menu's outer DIV
			showArrows: false,
			//customtheme: ["#1c5a80", "#18374a"],
	//		contentsource: ["menu_cntr",  rootPath+"shw_menu/menu.html"] //"markup" or ["container_id", "path_to_menu_file"]
			contentsource: ["menu_cntr",  rootPath+"shw_menu/menu.html"] //"markup" or ["container_id", "path_to_menu_file"]
		});
	}

//set up scroll panes
	if ($('.scroll-pane').length > 0) {
		$(function()
		{
			$('.scroll-pane').jScrollPane({
				scrollbarWidth: 15, // the width of the created scrollbar in pixels (defaults to 10)
				//scrollbarMargin [int] - the margin to leave to the left of the scrollbar in pixels (defaults to 5)
				//wheelSpeed [int] - controls how fast the mouse wheel makes the content scroll in pixels (defaults to 18)
				showArrows:true, // controls whether to display arrows for the user to scroll with (defaults to false)
				arrowSize: 16, // the height of the arrow buttons if showArrows=true (calculated from CSS if not provided)
				animateTo: true // whether to animate when calling scrollTo and scrollBy (defaults to false)
				//dragMinHeight [int] - the minimum height to allow the drag bar to be (defaults to 0)
				//dragMaxHeight [int] - the maximum height to allow the drag bar to be (defaults to 99999!)
				//animateInterval [int] - The interval in milliseconds to update an animating scrollPane (default 100)
				//animateStep [int] - The amount to divide the remaining scroll distance by when animating (default 3)
				//maintainPosition [boolean] - Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true)
				//scrollbarOnLeft [boolean] - Whether the scrollbar should appear on the left hand side of the panes content (make sure your CSS also reflects this)
				//reinitialiseOnImageLoad [boolean] - Whether the jScrollPane should automatically re-initialise itself when any contained images are loaded (defaults to false)
			});
		});
	}
	
	if ($('#main_thms_cntr').length > 0) {
		//$(window).load(function()
		$(function() {	
			//alert($('#main_thms_cntr').height());//alert($("#ssThm_15").load());
			//hscrh = 25;
		});
	}
});
var hscrh;