// Setsup the auto complete functions for each site / lookup type:
//  site: The site that the lookup refers to (bedford, shuttleworth or training)
//  type: What content to lookup (course or site)
function setAutoComplete(site, type)
{
    var siteCode = '';
    var siteURL = '';
    var typeCode = '';
    switch (site)
    {
    case 'training': { siteCode = 't'; siteURL = "bedford/website"; } // www.corporateskillstraining.co.uk
    case 'shuttleworth': { siteCode = 's'; siteURL = "bedford/website"; } // www.shuttleworth.ac.uk
    default: { siteCode = 'b'; siteURL = "bedford/website"; } // www.bedford.ac.uk
    }
    typeCode = (type == 'course' ? 'c' : 's');
    try
    {
	    if ($.browser.mozilla) {
    		//switch off default firefox autofill function
		    $("form").attr("autocomplete", "off");
	    }
	    $("div#searchBox input:text").autocomplete("http://" + siteURL + "/AutoCompleteLookUp.aspx?type=" + typeCode + "&site=" + siteCode);
	}
	catch(e) { }
}

function createCollapsibleElements()
{
	//if additional css style specified, add as class
	$("a[rel=cp_trigger]").each(function() {
	   var id = $(this).attr("class");
	   
	   $("*[class^='" + id + "']:not(a)").each(function() {
	        var cls = $(this).attr("class");
	        
	        if (cls.indexOf("*") > -1) {
	            var additionalCls = cls.substring(cls.indexOf("*")+1);			            
	            $(this).addClass(cls.substring(0, cls.indexOf("*")));
	            $(this).addClass(additionalCls);
	        }
	   });
	   
	   if ($("."+id+":not(a)")) {			        
	        $("."+id+":not(a)").hide();
	   } 
	});
    
    $("a[rel=cp_trigger]").click(function() {
        var id = $(this).attr("class");
	    $("."+id+":not(a)").slideToggle('fast');
	    return false;
    });
}

function outputAnalytics()
{
    try
    {
        var pageTracker = _gat._getTracker("UA-2127869-23"); //Bedford: "UA-2127869-10"; Shuttleworth: "UA-2127869-23"; Training: "UA-2127869-24"
        pageTracker._trackPageview();
    }
    catch(err) { }
}

function clearText(thefield) {
if (thefield.defaultValue == thefield.value)
	thefield.value = ""
} 

