/********************************************************************
**	Original Author: 
**	Date: 
**	Purpose: 
**
**
*********************************************************************
**	Revision History:
**	JC: 1/24/2011 Added for auto-suggest search box initialization.
**
********************************************************************/ 

function ConfirmAction(url) {
	if (confirm('Are you sure you want to do this?')) {
		window.location = url;
	}
	return;
}

// PH: 03/29/2006
// Pop up live help chat window.  Stolen from popupwin2 code used to send to a friend
// PH: 05/30/2006 Renamed window name...  Was using the same window name as the more info window
// when a customer would click on more info while in chat, it would overwrite the chat window
function popupLiveHelpChat(options)
{
	var left = 80 ;
	var top = 40 ;
	var width = 419 ;
	var height = 320 ;
	var source = "/lh/livehelp.cfm";
	var options = "scrollbars=no" ;
	var windowproperties = options + ",left=" + left + ",top=" + top + ",width=" + width + ",height=" + height ;
	popup = window.open(source,"PopupLiveChat",windowproperties) ;
	popup.focus() ;
}

// BPW 8/20/2011 - added new function
function openit(sURL,tWidth,tHeight,showToolbar,windowName) {
	tWidth = tWidth ? tWidth : 400;
	tHeight = tHeight ? tHeight : 400;
	showToolbar = showToolbar ? showToolbar : 'no';
	windowName = windowName ? windowName : 'popup'; // allows more than one popup to be opened from common parent window
	newwindow=open(sURL,windowName,"scrollbars=yes,toolbar=" + showToolbar + ",directories=no,menubar=no,resizable=yes,status=yes,width=" + tWidth + ",height=" + tHeight);
	if(newwindow.focus) {newwindow.focus();} // bring window to front if already open
}

function resetSearchBox(box, defaultvalue){
	if(box.value==defaultvalue){
		box.value = "";
	}
}

//MH: 11/8/11 added to fix js error's
if ((typeof Range !== 'undefined') && !Range.prototype.createContextualFragment) {
Range.prototype.createContextualFragment = function(html) {
	var frag = document.createDocumentFragment();
	var div = document.createElement('div');
	frag.appendChild(div);
	div.outerHTML = html;
	return frag;
	};
}

// helper function for colorbox
function getRevProp(rev,prop) {
	var result = '';
	if (typeof rev != 'undefined')
	{
		var aStyles = rev.split(';');
		for (var i = 0; i < aStyles.length; i++) {
			if (aStyles[i].indexOf(prop) >= 0) {
				result = aStyles[i].replace(prop, '');
				result = $.trim(result);
				break;
			}
		}
		return result;
	}
}

$(document).ready(function(){
sli_init() ; // JC: 1/24/2011 Added for auto-suggest search box initialization.
// associate rel=lyteframe with jquery.colorbox
$("a[rel='lyteframe']").colorbox({
	iframe:true,
	innerWidth: function(){
		var w = getRevProp($(this).attr('rev'),'width:');
		w = w ? w : '420px' ;
		return w;
		},
	innerHeight: function(){
		var h = getRevProp($(this).attr('rev'),'height:');
		h = h ? h : '300px' ;
		return h;
		},
	opacity:0.25,
	rel:'nofollow',
	speed:350 });
})

