var myClass = {
	isclass:function(name, css_class) {
		if (typeof name == "string") name = document.getElementById(name);
		var classes = name.className;
		if (!classes) return false;
		if (classes == css_class) return true;
	},
	add: function(name, css_class) {
		if (typeof name == "string") name = document.getElementById(name);
		if (myClass.isclass(name,css_class)) return;
		if (name.className) css_class = " " + css_class;
		name.className += css_class;
	},
	remove: function(name, css_class)  {
		if (typeof name == "string") name = document.getElementById(name);
		if (!myClass.isclass(name, css_class)) return;
		name.className = name.className.replace(new RegExp("\\b"+ css_class+"\\b\\s*","g"),"");
	}
};



function toggle(){
	o = document.getElementById("togLink");
	if (myClass.isclass("bio","noheight")) {
		myClass.remove("bio","noheight");
		o.innerHTML = "read more...";
	}
	else {
		myClass.add("bio","noheight");
		o.innerHTML = "shrink";
	}
}

function toggleTest(){
	o = document.getElementById("togTest");
	if (myClass.isclass("testimonial","noheight")) {
		myClass.remove("testimonial","noheight");
		o.innerHTML = "read more...";
	}
	else {
		myClass.add("testimonial","noheight");
		o.innerHTML = "shrink";
	}
}

function toggleBio(a,b){
	// a is link, b is div id
	o = document.getElementById(a);
	p = document.getElementById(b)
	if (myClass.isclass(p,"noheight")) {
		myClass.remove(p,"noheight");
		o.innerHTML = "read more...";
	}
	else {
		myClass.add(p,"noheight");
		o.innerHTML = "shrink";
	}
}

//function toc($a,$b,$c,$d){
function toc() {
	var	x = arguments.length;	
	if (x%2 != 0) {
		window.alert("missing parameter!");
	}
	else {
		var o = new Array();
		for (var loop = 0; loop < x; loop++) o[loop] = arguments[loop];
		for (var loop = 0; loop < (x/2); loop++){
			//window.alert(loop);
			if (loop == 0) {
				//window.alert(o[loop*2]);
			o[loop*2] = document.getElementById(o[loop*2]);
				//window.alert(o[loop*2+1]);
			o[loop*2+1] = document.getElementById(o[loop*2+1]);
			if (myClass.isclass(o[0],"open")) {
					myClass.remove(o[0],"open");
					myClass.remove(o[1],"script_sel");
				}
				else {
					myClass.add(o[loop*2],"open");
					myClass.add(o[loop*2+1],"script_sel");
				}
			}
			else {
				//window.alert(o[loop*2]);
				o[loop*2] = document.getElementById(o[loop*2]);
				//window.alert(o[loop*2+1]);
				o[loop*2+1] = document.getElementById(o[loop*2+1]);
				myClass.remove(o[loop*2],"open");
				myClass.remove(o[loop*2+1],"script_sel");
			}
		}
	}
}



function getTestimonial(pageLoad, divId,$id) {
	//alert("entry "+window.id);
	if ($id==0) {
		var newUrl = pageLoad+"&count=yes";
		$.get(newUrl,
			function(data) {
				window.idMax = parseInt(data);
	//			alert(idMax+" "+window.id);
			}
		);
	}
	newUrl = pageLoad+"&id="+$id;
//	alert(newUrl);
	var container = document.getElementById(divId);

	$(function(){
		$.get(newUrl,
			function(data) {  
				container.innerHTML = data;
			}
		);
		}
	);
	window.id = $id;
	++$id;

	window.id = $id;
	if (window.id > window.idMax) {
		window.id = 0;

	}
	//alert("exit "+window.id+" "+$id);
} 

function getStudent(studPage, divId,$st_id) {
	//alert("entry "+window.id);
	if ($st_id==0) {
		var newStudUrl = studPage+"?count=yes";
		$.get(newStudUrl,
			function(data) {
				window.stud_Max = parseInt(data);
				//alert(idMax+" "+window.st_id);
			}
		);
	}
	newStudUrl = studPage+"?id="+$st_id;
	//alert(newStudUrl);
	var st_container = document.getElementById(divId);

	$(function(){
		$.get(newStudUrl,
			function(data) {  
				//alert(data);
				$('#myGallery').html(data);

				//st_container.innerHTML = data;
			}
		);
	//$('#myGallery').fadeIn(10);
		}
	);
	window.stud_id = $st_id;
	++$st_id;

	window.stud_id = $st_id;
	if (window.stud_id > window.stud_Max && window.stud_Max !=0 ) {
		window.stud_id = 0;

	}
	//$('#myGallery').fadeOut(5000);
} 