/*
*
*	Tyndall Furniture Galleries Application Javascript
*	JJohnson | E-dreamz
*	Last Update: Feb. 2008
*
*/

/* Cache */
try {
	document.execCommand("BackgroundImageCache",false,true);
} catch (e) {
	
}

var popupLinkConfig = new Array;

popupLinkConfig["pop640"] = new Array ( "", "width=800,height=600,resizable=yes,scrollbars=no");

//on page load
$(document).ready(function() {
	initPopupLinks();
	initFurnitureSelect();
	initFurnHelp();
});

function initFurnitureSelect(){
	$("#room_select").change( function() { jsRedirect($("#room_select").val()) } );
}

function initFurnHelp(){
	$("#furn_help").mouseover(function(){
		$('#furn_help_text').css('display','block');
	});
	
	$("#furn_help_text").mouseover(function(){
		$('#furn_help_text').css('display','block');
	});
	
	$("#furn_help").mouseout(function(){
		$('#furn_help_text').css('display','none');
	});	
	
	$("#furn_help_text").mouseout(function(){
		$('#furn_help_text').css('display','none');
	});	
	
}

function jsRedirect(roomid){
	if(roomid.length){
		window.location = '/furniture/collection.cfm/room/'+roomid;
	}
}


function initPopupLinks(){		{
			  if (!document.getElementsByTagName) return true;
			  var pageLinks = document.getElementsByTagName("a");
			  for (var i = 0; i < pageLinks.length; i++) 
			  {
				if (((pageLinks[i].className != null) && 
					 (pageLinks[i].className != "")) ||
					((pageLinks[i].parentNode.className != null) && 
					 (pageLinks[i].parentNode.className != "")))
				{
				  var linkClass = " " + pageLinks[i].className + " ";
				  if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
				  {
					linkClass = " " + pageLinks[i].parentNode.className + " ";
				  }
				  for (var theKey in popupLinkConfig) 
				  {
					if (linkClass.indexOf(" " + theKey + " ") > -1)
					{
					  if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
					  {
						pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
					  }
					  pageLinks[i].settings = popupLinkConfig[theKey][1];
					  pageLinks[i].onclick = popUp;
					}
				  }
				}
			  }
			  return true;
			}
	function popUp(){
		newWin = window.open(this.href, this.target, this.settings);
		newWin.focus();
		return false;
	}
	}