// JavaScript Document
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_ro'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;

new Image().src = "/images/common/sub_close.gif";
op="/images/common/sub_close.gif";
cl="/images/common/sub_open.gif";
function dd(obj){
	if(document.getElementById){
		document.getElementById(obj).style.display=='none'?document.getElementById(obj).style.display='':document.getElementById(obj).style.display='none';
		document.getElementById(obj+"i").src.indexOf('/images/common/sub_open')>0?document.getElementById(obj+"i").src=op:document.getElementById(obj+"i").src=cl;
	}else if(document.all){
		document.all(obj).style.display=='none'?document.all(obj).style.display='':document.all(obj).style.display='none';
		document.all(obj+"i").src.indexOf('/images/common/sub_open')>0?document.all(obj+"i").src=op:document.all(obj+"i").src=cl;
		}
	else if(document.layers){
		document.layers[obj].display=='none'?document.layers[obj].display='':document.layers[obj].display='none';
		document.layers[obj+"i"].src.indexOf('/images/common/sub_open')>0?document.layers[obj+"i"].src=op:document.layers[obj+"i"].src=cl;
	}
}



function swap(a){
	if (a==1){
		document.getElementById("n1").className="on";
		document.getElementById("n2").className="off";
		document.getElementById("sub_box").style.display="none";
	}else{
		document.getElementById("n1").className="off";
		document.getElementById("n2").className="on";
		document.getElementById("sub_box").style.display="";
	}
}
function student_news(a){
	if (a==1){
		document.getElementById("student_b4_b1").style.display="";
		document.getElementById("student_b4_b2").style.display="none";
		document.getElementById("student_b4_b3").style.display="none";
	}else if (a==2){
		document.getElementById("student_b4_b1").style.display="none";
		document.getElementById("student_b4_b2").style.display="";
		document.getElementById("student_b4_b3").style.display="none";
	}else if(a==3){
		document.getElementById("student_b4_b1").style.display="none";
		document.getElementById("student_b4_b2").style.display="none";
		document.getElementById("student_b4_b3").style.display="";
	}
}
function student_b4(a){
	if (a==1){
		document.getElementById("student_b4_1").style.display="";
		document.getElementById("student_b4_2").style.display="none";
		document.getElementById("student_b4_3").style.display="none";
	}else if (a==2){
		document.getElementById("student_b4_1").style.display="none";
		document.getElementById("student_b4_2").style.display="";
		document.getElementById("student_b4_3").style.display="none";
	}else if(a==3){
		document.getElementById("student_b4_1").style.display="none";
		document.getElementById("student_b4_2").style.display="none";
		document.getElementById("student_b4_3").style.display="";
	}
}


function playsound(voicefilepath){
	if (navigator.appName.indexOf("Microsoft Internet Explorer")>-1) {
		document.all.voicefile.src="/images/teaching_materials/sound/"+voicefilepath;
	}else if(navigator.userAgent.indexOf("Firefox")>=0){
		window.open ('/teaching_materials/playsound.php?voicefile='+voicefilepath, 'playsound', 'height=100, width=100, top=200, left=200, toolbar=no, menubar=no, scrollbars=no,resizable=1,location=no, status=no');
	}else{
	document.getElementById("iframplaysound").innerHTML = "<iframe src='/images/teaching_materials/sound/"+voicefilepath+"' style='WIDTH: 1px; POSITION: absolute; HEIGHT: 1px' border='0' frameBorder='0' width='0' height='0'></iframe>"
	}
}

function wordsound1(voicefilepath){
	if (navigator.appName.indexOf("Microsoft Internet Explorer")>-1) {
		document.all.voicefile.src=voicefilepath;
	}else if(navigator.userAgent.indexOf("Firefox")>=0){
		window.open ('/wordsound.php?voicefile='+voicefilepath, 'playsound', 'height=100, width=100, top=200, left=200, toolbar=no, menubar=no, scrollbars=no,resizable=1,location=no, status=no');
	}else{
	document.getElementById("iframplaysound").innerHTML = "<iframe src='"+voicefilepath+"' style='WIDTH: 1px; POSITION: absolute; HEIGHT: 1px' border='0' frameBorder='0' width='0' height='0'></iframe>"
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

 function ReImgSize(){
  for (i=0;i<document.images.length;i++)
   {
   if (document.getElementsByTagName("img")){
	if (document.images[i].width>520)
	 {
       document.images[i].width="520"
       document.images[i].outerHTML='<a href="'+document.images[i].src+'" target="_blank" title="Win open">'+document.images[i].outerHTML+'</a>'
  	 }
   }
  else{
	if (document.images[i].width>600) {
	  document.images[i].title="Win open"
	  document.images[i].style.cursor="pointer"
	  document.images[i].onclick=function(e){window.open(this.src)}
	}
  }
  }
 } 
