// Integration function. Add custom code here
function ClickTale_WhenAvailableCallback() {
	
    window.ClickTaleCookieDomain = "igindex.co.uk";
	ClickTale(8876,1,"www07");
}
 
function ClickTale_GetRecorderFileUrl() {
	return "https://clicktale.pantherssl.com/WRc7.js";
}
 
window.CallClickTaleWhenAvailable = function() {
	// on first call, remove the function from the window
	window.CallClickTaleWhenAvailable = undefined;
 
	var loopCount = 0,
		// set to maximum number of tries running clicktale on page
		loopMax = 200;
 
	function CheckForClickTale() {
		if(typeof ClickTale == "function") {
			if(typeof ClickTale_WhenAvailableCallback != "function") return;
			ClickTale_WhenAvailableCallback();
		} else if(loopCount < loopMax) {
			loopCount++;
			setTimeout(arguments.callee, 100);
		}
	}
 
	// the first call
	CheckForClickTale();
};
// minified version of window.CallClickTaleWhenAvailable
// window.CallClickTaleWhenAvailable=function(){window.CallClickTaleWhenAvailable=undefined;var a=0,b=200;function c(){if(typeof ClickTale=="function"){if(typeof ClickTale_WhenAvailableCallback!="function"){return}ClickTale_WhenAvailableCallback()}else{if(a<b){a++;setTimeout(arguments.callee,100)}}}c()};
 
document.write('<div id="ClickTaleDiv" style="display: none;"></div>');
document.write('<script src="' + ClickTale_GetRecorderFileUrl() + '" type="text/javascript"></script>');
document.write('<script type="text/javascript">');
document.write('var ClickTaleSSL=1;');
document.write('window.CallClickTaleWhenAvailable();');
document.write('</script>');

function CTIsPlayback() {
   try { return parent && parent.WebPlayer; }
   catch(e) { return false; }
}
if(CTIsPlayback())
{
    document.body.style.position = "static";
}

if (typeof jQuery == 'function') {
    //add event on login
    jQuery(document).ready(function () {
        jQuery("form#login").live('submit',function () {
            if (typeof ClickTaleTag == 'function' && jQuery("input#password").val() != "" && jQuery("input#account_id").val() != "") {
                ClickTaleTag("Logged In");
            }
        });

        // main nav in agg reports
        try {
            ClickTaleContext.getAggregationContextAsync("1", function (context) {
                jQuery("ul#navigation > li").addClass("dropdown");
                jQuery("ul#navigation > li > div").css({ "display": "block", "visibility": "hidden" });
            });
        }
        catch (e) { }        
    });
}
