var cl = cl || {};
var uri = location.href.parseUri();
var URL_DOMAIN = uri.protocol + "://" + uri.host;

var SpinnerHtml = '<span class="spinnerText"><img src="/images/global/ajax-loading.gif" width="14" height="14"> Loading ...</span>';

var BehaviorRollover = 'def_rollover';

NO_USER_NOTIFY = 0;

// Create an image object for the livechat button.
// We want to do this asap because this image sometimes takes a while to load
// due to the logic and roundtrip time to query the liveperson server.
// I put this in this file due to its dependence on the above uri object.

// removed per bug 45928 - JDD

// var liveChatButtonImageObj = new Image();
// liveChatButtonImageObj.src = uri.protocol+'://service.liveperson.net/hc/24631554/?cmd=repstate&site=24631554&channel=web&&ver=1&imageUrl='+URL_DOMAIN+'/images/global/livepersonSm&skill=Clinique';
// liveChatButtonImageObj.name="hcIcon";
// liveChatButtonImageObj.style.border="0";

// Load any livechat links with the button above
var loadLiveChatButtons = function() {
	$$('a.livechat-image-tag').each(function(el){
		if ( el.empty() ) {
			var img = new Image();
			img.src = liveChatButtonImageObj.src;
			img.name = liveChatButtonImageObj.name;
			img.style.border = liveChatButtonImageObj.style.border;
			el.update(img);
		}
	});
}

/* old ELC front-end interface compatibility */
var el = $;
Element.addMethods({
    addBehavior: function(e,b){
        $(e).className = b;
    }
});

// Added this so we can check for boolean settings in html-template files.
// That's cuz this gives an error if no value is set: obj.checked = ( #{VAL} ? true : false )

// Why not toBool() method off the extended String object??? Think OO!!! '#{VAL}'.toBool() - CM

function CheckBooleanVar(val) {
	if ( val ) return true;
	return false;	
}

flashHandlerCallbacks = {};

function flashHandlerNamer ( flash_id, event_name ) {
    return flash_id.toLowerCase() + ':' + event_name.toLowerCase();
}

function addFlashHandlerCallback ( id, evt, func ) {
    flashHandlerCallbacks[ flashHandlerNamer ( id, evt  ) ] = func ( id, evt );
}

flashToJavascript = function ( flash_id, event_name ) {
    var idEvt = flashHandlerNamer ( flash_id, event_name );
    var handler = flashHandlerCallbacks[ idEvt ];
    if ( typeof handler == 'function' ) {
        handler( flash_id, event_name );
        return true;
    } else { return false; }
};

/* FLASH TEST FUNCTIONS

    addFlashHandlerCallback ( 'test', 'test', 
        function ( id, evt ) {
            alert ( flashHandlerNamer ( id, evt ) + ' is found.' ) });
    flashToJavascript ('test', 'test');

END TEST FUNCTIONS */
