	function cancelSurvey(button) {
	
		if(confirm('Are you sure you want to cancel the survey? Your answers will not be saved! ')) {
			document.surveyform.submit();
			return true
		}
		else {
			return false;
		}
	}
	
	var activatedMS = new Hash();
	
	function toggleOther(questionNumber, answerValue, questionType, orientation) {
		
		
		var otherDiv=null;
		fieldName = questionNumber + "-" + answerValue;
		
		if(document.getElementById("other_div" + fieldName)!=null) {
			otherDiv = document.getElementById("other_div" + fieldName);
		}
		
		//alert(activatedMS.getItem("q" + questionNumber));
		if (questionType=="ms" && activatedMS.getItem("q" + questionNumber)!=null) {
			document.getElementById("other_div" + questionNumber + "-" + activatedMS.getItem("q" + questionNumber)).style.display="none";
		}
		if(questionType=="mm" && otherDiv!=null && otherDiv.style.display=="inline") {
			document.getElementById("other_div" + fieldName).style.display="none";
		}
		else if(questionType=="mm" && otherDiv!=null && otherDiv.style.display=="block") {
			document.getElementById("other_div" + fieldName).style.display="none";
		}
		else if(otherDiv!=null) {
	
			if (oreintation="V")
			{
				otherDiv.style.display="block";

			}
			else
			{
				otherDiv.style.display="inline";
			}

			document.getElementById("field_other" + fieldName).focus();
	
			if(questionType=="ms") {
				activatedMS.setItem("q" + questionNumber , answerValue);
				//alert(activatedMS.questionValueKey);
				//alert("set question q" + questionNumber);
			}
	
		}
		
	}
	
	function showNote(avid, e) {
		//alert("dsfsdf");
		//alert(avid);
		
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY) 	{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
				//alert("dsfdsf");
				//alert("||"+document.getElementById("note_" + avid).style.display+"||");
		if(document.getElementById("note_" + avid).style.display == "none") {
			//document.getElementById("note_" + avid).style.top= posy + "px";
			//document.getElementById("note_" + avid).style.left= posx + "px";
			//document.getElementById("note_" + avid).style.z-index = "500";
			document.getElementById("note_" + avid).style.display = "block";
			//document.getElementById("note_" + avid).style="display:block;width:300px;height:150px;overflow:auto;z-index:400;position:relative;background-color:white;padding:5px;border: solid blue;";
		}
				//alert(document.getElementById("note_" + avid).style.display);
	}
	
	function closeNote(avid) {
//alert(document.getElementById("note_" + avid).style.display);
		document.getElementById("note_" + avid).style.display = "none";
		//alert(document.getElementById("note_" + avid).style.display);
	}
	
	function Hash()
	{
		this.length = 0;
		this.items = new Array();
		for (var i = 0; i < arguments.length; i += 2) {
			if (typeof(arguments[i + 1]) != 'undefined') {
				this.items[arguments[i]] = arguments[i + 1];
				this.length++;
			}
		}
	   
		this.removeItem = function(in_key)
		{
			var tmp_value;
			if (typeof(this.items[in_key]) != 'undefined') {
				this.length--;
				var tmp_value = this.items[in_key];
				delete this.items[in_key];
			}
		   
			return tmp_value;
		}
	
		this.getItem = function(in_key) {
			return this.items[in_key];
		}
	
		this.setItem = function(in_key, in_value)
		{
			if (typeof(in_value) != 'undefined') {
				if (typeof(this.items[in_key]) == 'undefined') {
					this.length++;
				}
	
				this.items[in_key] = in_value;
			}
		   
			return in_value;
		}
	
		this.hasItem = function(in_key)
		{
			return typeof(this.items[in_key]) != 'undefined';
		}
	}
	
	/*
	get all divs of a certain class, check if they are block or none display and then
	add them to the hash MSactivated if they are already block
	*/
	
	function addBlockToHash() {
		indentedCells = getElementsByClassName(document, "div", "indented_cell");
		
		for (var i=0;i<indentedCells.length;i++) {
			aElement = indentedCells[i];
			if(aElement.id.substring(0,9)=="other_div" && aElement.style.display=="block") {
				numElement = aElement.id.split("-");
				qid = numElement[0].substring(9,18);
				//alert(qid);
				avid = numElement[1].substring(0,10);
				//alert(avid);
				activatedMS.setItem("q" + qid , avid);
			}
		}
		
		//alert(indentedCells.length);
		
	}
	
	/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
	*/
	
	function getElementsByClassName(oElm, strTagName, strClassName){
	    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	    var arrReturnElements = new Array();
	    strClassName = strClassName.replace(/\-/g, "\\-");
	    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	    var oElement;
	    for(var i=0; i<arrElements.length; i++){
	        oElement = arrElements[i];      
	        if(oRegExp.test(oElement.className)){
	            arrReturnElements.push(oElement);
	        }   
	    }
	    return (arrReturnElements)
	}
	
