//
//
// functions to convert a repeater into a drop-down
function ul2select(hid, sel, foo){
  var select=document.createElement('select');
  var holder = document.getElementById(hid);
  var ul = holder.getElementsByTagName('ul')[0];
  var az = ul.getElementsByTagName('A');
  var createOption = function (a) {
    	var opt = document.createElement('option');
	opt.innerHTML = a.innerHTML;
	opt.value = a.href;
	opt.selected = a.id == sel ? "selected" : "";
	return opt;
  }

  select.onchange = function(){
    if(this.options[this.selectedIndex].value != false) 
      location.href = this.options[this.selectedIndex].value
  };

  var deft = {innerHTML:foo, href:0, id:"x0"};
  select.appendChild(createOption(deft));

  for (var i = 0;it = az[i];i++){
	select.appendChild(createOption(it));
  }
  holder.removeChild(ul);
  holder.appendChild(select);
  
}


var t;
var d;
function selectOn(dv)
{
dv.getElementsByTagName("ul")[0].className='on';
dv.getElementsByTagName("ul")[0].onmouseover=function(){
	On(this);
}
clearTimeout(t);
}
function On(dv)
{
dv.className='on';
clearTimeout(t);
}

function selectOff(dv)
{
d=dv;
t=setTimeout("d.getElementsByTagName('ul')[0].className=''",300);
}


// Quick search drop-downs
// fix DropDown if JS is not available (redefine styles by JS)
function selectFix(name, classname, selectedname)
{
	if (document.getElementById(name)!= null) 
		document.getElementById(name).className=classname;
		
	// make selected question visible
	// it will be hidden, if Java is disabled
	if (document.getElementById(selectedname) != null)
		document.getElementById(selectedname).style.display = "";
		
	
	/*// show results table
	// it will be hidden, if Java is disabled and no question is selected
	if (document.getElementById(results_name) != null)
		document.getElementById(results_name).style.display = "";*/
}


//Implement accordion for content pages
jQuery(document).ready(function() {
    jQuery(".accordion").accordion({ 
	    event: 'click', 
	    header: "h3",	    
	    active: '.selected',
		autoheight: false,
		alwaysOpen: false
	});
    jQuery(".accordion h3").click(function(){
	jQuery(document).scrollTop(0);
	});
});



function setOnFocus(keywords, control) {
    if (control.value == keywords) {
        control.value = '';
    }
}

function setOnBlur(keywords, control) {
    if (control.value == '') {
        control.value = keywords;
    }
}

