
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Close_Window() {
		window.close();
}
function numeric(string)
{
    for (var i=0, output='', valid="0123456789"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
}
function textCounter(field, count, maxLength)
{
	
	if (field.value.length > maxLength)
		field.value = field.value.substring(0, maxLength);
	else
		count.value = maxLength - field.value.length;
}

function hideShow(picked)
{
	students.style["display"]="none";
	
	if (picked == "students") students.style["display"]="";
}


function selectORdeselect(LABEL,SELECTBOX)
{
	if (LABEL.innerText == "Select All")
	{
		SelectAllList(SELECTBOX);
		LABEL.innerText = "Deselect All";
	}
	else
	{
		DeselectAllList(SELECTBOX);
		LABEL.innerText = "Select All";
	}			
}

var arrOldValues = new Array();
var triggered = false;

function SelectAllList(CONTROL){
	for(var i = 0;i < CONTROL.length;i++){
		CONTROL.options[i].selected = true;
		arrOldValues[i] = "1";
	}
}

function CheckForDeselect(CONTROL) {
	var temp = arrOldValues.toString();
	temp = temp.replace(new RegExp(",",["g"]),"");
	temp = temp.length - temp.replace(new RegExp("1",["g"]),"").length;
	if (temp == 1 && triggered == false)
	{
		DeselectAllList(CONTROL);
		for(var i=0;i<arrOldValues.length;i++)
			arrOldValues[i] = 0;
	}
		
	triggered = false;
}

function DeselectAllList(CONTROL){
	for(var i = 0;i < CONTROL.length;i++){
		CONTROL.options[i].selected = false;
		arrOldValues[i] = "0";
	}
}

function FillListValues(CONTROL){
	triggered = true;
	var arrNewValues = new Array()
	arrNewValues = GetListValues(CONTROL);
	
	for(var i=0;i<arrNewValues.length;i++)
		if(arrNewValues[i]==1)
			(arrOldValues[i]==1) ? arrOldValues[i] = 0 : arrOldValues[i] = 1;
	
	for(var i=0;i<arrOldValues.length;i++)
		(arrOldValues[i]==1) ? CONTROL.options[i].selected = true : CONTROL.options[i].selected = false;
}

function GetListValues(CONTROL){
	var strValues = new Array();
for(var i=0;i < CONTROL.length;i++)
	(CONTROL.options[i].selected == true) ? strValues[i] = "1" : strValues[i] = "0";
return (strValues); 
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function CreateBookmarkLink()
{
 title = "ClickN KIDS";
 url = "http://www.clicknkids.com/Public/MemberLogin.asp";
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");	
	} else if( window.external ) {
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) { return true; }
}


function changeModifySettings() {
	var chosenProduct = document.getElementById('product_settings').value;
	switch (chosenProduct) {
	case 'READ':
		document.getElementById('cnr_settings').style.display = '';
		document.getElementById('cns_settings').style.display = 'none';
		document.getElementById('studentlist_cnr').style.display = '';
		document.getElementById('studentlist_cns').style.display = 'none';
	break;
	case 'SPELL':
		document.getElementById('cnr_settings').style.display = 'none';
		document.getElementById('cns_settings').style.display = '';
		document.getElementById('studentlist_cnr').style.display = 'none';
		document.getElementById('studentlist_cns').style.display = '';
	break;
	}
}
function CreateBookmarkLink()
{
 title = "ClickN KIDS";
 url = "http://www.clicknkids.com/Public/MemberLogin.asp";
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");	
	} else if( window.external ) {
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) { return true; }
	document.getElementById("login").style["display"] = "";	
	document.getElementById("good").style["display"] = "";	
	document.getElementById("warning").style["display"] = "none";	

}
function startFlash(element, switchTime, color1, color2) {
	window.flashMe1 = function() {
		if (element.style.color == color1) {
			element.style.color = color2;
		}
		else {
			element.style.color = color1;
		}
	}
	window.setInterval(window.flashMe1, switchTime);
}
