﻿/* idffunctions.js  function.js ResponsesMgt.js */
/* ----------------------------- IDFfunctions.js -----------------------------*/

/* autosizing image popup */

// To use:
// popImage("url_of_image","title_of_image")
// e.g.  <a href="javascript:popImage('http://SomeSite.com/SomeImage.gif','Some Title')">Click Here</a>

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=yes,location=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=yes,location=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="yes" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}



/* --- REPLACE CHECKBOX FUNCTION --- */
var xL;
var currentExclu = ' ';

function writeText(id,val){
	document.getElementById(id).value = val;
}
function writeText2(id,id2,val){
	document.getElementById(id).value = val;
	document.getElementById(id2).click();
	document.getElementById(id2).checked = true;
}

function flashdialgraph(id, args) {
	alert(id);
	document.getElementById(id).value = args;
}

function Swap(id){
	startBrother = document.getElementById(id);
	memory = startBrother;
	getPreviousSibling(startBrother);
	rowCheck = endBrother.parentNode.parentNode.id;
	if(endBrother.type == 'checkbox'){
		if(endBrother.checked == false){
			if(endBrother.getAttribute('isExclu') == 1){
				var modList = id.split('bob');
				currentExclu = id;
				for (var i=0;i<50;i++){
					if(i != modList[1]){
						if(document.getElementById('bob'+i) == null) break;
						document.getElementById('bob'+i).style.background = 'url(http://www.theidfactor.co.uk/images/checkbox/box_empty.gif) no-repeat center';
						document.getElementById('bob'+i).previousSibling.previousSibling.checked = false;
					}
				}
			}else{
				if(currentExclu != ' '){
					document.getElementById(currentExclu).style.background = 'url(http://www.theidfactor.co.uk/images/checkbox/box_empty.gif) no-repeat center';
					document.getElementById(currentExclu).previousSibling.previousSibling.checked = false;
					currentExclu = ' ';
				}
			}
			document.getElementById(id).style.background = 'url(http://www.theidfactor.co.uk/images/checkbox/box.gif) no-repeat center';
		}else{
			document.getElementById(id).style.background = 'url(http://www.theidfactor.co.uk/images/checkbox/box_empty.gif) no-repeat center';
		}
	}else{ //check this works currentExclu might not be relevant !!!
		if(endBrother.checked == false){
			var modList = id.split('bob');
			currentExclu = id;
			for (var i=0;i<500;i++){
				if(i != modList[1]){
					if(document.getElementById('bob'+i) == null) break;
					if(document.getElementById('bob'+i).parentNode.parentNode.id != rowCheck){
						document.getElementById('bob'+i).style.background = 'url(http://www.theidfactor.co.uk/images/checkbox/radio_empty.gif) no-repeat center';
					}
				}
			}
			document.getElementById(id).style.background = 'url(http://www.theidfactor.co.uk/images/checkbox/radio.gif) no-repeat center';
		}
	}
	endBrother.click();
}

function getPreviousSibling(startBrother){ //checks to ensure previous sibling is not white space or other non element
	endBrother=startBrother.previousSibling;
	while(endBrother.nodeType!=1){
		endBrother = endBrother.previousSibling;
	}
	return endBrother;
}

//reset checkboxes
function resetCB() {
	var allElements;
	allElements = document.getElementsByTagName("input");
	for (var i=0;i<allElements.length;i++) {
		if ( allElements[i].type == 'checkbox' ) {//
			allElements[i].checked = false;
			allElements[i].removeAttribute('checked');
		}
	}
}


function findRename(iD) {
	var allElements;
	allElements = document.getElementsByTagName("input");
	var NoElements = 0;
	for (var i=0;i<allElements.length;i++) {
		if ( allElements[i].id == iD && allElements[i].type == 'checkbox' ) {//
			NoElements++;
			allElements[i].id = iD + NoElements;
			if ( allElements[i].style.display == 'none' ) {
				allElements[i].style.cssFloat = 'left';
				allElements[i].style.height = '1px';
				allElements[i].style.width = '1px';
			}
		}
	}
}

function findRename2(iD) {
	var allElements;
	allElements = document.getElementsByTagName("input");
	var NoElements = 0;
	for (var i=0;i<allElements.length;i++) {
		if ( allElements[i].id == iD ) {//
			NoElements++;
			allElements[i].id = iD + NoElements;
			if ( allElements[i].style.display == 'none' ) {
				allElements[i].style.cssFloat = 'left';
				allElements[i].style.height = '1px';
				allElements[i].style.width = '1px';
			}
		}
	}
}


function assignID(){
	xL = document.getElementsByName('bob');
	xTR = document.getElementsByTagName('tr');
	for (var i=0;i<xL.length;i++){
		xL[i].id = 'bob' + i;
		startBrother = document.getElementById(xL[i].id);
		getPreviousSibling(startBrother);
		if(endBrother.type == 'radio'){
			if(endBrother.checked == false){
				curBrowser = getBrowser();
				if (curBrowser.indexOf('NS') !=-1) { //firefox
					document.getElementById(xL[i].id).style.background = "url(http://www.theidfactor.com/images/checkbox/radio_empty.gif) no-repeat center";
					document.getElementById(xL[i].id).style.padding = "12px";
					document.getElementById(xL[i].id).style.marginRight = "4px";
					document.getElementById(xL[i].id).style.cssFloat = 'left';
					document.getElementById(xL[i].id).style.cursor = 'pointer';
					document.getElementById(xL[i].id).nextSibling.style.padding = "0 0 0 0";
					document.getElementById(xL[i].id).nextSibling.style.margin = "3px 0 0 0";
				}else{ //internet explorer
					document.getElementById(xL[i].id).style.background = "url(http://www.theidfactor.com/images/checkbox/radio_empty.gif) no-repeat center";
					document.getElementById(xL[i].id).style.padding = "6px";
					document.getElementById(xL[i].id).style.paddingRight = "15px";
					document.getElementById(xL[i].id).style.styleFloat = 'left';
					document.getElementById(xL[i].id).style.cssFloat = 'left';
					document.getElementById(xL[i].id).style.cursor = 'pointer';
					document.getElementById(xL[i].id).nextSibling.style.paddingTop = "4px";
				}
			}else{
				curBrowser = getBrowser();
				if (curBrowser.indexOf('NS') !=-1) { //firefox
					document.getElementById(xL[i].id).style.background = "url(http://www.theidfactor.com/images/checkbox/radio.gif) no-repeat center";
					document.getElementById(xL[i].id).style.padding = "12px";
					document.getElementById(xL[i].id).style.marginRight = "4px";
					document.getElementById(xL[i].id).style.cssFloat = 'left';
					document.getElementById(xL[i].id).style.cursor = 'pointer';
					document.getElementById(xL[i].id).nextSibling.style.padding = "0 0 0 0";
					document.getElementById(xL[i].id).nextSibling.style.margin = "3px 0 0 0";
				}else{ //internet explorer
					document.getElementById(xL[i].id).style.background = "url(http://www.theidfactor.com/images/checkbox/radio.gif) no-repeat center";
					document.getElementById(xL[i].id).style.padding = "6px";
					document.getElementById(xL[i].id).style.paddingRight = "15px";
					document.getElementById(xL[i].id).style.styleFloat = 'left';
					document.getElementById(xL[i].id).style.cssFloat = 'left';
					document.getElementById(xL[i].id).style.cursor = 'pointer';
					document.getElementById(xL[i].id).nextSibling.style.paddingTop = "4px";
				}
			}
		}else if(endBrother.type == 'checkbox' && endBrother.id !== 'option'){
			if(endBrother.checked == false){
				curBrowser = getBrowser();
				if (curBrowser.indexOf('NS') !=-1) { //firefox
					document.getElementById(xL[i].id).style.background = "url(http://www.theidfactor.com/images/checkbox/box_empty.gif) no-repeat center";
					document.getElementById(xL[i].id).style.padding = "12px";
					document.getElementById(xL[i].id).style.marginRight = "4px";
					document.getElementById(xL[i].id).style.cssFloat = 'left';
					document.getElementById(xL[i].id).style.cursor = 'pointer';
					document.getElementById(xL[i].id).nextSibling.style.padding = "0 0 0 0";
					document.getElementById(xL[i].id).nextSibling.style.margin = "3px 0 0 0";
				}else{ //internet explorer
					document.getElementById(xL[i].id).style.background = "url(http://www.theidfactor.com/images/checkbox/box_empty.gif) no-repeat center";
					document.getElementById(xL[i].id).style.padding = "6px";
					document.getElementById(xL[i].id).style.paddingRight = "15px";
					document.getElementById(xL[i].id).style.styleFloat = 'left';
					document.getElementById(xL[i].id).style.cssFloat = 'left';
					document.getElementById(xL[i].id).style.cursor = 'pointer';
					document.getElementById(xL[i].id).nextSibling.style.paddingTop = "4px";
				}
			}else{
				curBrowser = getBrowser();
				if (curBrowser.indexOf('NS') !=-1) { //firefox
					document.getElementById(xL[i].id).style.background = "url(http://www.theidfactor.com/images/checkbox/box.gif) no-repeat center";
					document.getElementById(xL[i].id).style.padding = "12px";
					document.getElementById(xL[i].id).style.marginRight = "4px";
					document.getElementById(xL[i].id).style.cssFloat = 'left';
					document.getElementById(xL[i].id).style.cursor = 'pointer';
					document.getElementById(xL[i].id).nextSibling.style.padding = "0 0 0 0";
					document.getElementById(xL[i].id).nextSibling.style.margin = "3px 0 0 0";
				}else{ //internet explorer
					document.getElementById(xL[i].id).style.background = "url(http://www.theidfactor.com/images/checkbox/box.gif) no-repeat center";
					document.getElementById(xL[i].id).style.padding = "6px";
					document.getElementById(xL[i].id).style.paddingRight = "15px";
					document.getElementById(xL[i].id).style.styleFloat = 'left';
					document.getElementById(xL[i].id).style.cssFloat = 'left';
					document.getElementById(xL[i].id).style.cursor = 'pointer';
					document.getElementById(xL[i].id).nextSibling.style.paddingTop = "4px";
				}
				if (document.getElementById(xL[i].id).previousSibling.previousSibling.getAttribute('isExclu') == 1)
					currentExclu = xL[i].id;
			}
		}
	}
	for (var j=0;j<xTR.length;j++){
		xTR[j].id = 'row' + j;
	}
}


/* ------ FLASH SELECT FUNCTIONS ---*/
function comboSelect(id,opt){
	document.getElementById(id).options[opt].selected = '1';
}

function loopTarget(h){
	targetL = document.getElementsByTagName('select');
	var targetCount = 1;
	if ( h == "hide" ) {
		hideBtn();	
	}
	for (var p=0;p<targetL.length;p++){
		if ( targetL[p].id == 'q' ) {
			targetL[p].id = 'q' + targetCount;
			targetCount++;
		}
	}
}

function setNone(id,qNo) {			//select None, deselect others
	document.getElementById(id + 'n').click();
	for ( i=0; i<qNo; i++ ) {
		tempID = id + (i+1);
		document.getElementById(tempID).checked = false;
		document.getElementById(tempID).removeAttribute('checked');
	}
}
function multiVal(id,state,qNo) {
	/*if (state == '0') {
		document.getElementById(id).checked = false;
		document.getElementById(id).removeAttribute('checked');
	} else if (state == '1') {
		document.getElementById(id).checked = true;
	}*/
	document.getElementById(id).click();
	if (id == 'none'){
		document.getElementById('none').click();
	}
}

function choose(id) {
	document.getElementById(id).click();
	document.getElementById(id).checked = true;
}
function unchoose(id) {
	document.getElementById(id).checked = false;
	document.getElementById(id).removeAttribute('checked');
}


function switchVal(id,state){
	var PrefixIdent = '';
	if (state == '0') {
		document.getElementById(id).checked = false;
		document.getElementById(id).removeAttribute('checked');
	} else if (state == '1') {
		document.getElementById(id).checked = true;
	}
	if (id == 'none'){
		//reset all checkboxes
		resetCB();
		//click none
		document.getElementById('none').click();
	}
}

// Reveal text box
function revealTBox(id) {
	document.getElementById(id).style.display = 'block';
}

// Reveal next button
function revealHOR() {
	document.getElementById('next').src = '/images2/hor/next.gif';
}

// Reveal next button (Rewarded opinions stylee.)
function revealRO() {
	document.getElementById('next').src = '/images2/Rewarded_Opinions/ro_next_button.jpg';
	played=true;
}

function revealIDF() {
	document.getElementById('next').src = '/survey_templates/idfactor/images/next.jpg';
}

function revealNext(myImage) {
	document.getElementById('next').src = myImage;
}

function hideNext() {
	document.getElementById('next').src = '/images2/synovate/invisible_button.gif';
}

function hideRank() {
	var rateTotal = document.getElementsByTagName('div').length;
	var sofour = new SWFObject("http://www.theidfactor.com/flash/bar/bar4.swf", "bar4", "72", "20", "8", "#ffffff", true);sofour.addParam("wmode", "transparent");sofour.addParam("allowScriptAccess","always");
	var sofive = new SWFObject("http://www.theidfactor.com/flash/bar/bar5.swf", "bar5", "90", "20", "8", "#ffffff", true);sofive.addParam("wmode", "transparent");sofive.addParam("allowScriptAccess","always");
	var sosix = new SWFObject("http://www.theidfactor.com/flash/bar/bar6.swf", "bar6", "108", "20", "8", "#ffffff", true);sosix.addParam("wmode", "transparent");sosix.addParam("allowScriptAccess","always");
	var sonine = new SWFObject("http://www.theidfactor.com/flash/bar/bar9.swf", "bar9", "162", "20", "8", "#ffffff", true);sonine.addParam("wmode", "transparent");sonine.addParam("allowScriptAccess","always");
	var soten = new SWFObject("http://www.theidfactor.com/flash/bar/bar10.swf", "bar10", "180", "20", "8", "#ffffff", true);soten.addParam("wmode", "transparent");soten.addParam("allowScriptAccess","always");
	var soeleven = new SWFObject("http://www.theidfactor.com/flash/bar/bar11.swf", "bar11", "198", "20", "8", "#ffffff", true);soeleven.addParam("wmode", "transparent");soeleven.addParam("allowScriptAccess","always");
	var soninev = new SWFObject("http://www.theidfactor.com/flash/bar/bar9v.swf", "bar9v", "20", "146", "8", "#ffffff", true);soninev.addParam("wmode", "transparent");soninev.addParam("allowScriptAccess","always");
	var sonineb = new SWFObject("http://www.theidfactor.com/flash/bar/bar9.swf", "bar9b", "200", "25", "8", "#ffffff", true);sonineb.addParam("wmode", "transparent");sonineb.addParam("allowScriptAccess","always");
	var sofiveb = new SWFObject("http://www.theidfactor.com/flash/IDQ3484/fqRate.swf", "bar5b", "325", "22", "8", "#ffffff", true);sofiveb.addParam("wmode", "transparent");sofiveb.addParam("allowScriptAccess","always");
	
	for ( i=1; i<=rateTotal; i++ ) {
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate4' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			sofour.addVariable("aid","rateq" + i);sofour.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate5' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			sofive.addVariable("aid","rateq" + i);sofive.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate6' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			sosix.addVariable("aid","rateq" + i);sosix.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate9' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			sonine.addVariable("aid","rateq" + i);sonine.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate10' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			soten.addVariable("aid","rateq" + i);soten.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate11' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			soeleven.addVariable("aid","rateq" + i);soeleven.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate9v' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			soninev.addVariable("aid","rateq" + i);soninev.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate9b' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			sonineb.addVariable("aid","rateq" + i);sonineb.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
		if ( document.getElementsByTagName('div')[i-1].getAttribute('name') == 'rate5b' ) {
			document.getElementsByTagName('div')[i-1].id = 'rateq' + i;
			sofiveb.addVariable("aid","rateq" + i);sofiveb.write("rateq" + i);
			document.getElementsByTagName('div')[i-1].previousSibling.style.display = 'none';
		}
	}
}

function aRank(id,val) {
	document.getElementById(id).previousSibling.options[val].selected = '1';
}


/* --- Preload images --- */

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/* ------ HOVERTEXT FUNCTIONS AND DOSUM ------*/
var currentTextBox=null;
//var oSliderType=eSliderType.scrollBar;

function textOver(Elt)    { 
	Elt.className='textbox-hover'; 
}
function textOut(Elt)      { 
	if (currentTextBox==Elt)return;
	Elt.className='textbox'; 
}
function textFocus(Elt) { 
	currentTextBox=Elt; 
	Elt.className='textbox-hover'; 
}
function textBlur(Elt)     { 
	currentTextBox=null;
	Elt.className='textbox'; 
}

var txtBoxCollection=[];
var inputPrefixArray=[];
var inputCBNameArray = [];

function LoadMeUp(){
	
	var posCount = 0; //position check variable
	var radioCount = 0;
	var txtCol=document.getElementsByTagName('input');
	var currentPrefix = '';
	var left = false;
	var nbChoice = false;
	var assignedClass = '';
	var spanElement;	//WYT20100330
	
	hideRank();
	
	for (var i=0;i<txtCol.length;i++){
		assignedClass = '';
		type = txtCol[i].type;
		name = txtCol[i].name;
		if ((type == 'checkbox')&&(txtCol[i].test !== 'TEST')&&(name !== 'Next')&&(name !== 'Previous')&&(name !== 'Action')&&(name !== 'Qstre')&&(name !== 'Intvw')&&(name !== 'Position')&&(name !== 'undefined')&&(txtCol[i].style.display !== 'none') && txtCol[i].id.indexOf('option') != '0'){
			if (txtCol[i].name != '' && txtCol[i].id != 'option') {
				inputCBNameArray[inputCBNameArray.length] = txtCol[i].name;
				for (j=0; j<txtCol[i].name.length; j++) { //grab first letters/numbers of name
					if (txtCol[i].name.charAt(j) !== ' ')
						currentPrefix += txtCol[i].name.charAt(j);
					else
						break;
				}
				for (k=0; k<inputPrefixArray.length; k++){
					if (inputPrefixArray[k] == currentPrefix){
						posCount++;
						break;
					}
				}
				if (posCount == '0'){
					if (currentPrefix !== 'undefinedAction'){
						inputPrefixArray[inputPrefixArray.length] = currentPrefix;
					}
				}else // check this later
					inputPrefixArray[k];
				posCount = 0;
				currentPrefix = '';
			}
		}
		
		if (type == 'radio' && (txtCol[i].id != "" || txtCol[i].style.display != 'none')) { // if a radio button
			
			if (document.getElementById("cpt" + txtCol[i].name.substring(1) + ' ' + txtCol[i].value).nodeName == 'SPAN') {   //Check radio button has a SPAN element and get a reference to it if so WYT20100330
				spanElement = document.getElementById("cpt" + txtCol[i].name.substring(1) + ' ' + txtCol[i].value); 		//Get corresponding span element WYT20100330
			}
						
			assignedClass = txtCol[i].className;
			oOuter = document.createElement('div');
			oInner = document.createElement('input');
			oInner.setAttribute('name',txtCol[i].name);
			oInner.setAttribute('type','radio');
			oInner.setAttribute('value',txtCol[i].value);
			if ( (txtCol[i].status || txtCol[i].status == true) || (txtCol[i].checked || txtCol[i].checked == 'true')){
				oInner.setAttribute('checked','true'); //null and void??
				nbChoice = true;
			}
			
			oOuter.appendChild(oInner); 
			
			if (spanElement != null) {

				var spanText = spanElement.innerHTML;		//Copy Spans text to variable WYT20100331 
				var tdNode = spanElement.parentNode;		//Get a reference to parent td node 
				tdNode.removeChild(spanElement);  		//Remove Original Span WYT20100330
				tdNode.innerHTML += spanText; 			//Set the text WYT20100330
			} 

			for ( n=0; n<txtCol[i].parentNode.childNodes.length; n++ ){
				if ( txtCol[i].parentNode.childNodes[n].nodeValue != null ) {
					if ( (txtCol[i].parentNode.childNodes[n].type == undefined || txtCol[i].parentNode.childNodes[n].type == 'text') && txtCol[i].parentNode.childNodes[n].nodeValue != ''
						 && txtCol[i].parentNode.childNodes[n].nodeValue.length >= 1 ) {
						left = true;	
					}
				}
			}

			txtCol[i].parentNode.replaceChild(oOuter,txtCol[i]);
			if ( nbChoice == true) {
				oOuter.getElementsByTagName('input')[0].checked = true;
				nbChoice = false;
			}
			if ( txtCol[i].status || txtCol[i].status == true || txtCol[i].checked || txtCol[i].checked == 'true'){
				txtCol[i].parentNode.className = 'radio';
			}else{
				txtCol[i].parentNode.className = 'unradio';
			}
			if ( left == true ) {
				if ( txtCol[i].parentNode.className == 'radio' ) {
					txtCol[i].parentNode.className = 'radioL';
				} else {
					txtCol[i].parentNode.className = 'unradioL';
				}
				left = false;
			}
			txtCol[i].parentNode.id = 'r' + radioCount;
			if ( assignedClass == 'clickGO' ) {
				txtCol[i].parentNode.onclick = function(){checkRadioGo(this.id)};
			} else if ( assignedClass == 'changeGO' ) {
				txtCol[i].parentNode.onchange = function(){goForward3()};
				txtCol[i].parentNode.onclick = function(){checkRadio(this.id)};
			} else {
				txtCol[i].parentNode.onclick = function(){checkRadio(this.id)};
			}
			
			txtCol[i].style.display = 'none';  //hide basic radio buttons
			radioCount++;
		}
		
		if (txtCol[i].type=='text'){ //last change
			txtBoxCollection[txtBoxCollection.length]=txtCol[i];
		}
		
	}
	for (var m=0;m<inputCBNameArray.length;m++){
		document.getElementsByName(inputCBNameArray[m])[0].id = inputCBNameArray[m];
		tester = document.getElementById(inputCBNameArray[m]);
		oOuter = document.createElement('div');
		oOuter.setAttribute('id',inputCBNameArray[m]);
		oInner = document.createElement('input');
		oInner.setAttribute('name',inputCBNameArray[m]);
		oInner.setAttribute('type','checkbox');
		oInner.setAttribute('onClick','checkAll(this.id);');
		if ( tester.checked || tester.checked == true )
			oInner.setAttribute('checked','true');
		if ( tester.getAttribute('isExclu') == 'true' || tester.getAttribute('isExclu') == '1'){
			oOuter.setAttribute('isExclu','true');
		}
		else if ( tester.getAttribute('isExclu') == 'false' ){
			oOuter.setAttribute('isExclu','false');
		}
		oOuter.appendChild(oInner);
		
		if (document.getElementById("cpt" + inputCBNameArray[m].substring(1)).nodeName == 'SPAN') {   						//Check radio button has a SPAN element and get a reference to it if so WYT20100330
					spanElement = document.getElementById("cpt" + inputCBNameArray[m].substring(1)); 					//Get corresponding span element WYT20100330
		}
		
		if (spanElement != null) {

			var spanText = spanElement.innerHTML;										//Copy Spans text to variable WYT20100331 
			var tdNode = spanElement.parentNode;										//Get a reference to parent td node 
			tdNode.removeChild(spanElement);  											//Remove Original Span WYT20100330
			tdNode.innerHTML += spanText; 												//Set the text WYT20100330
		} 

		tester = document.getElementById(inputCBNameArray[m]);							//Reset Tester WYT20100330

		for ( n=0; n<tester.parentNode.childNodes.length; n++ ){
			if (tester.parentNode.childNodes[n].nodeValue != null) {
				if ( (tester.parentNode.childNodes[n].type == undefined || tester.parentNode.childNodes[n].type == 'text') && tester.parentNode.childNodes[n].nodeValue != ''
					 && tester.parentNode.childNodes[n].nodeValue.length >= 1 ) {
					left = true;
				}
			}
		}

		document.getElementById(inputCBNameArray[m]).parentNode.replaceChild(oOuter,document.getElementById(inputCBNameArray[m]));
		if ( tester.status || tester.status == true || tester.checked || tester.checked == 'true'){
			if ( left == true ) {
				document.getElementById(inputCBNameArray[m]).className = 'checkboxL';
				left = false;
			} else {
				document.getElementById(inputCBNameArray[m]).className = 'checkbox';
			}
		}else{
			if ( left == true ) {
				document.getElementById(inputCBNameArray[m]).className = 'uncheckboxL';
				left = false;
			} else {
				document.getElementById(inputCBNameArray[m]).className = 'uncheckbox';
			}
		}
		if (getBrowser() == null){
			var curBrowser = '';
		}else{
			var curBrowser = getBrowser();
		}
		if ((curBrowser.indexOf('NS') !=-1)) { //firefox
			document.getElementById(inputCBNameArray[m]).onclick = document.getElementById(inputCBNameArray[m]).getElementsByTagName('input')[0].onclick;
			document.getElementById(inputCBNameArray[m]).getElementsByTagName('input')[0].setAttribute('onclick',null);
		}else{
			document.getElementById(inputCBNameArray[m]).onclick = function(){checkAll(this.id)};
		}
		document.getElementById(inputCBNameArray[m]).getElementsByTagName('input')[0].style.display = 'none';
		if ( document.getElementById(inputCBNameArray[m]).className == 'checkboxL' || document.getElementById(inputCBNameArray[m]).className == 'checkbox' ) {
			document.getElementById(inputCBNameArray[m]).getElementsByTagName('input')[0].checked = true;	
		}
	}
	
	doSumS();

	if ( typeof( window[ 'nowTesting' ] ) != "undefined" ) {
		if ( nowTesting == '1' ) {
			allowTesting();
		}
	}
}

function allowTesting() {
	var allHiddenCBS = document.getElementsByTagName('input');
	var allHiddenCombos = document.getElementsByTagName('select');
	var allHiddenTxts = document.getElementsByTagName('textarea');
	var allHiddenLoops = document.getElementsByClassName('loopitem');
	for (var i=0;i<allHiddenLoops.length;i++){
		if( allHiddenLoops[i].id == "t"){
			allHiddenLoops[i].style.display = 'block';
		}
	}
	for (var i=0;i<allHiddenCBS.length;i++){
		type = allHiddenCBS[i].type;
		if ( type == 'checkbox' ) {
			allHiddenCBS[i].style.display = 'block';
		}
		if ( type == 'text' ) {
			allHiddenCBS[i].style.display = 'block';
		}
	}
	for (var i=0;i<allHiddenCombos.length;i++){
		if ( allHiddenCombos[i].style.display == 'none' ) {
			allHiddenCombos[i].style.display = 'block';
		}
	}
	for (var i=0;i<allHiddenTxts.length;i++){
		if ( allHiddenTxts[i].style.display == 'none' ) {
			allHiddenTxts[i].style.display = 'block';
		}
	}
}

function doSumS(){
	var result=0;
	for (var i=0;i<txtBoxCollection.length;i++){
		if (txtBoxCollection[i].value=='')continue;
		result +=parseInt(txtBoxCollection[i].value);
	}
	if(document.getElementById('sum')!== null)
		document.getElementById('sum').innerHTML = result;
}

function checkAll(name){
	oneToCheck = document.getElementById(name);				//get object reference
	var prevChoice = oneToCheck.getElementsByTagName('input')[0].checked;
	oneToCheck.getElementsByTagName('input')[0].click(); 	//click checkbox
	if ( prevChoice == oneToCheck.getElementsByTagName('input')[0].checked && prevChoice == false ) {
		oneToCheck.getElementsByTagName('input')[0].checked = true;
	} else if ( prevChoice == oneToCheck.getElementsByTagName('input')[0].checked && prevChoice == true ) {
		oneToCheck.getElementsByTagName('input')[0].checked = false;
	}
	if ( oneToCheck.getElementsByTagName('input')[0].checked == true ){  // if checked
		if ( oneToCheck.className == 'uncheckboxL' || oneToCheck.className == 'checkboxL' ) {
			oneToCheck.className = 'checkboxL';
		} else {
			oneToCheck.className = 'checkbox';
		}
		if ( oneToCheck.getAttribute('isExclu')=='true' || oneToCheck.getAttribute('isExclu')=='1' ) {	// if also exclusive
			for ( j=0; j<inputPrefixArray.length; j++ ) {
				if ( oneToCheck.getElementsByTagName('input')[0].name.indexOf(inputPrefixArray[j]) == '0' )
					break;
			}
			for (i=0; i<inputCBNameArray.length; i++) {
				if(inputCBNameArray[i] !== oneToCheck.getElementsByTagName('input')[0].name && inputCBNameArray[i].indexOf(inputPrefixArray[j]) == '0'){
					document.getElementById(inputCBNameArray[i]).getElementsByTagName('input')[0].checked = false; //here is where it's gonna go wrong
					document.getElementById(inputCBNameArray[i]).getElementsByTagName('input')[0].removeAttribute('checked');
					if ( document.getElementById(inputCBNameArray[i]).className == 'uncheckboxL' || document.getElementById(inputCBNameArray[i]).className == 'checkboxL' ) {
						document.getElementById(inputCBNameArray[i]).className = 'uncheckboxL';
					} else {
						document.getElementById(inputCBNameArray[i]).className = 'uncheckbox';
					}
				}
			}
		} else if ( oneToCheck.getAttribute('isExclu') == 'false' || oneToCheck.getAttribute('isExclu') == null) {	
			for ( j=0; j<inputPrefixArray.length; j++ ) {
				if ( oneToCheck.getElementsByTagName('input')[0].name.indexOf(inputPrefixArray[j]) == '0' )
					break;
			}
			for (i=0; i<inputCBNameArray.length; i++) {
				if(inputCBNameArray[i].indexOf(inputPrefixArray[j]) == '0' &&
				   document.getElementById(inputCBNameArray[i]).getAttribute('isExclu')=='true' || document.getElementById(inputCBNameArray[i]).getAttribute('isExclu')=='1' && 
				   document.getElementById(inputCBNameArray[i]).getElementsByTagName('input')[0].checked == true){
						document.getElementById(inputCBNameArray[i]).getElementsByTagName('input')[0].checked = false;
						document.getElementById(inputCBNameArray[i]).getElementsByTagName('input')[0].removeAttribute('checked');
						if ( document.getElementById(inputCBNameArray[i]).className == 'uncheckboxL' || document.getElementById(inputCBNameArray[i]).className == 'checkboxL' ) {
							document.getElementById(inputCBNameArray[i]).className = 'uncheckboxL';
						} else {
							document.getElementById(inputCBNameArray[i]).className = 'uncheckbox';
						}
				}
			}
		}
	}else if ( oneToCheck.getElementsByTagName('input')[0].checked == false ){  // if unchecked
		oneToCheck.getElementsByTagName('input')[0].removeAttribute('checked');
		if ( oneToCheck.className == 'uncheckboxL' || oneToCheck.className == 'checkboxL' ) {
			oneToCheck.className = 'uncheckboxL';
		} else {
			oneToCheck.className = 'uncheckbox';
		}
	}
}

function reCheck(){ //recheck all pics in case of 
	for (i=0; i<inputCBNameArray.length; i++) {
		if (document.getElementById(inputCBNameArray[i]).getElementsByTagName('input')[0].checked == true && document.getElementById(inputCBNameArray[i]).style.display !== 'none'){
			if ( document.getElementById(inputCBNameArray[i]).className == 'uncheckboxL' || document.getElementById(inputCBNameArray[i]).className == 'checkboxL' ) {
				document.getElementById(inputCBNameArray[i]).className = 'checkboxL';
			} else {
				document.getElementById(inputCBNameArray[i]).className = 'checkbox';
			}
		}else if (document.getElementById(inputCBNameArray[i]).style.display !== 'none') {
			if ( document.getElementById(inputCBNameArray[i]).className == 'uncheckboxL' || document.getElementById(inputCBNameArray[i]).className == 'checkboxL' ) {
				document.getElementById(inputCBNameArray[i]).className = 'uncheckboxL';
			} else {
				document.getElementById(inputCBNameArray[i]).className = 'uncheckbox';
			}
		}
	}
}

function checkRadio(id) {
	nCheck = document.getElementById(id).getElementsByTagName('input')[0].name;
	for(i=0; i<document.getElementsByTagName('input').length; i++) {
		if ( document.getElementsByTagName('input')[i].type == 'radio' && document.getElementsByTagName('input')[i].name == nCheck) {
			if ( document.getElementsByTagName('input')[i].parentNode.className == 'unradioL' || document.getElementsByTagName('input')[i].parentNode.className == 'radioL' ) {
				document.getElementsByTagName('input')[i].parentNode.className = 'unradioL';
			} else {
				document.getElementsByTagName('input')[i].parentNode.className = 'unradio';
			}
			document.getElementsByTagName('input')[i].status = false;
			/*document.getElementsByTagName('input')[i].setAttribute('status','false');
			document.getElementsByTagName('input')[i].checked = false;
			document.getElementsByTagName('input')[i].setAttribute('checked','false');*/
			document.getElementsByTagName('input')[i].removeAttribute('status');
			document.getElementsByTagName('input')[i].removeAttribute('checked');
		}
	}
	document.getElementById(id).getElementsByTagName('input')[0].checked = true;
	document.getElementById(id).getElementsByTagName('input')[0].setAttribute('checked','true');
	document.getElementById(id).getElementsByTagName('input')[0].status = true;
	document.getElementById(id).getElementsByTagName('input')[0].setAttribute('status','true');
	document.getElementById(id).getElementsByTagName('input')[0].click();
	if ( document.getElementById(id).className == 'unradioL' || document.getElementById(id).className == 'radioL' ) {
		document.getElementById(id).className = 'radioL';
	} else {
		document.getElementById(id).className = 'radio';
	}
	//document.getElementsByTagName('input');
}

function checkRadioGo(id) {
	checkRadio(id);
	goForward3();
}


/* ------ RESIZABLE POP-UPS ---*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

window.onload = newWinLinks;
function newWinLinks() {
	for (var i=0; i<document.links.length; i++) {
		if (document.links[i].className == 'newWin') {
			document.links[i].onclick = newWindow;
		}
	}
}

var noRepeat = 0;

/* ------ AUTOMATIC PROGRESSION FUNCTIONS ---*/  
function goForward() {
	document.getElementById('next').click();
}

function goForward2(){				// continue after 200 milli seconds
	if ( noRepeat == 0 ) {
		setTimeout('goForward()', 200);
	}
	noRepeat++;
}

function goForward3(){				// continue after 200 milli seconds
	if ( noRepeat == 0 ) {
		setTimeout('goForward()', 250);
	}
	noRepeat++;
}

function goForward4(){				// continue after 3 Seconds
	if ( noRepeat == 0 ) {
		setTimeout('goForward()', 3000);
	}
	noRepeat++;
}

function hideBtn(){
	document.getElementsByName('Next')[1].style.display = 'none';
}

function unhideBtn(){
	document.getElementsByName('Next')[1].style.display = 'block';
}


/* ------ BLOCK TEXT INFORMATION ---*/  
function reveal(id){
	document.getElementById('d'+id).className = 'showMe';
}

function hide(id){
	document.getElementById('d'+id).className = 'hideMe';
}


/* ----------------------------- FUNCTION.JS -----------------------------*/

/*	JavaScript for Askia WebProd

	Functions to do live sum in numerical questions 
	You can use those scripts into loop or some numerical questions merge in same screen

	- isIEBrowser() return boolean;
	> Return true if browser is IE

	- GoNext() return void;
	> Go to next screen

	- DisplayHide(ElementId,isDisplay) return void;
	  ElementId			: Id of element
	  isDisplay			: true when display :block, false when display :none
	> Show or hide element

	- SetValue(ElementId,Value,isGoNext) return void;
	  ElementId			: Id of element (INPUT)
	  Value				: Value to set 
	  isGoNext			: true when auto-submittion
	> Set value in input element

	- GetObjectByName(strName,strObjectType)return Object;
	  strName			: Name of element
	  strObjectType		: Type of element
	> Return object using attribute NAME

	- Roll(MySelection,Mode) return void;
	  MySelection		: Element
	  Mode				: 'Over' or 'Out'
	> Called or not RollOver() function

	- RollOver(ImageId,ImageSrc,ElementId,NameOfClass) return void;
	  ImageId			: Id of image
	  ImageSrc			: Path of image
	  NameOfClass		: ClassName
	> Do roll over

	- SetImageOfModality(InputId,isSelected,ImgCheckedPath,ImgUnCheckedPath) return void;
	  InputId			: Id of input element
	  isSelected		: Do checked or not
	  ImgCheckPath		: Path of image when is checked
	  ImgUnCheckedPath	: Path of image when is unchecked
	> Set image of modality instead of radio button or checkbox

	- UncheckedAllModalities(QuestionId, isUsePicture, isMultiple,isSort,DefaultValue) return void;
	  QuestionId		: Id of question (using attribute QuestionId)
	  isUsePicture		: true when use picture instead of checkbox or radio button
	  isMultiple		: true when question allowed multiple responses
	  isSort			: true when question responses are sort
	  DefaultValue		: response of question => value which doesn't unchecked
	> Unchecked all modalities (except DefaultValue)

	- Replace(sString, sOldChar,sNewChar) return String
	  sString			: Original string 
	  sOldChar	 		: Characters that you want to replace
	  sNewChar			: Replacing characters 
	> Return string

Copyright Askia (c) 1994-2005 --- */

/* --- Global variables --- */
//Variables for Images
var g_strChecked="";		//Images of selected modality
var g_strUnchecked="";		//Images of unselected modality
var g_strOnHover="";		//Images of on hover

var g_strCheckedClass="";	//Class of selected modality
var g_strUncheckedClass=""; //Class of unselected modality
var g_strOnHoverClass="";	//Class on hover

var g_strCurrentImage="";	//Current images
var g_strCurrentClass="";	//Current class

/* --- 	TYPE OF BROWSER --- */
function isIEBrowser(){
	if(document.layers)return false;
	if(document.all)return true;
	if(!document.all && document.getElementById)return false;
}
	
/* --- GO TO NEXT SCREEN --- */
function GoNext(){
	document.FormAskia.submit();
}
	
/* --- DISPLAY / HIDE ELEMENT --- */
function DisplayHide(ElementId,isDisplay) {	
	var strStatus;

	if (isDisplay) 
		strStatus="block";
	else
		strStatus="none";
	if (isIEBrowser) 
		document.getElementById(ElementId).style.display=strStatus ;
	else 
		document.getElementById(ElementId).setAttribute("style","display:" + strStatus );
}
	
/* --- SET VALUE TO NUMERIC QUESTION --- */
function SetValue(ElementId,Value,isGoNext){
	document.getElementById(ElementId).value=Value;
	if (isGoNext)
		GoNext();
}
	
/* --- ENABLED OR DISABLED BUTTON --- */
function EnabledButton(sButtonType,isDisabled){
	switch (sButtonType.toLowerCase()){
		case 'next': 
			GetObjectByName("Next").disabled=isDisabled; 
			break;
		case 'previous': 
			GetObjectByName("Previous").disabled=isDisabled; 
			break;
	}
}
	
/* --- RETURN ELEMENT USING NAME --- */
function GetObjectByName(strName,strObjectType){
	if (strObjectType==null)
		strObjectType="input";
	var ObjectCollection=document.getElementsByTagName(strObjectType);		
				
	for (var i=0;i<ObjectCollection.length;i++){
		if (ObjectCollection[i].getAttribute("name")==strName)
			return ObjectCollection[i];
	}
	return null;
}

/* --- MANAGE ROLLOVER (attach event onMouseOver and onMouseOut) --- */
function Roll(MySelection,Mode){
	var ImageId;
	var strImgOver;
		
	if (MySelection.getAttribute("isUsePicture")=="true"){
		ImageId="IMG" + MySelection.getAttribute("QuestionId")+ " " + MySelection.getAttribute("ResponseId");
		//Search image over
		if (MySelection.getAttribute("OverImgPath")!="" && MySelection.getAttribute("OverImgPath")!=undefined && MySelection.getAttribute("OverImgPath")!=null)
			strImgOver=MySelection.getAttribute("OverImgPath");
		else
			strImgOver=g_strOnHover;
	} else {
		ImageId="";
	}
	if (Mode=="over") {
		//Save state of this image and class
		if (ImageId!="")
			g_strCurrentImage=document.getElementById(ImageId).src;
		g_strCurrentClass=MySelection.className;		
		RollOver(ImageId, strImgOver ,MySelection.id ,g_strOnHoverClass);	//RollOver
	} else {
		RollOver(ImageId, g_strCurrentImage,MySelection.id ,g_strCurrentClass);		//RollOver
	}
}

/* --- DO ROLLOVER --- */
function RollOver(ImageId,ImageSrc,ElementId,NameOfClass){
	if (ImageId!="" && ImageSrc!="") 
		document.getElementById(ImageId).src=ImageSrc;
	if (ElementId!="" && NameOfClass!="")
		document.getElementById(ElementId).className=NameOfClass;		
}

/* --- SET IMAGE AND CLASS OF MODALITY --- */
function SetImageOfModality(InputId,isSelected,ImgCheckedPath,ImgUnCheckedPath){
	if (ImgCheckedPath=="" || ImgCheckedPath==undefined || ImgCheckedPath==null)
		ImgCheckedPath=g_strChecked;
	if (ImgUnCheckedPath=="" || ImgUnCheckedPath==undefined || ImgUnCheckedPath==null)
		ImgUnCheckedPath=g_strUnchecked;
	if (isSelected) {
		GetObjectByName("IMG" + InputId,"IMG").src=ImgCheckedPath;
	}else{
		GetObjectByName("IMG" + InputId,"IMG").src=ImgUnCheckedPath;
	}			
}

/* --- UNCHECKED ALL MODALITIES --- */
/*function UncheckedAllModalities(qId, isUsePicture, isMultiple,isSort,DefaultValue){
	var tdCollection= document.getElementsByTagName("TD");
				
	for (var i=0;i<tdCollection.length;i++){
		t=tdCollection[i];
		if (t.getAttribute("QuestionId")==qId){
			id=qId + " " + t.getAttribute("ResponseId");
			if (isSort)id="chk" + id;
			if (t.getAttribute("ResponseId")!=DefaultValue) { //here somewhere
				GetObjectByName(id,"input").checked=false;
				if (isUsePicture)
					SetImageOfModality(id,false,t.getAttribute("SelectImgPath"),t.getAttribute("UnSelectImgPath"));
			} else {
				GetObjectByName(id,"input").checked=true;
				if (isUsePicture)
					SetImageOfModality(id,true,t.getAttribute("SelectImgPath"),t.getAttribute("UnSelectImgPath"));
			}
		}
	}
}*/
	
/* --- REPLACE --- */
function Replace(sString, sOldChar,sNewChar){
	var nCount=0;
	while (nCount!=-1){
		nCount=sString.indexOf(sOldChar,nCount);
		if (nCount>=0){
			sString=sString.substring(0,nCount)+sNewChar+sString.substring(nCount + sOldChar.length);
			nCount +=sNewChar.length;
		}
	}
	return sString;
}


/* ----------------------------- ResponsesMgt.js -----------------------------*/

/* --- JavaScript for Askia WebProd
	
	Content functions : 
	- Check modality with picture
	- Check exclusive modality in multiple question

	Copyright Askia (c) 1994-2005 --- */

/* --- Function to return the name of td of input --- */
function getTdId(td){
	return td.getAttribute("QuestionId") + " " + td.getAttribute("ResponseId");
}

/* --- Function for load picture of modalities => Call this on body load event --- */
function LoadPicture() {
	var tdCollection=document.getElementsByTagName("TD");
	var strImgChecked,strImgUnChecked;
	var sId, sQId;
		
	//Selection of images (Checked or unchecked)
	for (var i=0;i<tdCollection.length;i++) {
		var t=tdCollection[i];
		if (t.getAttribute("isUsePicture")=="true"){											
			sQId=t.getAttribute("QuestionId");
			ModalityType=getTdId(t).substring(0,1);
			SetImageOfModality(getTdId(t),t.childNodes(0).checked,t.getAttribute("SelectImgPath"),t.getAttribute("UnSelectImgPath"));
		}
	}
}

/* --- Function for load order of modalities => Call this on body load event --- */
function LoadOrder(){
	var tdCollection=document.getElementsByTagName("TD");
		
	//Search max
	for (var i=0;i<tdCollection.length;i++){
		var t=tdCollection[i];
		if (t.getAttribute("isSort")=="true"){
			if (GetObjectByName(getTdId(t)).value!=""){
				if (t.getAttribute("isUsePicture")=="false"){
					GetObjectByName("chk" + getTdId(t)).checked=true;
					if (g_strCheckedClass!="")t.className=g_strCheckedClass;
				}
			} else {
				if (t.getAttribute("isUsePicture")=="false" && g_strUncheckedClass!="")t.className=g_strUncheckedClass;
			}
		}
	}
}

/* --- Function for click checked modality => Call this on click event --- */

function ClickMod(tdClicked) {
} //remove
	/*
	var tdCollection=document.getElementsByTagName("TD");
	var isMultiple=false;
	var isExclu=false;
	var isUsePicture=false;
	var isSort=false;
	var qId=tdClicked.getAttribute("QuestionId");
	var rId=tdClicked.getAttribute("ResponseId");
		
	if (tdClicked.getAttribute("isSort")=="true")isSort=true;
	if (tdClicked.getAttribute("isUsePicture")=="true")isUsePicture=true;
	if (tdClicked.getAttribute("isExclu")=="true")isExclu=true;
	var sImgChk=tdClicked.getAttribute("SelectImgPath");
	var sImgUChk=tdClicked.getAttribute("UnSelectImgPath");
		
	if (!sImgChk)sImgChk=g_strChecked;
	if (!sImgUChk)sImgUChk=g_strUnchecked;			
		
	//Search type of question
	id=getTdId(tdClicked);
	if (id.substring(0,1)=="M") isMultiple=true;
	if (id.substring(0,1)=="R") isMultiple=true;
	if (id.substring(0,1)=="U") isExclu=true;
	
	//Only checked the semi-open
	if (!isMultiple && !isUsePicture){
		CheckSemiOpen();
		return;
	}
		
	//Corrected the id for the virtual checkboxes when 
	//we use the sort of response
	if (isSort && !isUsePicture)id="chk" + id;
				
	switch (isExclu) {
		//EXCLUSIVE (QUESTION IS SIMPLE OR MULTIPLE)
		case true:													
			//Unchecked all modalities and checked my selected modalties
			UncheckedAllModalities(qId,isUsePicture,false,isSort,rId);
			if (isUsePicture)SetImageOfModality(id,true,sImgChk,sImgUChk);
			break;
					
		//NON-EXCLUSIVE (QUESTION IS MULTIPLE)					
		case false:
			var isChecked=false;
					
			if (isUsePicture)InverseSelection(tdClicked.childNodes(0));
			//Search if modality is checked or not
			isChecked=GetObjectByName(id,"input").checked;
							
			//UNCHECKED	MODALITY			
			if (!isChecked){
				if (isUsePicture)SetImageOfModality(id,false,sImgChk,sImgUChk);
			} else {
				if (isUsePicture)SetImageOfModality(id,true,sImgChk,sImgUChk);
							
				//Unchecked all exclusive modalities
				for (var i=0;i<tdCollection.length;i++) {
					t=tdCollection[i];
					if ((t.getAttribute("QuestionId")==qId) && (t.getAttribute("isExclu")=="true")) {
						id=qId+ " " + t.getAttribute("ResponseId");
						if (isSort && !isUsePicture)id="chk" + id;											
						if (isSort) GetObjectByName(qId + " " + t.getAttribute("ResponseId"),"input").value="";
						GetObjectByName(id,"input").checked=false;
						if (isUsePicture)SetImageOfModality(id,false,t.getAttribute("SelectImgPath") ,t.getAttribute("UnSelectImgPath"));
					}
				}
			}
			break;																
	}
	if (isSort)SelectOrder(qId,rId,isChecked,isExclu);
	//CheckSemiOpen();
}
*/
/* --- Function for check is modality is semi-open => Called this on body load event --- */
function CheckSemiOpen(){
	var tdCollection=document.getElementsByTagName("TD");

	for (var i=0;i<tdCollection.length;i++){
		t=tdCollection[i];
		if (t.getAttribute("SemiOpenName")) {
			var txtId=t.getAttribute("SemiOpenName");
			var isUsePicture=false;
			var isMultiple=false;
			var isChecked =false;
			
			id=getTdId(t);
			if (t.getAttribute("isUsePicture")=="true")isUsePicture=true;								
			if (id.substring(0,1)=="M") isMultiple=true;
			if (id.substring(0,1)=="R") isMultiple=true;
						
			//Corrected the id if we use the sorted responses
			if (t.getAttribute("isSort")=="true" && !isPicture) id="chk" + InputId;
			if (isMultiple) isChecked=GetObjectByName(id,"input").checked;
			else isChecked=t.childNodes(0).checked;
			if (isChecked) {
				if (isIEBrowser)
					GetObjectByName(txtId,"input").style.display="block";
				else
					GetObjectByName(txtId,"input").setAttribute("style","display:block");
			} else {
				if (isIEBrowser)
					GetObjectByName(txtId,"input").style.display="none";
				else
					GetObjectByName(txtId,"input").setAttribute("style","display:none");
			}
		}
	}
}
	
/* --- Function use if response was ordered --- */
function SelectOrder(qId,rId,isChecked,isExclu){
	var tdCollection=document.getElementsByTagName("TD");
	var nMax=0;
	var nValue=0;
		
	if (GetObjectByName(qId+ " " + rId).value!="" && isChecked)return;
	
	//Unchecked all responses and clear the textboxes
	if (isExclu){
		for (var i=0;i<tdCollection.length;i++) {
			t=tdCollection[i];
			if (t.getAttribute("QuestionId")==qId){
				if (t.getAttribute("isSort")!="" && t.getAttribute("isSort")!=undefined && t.getAttribute("isSort")!=null)
					GetObjectByName(getTdId(t)).value="";
			}
		}
		GetObjectByName(qId+ " " + rId).value="1";
		return;
	}
	if (isChecked){
		//Search max
		for (var i=0;i<tdCollection.length;i++){
			t=tdCollection[i];
			if (t.getAttribute("QuestionId")==qId){
				if (t.getAttribute("isSort")!="" && t.getAttribute("isSort")!=undefined && t.getAttribute("isSort")!=null) {
					if (parseInt(GetObjectByName(getTdId(t)).value)>nMax)
						nMax=parseInt(GetObjectByName(getTdId(t)).value);
				}
			}
		}								
		GetObjectByName(qId+ " " + rId).value=parseInt(nMax) +1;
	} else {
		nValue=parseInt(GetObjectByName(qId + " " + rId).value);
		for (var i=0;i<tdCollection.length;i++) {
			t=tdCollection[i];
			if (t.getAttribute("QuestionId")==qId) {
				if (t.getAttribute("isSort")!="" && t.getAttribute("isSort")!=undefined && t.getAttribute("isSort")!=null) {
					if (GetObjectByName(getTdId(t)).value>nValue && GetObjectByName(getTdId(t)).value!="")
						GetObjectByName(getTdId(t)).value-=1;
				}
			}
		}
		GetObjectByName(qId+ " " + rId).value="";					
	}
}
	
/* --- Function for inverse selection (if you checked modality with checkbox) => Called this function on click event of checkbox --- */ 
function InverseSelection(chkBox){
	chkBox.checked=!chkBox.checked;
}


/* ----------------------------- Demo.js -----------------------------*/

/* -------------------------------------------------------------------- */
/* Collection of checkboxes which managed by pictures				 	*/
/* -------------------------------------------------------------------- */
function checkboxCollection(){	
	this.all={};
	this.childNodes=[];
	this.load();
}
checkboxCollection.prototype.load=function(){
	var arrchk=document.getElementsByTagName("INPUT");
	for (var i=0;i<arrchk.length;i++){
		if (arrchk[i].type!="checkbox")continue;
		this.add(new checkboxItem (arrchk[i]));
	}
}
checkboxCollection.prototype.add=function(oCheckBoxItem){	
	oCheckBoxItem.parentNode=this;
	this.all[oCheckBoxItem.name]=oCheckBoxItem;
	this.childNodes[this.childNodes.length]=oCheckBoxItem;
}
checkboxCollection.prototype.click=function(imgElt){
	/*if (document.getElementById) // IE*/
	if (document.getElementById && !document.all) // Firefox
		var chk=this.all[imgElt.parentNode.childNodes[1].name];
	else
		var chk=this.all[imgElt.parentNode.childNodes[0].name];
	if (chk.isExclu && !chk.isChecked){
		for (var i=0;i<this.childNodes.length;i++){
			if (this.childNodes[i].name==chk.name)continue;
			this.childNodes[i].setValue(false);
		}
		chk.setValue(true);
	} else {
		for (var i=0;i<this.childNodes.length;i++){
			if (!this.childNodes[i].isExclu)continue;
			this.childNodes[i].setValue(false);
		}
		chk.setValue(!chk.isChecked);		
	}
}
	
function checkboxItem(htmlElt){
	this.name=htmlElt.name;
	this.isExclu=false;
	this.isChecked=htmlElt.checked;
	if (htmlElt.getAttribute("isExclu")=="true")this.isExclu=true;
	if (htmlElt.getAttribute("isExclu")=="false")this.isExclu=false;
	this._htmlElt=htmlElt;
	this.setBorder();
	this.parentNode=null;
}
checkboxItem.prototype.setValue=function(isChecked){
	this.isChecked=isChecked ;
	this._htmlElt.checked=isChecked ;
	this.setBorder();
}
checkboxItem.prototype.setBorder=function(){
	var i=(this._htmlElt.parentNode.childNodes[1].tagName=='img')?1:2;
	if (this.isChecked)
		if (document.getElementById && !document.all) // Firefox
			this._htmlElt.parentNode.childNodes[i+1].className="checked";
		else
			this._htmlElt.parentNode.childNodes[i].className="checked";
	else
		if (document.getElementById && !document.all) // Firefox
			this._htmlElt.parentNode.childNodes[i+1].className="unchecked";
		else
			this._htmlElt.parentNode.childNodes[i].className="unchecked";
}
	
/* -------------------------------------------------------------------- */
/* Collection of radio button which managed by pictures				 	*/
/* -------------------------------------------------------------------- */
function radioCollection(){	
	this.all={};
	this.childNodes=[];
	this.load();
}
radioCollection.prototype.load=function(){
	var arrRd=document.getElementsByTagName("INPUT");
	for (var i=0;i<arrRd.length;i++){
		if (arrRd[i].type!="radio")continue;
		this.add(new radioItem (arrRd[i]));
	}
}
radioCollection.prototype.add=function(oRadioItem){	
	oRadioItem.parentNode=this;
	this.all[oRadioItem.name]=oRadioItem;
	this.childNodes[this.childNodes.length]=oRadioItem;
}
radioCollection.prototype.click=function(imgElt){	
	var rd=this.all[imgElt.parentNode.childNodes[0].value];
	for (var i=0;i<this.childNodes.length;i++){
		if (this.childNodes[i].name==rd.name)continue;
		this.childNodes[i].setValue(false);
	}
	rd.setValue(true);	
}
	
function radioItem(htmlElt){
	this.name=htmlElt.value;
	this.isExclu=false;
	this.isChecked=htmlElt.checked;
	if (htmlElt.getAttribute("isExclu")=="true")this.isExclu=true;
	this._htmlElt=htmlElt;
	this.setBorder();
	this.parentNode=null;
}
radioItem.prototype.setValue=function(isChecked){
	this.isChecked=isChecked ;
	this._htmlElt.checked=isChecked ;
	this.setBorder();
}
radioItem.prototype.setBorder=function(){
	var i=(this._htmlElt.parentNode.childNodes[1].tagName.toLowerCase()=='img')?1:2;
	if (this.isChecked)
		if (document.getElementById && !document.all) // Firefox
		 	this._htmlElt.parentNode.childNodes[i+1].className="checked";
		else
			this._htmlElt.parentNode.childNodes[i].className="checked";
	else
		if (document.getElementById && !document.all) // Firefox
			this._htmlElt.parentNode.childNodes[i+1].className="unchecked";
		else
			this._htmlElt.parentNode.childNodes[i].className="unchecked";
}
/* -------------------------------------------------------------------- */
/* Collection of textbox to manage the drag'n drop of rank				*/
/* -------------------------------------------------------------------- */
var textBoxHandler={
	lastSelection : null
};
function textBoxCollection(beginIndex){
	this.all={};
	this.childNodes=[];
	this.selectedValues={};
	this.lastSelection=null;
	this.lastHTMLSelection=null;
	this.htmlDrop=null;
	this._dX;
	this._dY;
	this.beginIndex=beginIndex;
	textBoxHandler.lastSelection=this;
	this.load();
}
textBoxCollection.prototype.load=function(){
	var arrTxt=document.getElementsByTagName("INPUT");
	for (var i=0;i<arrTxt.length;i++){
		if (arrTxt[i].type!="text")continue;
		this.add(new textboxItem(arrTxt[i],this.childNodes.length + 1));
	}
	
	//Set default values
	for (var i=0;i<this.childNodes.length;i++){
		if (this.childNodes[i]._htmlTextBox.value!=''){
			this.childNodes[i].setValue(this.childNodes[i]._htmlTextBox.value);
		}
	}
}
textBoxCollection.prototype.add=function(oTextBoxItem){
	oTextBoxItem.parentNode=this;
	this.all[oTextBoxItem.name]=oTextBoxItem;
	this.childNodes[this.childNodes.length]=oTextBoxItem;
}
textBoxCollection.prototype.setDropElt=function(htmlElt){
	textBoxHandler.lastSelection.htmlDrop=htmlElt;
	window.status=htmlElt;
}
textBoxCollection.prototype.beginDrag=function(e){
	if (!e)e=window.event;
	var txtBoxCol=textBoxHandler.lastSelection;
	if (e.target) 
		txtBoxCol.lastHTMLSelection=e.target;
	else 
		txtBoxCol.lastHTMLSelection=e.srcElement;

	if (txtBoxCol.lastHTMLSelection.tagName!="div")txtBoxCol.lastHTMLSelection=txtBoxCol.lastHTMLSelection.parentElement;
	txtBoxCol._dX=e.clientX - parseInt(txtBoxCol.lastHTMLSelection.style.left);
	txtBoxCol._dY=e.clientY - parseInt(txtBoxCol.lastHTMLSelection.style.top);
	txtBoxCol.lastSelection=txtBoxCol.all[txtBoxCol.lastHTMLSelection.id.replace('div','')];		
	document.onmousemove=textBoxHandler.lastSelection.drag;
	document.onmouseup=textBoxHandler.lastSelection.drop;

//Stop propagation of event	
	if (e.stopPropagation)e.stopPropagation();
	else e.cancelBubble=true;

	//Unactive default action
	if (e.preventDefault)e.preventDefault();
	else e.returnValue=false;
}
textBoxCollection.prototype.drag=function(e){
	if(!e) e=window.event;
	if (!textBoxHandler.lastSelection)return;
	if (!textBoxHandler.lastSelection.lastHTMLSelection)return;
	var txtBoxCol=textBoxHandler.lastSelection;
	txtBoxCol.lastHTMLSelection.style.left=(e.clientX - txtBoxCol._dX) + "px";
	txtBoxCol.lastHTMLSelection.style.top=(e.clientY - txtBoxCol._dY) + "px";
	
	if (e.stopPropagation)e.stopPropagation();
	else e.cancelBubble=true;	
}
textBoxCollection.prototype.drop=function(e){
	var txtBoxCol=textBoxHandler.lastSelection;
	if(!e) e=window.event;
	//Remove event
	document.onmouseup=null;
	document.onmousemove=null;
	
	var iLeft,iTop;
	iLeft=parseInt(txtBoxCol.lastHTMLSelection.style.left);
	iTop=parseInt(txtBoxCol.lastHTMLSelection.style.top);
	txtBoxCol.htmlDrop=null;
	
	var iVal=null;
	var lOk,tOk;
	for (var i=1;i<txtBoxCol.childNodes.length + 1;i++){
		l=parseInt(document.getElementById("target" + i).style.left);
		t=parseInt(document.getElementById("target" + i).style.top);								
		lOk=((l - 289)<=iLeft && iLeft<=(l + 290));
		tOk=((t - 27)<=iTop && iTop<=(t + 27));
		if (lOk && tOk){
			iVal=i;
			break;
		}
	}
		
	if (iVal!=null){
		if (txtBoxCol.selectedValues[iVal])txtBoxCol.selectedValues[iVal].setValue(iVal,true);
	}
	txtBoxCol.lastSelection.setValue(iVal);
}

function textboxItem(htmlElt,index){
	this.name=htmlElt.name;
	this._htmlTextBox=htmlElt;
	this._htmlDiv=document.getElementById("div" + this.name);
	this.value=this._htmlTextBox.value;
	this.parentNode=null;
	
	var l,t;
	l=parseInt(getOffSet(this._htmlTextBox.parentElement,'offsetLeft'));
	t=parseInt(getOffSet(this._htmlTextBox.parentElement,'offsetTop'));
	var str='<div style="left:' + l + 'px;top:' + t  + 'px;border:1px solid black;width:290px;height:25px;padding-top:2px" id="target' + index + '">'  +   (textBoxHandler.lastSelection.beginIndex + index) + '.</div>';
	this._htmlTextBox.parentElement.insertAdjacentHTML('AfterBegin',str);
			
	//Add left and top in style		
	this.originalTop=parseInt(getOffSet(document.getElementById("target" + index),'offsetTop'));
	this.originalLeft=parseInt(getOffSet(document.getElementById("target" + index),'offsetLeft')) + 320;
	
	this._htmlDiv.style.left= this.originalLeft + 'px';
	this._htmlDiv.style.top= this.originalTop + 'px';
			
	//Return position of element		
	function getOffSet(oObj,sProp ){
		var iVal = 0; 
		while (oObj && oObj.tagName != 'BODY') { 
			eval('iVal += oObj.' + sProp + ';');
			oObj = oObj.offsetParent; 
		} 
		return iVal; 
	}  		
}
textboxItem.prototype.setValue=function(val,isClear){
	if (isClear || !val){	
		if (val){
			if (val !=this.value){
				this.parentNode.selectedValues[this.value]=this;
				return;
			}
		}
		this.parentNode.selectedValues[this.value]=null;
		this._htmlDiv.style.left= this.originalLeft + 'px';
		this._htmlDiv.style.top= this.originalTop + 'px';				
		this._htmlTextBox.value='';
		this.value='';		
		return;
	}
	var l,t;
	l=parseInt(document.getElementById("target" + val).style.left) + 20;
	t=parseInt(document.getElementById("target" + val).style.top) + 5;

	this._htmlDiv.style.left= l+ 'px';
	this._htmlDiv.style.top= t + 'px';	
	this._htmlTextBox.value=val;
	this.value=val;
	this.parentNode.selectedValues[val]=this;
}
	
/* -------------------------------------------------------------------- */
/* Collection of sliders												*/
/* -------------------------------------------------------------------- */
function slidersCollection(){
	this.all={};
	this.childNodes=[];
	this.lastSelection=null;
	this.lastHTMLSelection=null;
	this.id='sldCol';
	this._dX;
	this._dY;
	window['sldCol']=this;
	this.load();
}
slidersCollection.prototype.load=function(){
	var arrDiv=document.getElementsByTagName("DIV");
	for (var i=0;i<arrDiv.length;i++){
		if(arrDiv[i].id.indexOf("sld")==-1)continue;
		this.add(new slider(arrDiv[i].id.replace("sld",""),this));
	}
}
slidersCollection.prototype.add=function(oSlider){
	oSlider.parentNode=this;
	this.all[oSlider.id]=oSlider;
	this.childNodes[this.childNodes.length]=oSlider;
}

slidersCollection.prototype.beginDrag=function(e){
	if (!e)e=window.event
	if (e.target) 
		sldCol.lastHTMLSelection=e.target;
	else 
		sldCol.lastHTMLSelection=e.srcElement;
			
	sldCol._dX=e.clientX - parseInt(sldCol.lastHTMLSelection.style.left);
	sldCol._dY=e.clientY - parseInt(sldCol.lastHTMLSelection.style.top);
				
	sldCol.lastSelection=sldCol.all[sldCol.lastHTMLSelection.id.replace('cur','')];		
	document.onmousemove=sldCol.drag;
	document.onmouseup=sldCol.drop;

	//Stop propagation of event	
	if (e.stopPropagation)e.stopPropagation();
	else e.cancelBubble=true;

	//Unactive default action
	if (e.preventDefault)e.preventDefault();
		else e.returnValue=false;
	}
slidersCollection.prototype.drag=function(e){
	if(!e) e=window.event;
	if (!sldCol.lastSelection)return;
	if (!sldCol.lastHTMLSelection)return;
	
	var l=parseInt(e.clientX - sldCol._dX);
	if (l>sldCol.lastSelection.width)return;
	if (l<0)return;
	sldCol.lastHTMLSelection.style.left=l + "px";
	
	var iVal=sldCol.lastSelection.ratio * l;
	iVal=parseInt(iVal) ;
	var iAdd=(5 -(iVal % 5 ));
	if (iAdd==5)iAdd=0;
	iVal +=iAdd;
	iVal +=sldCol.lastSelection.availMin;
	sldCol.lastSelection.setValue(iVal);
	
	//sldCol.lastHTMLSelection.style.top=(e.clientY - sldCol._dY) + "px";
	
	if (e.stopPropagation)e.stopPropagation();
	else e.cancelBubble=true;	
}
slidersCollection.prototype.drop=function(e){
		if(!e) e=window.event;
		//Remove event
		document.onmouseup=null;
		document.onmousemove=null;
		sldCol.lastSelection.swap();
	}

function slider(id,parentNode){
	this.id=id;
	this._htmlElt=document.getElementById("sld" + this.id);
	this.width=parseInt(this._htmlElt.style.width)-30;
	this.availMin=parseInt(this._htmlElt.getAttribute("vMin"));
	this.availMax=parseInt(this._htmlElt.getAttribute("vMax")) - this.availMin;
	this.ratio=this.availMax / this.width;
	this.minValue=this.availMin;
	this.maxValue=this.availMax + this.availMin;
	this._txtMin=document.getElementById("txtMin" + this.id);
	this._txtMax=document.getElementById("txtMax" + this.id);
	if (this._txtMin.value!='')this.minValue=this._txtMin.value;
	if (this._txtMax.value!='')this.maxValue=this._txtMax.value;
	this._txtMin.value=this.minValue;
	this._txtMax.value=this.maxValue;
		
	document.getElementById("rspMin" + this.id).innerText=this.minValue;
	document.getElementById("rspMax" + this.id).innerText=this.maxValue;
	this.currentSelection=this._txtMin;
	this.parentNode=parentNode;
		
	var str='<div onmousedown="' + this.parentNode.id  + '.beginDrag();" id="cur' + this.id + '" style="position:relative;left:0px;width:30px;cursor:hand;background:url(\'../resources/rndemo/slidCur.gif\');background-repeat: no-repeat;" class="curMin"></div>';
	this._htmlElt.innerHTML=str;	
	this.setPosition();	
}
slider.prototype.swap=function(){
	this.currentSelection=(this.currentSelection==this._txtMin)?this._txtMax:this._txtMin;
	document.getElementById("cur" + this.id).className=(this.currentSelection==this._txtMin)?'curMin':'curMax';
	document.getElementById("cur" + this.id).title=(this.currentSelection==this._txtMin)?"Min":"Max";
}
slider.prototype.setPosition=function(){
	var iVal=parseInt(this.currentSelection.value);
	iVal -=this.availMin;
	var l=parseInt(iVal / this.ratio);	
	document.getElementById("cur" + this.id).style.left=l + "px";
}
slider.prototype.setValue=function(val){
	if (this.currentSelection==this._txtMin){
		this.minValue=val;
		document.getElementById("rspMin" + this.id).innerText=val;
	} else {
		this.maxValue=val;
		document.getElementById("rspMax" + this.id).innerText=val;
	}
	this.currentSelection.value=val;
}



/* ------------------------------ Calendar.js --------------------------------*/

///////////////////////////////////////////////////////////////////////////////////////////
//*								GLOBAL VARIABLES DECLARATION							 */
///////////////////////////////////////////////////////////////////////////////////////////

//VARIABLES OF PARENT AND CHILD OF DOCUMENT 
	var g_strCellOfCal;
	var g_strIdTxtBoxOfCal;
	
//VARIABLES FOR INITIALIZE DATE TODAY
	var g_dtToday		= new Date();				//Date today
	var g_dtDayToday	= g_dtToday.getDate();		//Day of date today
	var g_dtMonthToday	= g_dtToday.getMonth();		//Month of date today
	var g_dtYearToday	= g_dtToday.getFullYear();	//Year today with 4 digits

//VARIABLES FOR SELECTED DATE
	var g_dtSelDay		= null;						//Day is selected
	var g_dtSelMonth	= null;						//Month is selected
	var g_dtSelYear		= null;						//Year is selected
	var g_strFormatDate;							//Format date (dd/mm/yyyy) by default

//VARIABLES FOR NAVIGATION
	var g_dtMonth;									//Current month in calendar 
	var g_dtYear;									//Current year in calendar
	
	var g_isCalendarVisible = false;                //Is Calendar visible

//VARIABLES OF MINIMUM / MAXIMUM AND DEFAULT VALUES
	var g_isDisabledDay	= false;                    //Is day is enabled or not
	var g_dtMinDay;		var g_dtMinMonth;		var g_dtMinYear;
	var g_dtMaxDay;		var g_dtMaxMonth;		var g_dtMaxYear;
	var g_dtDefaultDay; var g_dtDefaultMonth;	var g_dtDefaultYear;
	
//SET-UP VARIABLES
	//VARIABLES FOR ARRAY OF MONTH AND DAY
	var g_arrStrMonth = new Array;
	var g_arrStrDay	  = new Array;

	//VARIABLES FOR PATH OF IMAGES	
	var imgNextMonth	= "../Scripts/cal_Next.gif";		//Image for next button
	var imgPrevMonth	= "../Scripts/cal_Prev.gif";		//Image for previous button
	var imgCloseButton	= "../Scripts/cal_Close.gif";	//Image for close calendar

	//VARIABLES FOR TOOLTIPTEXT (Title)
	var strTitlePrevMonth;							  //Title for previous month
	var strTitleNextMonth;							  //Title for next month
	var strTitleClose;				                  //Title for Close button


/////////////////////////////////////////////////////////////////////////////////////////////////
//										FUNCTIONS FOR SHOW CALENDAR							   //
/////////////////////////////////////////////////////////////////////////////////////////////////


//****************************************************************************************/
//*								FUNCTION FOR SHOW CALENDAR								 */
//*									*** PARAMETERS	***									 */
//* - nLangId		 : Id of language (same *.qes)										 */
//* - strIdTDOfCal	 : Id of frame for display calendar in parent document				 */
//* - strIdTxtBoxCal : Id of text box for return value									 */
//* - datDefault	 : Default date when calendar is open								 */
//* - datMin		 : Minimum date is available										 */
//* - datMax		 : Maximum date is available										 */
//* - strFormat      : Format of date is return separated with "/" example :"JJ/MM/YYYY" */
//****************************************************************************************/

function ShowCalendar(nLangId,strIdTDOfCal,strIdTxtBoxOfCal,datDefault,datMin,datMax,strFormat) {
	//If calendar is not visible
	if (g_isCalendarVisible==false) {
		//Init Id of object for display Calendar in parent doc
		g_strCellOfCal = strIdTDOfCal;
		g_strIdTxtBoxOfCal=strIdTxtBoxOfCal;

		//Init language
		if (nLangId!='') {GetLanguage(nLangId);}
		else {GetLanguage('2057');}
	
		//Init format date is return
		g_strFormatDate=strFormat;
					
		//Init min/max/default date and format of date is return
		if (datMin!='' && isNaN(datMin.substring(3,5))==false) {g_dtMinDay=parseInt(datMin.substring(0,2)); g_dtMinMonth=parseInt(datMin.substring(3,5))-1; g_dtMinYear=parseInt(datMin.substring(6,10));}
		else {g_dtMinDay=1;g_dtMinMonth=1;g_dtMinYear=1900;}
		if (datMax!='' && isNaN(datMax.substring(3,5))==false){g_dtMaxDay=parseInt(datMax.substring(0,2));  g_dtMaxMonth=parseInt(datMax.substring(3,5))-1; parseInt(g_dtMaxYear=datMax.substring(6,10));}
		else {g_dtMaxDay=31;g_dtMaxMonth=11; g_dtMaxYear=2033;}
		if (datDefault!='' && isNaN(datDefault.substring(3,5))==false){g_dtDefaultDay=parseInt(datDefault.substring(0,2)); g_dtMonth=parseInt(datDefault.substring(3,5))-1; g_dtYear=parseInt(datDefault.substring(6,10));}
		else {g_dtDefaultDay=g_dtDayToday; g_dtMonth=g_dtMonthToday; g_dtYear=g_dtYearToday;}
			
		//Search Last selected date
		var strSelectedDate=document.getElementById(g_strIdTxtBoxOfCal).value;
		if (strSelectedDate!=""){InitSelectedDate(strSelectedDate);}
			
		DrawTableOfCalendar();					//Draw Calendar
		g_isCalendarVisible=true;
		GetItemsOfCalendar(g_dtMonth,true);		//Add item in Calendar			
	}
}



//****************************************************************************************/
//*									FUNCTION FOR DRAW CALENDAR							 */
//*																						 */
//****************************************************************************************/

function DrawTableOfCalendar(){
	//Declaration
	var nCounter=0;               //Counter
	var nCounter2=0;              //Second Counter
	var strHTMLTable;             //String of HTML Table for Calendar
	var strCmbMonth="";		      //String for combo Month
	var strCmbYear="";		      //String for combo Year
	var strTemp="";               //Temporary string 
	
	//Combo of Month
	strCmbMonth="<select class='calCmbMonth' name='cmbMonth' id='cmbMonth' onclick='GetItemsOfCalendar(this.options[this.selectedIndex].value,true);'>";	
	for (nCounter=0; nCounter<12; nCounter++){	
			if(nCounter==g_dtMonth){strCmbMonth=strCmbMonth + "<option value='" + nCounter + "' selected>" + g_arrStrMonth[nCounter] + "</option>";}
			else {strCmbMonth=strCmbMonth + "<option value='" + nCounter + "'>" + g_arrStrMonth[nCounter] + "</option>";}
		}	
	strCmbMonth=strCmbMonth + "</select>";

	//Combo of Year
	strCmbYear="<select class='calCmbYear'  name='cmbYear' id='cmbYear' onclick='GetYearOfCalendar(this.options[this.selectedIndex].value);'>" ;
	if (g_dtMinYear!=g_dtMaxYear){
		for (nCounter=g_dtMinYear; nCounter<=g_dtMaxYear; nCounter++){
			if (nCounter==g_dtYear){strCmbYear=strCmbYear + "<option value='" + nCounter + "' selected>" + nCounter + "</option>" ;}
			else{strCmbYear=strCmbYear + "<option value='" + nCounter + "'>" + nCounter + "</option>" ;	}
		}
	}else{
		strCmbYear=strCmbYear + "<option value='" + g_dtMinYear +"'>" + g_dtMinYear + "</option>";
	}
	
	//HTML structure of calendar table
	strHtmlTable = "<table id='tblCal' class='calTblCalendar' cellspacing='0' cellpadding='0'>"
	+ "<tr class='calTopBorder'><td class='calTopLeftBorder'><input type='image' src='" + imgPrevMonth + "' onclick='GetItemsOfCalendar(g_dtMonth-=1,true);return false;' title='" + strTitlePrevMonth + "'></td><td id='cbMonth' class='calMonth' colspan='4'>" + strCmbMonth + "</td><td class='calYear' id='cbYear' colspan='3'>" + strCmbYear + "</td><td class='calTopRightBorder'><input type='image' src='" + imgNextMonth + "' onclick='GetItemsOfCalendar(g_dtMonth+=1,true);return false;' title='" + strTitleNextMonth + "'></td></tr>"
	+ "<tr class='calLetterOfDay'><td rowspan='7'class='calBorderLeft'></td><td class='calLetterOfDay'>" + g_arrStrDay[0] + "</td><td class='calLetterOfDay'>" + g_arrStrDay[1]+ "</td><td class='calLetterOfDay'>" + g_arrStrDay[2]+ "</td><td class='calLetterOfDay'>" + g_arrStrDay[3]+ "</td><td class='calLetterOfDay'>" + g_arrStrDay[4]+ "</td><td class='calLetterOfDay'>" + g_arrStrDay[5]+ "</td><td class='calLetterOfDay'>" + g_arrStrDay[6]+ "</td><td rowspan='7'class='calBorderRight'></td></tr>" 
	strTemp="<tr class='calDay'>";
	for (nCounter=0; nCounter<=41; nCounter++){
		if (nCounter2!=7){strTemp=strTemp + "<td id='" + nCounter + "' class='calEnabledDay'></td>";nCounter2++;}
		else {strTemp=strTemp + "</tr><tr class='calDay'><td class='calEnabledDay' id='" + nCounter + "'></td>";	nCounter2=1;}
	}
	strHtmlTable=strHtmlTable + strTemp	
	+ "</tr><tr class='calBottomBorder'><td class='calBottomLeftBorder'></td><td class='calBottomMiddleBorder' colspan='7'></td><td class='calBottomRightBorder' onClick='CloseCalendar(this,true);' title='" + strTitleClose + "'><img src='" + imgCloseButton + "'></td></tr>"
	+ "</table>";
		
	//Write table of calendar in parent document
	document.getElementById(g_strCellOfCal).innerHTML = strHtmlTable;

	//SET-UP Of Table
	with(document.getElementById('tblCal').style){borderCollapse = 'collapse';}
}


//****************************************************************************************/
//*									 GET ITEM BY YEAR									*/
//*									*** PARAMETERS ***									*/
//* -nYear : Year is display																*/																						*/
//****************************************************************************************/

function GetYearOfCalendar(nYear)
{
	g_dtYear=nYear; 
	GetItemsOfCalendar(g_dtMonth,true);
}

//****************************************************************************************/
//*								FUNCTION FOR ADD ITEM IN CALENDAR					    */
//*									*** PARAMETERS	***									*/
//* - nMonth	: Month is display (nMonth=Really Month - 1									*/
//****************************************************************************************/

function GetItemsOfCalendar(nMonth,isNavigation){
	//Declaration
	var dtNow=new Date(); //Date today
	var nCounter;         //Counter for loops (FOR)
	var nDayCounter;      //Counter of day
	var nCellCounter;     //Counter of Cell
	var isDisabledDay;    //If day is not between min and max value
	
	//Initialize g_dtYear and g_dtMonth by nMonth
	if (nMonth == null || nMonth==""){
		//Get Current Month and Year
		g_dtMonth = dtNow.getMonth();		//Current month
		g_dtYear = dtNow.getFullYear();	    //Current year
	} else {
		//IF month < 1 then YEAR =YEAR -1 AND MONTH =12
		if (nMonth < 0){
			g_dtYear = dtNow.getFullYear(dtNow.setFullYear(g_dtYear-1));
			g_dtMonth = dtNow.getMonth(dtNow.setMonth(11));
		} 
		//IF MONTH > 12 THEN YEAR=YEAR+1 AND MONTH=1
		else if (nMonth>11){
			g_dtYear = dtNow.getFullYear(dtNow.setFullYear(g_dtYear+1));		
			g_dtMonth = dtNow.getMonth(dtNow.setMonth(0));
		}
		//ELSE YEAR AND MONTH IS OK
		else {
			g_dtYear = dtNow.getFullYear(dtNow.setFullYear(g_dtYear));
			g_dtMonth = dtNow.getMonth(dtNow.setMonth(nMonth));
		}
	}
	
	//Clear calendar item in calendar (TD 0 to TD 42)
	for(nCounter=0;nCounter<42;nCounter++) {
		document.getElementById(nCounter).innerHTML = "";
		document.getElementById(nCounter).className="calEmptyDay";
	}

	//Initialize index of first day in month
	nDayCounter = 1;
	dtNow.setDate(nDayCounter);
	
	//Search first day in month and initialize counter for start loops
	switch (dtNow.getDay()) {
		case 0 : nCellCounter = 6; break; 
		case 1 : nCellCounter = 0; break; 
		case 2 : nCellCounter = 1; break; 
		case 3 : nCellCounter = 2; break; 
		case 4 : nCellCounter = 3; break; 
		case 5 : nCellCounter = 4; break; 
		case 6 : nCellCounter = 5; break;
	}	

	//Add-item all day in month table
	//While Month is always in dtNow month...
	while(g_dtMonth == dtNow.getMonth()) {
		g_isDisabledDay=false;
		CheckMinAndMaxDay(nDayCounter);
				
		//DAY IS ENABLED
		if (g_isDisabledDay==false) {
			document.getElementById(nCellCounter).innerHTML = "<a onclick='CloseCalendar(this,false);'>" + dtNow.getDate() + "</a>";
				
			//If date is draw is date today, define specific style for this cell
			if (nDayCounter == g_dtDayToday && g_dtMonth == g_dtMonthToday && g_dtYear == g_dtYearToday) 
			{document.getElementById(nCellCounter).className="calDayToDay";} 
			else {document.getElementById(nCellCounter).className="calEnabledDay";}
		}
	
		//DAY IS DISABLED
		else {
			document.getElementById(nCellCounter).innerHTML ="<Nothing>" + dtNow.getDate() + "</Nothing>";
			document.getElementById(nCellCounter).className="calDisabledDay";
		}	
		nDayCounter++;
		nCellCounter++;
		dtNow.setDate(nDayCounter);		//Next day
	}

	//Show information of month and year		
	document.getElementById("cmbMonth").selectedIndex =g_dtMonth;
	document.getElementById("cmbYear").selectedIndex = g_dtYear - g_dtMinYear;
		
}

//****************************************************************************************/
//*									FUNCTION FOR CLOSE CALENDAR					         */
//*																						 */
//****************************************************************************************/

function CloseCalendar(objSelectedCell,isCloseButton)
{
	//Declaration
	var dtNow=new Date(); //Date today
	var nCounter;         //Counter for loops (FOR)
	var dtDateReturn="";  //Date is return
	var strFormat;		  //Format of date
	var strTemp="";
		
	//Close calendar with close button
	if(isCloseButton==true){							
		g_isCalendarVisible = false;
	}
		
	//If close by click on the date
	else {
		//Show selected date in form
		g_dtSelDay = objSelectedCell.innerHTML;
		g_dtSelDay=((g_dtSelDay)<10)? "0"+(g_dtSelDay) : g_dtSelDay;
		g_dtSelMonth=g_dtMonth+1;
		g_dtSelMonth=((g_dtSelMonth)<10)? "0"+(g_dtSelMonth) : g_dtSelMonth;
		g_dtSelYear = g_dtYear;
			
		//Format of date is return
		if (g_strFormatDate!='') {
			strFormat=g_strFormatDate.split("/");
			for (nCounter=0;nCounter<strFormat.length;nCounter++){
				switch(strFormat[nCounter].toLowerCase()) {
					case 'dd'	:dtDateReturn=dtDateReturn + g_dtSelDay;break;
					case 'jj'	:dtDateReturn=dtDateReturn + g_dtSelDay;break;
					case 'mm'	:dtDateReturn=dtDateReturn + g_dtSelMonth;break;
					case 'yy'	:dtDateReturn=dtDateReturn + g_dtSelYear;break;
					case 'aa'	:dtDateReturn=dtDateReturn + g_dtSelYear;break;
					case 'yyyy'	:dtDateReturn=dtDateReturn + g_dtSelYear;break;
					case 'aaaa'	:dtDateReturn=dtDateReturn + g_dtSelYear;break;
				}
				if (nCounter<(strFormat.length - 1)){dtDateReturn=dtDateReturn + '/';}
			}
		} else {
			dtDateReturn=g_dtSelDay + "/" + g_dtSelMonth + "/" + g_dtSelYear;}
			
		//Get date in text box
		document.getElementById(g_strIdTxtBoxOfCal).value = dtDateReturn;
			
		//Reinit variable of navigation and init year and month for next navigation in calendar
		g_isCalendarVisible = false;
	}

	//Not display calendar
	document.getElementById(g_strCellOfCal).innerHTML = "";
}


//****************************************************************************************/
//*                        FUNCTION FOR INIT SELECTED DATE						         */
//****************************************************************************************/

function InitSelectedDate(strSelectedDate)
{
	//Declaration
	var strSelDate;
	var nSelDay;
	var nSelMonth;
	var nSelYear;
	var strFormat;
	var nCounter;
	
	//Search with Format of date
	strSelDate=strSelectedDate.split("/");
	if (g_strFormatDate!=''){
		strFormat=g_strFormatDate.split("/");
		for (nCounter=0;nCounter<strFormat.length;nCounter++) {
			switch(strFormat[nCounter].toLowerCase()) {
				case 'dd'	:nSelDay=strSelDate[nCounter];break;
				case 'jj'	:nSelDay=strSelDate[nCounter];break;
				case 'mm'	:nSelMonth=strSelDate[nCounter];break;
				case 'yy'	:nSelYear=strSelDate[nCounter];break;
				case 'aa'	:nSelYear=strSelDate[nCounter];break;
				case 'yyyy'	:nSelYear=strSelDate[nCounter];break;
				case 'aaaa'	:nSelYear=strSelDate[nCounter];break;
			}
		}
	} else {
		nSelDay=strSelDate[0];
		nSelMonth=strSelMonth[1];
		nSelYear=strSelYear[2];
	}
	if (isNaN(nSelMonth)==false){g_dtMonth=nSelMonth-1;}
	if (isNaN(nSelMonth)==false){g_dtYear=nSelYear;}
}

//****************************************************************************************/
//*                        FUNCTION FOR CHECK IS DATE IS AVAILABLE FOR SELECTION         */
//****************************************************************************************/
function CheckMinAndMaxDay(nDay) {
		if (g_dtMaxYear<g_dtYear || g_dtMinYear>g_dtYear){g_isDisabledDay=true;}
			
		//MAX YEAR IS EQUAL OF THIS YEAR
		else if (g_dtMaxYear==g_dtYear && g_dtMinYear!=g_dtYear) {
			if (g_dtMaxMonth<g_dtMonth){g_isDisabledDay=true;}
			else if (g_dtMaxMonth==g_dtMonth) {
				if (g_dtMaxDay<nDay){g_isDisabledDay=true;}
				else{g_isDisabledDay=false;}
			} else {g_isDisabledDay=false;}
		}
			
		//MIN YEAR IS EQUAL OF THIS YEAR
		else if (g_dtMinYear==g_dtYear && g_dtMaxYear!=g_dtYear) {
			if (g_dtMinMonth > g_dtMonth){g_isDisabledDay=true;}
			else if (g_dtMinMonth==g_dtMonth) {
				if (g_dtMinDay>nDay){g_isDisabledDay=true;}
				else{g_isDisabledDay=false;}
			} else {g_isDisabledDay=false;}
		}
		//SAME YEAR BETWEEN THREE VARIABLE
		else if (g_dtMinYear==g_dtYear && g_dtMaxYear==g_dtYear) {
			//SAME MONTH
			if (g_dtMaxMonth==g_dtMinMonth && g_dtMaxMonth==g_dtMonth) {
				if (nDay>g_dtMaxDay || nDay<g_dtMinDay){g_isDisabledDay=true;}
				else{g_isDisabledDay=false;}
			} else if(g_dtMaxMonth < g_dtMonth || g_dtMinMonth > g_dtMonth) {
				g_isDisabledDay=true;
			} else if (g_dtMaxMonth==g_dtMonth && g_dtMinMonth!=g_dtMonth) {
				if (nDay>g_dtMaxDay){g_isDisabledDay=true;}
				else {g_isDisabledDay=false;}
			} else if (g_dtMinMonth == g_dtMonth && g_dtMaxMonth!=g_dtMonth) {
				if (nDay < g_dtMinDay){g_isDisabledDay=true;
			} else {g_isDisabledDay=false;}
		}
	} else {g_isDisabledDay=false;}
}

//****************************************************************************************/
//*                        FUNCTION FOR GET LANGUAGE							         */
//****************************************************************************************/

function GetLanguage(nLangId){	
	switch(nLangId){
	//FRENCH
	case '1036' :
		g_arrStrMonth	=  Array('Janvier','F&eacute;vrier','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','D&eacute;cembre');
		g_arrStrDay		=  Array('L','M','M','J','V','S','D');
		strTitlePrevMonth	= "Mois pr&eacute;c&eacute;dent";
		strTitleNextMonth	= "Mois suivant";
		strTitleClose		= "Fermer";
		break;
				
	//ENGLISH UK	
	case '2057' :
		g_arrStrMonth	=  Array('January','February','March','April','May','June','July','August','September','October','November','December');
		g_arrStrDay		=  Array('M','T','W','T','F','S','S');
		strTitlePrevMonth	= "Previous Month";
		strTitleNextMonth	= "Next Month";
		strTitleClose		= "Close";				
		break;
	}		
}

/*------------------------------------ Slider.js -----------------------------------------*/

/* ---------
								Slider object
				This component will manage the Slider GUI control
	- Dependencies
		- classical.js or other available skin
		- boxsizing.htc
		- AskQuestion.js
	- Created 2005-09-07
	- Updated 2005-09-12
	
All rights reserved
Copyright � Askia 1994 - 2005
--------- */

//----------------------------------------------------------------------------
/* --- Public enum	--- */
//Type of sliders
var eSliderType ={
	slider	: 0,
	scrollBar : 1	
};
//Direction of scrolling
var eScroll={
	down	:-1,
	up		:1
};
//Orientation of sliders
var eOrientation={
	horizontal : 'horizontal',
	vertical   : 'vertical'
};
	
//ClassName of HTMLelements
var eClassName={
	slider		: 'slider-container',
	bar			: 'bar',
	minSide		: 'minSide',
	maxSide		: 'maxSide',
	cursor		: 'cursor',
	cursorOver  : 'cursor hover'
};
	
//----------------------------------------------------------------------------
/* --- Collection of sliders--- */
var slidersCollection=[];

//----------------------------------------------------------------------------
/* --- Slider CONSTRUCTOR --- */
function Slider(sliderType,htmlElementId, htmlInputId, htmlOutputId, orientation, isUseQuestion,isNumeric,isAllowDk, minValue, maxValue) {
	if (!htmlElementId) return;
	if (!htmlInputId)return;
		
	this.type=sliderType;
	this.container = document.getElementById(htmlElementId);//Container of slider
	this.input = document.getElementById(htmlInputId);		//Classical input to set the value of change
	this.output=null;										//HtmlElement to write the value
	if (htmlOutputId)this.output=document.getElementById(htmlOutputId);
	
	this._orientation = eOrientation.horizontal;		//Orientation of slider
	if (orientation)this._orientation=orientation;
	this.question=null;								//Question associated with slider
		
	if (isUseQuestion){
		var min=0;
		var max=100;
		var value=0;
		
		if (minValue)min=minValue;
		if (maxValue)max=maxValue;
		this.question=new AskQuestion(this.input,'',isNumeric,null,min,max);
		this.question.isAllowDk=isAllowDk;
		this.question.init();
			
		if (!this.question.isNumeric) {
			max=this.question.responses.length-1;				
		}
			
		//Set the current value and write it on output element
		value=this.question.value;
		if (this.question.isNumeric && this.output)this.output.innerHTML=value;
		if (!this.question.isNumeric && this.output)this.output.innerHTML=this.question.responses[value].text;
			
		//Add range of question
		this._range=new sliderRange(min,max,value);		
	} else {
		this._range = new sliderRange();					//Range of value
	}

	this.blockIncrement = 10;							//Increment when mousewheel, pgUp, pgDown ....
	this.unitIncrement = 1;								//Unit of increment
	this._timer = new sliderTimer(100);					//Timer to simulate drag event when classical drag method failed				
	
	//Create the slider container
	if (Slider.isSupported) {
		//keep document in memory
		this.document = this.container.ownerDocument || this.container.document;

		//Keep container in memory
		this.container.slider = this;
		
		//Set the style and className of container
		this.container.unselectable = "on";
		this.container.className = this._orientation + " " + eClassName.slider + " " + this.container.className;
		
		//Create min side
		this.minSide=this.document.createElement("DIV");
		this.minSide.className=eClassName.minSide;
		this.container.appendChild(this.minSide);
		
		//Create max side
		this.maxSide=this.document.createElement("DIV");
		this.maxSide.className=eClassName.maxSide;
		this.container.appendChild(this.maxSide);
				
		//Create and add bar in container
		this.bar = this.document.createElement("DIV");
		this.bar.className = eClassName.bar;
		this.bar.unselectable = "on";
		this.bar.appendChild(this.document.createElement("DIV"));
		this.container.appendChild(this.bar);
			
		//Create and add cursor in container
		this.cursor = this.document.createElement("DIV");
		this.cursor.className = eClassName.cursor;
		this.cursor.unselectable = "on";
		this.cursor.appendChild(this.document.createElement("DIV"));
		this.cursor.firstChild.appendChild(this.document.createTextNode(String.fromCharCode(160)));
		this.container.appendChild(this.cursor);
				
		//Define the behaviour on HTMLElement
		this.container.onfocus		= SliderEventHandler.onfocus;
		this.container.onblur		= SliderEventHandler.onblur;
		this.container.onmousedown	= SliderEventHandler.onmousedown;
		this.container.onmouseover	= SliderEventHandler.onmouseover;
		this.container.onmouseout	= SliderEventHandler.onmouseout;
		this.container.onkeydown	= SliderEventHandler.onkeydown;
		this.container.onkeypress	= SliderEventHandler.onkeypress;
		this.container.onmousewheel	= SliderEventHandler.onmousewheel;
		this.cursor.onselectstart	= this.container.onselectstart = function () { return false; };
		
		//Behaviour for scollbar
		if (this.type==eSliderType.scrollBar){
			this.minSide.onmousedown	= SliderEventHandler.onscrolldown;
			this.maxSide.onmousedown	= SliderEventHandler.onscrollup;
			this.minSide.onmouseup		= SliderEventHandler.cancelScroll;
			this.maxSide.onmouseup		= SliderEventHandler.cancelScroll;
		}
	}
	
	//Attached function if the value of range is changing
	var _THIS = this;
	this._range.onchange = function () {
		_THIS.recalculate();
		if (_THIS.question){
			if (!_THIS.question.isNumeric){
				r=_THIS.question.responses[_THIS.getValue()];
				if (_THIS.output)_THIS.output.innerHTML=r.text;
				_THIS.onchange(r);
				return;
			}
			if (_THIS.question.isNumeric && _THIS.output){
				_THIS.output.innerHTML=_THIS.getValue();
			}
		}
		_THIS.onchange();
	};
			
	//Management of timer
	this._timer.ontimer = function () {
		_THIS.ontimer();
	};
		
	//Extra recalculate for IE
	window.setTimeout(function() {
		_THIS.recalculate();
	}, 1);		
		
	//Function when slider is not supported		
	if (!Slider.isSupported) {
		this.input.onchange = function (e) {
			_THIS.setValue(_THIS.input.value);
		}
	}
		
	//Add current sliders in slidersCollection
	slidersCollection[slidersCollection.length]=this;
}

/* --- Public events --- */
//This event is called when the state (value) of slider change
Slider.prototype.onchange=function(response){/*RaiseEvent*/}

//This event is used when the normal drag method failed. 
//It will manage the drag effect when the cursor of slider not found
Slider.prototype.ontimer = function () {
	var hw = this.cursor.offsetWidth;
	var hh = this.cursor.offsetHeight;
	var hl = this.cursor.offsetLeft;
	var ht = this.cursor.offsetTop;
	
	switch(this._orientation){
		case eOrientation.horizontal : //Management of horizontal slider
			//Increasing the value
			if (this._mouseX > (hl + hw)  &&  (this._increasing == null || this._increasing)) {
				this.setValue(this.getValue() + this.blockIncrement);
				this._increasing = true;
			}
			//Decreasing the value
			if (this._mouseX < hl && (this._increasing == null || !this._increasing)) {
				this.setValue(this.getValue() - this.blockIncrement);
				this._increasing = false;
			}
			break;
				
		case eOrientation.vertical : //Management of vertical slider
			//Decreasing the value
			if (this._mouseY > (ht + hh) && (this._increasing == null || !this._increasing)) {
				this.setValue(this.getValue() - this.blockIncrement);
				this._increasing = false;
			}
			//Increasing the value
			if (this._mouseY < ht &&  (this._increasing == null || this._increasing)) {
				this.setValue(this.getValue() + this.blockIncrement);
				this._increasing = true;
			}
			break;			
	}
	this._timer.start();
};

/* --- Public shared method : Return true if the browser can manage this slider --- */
Slider.isSupported = typeof document.createElement != "undefined" && typeof document.documentElement != "undefined" && typeof document.documentElement.offsetWidth == "number";

/* --- Specify value on slider --- */
Slider.prototype.setValue = function (value) {
	this._range.setValue(value);
	//Management of combo-box for closed question
	if (this.question){
		if (!this.question.isNumeric){
			this.input.value = this.question.responses[this.getValue()].value;
			return;
		}
	}
	this.input.value = this.getValue();
};
/* --- Return the value of slider --- */
Slider.prototype.getValue = function () {
	return this._range.getValue();
};
/* --- Specify the minimum value of range --- */
Slider.prototype.setMinimum = function (minimum) {
	this._range.setMinimum(minimum);
	this.input.value = this.getValue();
};
/* --- Return the minimum value of range --- */
Slider.prototype.getMinimum = function () {
	return this._range.getMinimum();
};
/* --- Set the maximum value of range --- */
Slider.prototype.setMaximum = function (maximum) {
	this._range.setMaximum(maximum);
	this.input.value = this.getValue();
};
/* --- Return the maximum value of range --- */
Slider.prototype.getMaximum = function () {
		return this._range.getMaximum();
	};
/* --- Specify the orientation of slider --- */
Slider.prototype.setOrientation = function (orientation) {
	if (!orientation)return;
	if (this._orientation== orientation)return;
	if (Slider.isSupported && this.container) {
		// Replace the classname
		this.container.className = this.container.className.replace(this._orientation,orientation);
	}
	this._orientation = orientation;
	this.recalculate();
};	
/* --- Return the orientation of slider --- */
Slider.prototype.getOrientation = function () {
	return this._orientation;
};


/* --- Recalculate the border, position and size of HTMLElements---- */
Slider.prototype.recalculate = function() {
	if (!Slider.isSupported || !this.container) return;

	var w = this.container.offsetWidth;
	var h = this.container.offsetHeight;
	var hw = this.cursor.offsetWidth;
	var hh = this.cursor.offsetHeight;
	var lw = this.bar.offsetWidth;
	var lh = this.bar.offsetHeight;
		
	switch(this._orientation){
		case eOrientation.horizontal : // Border-box layout for horizontal slider
			maxWidth=(w - hw);
			realValue=(this.getValue() - this.getMinimum());
			sizeOfRange=(this.getMaximum() - this.getMinimum());
			//Calculate the left position of cursor
			this.cursor.style.left = (maxWidth * (realValue / sizeOfRange)) + "px"; 
			//Place cursor in middle
			this.cursor.style.top = ((h - hh)/2) + "px";						
			//Place the bar in middle
			this.bar.style.top = (h - lh) / 2 + "px";
			//Calculate the left position of bar
			this.bar.style.left = hw / 2 + "px";
			//Set border of slider
			this.bar.style.width = Math.max(0, w - hw - 2)+ "px";
			this.bar.firstChild.style.width = Math.max(0, w - hw - 4)+ "px";				
			break;
					
		case eOrientation.vertical : //Border-box layout for vertical slider				
			//Place cursor in center 
			this.cursor.style.left = ((w - hw) / 2) + "px";
			//Calculate the top position of cursor
			this.cursor.style.top = h - hh - (h - hh) * (this.getValue() - this.getMinimum()) / (this.getMaximum() - this.getMinimum()) + "px";
			//Place the bar in center
			this.bar.style.left = ((w - lw) / 2) + "px";
			//Calculate the top position of bar
			this.bar.style.top = (hh / 2) + "px";
			//Set border of slider 
			this.bar.style.height = Math.max(0, h - hh - 2) + "px";	
			this.bar.firstChild.style.height = Math.max(0, h - hh - 4) + "px";			
			break;
	}
};

//----------------------------------------------------------------------------
/* --- Unique instance of object to manage the behaviour and event of all sliders --- */
var SliderEventHandler ={
	/* --- PRIVATE MEMBERS --- */
	_currentSlider : null ,	//Current selected slider
	_dragData : null,		//Dragged data
	_scrollDirection:eScroll.down,	//Direction of scrolling when use the button down & up
	_scrollTimer :null,				//Timer of scroll
	
	/* --- PUBLIC METHODS ---*/
	
	/*  Return event  */
	getEvent : function (e, elt) {
		//Define event
		if (!e) {
			if (elt)
				e = elt.document.parentWindow.event;
			else
				e = window.event;
		}
		//Define element
		if (!e.srcElement) {
			var elt = e.target;
			while (elt != null && elt.nodeType != 1){
				elt = elt.parentNode;
			}
			e.srcElement = elt;
		}
		//Define the position of mouse cursor
		if (typeof e.offsetX == "undefined") {
			e.offsetX = e.layerX;
			e.offsetY = e.layerY;
		}
		return e;
	},
		
	/* Return document of container */
	getDocument:	function (e) {
		if (e.target) return e.target.ownerDocument;
		return e.srcElement.document;
	},
		
	/* Return the slider object */
	getSlider:	function (e) {
		var elt = e.target || e.srcElement;
		while (elt != null && elt.slider == null)	{
			elt = elt.parentNode;
		}
		if (elt) return elt.slider;
		return null;
	},
		
	/* Return HTMLElement which represent the bar of slider */
	getLine:	function (e) {
		var elt = e.target || e.srcElement;
		while (elt != null && elt.className != eClassName.bar){
			elt = elt.parentNode;
		}
		return elt;
	},

	/* Return the HTMLElement which represent the cursor of slider */
	getHandle:	function (e) {
		var elt = e.target || e.srcElement;
		var re = /cursor/;
		while (elt != null && !re.test(elt.className))	{
			elt = elt.parentNode;
		}
		return elt;
	},
	
	/* --- PUBLIC EVENTS  --- */
	/* Fire when ab slider get the focus */
	onfocus:	function (e) {
		var s = this.slider;
		s._focused = true;
		s.cursor.className = eClassName.cursorOver;
	},
	/* Fire when an slider lost the focus */
	onblur:	function (e) {
		var s = this.slider;
		s._focused = false;
		s.cursor.className = eClassName.cursor;
	},
	/* Fire when the mouse is over an slider */
	onmouseover:	function (e) {
			e = SliderEventHandler.getEvent(e, this);
			var s = this.slider;
			if (e.srcElement==s.cursor)
				s.cursor.className = eClassName.cursorOver;
	},
	/* Fire when the mouse leave an slider */
	onmouseout:	function (e) {
		e = SliderEventHandler.getEvent(e, this);
		var s = this.slider;
		if (e.srcElement == s.cursor && !s._focused)
		s.cursor.className = eClassName.cursor;
	},
	/* Fire when the mouse down	*/
	onmousedown:	function (e) {
		e = SliderEventHandler.getEvent(e, this);
		var s = this.slider;
		if (s.container.focus) s.container.focus(); //Set the focus on slider
		SliderEventHandler._currentSlider= s; //Keep slider in memory
			
		//Attach events for the drag & drop of cursor
		var doc = s.document;
		if (doc.addEventListener) {
			doc.addEventListener("mousemove", SliderEventHandler.onmousemove, true);
			doc.addEventListener("mouseup", SliderEventHandler.onmouseup, true);
		} else if (doc.attachEvent) {
			doc.attachEvent("onmousemove", SliderEventHandler.onmousemove);
			doc.attachEvent("onmouseup", SliderEventHandler.onmouseup);
			doc.attachEvent("onlosecapture", SliderEventHandler.onmouseup);
			s.container.setCapture();
		}

		//Start drag
		if (SliderEventHandler.getHandle(e)) {	
			//Keep dragged data in memory
			sdata=new sliderdragData();
			sdata.screenX=e.screenX;
			sdata.screenY=e.screenY;
			sdata.dx=e.screenX - s.cursor.offsetLeft;
			sdata.dy=e.screenY - s.cursor.offsetTop;
			sdata.startValue=s.getValue();
			sdata.slider=s;
			SliderEventHandler._dragData =sdata;
		} else {
			//onTimer will automatically manage the movement of mouse
			var barEl = SliderEventHandler.getLine(e);
			s._mouseX = e.offsetX + (barEl ? s.bar.offsetLeft : 0);
			s._mouseY = e.offsetY + (barEl ? s.bar.offsetTop : 0);
			s._increasing = null;
			s.ontimer();
		}
	},
	/*Fire when the mouse move */
	onmousemove:	function (e) {
		e = SliderEventHandler.getEvent(e, this);
	
		//Drag
		if (SliderEventHandler._dragData) {
			var s = SliderEventHandler._dragData.slider;
			var boundSize = s.getMaximum() - s.getMinimum();
			var size, pos, reset;
				
			switch(s.getOrientation()){
				case eOrientation.horizontal :
					size = s.container.offsetWidth - s.cursor.offsetWidth;
					pos = e.screenX - SliderEventHandler._dragData.dx;
					reset = Math.abs(e.screenY - SliderEventHandler._dragData.screenY) > 100;
					break;
				case eOrientation.vertical :
					size = s.container.offsetHeight - s.cursor.offsetHeight;
					pos = s.container.offsetHeight - s.cursor.offsetHeight -(e.screenY - SliderEventHandler._dragData.dy);
					reset = Math.abs(e.screenX - SliderEventHandler._dragData.screenX) > 100;					
					break;
			}
			//Calculate the new value
			v=reset ? (SliderEventHandler._dragData.startValue):(((s.getMinimum() + boundSize) * pos) / size);
				
			//Set the size
			s.setValue(v);
			return false;
		} else {
			//Change  the position of mouse (onTimer will affect automatically affect the value)
			var s = SliderEventHandler._currentSlider;
			if (s == null) return;
			var barEl = SliderEventHandler.getLine(e);
			s._mouseX = e.offsetX + (barEl ? s.bar.offsetLeft : 0);
			s._mouseY = e.offsetY + (barEl ? s.bar.offsetTop : 0);
		}
	},
	/* Fire when the mouse up */
	onmouseup:	function (e) {
		e = SliderEventHandler.getEvent(e, this);
		var s = SliderEventHandler._currentSlider;
		var doc = s.document;
			
		//Detach events for the drag & drop of cursor
		if (doc.removeEventListener) {
			doc.removeEventListener("mousemove",SliderEventHandler.onmousemove, true);
			doc.removeEventListener("mouseup", SliderEventHandler.onmouseup, true);
		} else if (doc.detachEvent) {
			doc.detachEvent("onmousemove", SliderEventHandler.onmousemove);
			doc.detachEvent("onmouseup", SliderEventHandler.onmouseup);
			doc.detachEvent("onlosecapture", SliderEventHandler.onmouseup);
			s.container.releaseCapture();
		}

		// Stop the drag (reset all value)
		if (SliderEventHandler._dragData) {
			SliderEventHandler._dragData=null;
		} else { 
			s._timer.stop();
			s._increasing = null;
		}
		SliderEventHandler._currentSlider = null;
	},	
	/* Fire when key down */
	onkeydown:	function (e) {
		e = SliderEventHandler.getEvent(e, this);
			
		var s = this.slider;
		var keyCode = e.keyCode;
		switch (keyCode) {
			case 33:	//page up
				s.setValue(s.getValue() + s.blockIncrement);
				break;
			case 34:	// page down
				s.setValue(s.getValue() - s.blockIncrement);
				break;
			case 35:	// end
				s.setValue(s.getOrientation()==eOrientation.horizontal?s.getMaximum():s.getMinimum());
				break;
			case 36:	// home
				s.setValue(s.getOrientation()==eOrientation.horizontal?s.getMinimum():s.getMaximum());
				break;
			case 38:	// up (see right)
			case 39:	// right
				s.setValue(s.getValue() + s.unitIncrement);
				break;
			case 37:	// left (see down)
			case 40:	// down
				s.setValue(s.getValue() - s.unitIncrement);
				break;
		}
		if (keyCode >= 33 && keyCode <= 40)return false;
	},
	/* Fire when key press */
	onkeypress:	function (e) {
		e = SliderEventHandler.getEvent(e, this);
		var keyCode = e.keyCode;
		if (keyCode >= 33 && keyCode <= 40) return false;
	},	 
	/* Fire when mouse wheel */
	onmousewheel:	function (e) {
		e = SliderEventHandler.getEvent(e, this);
		var s = this.slider;
		if (!s._focused)return;
		s.setValue(s.getValue() + e.wheelDelta / 120 * s.unitIncrement);
		return false;
	},
	/* Fire when mouse is down on the minSide (button down)(only available for scrollBar type) */
	onscrolldown : function(e){
		e = SliderEventHandler.getEvent(e, this);
			
		SliderEventHandler._currentSlider=SliderEventHandler.getSlider(e);
		SliderEventHandler._scrollDirection=eScroll.down;
		SliderEventHandler.onscroll(e);
			
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
	},
	/* Fire when mouse is down on the maxSide (button up)(only available for scrollBar type) */
	onscrollup : function(e){
		e = SliderEventHandler.getEvent(e, this);
			
		SliderEventHandler._currentSlider=SliderEventHandler.getSlider(e);
		SliderEventHandler._scrollDirection=eScroll.up;
		SliderEventHandler.onscroll(e);
			
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();			
	},
	/* Fire when mouse is up on scrolling buttons */
	cancelScroll : function(e){
		e=SliderEventHandler.getEvent(e, this);
		SliderEventHandler._currentSlider=null;
		window.clearTimeout(SliderEventHandler._scrollTimer);
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();	
	},
	/* Fire when mouse is down on scrolling buttons */
	onscroll : function(e){	
		if (!SliderEventHandler._currentSlider)return;
		s=SliderEventHandler._currentSlider;
		v=s.getValue();
		if (SliderEventHandler._scrollDirection==eScroll.up)
			v +=s.unitIncrement;
		else 
			v -=s.unitIncrement;
		s.setValue(v);
		SliderEventHandler._scrollTimer=window.setTimeout("SliderEventHandler.onscroll()",150);
	}
};
	
//----------------------------------------------------------------------------
/* --- Range of values  --- */
function sliderRange(min,max,value) {
	this._value = 0;			//Actual value
	this._minimum = 0;			//Minumum value
	this._maximum = 100;		//Maximum value
	if (min)this._minimum=min;
	if (max)this._maximum=max;
	if (value) this._value=value;
	this._extent = 0;			//Increment
	this._isChanging = false;	//Don't change the value when the slider changing 
}
/* --- Events	---*/
sliderRange.prototype.onChange = function(){/*RaiseEvent*/}
/* --- Set value on range --- */
sliderRange.prototype.setValue = function (value) {
	//check if available number
	value = parseInt(value);
	if (isNaN(value)) return;

	//If no change
	if (this._value == value) return;
		
	//Set value
	this._value = value;
		
	//Corrected maximum, minimum
	if (value + this._extent > this._maximum) this._value = this._maximum - this._extent;
	if (value < this._minimum) this._value = this._minimum;

	//Fire event onChange()
	if (!this._isChanging)this.onchange();
};
/* --- Return the value --- */
sliderRange.prototype.getValue = function () {
	return this._value;
};
/* --- Specify the extent --- */
sliderRange.prototype.setExtent = function (extent) {
	//check if available number
	extent=parseInt(extent);
	if (isNaN(extent))return;
	
	//If no change
	if (this._extent==extent)return;
		
	//Set value
	this._extent = extent;
	
	//Corrected maximum, minimum
	if (extent < 0) this._extent = 0;	
	if (this._value + extent > this._maximum)this._extent = this._maximum - this._value;
	
	//Fire event onChange()
	if (!this._isChanging)this.onchange();
};
/* --- Return the extent --- */
sliderRange.prototype.getExtent = function () {
	return this._extent;
};
/* --- Specify the minimum value --- */
sliderRange.prototype.setMinimum = function (minimum) {
	//check if available number
	minimum=parseInt(minimum);
	if (!isNaN(minimum))return;
		
	//No change
	if (this._minimum==minimum)return;
		
	//Keep the last state of _isChanging
	//The minimum is begin to change (state : _isChanging=true)
	var oldIsChanging = this._isChanging;
	this._isChanging = true;
		
	//Set the minimum
	this._minimum = minimum;

	//Corrected values
	if (minimum > this._value) this.setValue(minimum);
	if (minimum > this._maximum) {
		this._extent = 0;
		this.setMaximum(minimum);
		this.setValue(minimum)
	}
	if (minimum + this._extent > this._maximum)this._extent = this._maximum - this._minimum;

	//Restore _isChanging state 
	this._isChanging = oldIsChanging;
		
	//Fire event onChange()
	if (!this._isChanging)this.onchange();
};
/* --- Return the minimum value --- */
sliderRange.prototype.getMinimum = function () {
	return this._minimum;
};
/* --- Specify the maximum value --- */
sliderRange.prototype.setMaximum = function (maximum) {
	//Check if available number
	maximum=parseInt(maximum)
	if (!isNaN(maximum))return;
	
	//If no change
	if (this._maximum==maximum)return;
		
	//Keep the last state of _isChanging
	//The maximum is begin to change (state : _isChanging=true)
	var oldIsChanging = this._isChanging;
	this._isChanging = true;

	//Set the maximum
	this._maximum = maximum;		
			
	//Corrected value
	if (maximum < this._value) this.setValue(maximum - this._extent);
	if (maximum < this._minimum) {
		this._extent = 0;
		this.setMinimum(maximum);
		this.setValue(this._maximum);
	}		
	if (maximum < this._minimum + this._extent) this._extent = this._maximum - this._minimum;
	if (maximum < this._value + this._extent) this._extent = this._maximum - this._value;
			
	//Restore _isChanging state 
	this._isChanging = oldIsChanging;
		
	//Fire event onChange()
	if (!this._isChanging)this.onchange();
};
/* --- Return the maximum --- */
sliderRange.prototype.getMaximum = function () {
	return this._maximum;
};
	
	
//----------------------------------------------------------------------------
/* --- Information of dragged object --- */ 
function sliderdragData(sX,sY,dX,dY,startValue,slider){
	this.screenX=sX;
	this.screenY=sY;
	this.dx=dX;
	this.dy=dY;
	this.startValue=startValue;
	this.slider=slider;
}


//----------------------------------------------------------------------------
/* --- Timer of slider --- */
function sliderTimer(nPauseTime) {
	this.pauseTime = (!nPauseTime)? 1000 :nPauseTime;
	this._timer = null;
	this._isStarted = false;
}
/* ---- Public event ---- */
sliderTimer.prototype.ontimer=function(){/*RaiseEvent*/}

/* --- Start the timer --- */
sliderTimer.prototype.start = function () {
	if (this.isStarted()) this.stop();
	var _THIS = this;
	this._timer = window.setTimeout(function () {
		_THIS.ontimer();
	},
	this.pauseTime);
	this._isStarted = false;
};
/*  --- Stop the timer --- */
sliderTimer.prototype.stop = function () {
		if (this._timer != null) window.clearTimeout(this._timer);
		this._isStarted = false;
	};
/* --- Return the state of timer --- */
sliderTimer.prototype.isStarted = function () {
	return this._isStarted;
};


/*--------------------------------------- MapManagement.js -----------------------------------------------*/

/*----------------------------------------------------------------------------\
|								Askia MapManagement							  |
|-----------------------------------------------------------------------------|
|                          Created by Askia Company							  |
|							(http://www.askia.com)							  |
|-----------------------------------------------------------------------------|
| This library content object and functions to manage the image map in WebProd|
| Works in navigator which implement DOM API							      |
|-----------------------------------------------------------------------------|
|							Copyright Askia � 1994-2005						  |
|-----------------------------------------------------------------------------|
| Dependencies: no															  |
|-----------------------------------------------------------------------------|
| 2005-06-20 |V 1.0.0														  |
|			 | + ImageMapHandler object to manage all elements				  |
|			 | + Preload the pictures of ImageArea items					  |
|			 | + Catch the events for rollover (mouseover, mouseout)		  |
|			 | + Catch the events of click to set responses					  |
|-----------------------------------------------------------------------------|
| 2005-08-07 | + Can disabled the rollover functionnalities					  |
|-----------------------------------------------------------------------------|
| Created 2005-06-20 | All changes are in the log above. | Updated 2005-08-07 |
|-----------------------------------------------------------------------------|
|														All rights reserved	  |
|WebProd - MapManagement - API Version 1.0.0	Copyright Askia � 1994-2005   |
\----------------------------------------------------------------------------*/

/*--------------------------------------------------------------*/
//Main elements which content the collections of the ImageArea
//This element will manage the rollover event for each elements
function ImageMapHandler(name,src,width,height,pathRoot,cmbCoordsId, cmbTitleId, cmbSelectionId,cmbSelectedAreaId,isNotUseRollOver){
	this.name=name;				//Name of this variable
	this.all={};				//Item library
	this.childNodes=[];			//Item library
	this.width=width;			//Width of image
	this.height=height;			//Height of image
	this.pathRoot=pathRoot;		//Root of image
	this.src=this.pathRoot + src;		 //Source of image
	this._cmbCoordsId=cmbCoordsId;		 //Id of combo for coords
	this._cmbTitleId=cmbTitleId;		 //Id of combo for title
	this._cmbSelectionId=cmbSelectionId; //Id of combo for selection
	this._cmbSelectedAreaId=cmbSelectedAreaId;	//If of combo for the selected are
	this._image;				//Image
	this._answerEltId;
	this.isNotUseRollOver=isNotUseRollOver;	//false when use roll-over
}
	
//Main functions to loadElements using the combo-boxes.
//'htmlElementId' it's the id of html element which will content the image
ImageMapHandler.prototype.loadElements=function(htmlElementId,answerEltId){
	this._answerEltId=answerEltId;
	var cmbSelection=document.getElementById(this._cmbSelectionId);
	var cmbCoords=document.getElementById(this._cmbCoordsId);
	var cmbTitle=document.getElementById(this._cmbTitleId);
	var cmbSelectedArea=null;
	if (this._cmbSelectedAreaId)cmbSelectedArea=document.getElementById(this._cmbSelectedAreaId);
		
	for (var i=0; i< cmbSelection.options.length;i++){
		if (cmbSelection.options[i].value=='0') continue;
		v=cmbSelection.options[i].value;	//Value
		s=cmbSelection.options[i].text;		//Src
		if (cmbSelectedArea)
			sS=cmbSelectedArea.options[i].text;	//SelectedSrc
		else
			sS=null;
		coord=cmbCoords.options[i].text;	//Coords
		t=cmbTitle.options[i].text;			//Title
		this.add(new ImageArea(v,v,s,sS,coord,t,'POLY'));
		//Show latest selection				
		if (cmbSelection.options[i].selected) document.getElementById(this._answerEltId).innerText=t;
	}
	if(htmlElementId)this.writeIn(htmlElementId);
}
//This function write the image in the container using the id define by 'htmlElementId'
ImageMapHandler.prototype.writeIn=function(htmlElementId){
	document.getElementById(htmlElementId).innerHTML=this.toString();
	this._image=document.getElementById(this.name + '-img');
}
//This function is used to added the ImageArea item of the main image
ImageMapHandler.prototype.add=function(oImageArea){	
	oImageArea.parentNode=this;
	oImageArea.src=this.pathRoot + oImageArea.src;
	if (oImageArea.selectedSrc)oImageArea.selectedSrc=this.pathRoot + oImageArea.selectedSrc;
	//Preload pictures
	oImageArea._image=new Image(this.width,this.height);
	oImageArea._image.src = oImageArea.src;
	if (oImageArea.selectedSrc){
		oImageArea._selectedImage=new Image(this.width,this.height);
		oImageArea._selectedImage.src=oImageArea.selectedSrc;
	}
	this.all[oImageArea.name]=oImageArea;
	this.childNodes[this.childNodes.length]=oImageArea;
	return this.all[oImageArea.name];
}

//Transform object to html string
ImageMapHandler.prototype.toString=function(){
	var str='';
	str='<img style="cursor:hand" id="' + this.name + '-img" name="' + this.name + '-img" src="'  + this.src + '" usemap="#' + this.name + '-map" border="0">';
	str +='<MAP NAME="' + this.name + '-map">';
	for (var i=0; i<this.childNodes.length;i++){
		str +=this.childNodes[i].toString();
	}
	str +='<AREA SHAPE="default" nohref>';
	str +='</MAP>'
	return str;
}
//UI EVENT used for the rollover
ImageMapHandler.prototype.mouseOver=function(htmlElement){
	if (this.isNotUseRollOver)return;
	var name=htmlElement.id.replace('-area','');
	this._image.src=this.all[name].src;
}
//UI EVENT used for the rollover
ImageMapHandler.prototype.mouseOut=function(){
	if (this.isNotUseRollOver)return;
	this._image.src=this.src;
}
//UI EVENT used to set the value when clicking on an area
ImageMapHandler.prototype.click=function(htmlElement){
	var name=htmlElement.id.replace('-area','');
	document.getElementById(this._cmbSelectionId).value=this.all[name].value;
	document.getElementById(this._answerEltId).innerText=this.all[name].title;
}
	
/*--------------------------------------------------------------*/
//This element will manage the area elements
function ImageArea(name,value,src,selectedSrc,coords,title,shape){
	this.parentNode;
	this.name=name;
	this.value=value;
	this.src=src;
	this.selectedSrc=selectedSrc;
	this.coords=coords;
	this.title=title;
	this.shape=shape;
	this._image; 
	this._selectedImage;		
}
//Transform object to html string
ImageArea.prototype.toString=function(){
	var str='';
	str ='<AREA ALT="' + this.title + '"  id="' + this.name + '-area" NAME="' + this.name + '-area" SHAPE="' + this.shape + '" COORDS="'  + this.coords + '"  onMouseOver="' + this.parentNode.name + '.mouseOver(this);" onClick="' + this.parentNode.name + '.click(this);" onMouseOut="' + this.parentNode.name + '.mouseOut(this);">';
	return str;
}


/*---------------------------------------------------------------- AskQuestion.js -------------------------------------*/

/* ---------
								AskQuestion object
				This component will manage the response of question
	- No dependencies
	- Created 2005-09-07
	- Updated 2005-09-08
	
All rights reserved
Copyright � Askia 1994 - 2005
--------- */

//----------------------------------------------------------------------------
/* --- Question Object --- */
function AskQuestion(htmlElement,caption,isNumeric,maxResponses,minValue,maxValue){
	this.caption=caption;		//Caption of question
	this.input=htmlElement;		//Input to set the value
	this.isNumeric=false;		//Is numeric of closed question
	this.maxResponses=1;		//Represent the maximum number of responses
	this.minValue=0;			//Minimum value for numeric question
	this.maxValue=0;			//Maximum value	for numeric question
	this.allResponses={};		//Collection of AskResponse
	this.responses=[];			//Collection of AskResponse
	this.value=-1;			    //Value of question
	this.isAllowDk=true;		//Is allow don't know response
	this.isInit=false;			//True when question is initialized
		
	if (maxResponses)this.maxResponses=maxResponses;
	if (minValue)this.minValue=minValue;
	if (maxValue)this.maxValue=maxValue;
	if (isNumeric)this.isNumeric=isNumeric;
}
/* --- Add response into collection --- */
AskQuestion.prototype.addResponse=function(response){
	this.responses[this.responses.length]=response;
	this.allResponses[response.value]=response;
	return this.allResponses[response.value];
}
/* --- Load all responses using input --- */
AskQuestion.prototype.init=function(){
	//Load question using combo-box
	if (this.input.tagName=='SELECT'){
		min=(this.isAllowDk)?0:1;
		this.value=min;
		for (var i=min;i<this.input.options.length;i++){
			r=new AskResponse((i - min),this.input.options[i].value,this.input.options[i].text);
			if (i==0)r.text="Don't know";
			r=this.addResponse(r);
			if (this.input.options[i].selected)this.value=r.index;
		}
		this.isInit=true;
		return;
	}

	//Load response using textbox or hidden input
	this.value=parseInt(this.input.value);
	if (this.input.value=='' && !this.isAllowDk)this.value=this.minValue;
	this.isInit=true;
}
//----------------------------------------------------------------------------
/* --- Response Object --- */
function AskResponse(index,value,text){
	this.index=index;
	this.value=value;
	this.text=text;
}


/*--------------------------------------- GlobalWebProd.js -------------------------------------*/

/*----------------------------------------------------------------------------\
|								Askia globalWebProd							  |
|-----------------------------------------------------------------------------|
|                          Created by Askia Company							  |
|							(http://www.askia.com)							  |
|-----------------------------------------------------------------------------|
| This library content all global functions that you can use in WebProd		  |
| Works in navigator which implement DOM API							      |
|-----------------------------------------------------------------------------|
|							Copyright Askia � 1994-2005						  |
|-----------------------------------------------------------------------------|
| Dependencies: no															  |
|-----------------------------------------------------------------------------|
| 2005-05-26 |V 1.0.0														  |
|			 |+ getBrowser() or new getBrowser()							  |
|			 |+	getElement(eltId)											  |
|			 |+	goToNextScreen([formName])									  |
|			 |+	showOrHide(eltId,[isShow])									  |
|			 |+	setValue(eltId,value,[isAutoSubmit])						  |
|			 |+	enableElement(eltId)										  |
|			 |+	disableElement(eltId)										  |
|-----------------------------------------------------------------------------|
|2005-09-15  |V 1.1.0														  |
|			 |+	Correction in goToNextScreen([formName])					  |
|			 |+	goToPreviousScreen([formName])								  |
|-----------------------------------------------------------------------------|
| Created 2005-05-26 | All changes are in the log above. | Updated 2005-05-26 |
|-----------------------------------------------------------------------------|
|														All rights reserved	  |
|AskiaVista - globalWebProd - API Version 1.0.0	Copyright Askia � 1994-2005   |
\----------------------------------------------------------------------------*/

/*------------------------------------------------------------------*/
//Return the type of the current browser
function getBrowser (){	
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera5=this.agent.indexOf("Opera 5")>-1;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	this.mac=this.agent.indexOf("Mac")>-1;
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
				
	if (this.ie4==1) return "IE4";
	if (this.ie5==1) return "IE5";
	if (this.ie6==1) return "IE6";
	if (this.opera5==1) return "OPERA5";
	if (this.ns4==1) return "NS4";
	if (this.ns6==1) return "NS6";
}
	
/*------------------------------------------------------------------*/
//Return element using id or name
function getElement(eltId){
	if (!eltId)return null;
	return (document.getElementById(eltId))?document.getElementById(eltId):((document.all[eltId])?document.all[eltId]:null);	
}
	
/*------------------------------------------------------------------*/
//Submit the current form 
function goToNextScreen(formName){
	if (!formName)formName='FormAskia';
	try {
		document[formName].submit();
	}catch(ex){
		document.forms[0].submit();
	}
}
/*------------------------------------------------------------------*/
//Submit the current form to go on previous screen
function goToPreviousScreen(formName){
	if (!formName)formName='FormAskia';
	try {
		document[formName].Previous.click();
	} catch(ex){
		document.forms[0].Previous.click();
	}
}
/*------------------------------------------------------------------*/
//Display or hide elements
function showOrHide(eltId,isShow){
	var elt=getElement(eltId);
	if (!elt)return null;
	bw=new getBrowser();
	if (bw.ie==1)
		elt.style.display=(isShow)?'block':'none';
	else
		elt.setAttribute("style","display:" + (isShow)?'block':'none');
	return isShow;
}
	
/*------------------------------------------------------------------*/
//Set value to an input
function setValue(eltId,value,isAutoSubmit){
	var elt=getElement(eltId);
	if (!elt)return null;
	if (!elt.type)return null;
	if (elt.type=="radio"){
		elt=document.all[eltId];
		for (var i=0;i<elt.length;i++){
			elt[i].checked =(elt[i].value==value)?true:false;
		}
	} else {
		elt.value=value;
	}
	if (isAutoSubmit)goToNextScreen();
	return true;
}

/*------------------------------------------------------------------*/
//Enable / disable element
function enableElement(eltId){
	var elt=getElement(eltId);
	if (!elt)return null;
	elt.disabled=false;
	return elt.disabled;
}	
function disableElement(eltId){
	var elt=getElement(eltId);
	if (!elt)return null;
	elt.disabled=true;
	return elt.disabled;
}


/*----------------------------------------- wpDragNDrop.js -------------------------------------*/

var dragDropHandler=null;

/*--------------------------------------------------------------*/
//Main elements which content the collections of the wpItem
//This element will manage the drag and drop event for each elements
function wpDragDrop(name){
	this.name=name;					//Name of instance
	this.containerId=null;			//Id of container of elements
	this.all={};					//Collection of item
	this.childNodes=[];				//Collection of item
	this.lastSelection=null;		//Latest selected items
	this.lastHTMLSelection=null;	//Latest selected html element
	this._dX;						//Mouse X position
	this._dY;						//Mouse Y position
	this.responses=[];				//Collection of responses
	this._responsesValue={};		//Collection of responses init with value
	this.minTop=15;					//Min top of elements
	this.minLeft=15;				//Min left of elements
	this.textStyle='font-weight:bold;';	//The style of text for the targetCaption
	this.textClassName='';				//ClassName of text for the targetCaption
	this.containerStyle='border:2px groove black;background-color:#DCDCDC;';	//The style of container box
	this.sourceLeft=85;					//Left of source container (85 by default)
	this.containerWidth=150;			//Width of containers (150 by default)
	this.containerHeight=200;			//Height of containers (200 by default)
	this.cardWidth=125;					//Width of cards (125 by default)
	this.cardHeight=150;					//Height of cards (150 by default) 
	this.spaceBetweenTargets=10;		//Space between targets (10 by default)
	this.spaceBetweenTargetAndSource=55; //Space between target and source (55 by default)
	this.heightTargetText=80;		//Bottom space between caption of target and target (80 by default)
	this.imgRoot='../resources/DragNDrop/';	//Path of images
	this.lastZIndex=1000;					//The latest zIndex
	this._bw=new getBrowser();				//Browser object
	this.ErrorMessages={NonAnswer : ''};		//Error messages
	this.isAllowNonAnswer=true;				//Allow non answer
	dragDropHandler=this;
}
//Insert html string into a document
wpDragDrop.prototype.insertHtml=function(HTML){
	if (this.containerId){
		var d=document.getElementById(this.containerId);
		d.innerHTML +=HTML;
	} else {
		if (this._bw.ie==1)
			document.body.innerHTML +=HTML;
		else 
			document.documentElement.innerHTML +=HTML;
	}
}
	
//Add item
wpDragDrop.prototype.add=function(node){
	node.parent=this;
	this.all[node.name]=node;
	this.childNodes[this.childNodes.length]=node;
	return this.all[node.name];
}
//Load item and responses using the select box elements
wpDragDrop.prototype.loadElements=function(){	
	//Create stylesheet rules
	var str="<style>.target {position:absolute;top:" +  parseInt(parseInt(this.minTop) + parseInt(this.heightTargetText)+ 5) + "px;width:" +  parseInt(this.containerWidth) + "px;height:" + parseInt(this.containerHeight) + "px;"  + this.containerStyle + "}" 
						+ ".targetCaption  {position:absolute;top:" + this.minTop + "px;width:" +  parseInt(this.containerWidth) + "px;height:" + this.heightTargetText + "px;" + this.textStyle + "}"
						+ ".source {position:absolute;left:"  + parseInt(parseInt(this.minLeft) + parseInt(this.sourceLeft)) + "px;top:" + parseInt(parseInt(this.minTop) + parseInt(this.heightTargetText)+ parseInt(this.containerHeight) + parseInt(this.spaceBetweenTargetAndSource)) + "px;width:" +  parseInt(this.containerWidth) + "px;height:" +  parseInt(this.containerHeight) + "px;" +  this.containerStyle + "}"
						+ ".card   {z-Index:1000;position:absolute;border:1px solid black;background-repeat:no-repeat;}</style>";
					
	this.insertHtml(str);		
		
	//Load collection of select box
	arrSelects=document.getElementsByTagName("select");
	
	//Using the select box properties and span text, 
	//create a collection of wpItem
	for (var i=0;i<arrSelects.length;i++){
		this.add(new wpItem(arrSelects[i].name,arrSelects[i].value,arrSelects[i].parentNode.childNodes.item(0).innerHTML));
	}
			
	//Load the available values using the first select box
	for (var i=0;i<arrSelects[0].options.length;i++){
		var l=this.responses.length;
		v=arrSelects[0].options[i].value;
		c=arrSelects[0].options[i].text;
		this.responses[l]=new wpResponse(v,c);
		this._responsesValue[v]=this.responses[l];
	}
			
	//Write the target zone for answer
	this.writeTarget();
		
	//Write the source zone
	this.writeSource();
}
//Write target element of responses
wpDragDrop.prototype.writeTarget=function(){
	var str='';
	var l=this.minLeft;
	str='<div id="container" class="source">&nbsp;</div>';
	for (var i=0;i<this.responses.length;i++){
		if (this.responses[i].name=='0')continue;
		str +='<div id="txt' + this.responses[i].name + '" class="targetCaption ' +  this.textClassName + '" style="left:' + l + 'px;">' + this.responses[i].caption + '</div>' ;
		str +='<div id="rsp' + this.responses[i].name + '" class="target" style="left:' + l + 'px;">&nbsp;</div>';
		this.responses[i].left=l;
		this.responses[i].width=parseInt(this.containerWidth);
		l += parseInt(this.containerWidth) + parseInt(this.spaceBetweenTargets);
	}
	this.insertHtml(str);
}
//Write all items
wpDragDrop.prototype.writeSource=function(){
	var rndArray=_getRandomArray(this.childNodes.length);
	
	//Create draggable element
	for (var i=0;i<rndArray.length;i++){
		this.insertHtml(this.childNodes[rndArray[i]].toString(this.lastZIndex));
		this.lastZIndex ++;
	}
		
	//Attach the drag event
	for (var i=0;i<this.childNodes.length;i++){
		getElement("it" + this.childNodes[i].name).onmousedown=this.beginDrag;	
		if (this.childNodes[i].value!=0){
			this.setValue(this.childNodes[i].name,this._responsesValue[this.childNodes[i].value]);
		}
	}
	function _getRandomArray(l){
		var arr = [];
		for (var i=0; i<l; i++)arr[i] = i;
		var ret = [];
		// Randomize numbers in array
		for (var i=0; i<l-1; i++) {
			var rnd = Math.floor(Math.random()* arr.length);
			ret[i] = arr[rnd];
			arr[rnd] = arr[arr.length-1];
			arr.pop();
		}
		ret[l-1] = arr[0];
		return ret;
	}
}
//Drag and drop management
wpDragDrop.prototype.beginDrag=function(e){
	if (!e)e=window.event
	if (e.target) 
		dragDropHandler.lastHTMLSelection=e.target;
	else 
		dragDropHandler.lastHTMLSelection=e.srcElement;
		
	dragDropHandler._dX=e.clientX - parseInt(dragDropHandler.lastHTMLSelection.style.left);
	dragDropHandler._dY=e.clientY - parseInt(dragDropHandler.lastHTMLSelection.style.top);
	
	dragDropHandler.lastSelection=dragDropHandler.all[dragDropHandler.lastHTMLSelection.id.replace('it','')];
	dragDropHandler.lastHTMLSelection.style.zIndex = dragDropHandler.lastZIndex++;
				
	document.onmousemove=dragDropHandler.drag;
	document.onmouseup=dragDropHandler.drop;

	//Stop propagation of event	
	if (e.stopPropagation)e.stopPropagation();
	else e.cancelBubble=true;

	//Unactive default action
	if (e.preventDefault)e.preventDefault();
	else e.returnValue=false;
}

//Drag element
wpDragDrop.prototype.drag=function(e){
	if(!e) e=window.event;
	if (!dragDropHandler.lastHTMLSelection || !dragDropHandler.lastSelection)return;
	dragDropHandler.lastHTMLSelection.style.left=(e.clientX - dragDropHandler._dX) + "px";
	dragDropHandler.lastHTMLSelection.style.top=(e.clientY - dragDropHandler._dY) + "px";
	
	if (e.stopPropagation)e.stopPropagation();
	else e.cancelBubble=true;		
}
//Drop in target element
wpDragDrop.prototype.drop=function(e){
	if (!dragDropHandler.lastHTMLSelection || !dragDropHandler.lastSelection)return;		
	if(!e) e=window.event;
	document.onmouseup=null;
	document.onmousemove=null;
		
	l=parseInt(dragDropHandler.lastHTMLSelection.style.left);
	w=parseInt(dragDropHandler.lastHTMLSelection.style.width);
	t=parseInt(dragDropHandler.lastHTMLSelection.style.top)
	pos=l + parseInt(w/2);
	for (var i=0;i<dragDropHandler.responses.length;i++){
		min=parseInt(dragDropHandler.responses[i].left) - parseInt((parseInt(dragDropHandler.spaceBetweenTargets)/2) -1);
		max=parseInt(dragDropHandler.responses[i].left) + parseInt(dragDropHandler.responses[i].width) + parseInt((parseInt(dragDropHandler.spaceBetweenTargets)/2) +1);
		minTop= parseInt(dragDropHandler.minTop) + parseInt(dragDropHandler.heightTargetText) + parseInt(dragDropHandler.containerHeight) + 5;
		if (pos>=min && pos<max && t <=minTop){
			dragDropHandler.setValue(dragDropHandler.lastSelection.name,dragDropHandler.responses[i]);
			dragDropHandler.lastSelection=null;	
			dragDropHandler.lastHTMLSelection=null;							
			if (e.stopPropagation)e.stopPropagation();
			else e.cancelBubble=true;								
			return;
		}
	}
		
	dragDropHandler.lastSelection.setValue('0');
	dragDropHandler.lastSelection=null;		
	dragDropHandler.lastHTMLSelection=null;
}
//Set value put the card into a good zone
wpDragDrop.prototype.setValue=function(name,response){
	var htmlElt=getElement("it" + name);
		
	//Search left of cards for center if in target container
	var l= parseInt(dragDropHandler.containerWidth) - parseInt(dragDropHandler.cardWidth);
	l=parseInt(l/2) +  parseInt(response.left);
	
	//Search top of cards for center if in source container
	var t=parseInt(dragDropHandler.containerHeight) - parseInt(dragDropHandler.cardHeight);
	t=parseInt(t/2) + parseInt(dragDropHandler.minTop) +  parseInt(dragDropHandler.heightTargetText)+ 5;
			
	htmlElt.style.left = l + 'px';
	htmlElt.style.top = t + 'px';
	dragDropHandler.all[name].setValue(response.name);
}
	
//Validate the form according the authorizations
wpDragDrop.prototype.validateForm=function(){
	if (this.isAllowNonAnswer)return true;
	for (var i=0;i<this.childNodes.length;i++){
		if (this.childNodes[i].value=='0'){
			alert(this.ErrorMessages.NonAnswer);
			return false;		
		}
	}
	return true;
}
/*--------------------------------------------------------------*/
//Response		
function wpResponse(name,caption){
	this.name=name;
	this.caption=caption;
	this.left=null;
	this.width=null;
}
	
/*--------------------------------------------------------------*/
//Questions
function wpItem(name,value,imgSrc){
	this.name=name;
	this.value='';
	this.imgSrc=imgSrc;
	this.parent=null;
	if (value)this.value=value;
}
	
//Transform object to html string
wpItem.prototype.toString=function(zIndex){
	var s='';
	if (zIndex)s='z-Index:' + zIndex +';';
	//Search left of cards for center if in source container
	var l= parseInt(this.parent.containerWidth) - parseInt(this.parent.cardWidth);
	l=parseInt(l/2) + parseInt(this.parent.minLeft) + parseInt(this.parent.sourceLeft);
	
	//Search top of cards for center if in source container
	var t=parseInt(this.parent.containerHeight) - parseInt(this.parent.cardHeight);
	t=parseInt(t/2) + parseInt(this.parent.minTop) +  parseInt(this.parent.heightTargetText)+ parseInt(this.parent.containerHeight) + parseInt(this.parent.spaceBetweenTargetAndSource);
	str ='<div id="it' + this.name + '"  class="card" style="background-image:url(' + this.parent.imgRoot + this.imgSrc + ');' +  s + 'left:' + l + 'px;top:' + t + 'px;width:' + this.parent.cardWidth + 'px;height:' + this.parent.cardHeight + 'px;">&nbsp;</div>';
	return str;
}	
//Set response value 
wpItem.prototype.setValue=function(value){
	if (value)this.value=value;
	setValue(this.name,this.value);
}

