function showDIV(nameDIV) {
document.getElementById(nameDIV).style.visibility = "visible";
}

function hideDIV(nameDIV) {
document.getElementById(nameDIV).style.visibility = "hidden";
}

function kbase() {
var strString = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width=454 height=202><param name=movie value="images/kbase-home.swf"><param name=quality value=high><param name="wmode" value="transparent"><embed src="images/kbase-home.swf" quality=high wmode="transparent" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width=454 height=202></embed></object>';
document.write (strString);
}

function sliderNav(FlashVars) {
var strString = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="250" height="50" align="middle"><param name="FlashVars" value="' + FlashVars + '" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="images/slider.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="images/slider.swf" quality="high" FlashVars="' + FlashVars + '" bgcolor="#ffffff" width="250" height="50" name="slider" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
document.write (strString);
}

function promo() {
var strString = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width=454 height=80><param name=movie value="images/ad_top0408.swf"><param name=quality value=high><param name="wmode" value="transparent"><embed src="images/ad_top0408.swf" quality=high wmode="transparent" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width=454 height=80></embed></object>';
document.write (strString);
}

function doPostBack(id,val)
{
	var commsfra;
	commsfra = parent.document.getElementById('commsframe');
	commsfra.src = 'QTree.asp?view=getquiz&id=DD' + id + '&AnsID=' + val + '&rnd=' + Math.random();
	var prdFra;
	prdFra = parent.document.getElementById('fraproducts');
	prdFra.src = 'QTree.asp?view=listProducts&AnsID=' + val + '&rnd=' + Math.random();
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

var timerID = "global";
function hidemenus() { MM_showHideLayers('Layer1','','hide') }
function startTimer() { stopTimer(); timerID = setTimeout("hidemenus()", 2000); }
function startTimer2() { stopTimer(); timerID = setTimeout("hidemenus()", 1); }
function stopTimer() { clearTimeout(timerID); }

function MM_callJS(jsStr) { return eval(jsStr) }


function changeStyle(tag,att,val,target,idVal){
if (target != "") { var el = document[target].document.getElementsByTagName(tag); }
else { var el = document.getElementsByTagName(tag); }
for(var i=0;i<el.length;i++){
if (idVal != "" && el.item(i).id == idVal) { el[i].style[att] = val; }
if (idVal == "" && el.item(i).id == "") { el[i].style[att] = val; }
}
}


// COLOUR PICKER STUFF

function OpenPopup(fileName,windowname, width, height) 
	{ 
		leftVal = (screen.width - width) / 2;
		topVal = ( screen.height - height) / 2;
		//leftVal=0;
		//topVal=0;
		window.open(fileName,windowname,'width='+width+',height='+height+',left='+leftVal+',top='+topVal+',directories=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes'); 
} 

function fcnSetcolour(colour,field)
    {
        //Used by the colour picker to return the value to the calling page
        var WPColour;
        WPColour = document.getElementById(field);   
        WPColour.value = colour;
        WPColour.style.backgroundColor = colour;
        fcnSetFieldInverseFgColour(WPColour);
    }
function fcnOpenColourPicker(fieldname)
    {
        //Calls the colour picker into a popup
        var obj;
        obj = document.getElementById(fieldname);
        OpenPopup('/colorpicker/colorpicker.html?Colour=' + obj.value + '&InputID=' + fieldname,'PickColour',440,310);
    }
function fcnSetFieldBGColour(obj)
    {
        //sets the bacground colour of a field to the entered hex colour value
        obj.value = obj.value.toUpperCase();
    
        if (obj.value.length == 6)
            {
                obj.style.backgroundColor = obj.value;
                fcnSetFieldInverseFgColour(obj);
            }
    }
function fcnSetFieldInverseFgColour(obj)
    {
        //sets the foreground colour to a contrasing colour to the backgroung colour
        var VR,VG,VB,VT;
        VR = parseInt('0x' + obj.value.substring(2,-2));
        VG = parseInt('0x' + obj.value.substring(2,4));
        VB = parseInt('0x' + obj.value.substring(6,4));
        VT = VR + VG + VB;
        
        if (VT > 382)
            {
                obj.style.color = '000000';
            }
        else
            {
                obj.style.color = 'FFFFFF';
            }
        }

function unescapeHTML(html) {
    var htmlNode = document.createElement("DIV");
    htmlNode.innerHTML = html;
    if (htmlNode.innerText)
        return htmlNode.innerText; // IE
    return htmlNode.textContent; // FF
}

function isShortDateValid(dateStr) {
    // Check if date is valid in format dd/mm/yy
    if (!/^\d{2}\/\d{2}\/\d{2}$/.test(dateStr))
        return false;
    month = dateStr.substr(3, 2);
    day = dateStr.substr(0, 2);
    year = dateStr.substr(6, 2);
    if (day < 1 || day > 31)
        return false;
    if (month < 1 || month > 12)
        return false;
    if ((month == 4 || month == 6 || month == 9 || month == 11) && day >= 31)
        return false;
    if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day == 29 && !isleap))
            return false;
    }
    return true;
}