function showDIV(nameDIV) {
document.getElementById(nameDIV).style.visibility = "visible";
}

function hideDIV(nameDIV) {
document.getElementById(nameDIV).style.visibility = "hidden";
}

function wincat() {
var strString = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="416" HEIGHT="214" id="intro" ALIGN=""><PARAM NAME=movie VALUE="/images/wincat.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="/images/wincat.swf" quality=high bgcolor=#FFFFFF  WIDTH="416" HEIGHT="214" NAME="intro" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></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 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';
            }
    }