
/*
// TEXTAREA LIMIT
// clean lines
cleanUpLine = function (str,limit) { // clean string
 	var clean_pass1 = str.replace(/\W/g, ' ');	//replace punctuation with spaces
 	var clean_pass2 = clean_pass1.replace(/\s{2,}/g, ' ');		// compact multiple whitespaces
 	var clean_pass3 = clean_pass2.replace(/^\s+|\s+$/g, '');	// trim whitespaces from beginning or end of string
 	var clean_pass4 = clean_pass3.substring(0,limit);			// trim string
 	return clean_pass4;
}



// number of keywords and keyword length validation
cleanUpList = function (fld) {
	
	// var filename = location.href.substring(location.href.lastIndexOf('/')+1); 
	var url = document.URL; 
	// var DocName =(url.substring(url.lastIndexOf("\\")+1,url.lastIndexOf("\."))) // for windows 
	var DocName =(url.substring(url.lastIndexOf("\/")+1,url.lastIndexOf("\."))) // for *nix 
	
	
	if ( DocName != 'create-charting') {
 	var charLimit = 20;		// ADJUST: number of characters per line
	var lineLimit = 12;		// ADJUST: number of lines
	} else {
 	var charLimit = 50;		// ADJUST: number of characters per line
	 var lineLimit = 15;		// ADJUST: number of lines		
	}
 	var cleanList = [];
	 var re1 = /\S/;			// all non-space characters
  var re2 = /[\n\r]/;		// all line breaks
	 var tempList = fld.value.split('\n');
	 for (var i=0; i<tempList.length;i++) {
		  if (re1.test(tempList[i])) { // store filtered lines in an array
  			 var cleanS = cleanUpLine(tempList[i],charLimit);
		  	 cleanList.push(cleanS);
  		}
  }
  for (var j=0; j<tempList.length;j++) {
		  if (tempList[j].length > charLimit && !re2.test(tempList[j].charAt(charLimit))) { // make sure that last char is not a line break - for IE compatibility
  		fld.value = cleanList.join('\n'); // restore from array
  		}
	 }
	 if (cleanList.length > lineLimit) {
  		cleanList.pop();	// remove last line
		  fld.value = cleanList.join('\n'); // restore from array
	 }
	 fld.onblur = function () {this.value = cleanList.join('\n');} // onblur - restore from array
}	

// Multiple onload function 
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(
  function () {
		  document.main.tips.onkeyup =	function () {
				  cleanUpList(document.main.tips);
  		}
  }
);
*/

//here you place the ids of every element you want.
// 'tips' was left out as div id 2008-09-14
var ids=new Array('a0','a1','a2','a3','a4','a5','a6','a7','a8','a9','a10','a11','a12','a13','a14','a15','a16','a17','a18','a19','a20','a21','a22','a23');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}
function displaytips(divid)

{
	if (getbrowsertype()=='firefox')
		 {
	document.getElementById('displayarea').innerHTML=document.getElementById(divid).textContent;
		
		
	}
	else
	{
		document.getElementById('displayarea').innerHTML=document.getElementById(divid).innerText;
	
	}
}
function  resetdisplay()
{
	document.getElementById('displayarea').innerHTML="";
}
function getbrowsertype()
	  {
			var BrowserAgent;
			BrowserAgent=navigator.userAgent;
			var BrowserType="";
						try
						{
							
							if ((BrowserAgent.indexOf("Firefox/1")!=-1) || (BrowserAgent.indexOf("Firefox/2")!=-1) || (BrowserAgent.indexOf("Firefox/3")!=-1))
								{
								BrowserType="firefox";
				
								}
								else
								{
								BrowserType="others";
								}
							}
						catch(Exception)
						{
						BrowserType="others";
						}
						return BrowserType;
						
			}
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function printPage() {
if (window.print) {
agree = confirm('Do you want to print this assessment? \n\nClick OK to print');
if (agree) window.print(); 
   }
}

function showIt() {
document.compareform.text.style.visibility="visible";
// showdiv('tips');
}

function showFemale() {
window.document.location.href = 'create-assessment.php?gender=female';

}

function showMale() {
window.document.location.href = 'create-assessment.php';

}

function get_el ( el )
{
	return ( typeof(el) == "string" ) ? 
				el = document.getElementById(el) : 
				el
}

function hasClass( el, className )
{
	var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)')

	return re.test( get_el(el).className);
}

function addClass( el, className )
{
	el = get_el(el)
	if ( !hasClass( el, className ) )
	{
		el.className += (" " + className)
	}
}

function removeClass( el, className )
{
	el = get_el(el)
	var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g')
	if ( hasClass( el, className ) )
	{
		el.className = el.className.replace( re, ' ' )

		// in case of duplicates
		if ( hasClass( el, className ) )
			removeClass( el, className );
	}
}


function hide( el )
{
	get_el(el).style.display = 'none' 
}

function show( el )
{
	get_el(el).style.display = '' 
}

function toggle_display( el )
{
	el = get_el(el)
	if ( el.style.display == 'none' )
		show(el)
	else
		hide(el)
}


function getScrollXY() 
{
    var scrOfX = 0, scrOfY = 0;
    if( typeof( window.pageYOffset ) == 'number' ) 
    {
        // Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } 
    else if( document.body && 
             ( document.body.scrollLeft || document.body.scrollTop ) ) 
    {
        // DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } 
    else if( document.documentElement && 
            ( document.documentElement.scrollLeft || 
              document.documentElement.scrollTop ) ) 
    {
        // IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }

    return [ scrOfX, scrOfY ];
}


function getCursorPosition( e ) 
{
    if (e.pageX || e.pageY) 
	{
        x = e.pageX;
        y = e.pageY;
    }
    else if (e.clientX || e.clientY) 
	{
        var scroll = getScrollXY( )
        x = e.clientX + scroll[0];
        y = e.clientY + scroll[1];
    }

    return [x,y]
}

function createLabel( id, text )
{
	var label = document.createElement("label")
	label.control = id
	label.appendChild(document.createTextNode(text))
	return label
}

