/**
 *
 * Switch with Which
 *
 */ 

/**
 * Popup window used throughout and within CMS.
 *
 */
function popUp(strURL, strType, strWidth, strHeight, target)
{
	var strOptions = "";
	if (strType == "console") strOptions = "resizable, height = " + strHeight + ", width = " + strWidth;
	if (strType == "fixed") strOptions = "status, height = " + strHeight + ", width = " + strWidth;
	if (strType == "fixed_scroll") strOptions = "scrollbars, height = " + strHeight + ", width = " + strWidth;
	if (strType == "elastic") strOptions = "directories, status, toolbar, menubar, scrollbars, resizable, location, height = " + strHeight + ", width = " + strWidth;
	window.open(strURL, target, strOptions);
}

/**
 * Top navigation bar to increase font-size for accessibility.
 *
 */
function setsize(fsize)
{
	document.getElementsByTagName("body")[0].style.fontSize = fsize;
}


/**
 * Step3 preferences tickbox/checkbox.
 *
 */
$(document).ready(function () {
	function onepref() {
		var n = $("#step3form input:checked").length;
		if (n > 0) {
			$("#step3form :checkbox").each(function (i) {
				if (!this.checked) {
					this.disabled = true;
				}
			});
		} else {
			$("#step3form :checkbox").each(function (i) {
				if (this.value != "0a") {
					this.disabled = false;
				}
			});
		}
	};
	onepref();
	$(":checkbox").click(onepref);
});


/**
 * Set checked input type
 *
 */
function setCheckedValue(radioObj, newValue) 
{
	if(!radioObj)
	return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}



function copyToList(from,to)
{
	fromList = eval('document.myform.' + from);
	toList = eval('document.myform.' + to);
	if (toList.options.length > 0 && toList.options[0].value == 'temp')
	{
		toList.options.length = 0;
	}
	var sel = false;
	for (i=0;i<fromList.options.length;i++)
	{
		var current = fromList.options[i];
		if (current.selected)
		{
			sel = true;
			if (current.value == 'temp')
			{
				alert ('You cannot move this text!');
				return;
			}
			txt = current.text;
			val = current.value;
			toList.options[toList.length] = new Option(txt,val);
			fromList.options[i] = null;
			i--;
		}
	}
	if (!sel) alert ('You haven\'t selected any options!');
	document.myform.pref.value='';

	for (i=toList.options.length-1;i>-1;i--)
	{
		var current = toList.options[i];
		document.myform.pref.value=document.myform.pref.value+current.value;
		if (i>0) document.myform.pref.value=document.myform.pref.value+',';
	}
	
}

function allSelect()
{
  alert('dddd');
  List = document.forms[0].chosen;
  if (List.length && List.options[0].value == 'temp') return;
  for (i=0;i<List.length;i++)
  {
     List.options[i].selected = true;
  }
}

function SwitchMenu(obj){
	if(document.getElementById){
		
	var el = document.getElementById(obj);
	//var ar = document.getElementById("masterdiv").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			//for (var i=0; i<ar.length; i++){
				//if (ar[i].className=="submenu")  ar[i].style.display = "none";
			//}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function asc_input(myobject)
{
	// if (myobject.value=='...')   { myobject.value=''; } else if (myobject.value=='') { myobject.value='...'; } 
}
