//-- ==================================================================== --//
//-- Name: KU Identity Theme                                              --//
//-- ==================================================================== --//

/* Global variable for the AntiDoubleClick function */
var button_clicked = false;
var pool_list;
var picked_ist;

function popup( url ) {
	var page = url;
	window.open( page,"","toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,height=500,width=650,left=80,top=50");
}

function AntiDoubleClick() {
	if( button_clicked == true ) {
		return false;
	}
	button_clicked = true;
	return true;
}

function setSize() {
	var maxContentWidth = 800;
	var minContentWidth = 600;
	width = (window.innerWidth) ? window.innerWidth : document.body.offsetWidth;
	if (width > maxContentWidth)
		contentWidth = maxContentWidth;
	else if (width < minContentWidth)
		contentWidth = minConentWidth;
	else
		contentWidth = width - 20;				
	
	var size = document.getElementById("setSize");
	size.setAttribute("width",contentWidth);
	var contentSize = document.getElementById("setContentSize");
	contentSize.setAttribute("width",contentWidth);
	var footerSize = document.getElementById("setFooterSize");
	footerSize.setAttribute("width",contentWidth);
}

function toggleDisplayOnOff(id){	
	if (document.all){	// IE4+
		x=document.all[id].style;
		x['display'] = (x['display']=='none' ? '' : 'none')
	}	
	else if (document.getElementById){ // NN5+
			x=document.getElementById(id).style;	
			x['display'] = (x['display']=='none' ? '' : 'none');

			y=document.getElementById(content).style;	
			y['border-left'] = (y['border-left']=='1px solid #49729c' ? 'none' : 'none');
			}
	}

function toggleDisplay() {
	toggleDisplayOnOff('toggle');
}

function showboth(roomtop,roommid) {
	if( ! roomtop && ! roommid ) {
		document.locationForm.display_top.value = 'Place your mouse'
		document.locationForm.display_mid.value = 'over a room'
	}
	else {
		document.locationForm.display_top.value = roomtop
		document.locationForm.display_mid.value = roommid
	}
}

function showthree(roomtop,roommid,roombot) {
	if( ! roomtop && ! roommid && ! roombot ) {
		document.locationForm.display_top.value = 'Place your mouse'
		document.locationForm.display_mid.value = 'over a room'
		document.locationForm.display_bot.value = ''
	}
	else {
		document.locationForm.display_top.value = roomtop
		document.locationForm.display_mid.value = roommid
		document.locationForm.display_bot.value = roombot
	}
}

function createListObjects() {
    pool_list = document.getElementById("select_pool");
    picked_list = document.getElementById("select_picked");
}

function moveItemLeft() {
   var index = picked_list.selectedIndex;
   if(index < 0)
      return;
   pool_list.appendChild(
      picked_list.options.item(index))
   selectNone(picked_list,pool_list);
}

function moveItemRight() {
   var index = pool_list.selectedIndex;
   if(index < 0)
      return;
   picked_list.appendChild(
      pool_list.options.item(index));
   selectNone(picked_list,pool_list);
}

function selectNone(list1,list2) {
    list1.selectedIndex = -1;
    list2.selectedIndex = -1;
    index = -1;
}

function selectNone(list1,list2){
    list1.selectedIndex = -1;
    list2.selectedIndex = -1;
    index = -1;
}

function moveAllItemsLeft(){
    var len = picked_list.length -1;
    for(i=len; i>=0; i--){
        pool_list.appendChild(picked_list.item(i));
    }
    selectNone(picked_list,pool_list);
}

function moveAllItemsRight(){
    var len = pool_list.length -1;
    for(i=len; i>=0; i--){
        picked_list.appendChild(pool_list.item(i));
    }
    selectNone(picked_list,pool_list);
}

window.onload = function() {
        createListObjects();
}

    function popup(url, id, width, height)
    {
      newwindow =
window.open(url,id,'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width='
+ width + ',height=' + height);
      newwindow.focus();
    }


/*
 * Summary:      Core experiment function that applies any number of
 * classes to all child elements
 *               contained in all occurences of a parent element (either
 *               with or without a specific class)
 * Parameters:   parentElementTag - parent tag name
 *               parentElementClass - class assigned to the parent; if
 *               null, all parentElementTag elements will be affected
 *               childElementTag -  tag name of the child elements to
 *               apply the styles to
 *               styleClasses - comma separated list of any number of
 *               style classes (using 2 classes gives the classic
 *               "zebra" effect)
 * Return:       none
 */
function striper(parentElementTag, parentElementClass, childElementTag, styleClasses)
{
    var i=0,currentParent,currentChild;
    // capability and sanity check
    if
((document.getElementsByTagName)&&(parentElementTag)&&(childElementTag)&&(styleClasses))
{
        // turn the comma separate list of classes into an array
        var styles = styleClasses.split(',');
        // get an array of all parent tags
        var parentItems = document.getElementsByTagName(parentElementTag);
        // loop through all parent elements
        while (currentParent = parentItems[i++]) {
            // if parentElementClass was null, or if the current
            // parent's class matches the specified class
            if ((parentElementClass == null)||(currentParent.className == parentElementClass)) {
                var j=0,k=0;
                // get all child elements in the current parent element
                var childItems = currentParent.getElementsByTagName(childElementTag);
                // loop through all child elements
                while (currentChild = childItems[j++]) {
                    // based on the current element and the number of
                    // styles in the array, work out which class to
                    // apply
                    k = (j+(styles.length-1)) % styles.length;
                    // add the class to the child element - if any other
                    // classes were already present, they're kept intact
                    currentChild.className = currentChild.className+" "+styles[k];
                }
            }
        }
    }
}

/*
 *  Popup window (From KU Template)
 */

function popup(url, id, width, height)
{
	newwindow = window.open(url,id,'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width='
+ width + ',height=' + height);
	newwindow.focus();
}

/*
 * Added by MSK for the prospective students FAQ.
 * when the question is clicked we want to make the answer visible.
 */

function showAnswer(question_id)
{
	var base_id = question_id.substr(0, question_id.length - 1);
	var answer_id = base_id + "a";
	var answer_element = document.getElementById(answer_id);

	if(answer_element.style.display == "block")
	{
		answer_element.style.display = "none";
	}
	else
	{
		answer_element.style.display = "block";
	}
}


