/* CSS Document */
function pop_me_up(pURL){ 
	new_window = window.open(pURL, "popup_window", "width=400,height=338,toolbar,scrollbars,menubar,resizable");
	new_window.focus();
}

function pop_me_up2(pURL){ 
	new_window2 = window.open(pURL, "popup_window2", "width=400,height=338,toolbar,scrollbars,menubar,resizable");
	new_window2.focus();
}

function pop_me_uph(pURL){ 
	new_windowh = window.open(pURL, "popup_windowh", "width=400,height=338,toolbar,scrollbars,menubar,resizable");
	new_windowh.focus();
}

function pop_close(){ 
	new_window = window.close();
}

function toggle(foo) {
	if (document.getElementById(foo).style.display == "none") {
		show(foo);

		setCookie(foo, "o");
	} else {
		if (document.getElementById(foo).style.display == "block") {
			hide(foo,1);
		} else {
			show(foo,1);
		}
	}
}

function show(foo,f) {
        if (document.getElementById(foo)) {
	   document.getElementById(foo).style.display = "block";
	   if (f) { setCookie(foo, "o"); }
	}
}

function hide(foo,f) {
	 
        if (document.getElementById(foo)) {
	   document.getElementById(foo).style.display = "none";
	   if (f) { setCookie(foo, "c"); }
	}
}

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "")
		+ ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");

	document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
	var dc = document.cookie;

	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);

	if (begin == -1) {
		begin = dc.indexOf(prefix);

		if (begin != 0)
			return null;

	} else begin += 2;

	var end = document.cookie.indexOf(";", begin);

	if (end == -1)
		end = dc.length;

	return unescape(dc.substring(begin + prefix.length, end));
}

function hideallcalc() {
	 hide("basiccalc");
	 hide("intermediatecalc");
	 hide("advancedcalc");	
}

function hideallana() {
	hide("domainrange");
	hide("intercepts");
	hide("symmetry");
	hide("endbehavior");
	hide("holes");
	hide("vertasym");
	hide("othersym");
	hide("incdec");
	hide("firstderivative");
	hide("extrema");
	hide("secondderivative");
	hide("poi");
	hide("concupdown");	 

	hide("domain");
	hide("peramp");
	hide("horizasym");
	hide("jumps");
	hide("vtvccorn");
}

function showallana() {
	show("domainrange");
	show("intercepts");
	show("symmetry");
	show("endbehavior");
	show("holes");
	show("vertasym");
	show("othersym");
	show("incdec");
	show("firstderivative");
	show("extrema");
	show("secondderivative");
	show("poi");
	show("concupdown");	 

	show("domain");
	show("peramp");
	show("horizasym");
	show("jumps");
	show("vtvccorn");

}

var formnames = new Array(3);
formnames[0] = "basicfunctionform";
formnames[1] = "intermediatefunctionform";
formnames[2] = "advancedfunctionform";

function typefunction(chrs, clear, formname){

	if (clear == 1) {
		document.basicfunctionform.functionenter.value = "";
		document.intermediatefunctionform.functionenter.value = "";
		document.advancedfunctionform.functionenter.value = "";
	} else {
		//document.getElementById(formnames[i]).functionenter.value = document.getElementById(formnames[i]).functionenter.value + chrs;
		//document.formnames[i].functionenter.value = document.formnames[i].functionenter.value + chrs;
		document.basicfunctionform.functionenter.value = document.basicfunctionform.functionenter.value + chrs;
		document.intermediatefunctionform.functionenter.value = document.intermediatefunctionform.functionenter.value + chrs;
		document.advancedfunctionform.functionenter.value = document.advancedfunctionform.functionenter.value + chrs;
	}
	
	try {
	 document.basicfunctionform.functionenter.focus();
	 document.basicfunctionform.functionenter.value = document.basicfunctionform.functionenter.value + "";
		document.intermediatefunctionform.functionenter.value = document.intermediatefunctionform.functionenter.value + "";
		document.advancedfunctionform.functionenter.value = document.advancedfunctionform.functionenter.value + "";
	} catch (error) {
	}

	try {
	 document.intermediatefunctionform.functionenter.focus();
	 document.basicfunctionform.functionenter.value = document.basicfunctionform.functionenter.value + "";
		document.intermediatefunctionform.functionenter.value = document.intermediatefunctionform.functionenter.value + "";
		document.advancedfunctionform.functionenter.value = document.advancedfunctionform.functionenter.value + "";
	} catch (error) {
	}

	try {
	 document.advancedfunctionform.functionenter.focus();
	 document.basicfunctionform.functionenter.value = document.basicfunctionform.functionenter.value + "";
		document.intermediatefunctionform.functionenter.value = document.intermediatefunctionform.functionenter.value + "";
		document.advancedfunctionform.functionenter.value = document.advancedfunctionform.functionenter.value + "";
	} catch (error) {
	}

//print(formnames[i]);

	return;
}

function typefunction2(chrs, clear, formId, eleId){

  	try{
		if (clear == 1) {
			document.getElementById(formId).elements[eleId].value = "";
		} else if (clear == 2) {
			var strValue = document.getElementById(formId).elements[eleId].value;
			strValue = strValue.substring(0, strValue.length - 1);
			document.getElementById(formId).elements[eleId].value = strValue;
		}
		
		document.getElementById(formId).elements[eleId].focus();
		document.getElementById(formId).elements[eleId].value = document.forms[formId].elements[eleId].value + chrs;
		
	} catch (error) {}

	return;
}
