// StatCounter Constants
var sc_project=3315615; 
var sc_invisible=0; 
var sc_partition=36; 
var sc_security="24a628e3"; 
//End of StatCounter Constants

//Google analytics
var google_conversion_id = 1067103583;
var google_conversion_language = "en_GB";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
//End of Google analytics
  
//AddThis
var addthis_pub="legalclarity";
var addthis_brand = "Legal Clarity";
var addthis_header_color = "#053A62";
var addthis_header_background = "#EAE683";
var addthis_options = 'favorites, linkedin, google, facebook, twitter, email, more';
var addthis_hover_delay = 100;
//End of AddThis

var PAGE_WIDTH = 900;

var SLIDE_TIMER_TICK = 5;
var SLIDE_TIMER_DURATION = 200;
var CURRENT_SLIDE_TOGGLE_GROUP = new Array();
var CAROUSEL_CURRENT_PAGE = 0;


function assessBrowser() 
{
    isIE = (document.all);
    isNS6 = (document.getElementById) && (!document.all);
    isNS = document.layers;
}

assessBrowser();

function getPageWidth() {
    return (window.innerWidth != null) ? window.innerWidth : 
            (document.body != null) ? document.body.clientWidth : null;
}

function getPageHeight() {
    return (window.innerHeight != null) ? window.innerHeight :
            (document.body != null) ? document.body.clientHeight : null;
}


function doOnLoad()
{
    doGoogleAnalytics();
}


function doGoogleAnalytics()
{
    trackPageVisit(null);
}


function trackPageVisit(pageName)
{
    if (typeof(_gat) == 'object')
    {
        try
        {
            var pageTracker = _gat._getTracker("UA-3223686-5");
            pageTracker._initData();
            if (pageName == null)
                setTimeout(pageTracker._trackPageview(), 1)
            else
                setTimeout(pageTracker._trackPageview(pageName), 1)
        }
        catch(err) 
        {} 
    }
}


function getDiv(divName)
{
    var div;
    if (isNS) 
        div = eval("document." + divName);
    else if (isIE) 
        div = eval("document.all." + divName);
    if (div == null)
        div = document.getElementById(divName);

    return div;
}

function getDivStyle(divName)
{
    var div = getDiv(divName);
    var style = div;
    if (div.style != null)
        style = div.style;
        
    return style;        
}
 
function getEm()
{
    return getDiv("emSize").offsetLeft;
}

function toggleFAQPanel(divName)
{
    var style = getDivStyle(divName);
    style.display = ((style.display == "") || (style.display == "none")) ? "block" : "none";
}

function enableButton(buttonDivName, enabled)
{
    var buttonDiv = getDiv('submitButton'); 
    buttonDiv.className = (enabled) ? 'w-b' : 'w-b w-b-disabled';

}

function comfirmDeletion(objectDescription)
{
    return confirm("You are about to delete " + objectDescription +".\n\nAre you sure you want to continue?");
}

function comfirmLeaveApplication(applicationName)
{
    return confirm("You are about to leave the " + applicationName +".\n\nAre you sure you want to continue?");
}

function schedulePageRefresh(intervalInSeconds)
{
    setTimeout("window.location.reload();", intervalInSeconds * 1000);
}

function addToSlideToggleGroup(toogleGroupId, groupDivName, selected)
{
	if (selected)
		CURRENT_SLIDE_TOGGLE_GROUP[toogleGroupId] = groupDivName;
}

function slideToggleGroup(toogleGroupId, groupDivName)
{
	if (CURRENT_SLIDE_TOGGLE_GROUP[toogleGroupId] != groupDivName)
	{
		if (CURRENT_SLIDE_TOGGLE_GROUP[toogleGroupId] != null)
			startSlideToggleGroup(CURRENT_SLIDE_TOGGLE_GROUP[toogleGroupId], -1);
		
		startSlideToggleGroup(groupDivName, 1);
		CURRENT_SLIDE_TOGGLE_GROUP[toogleGroupId] = groupDivName;
	}	
	else
	{
		startSlideToggleGroup(groupDivName, -1);
		CURRENT_SLIDE_TOGGLE_GROUP[toogleGroupId] = null;
	}
}

function startSlideToggleGroup(groupDivName, direction)
{
	var style = getDivStyle(groupDivName);
    var isShown = (style.display != "none");
    var startTimer = false;
    var fullHeight = parseInt(getDivStyle(groupDivName).height);
    
    if (isShown && (direction == -1))
    {
    	startTimer = true;
    }
    else if (!isShown && (direction == 1))
    {
    	style.height = 1;
    	startTimer = true;
    }

    if (startTimer)
    {
    	style.display = "block";
    	setTimeout('slideToggleGroupTick(\'' + groupDivName + '\', ' + direction + ', ' + fullHeight + ', ' + (new Date()).getTime() + ');', SLIDE_TIMER_TICK);
    }
}

function slideToggleGroupTick(groupDivName, direction, fullHeight, startTime)
{
	var style = getDivStyle(groupDivName);
    var elapsed = (new Date()).getTime() - startTime;
    if (elapsed > SLIDE_TIMER_DURATION)
    {
    	if (direction == -1)
    		style.display = "none";
    	
    	style.height = fullHeight + "px";
    }
    else 
    {
        var slideDistance = Math.round(elapsed / SLIDE_TIMER_DURATION * fullHeight);
        if (direction == -1)
        	style.height = fullHeight - slideDistance;
        else
        	style.height = slideDistance;

        setTimeout('slideToggleGroupTick(\'' + groupDivName + '\', ' + direction + ', ' + fullHeight + ', ' + startTime + ');', SLIDE_TIMER_TICK);
    }
}

