var isIE = document.all ?1:0
var	currentTime = 46;

function embedSwf(audioPath)
{
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
	document.write('WIDTH="206" HEIGHT="20" id="audio" ALIGN="absmiddle">\n');
	document.write('<PARAM NAME=movie VALUE="images/audio.swf?audioPath='+ audioPath +'">\n');
	document.write('<PARAM NAME=quality VALUE=high>\n');
	document.write('<PARAM NAME=bgcolor VALUE=#F3FAFF>\n');
	document.write('<PARAM NAME=scale VALUE=noscale>\n');
	document.write('<EMBED src="images/audio.swf" quality=high bgcolor=#FFFFFF width="206" height="20" NAME="audio" ALIGN="absmiddle"');
	document.write('TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>\n');
	document.write('</OBJECT>');
}
function loadSwf(swfPath, w, h)
{
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
	document.write('WIDTH="'+w+'" HEIGHT="'+h+'" id="audio" ALIGN="absmiddle">\n');
	document.write('<PARAM NAME=movie VALUE="'+ swfPath +'">\n');
	document.write('<PARAM NAME=quality VALUE=high>\n');
	document.write('<PARAM NAME=bgcolor VALUE=#FFFFFF>\n');
	document.write('<PARAM NAME=scale VALUE=noscale>\n');
	document.write('<EMBED src="'+ swfPath +'" quality=high bgcolor=#FFFFFF width="'+w+'" height="'+h+'" NAME="audio" ALIGN="absmiddle"');
	document.write('TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>\n');
	document.write('</OBJECT>');
}

function getCalendar(year, month)
{
	var today = new Date();
	var vaildDate = new Date(today.getYear(), today.getMonth(), today.getDate()+7);
	//alert(vaildDate)
	var selectedDate = new Date(year, month, 1);
	var date = new Date(selectedDate.getYear(),selectedDate.getMonth(),1)
	monthAry = ["January", "February", "March", "April", "May", "June", "July", "August", "septempber", "October", "November", "December"];
	
	calendarString = '<TABLE width=240 cellpadding=0 cellspacing=0 border=0 align=center>';
	calendarString += '<TR valign=top>';
	calendarString += '<TD align=center class=calendar_head height=20><A href="javascript:newCalendar(calendar, '+selectedDate.getYear()+', '+(selectedDate.getMonth()-1)+')" onMouseOver="MM_swapImage(\'btn_calendarBack\',\'\',\'images/btn_calendarBack_f2.gif\',1)" onMouseOut="MM_swapImgRestore()"><IMG src="images/btn_calendarBack.gif" border=0 align=absmiddle name="btn_calendarBack"></A>&nbsp;&nbsp;&nbsp;&nbsp;<B>'+monthAry[selectedDate.getMonth()]+' '+selectedDate.getYear()+'</B>&nbsp;&nbsp;&nbsp;&nbsp;<A href="javascript:newCalendar(calendar, '+selectedDate.getYear()+', '+(selectedDate.getMonth()+1)+')" onMouseOver="MM_swapImage(\'btn_calendarNext\',\'\',\'images/btn_calendarNext_f2.gif\',1)" onMouseOut="MM_swapImgRestore()"><IMG src="images/btn_calendarNext.gif" border=0 align=absmiddle name="btn_calendarNext"></A></TD>';
	calendarString += '</TR>';
	calendarString += '<TR valign=top>';
	calendarString += '<TD bgcolor=#86DBFF>';
	calendarString += '<TABLE width=100% cellpadding=0 cellspacing=1 border=0>';
	calendarString += '<TR valign=top>';
	calendarString += '<TD>';
	calendarString += '<TABLE width=100% cellpadding=0 cellspacing=1 border=0>';
	calendarString += '<TR valign=top>';
	calendarString += '<TD width=14% align=center class=calendar_title>Sun</TD>';
	calendarString += '<TD width=14% align=center class=calendar_title>Mon</TD>';
	calendarString += '<TD width=14% align=center class=calendar_title>Tue</TD>';
	calendarString += '<TD width=14% align=center class=calendar_title>Wed</TD>';
	calendarString += '<TD width=14% align=center class=calendar_title>Thu</TD>';
	calendarString += '<TD width=14% align=center class=calendar_title>Fri</TD>';
	calendarString += '<TD width=14% align=center class=calendar_title>Sat</TD>';
	calendarString += '</TR>';
	calendarString += '</TABLE>';
	calendarString += '</TD>';
	calendarString += '</TR>';
	calendarString += '</TABLE>';
	calendarString += '<TABLE width=100% cellpadding=0 cellspacing=1 border=0>';
	calendarString += '<TR valign=top>';
	calendarString += '<TD bgcolor=#EEEEEE>';
	calendarString += '<TABLE width=100% cellpadding=0 cellspacing=1 border=0>';


	var d = 1;
	var isDone = false;
	for(i=1; i<=6; i++)
	{
		calendarString += '<TR valign=top>';
		for(j=0; j<7; j++)
		{
			if(i == 1)
			{
				
				if(j < date.getDay())
				{
					calendarString += '<TD width=14% align=center bgcolor=#FFFFFF class=calendar>&nbsp;</TD>';
				}
				else
				{
//					alert(selectedDate.valueOf()-vaildDate.valueOf())
					var checkDate = new Date(selectedDate.getYear(), selectedDate.getMonth(), d);
					if(checkDate.valueOf() > today.valueOf() && checkDate.valueOf() <= vaildDate.valueOf())
					{
						calendarString += '<TD width=14% align=center bgcolor=#FFFFFF><A href="#" onClick="javascript:document.thisForm.day.value='+d+';showSelectedDay(s'+d+', '+d+')" class=calendar><SPAN id="s'+d+'">'+d+'</SPAN></A></TD>';
					}
					else
					{
						calendarString += '<TD width=14% align=center bgcolor=#FFFFFF class=calendar><SPAN id="s'+d+'">'+d+'</SPAN></TD>';
					}
					d++;
				}
			}
			else
			{
				var checkDate = new Date(selectedDate.getYear(), selectedDate.getMonth(), d);
				if(checkDate.getMonth() != selectedDate.getMonth())
				{
					calendarString += '<TD width=14% align=center bgcolor=#FFFFFF class=calendar>&nbsp;</TD>';
					if(j == 6 && i <= 5)
					{
						var checkDate = new Date(selectedDate.getYear(), selectedDate.getMonth(), d+1);
						if(checkDate.getMonth() != selectedDate.getMonth())
						{
							isDone = true;
							break;
						}
					}
				}
				else
				{
					var checkDate = new Date(selectedDate.getYear(), selectedDate.getMonth(), d);
					if(checkDate.valueOf() > today.valueOf() && checkDate.valueOf() <= vaildDate.valueOf() && j != 0 && j != 6)
					{
						calendarString += '<TD width=14% align=center bgcolor=#FFFFFF><A href="#" onClick="javascript:document.thisForm.day.value='+d+';showSelectedDay(s'+d+', '+d+')" class=calendar><SPAN id="s'+d+'">'+d+'</SPAN></A></TD>';
					}
					else
					{
						calendarString += '<TD width=14% align=center bgcolor=#FFFFFF class=calendar><SPAN id="s'+d+'">'+d+'</SPAN></TD>';
					}

					if(j == 6 && i <= 5)
					{
						var checkDate = new Date(selectedDate.getYear(), selectedDate.getMonth(), d+1);
						if(checkDate.getMonth() != selectedDate.getMonth())
						{
							isDone = true;
							break;
						}
					}
					d++;
				}
			}			
		}
		calendarString += '</TR>';
		if(isDone) break;
	}

	calendarString += '</TABLE>';
	calendarString += '</TD>';
	calendarString += '</TR>';
	calendarString += '</TABLE>';
	calendarString += '</TD>';
	calendarString += '</TR>';
	calendarString += '</TABLE>';
	calendarString += '<input name="year" type="hidden" class=form_txt style=width:250px value='+selectedDate.getYear()+'>';
	calendarString += '<input name="month" type="hidden" class=form_txt style=width:250px value='+(selectedDate.getMonth()+1)+'>';
	calendarString += '<input name="day" type="hidden" class=form_txt style=width:250px>';

	return calendarString;
}

function showCalendar()
{
	var today = new Date();
	document.write(getCalendar(today.getYear(), today.getMonth()));
}
function newCalendar(obj, year, month)
{
	if(isIE)
	{
		obj.innerHTML=getCalendar(year, month);
	}
	else
	{
		document.obj.open();
		document.obj.write(getCalendar());
		document.obj.close();
	}
}
function showSelectedDay(obj, q)
{
	if(isIE)
	{
		for(i=1; i<=28; i++)
		{		
			eval("s"+i).innerHTML = i;
		}
		if(typeof(s29) == "object") s29.innerHTML = '29';
		if(typeof(s30) == "object") s30.innerHTML = '30';
		if(typeof(s31) == "object") s31.innerHTML = '31';

		obj.innerHTML = '<SPAN style=color:#86DBFF><U>'+q+'</U></SPAN>';
	}
	else
	{
		for(i=1; i<=28; i++)
		{
			document.eval("s"+i).open();
			document.eval("s"+i).write(i);
			document.eval("s"+i).close();
		}
		if(typeof(s29) == "object")
		{
			document.s29.open();
			document.s29.write('29');
			document.s29.close();
		}
		if(typeof(s30) == "object")
		{
			document.s30.open();
			document.s30.write('30');
			document.s30.close();
		}
		if(typeof(s31) == "object")
		{
			document.s31.open();
			document.s31.write('31');
			document.s31.close();
		}
		document.obj.open();
		document.obj.write('<U>'+q+'</U>');
		document.obj.close();
	}

	
}
function showTextfield(obj, a, q)
{
	if(isIE)
	{
		obj.innerHTML='<input name="txt_q'+a+'_'+q+'" type=text class=form_txt style=width:100px>&nbsp;';
	}
	else
	{
		document.obj.open();
		document.obj.write('<input name="txt_q'+a+'_'+q+'" type=text class=form_txt style=width:100px>&nbsp;');
		document.obj.close();
	}
}
function hideTextfield(obj)
{
	if(isIE)
	{
		obj.innerHTML='';
	}
	else
	{
		document.obj.open();
		document.obj.write('');
		document.obj.close();
	}
}
function resetTimer()
{
	clearTimeout(timer);
}
function showTimer(obj)
{
	timer = setTimeout("showTimer(obj)", 500);
	if(currentTime <= 0)
	{
		resetTimer();
	}
	else
	{
		currentTime--;
		if(currentTime < 10)
		{
			string = "00:0"+currentTime;
		}
		else
		{
			string = "00:"+currentTime;
		}		
	}

	if(isIE)
	{
		obj.innerHTML = string;
	}
	else
	{
		document.obj.open();
		document.obj.write(string);
		document.obj.close();
	}
}
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_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_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 MM_openBrWindow(theURL,winName,features) { //v2.0
  win = window.open(theURL,winName,features);
  win.focus();
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function chknull(obj, msg)
{
	if (obj.value == "")
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}

function chkemailformat(obj, msg)
{
	if (obj.value.indexOf("@") == -1 || obj.value.indexOf(".") == -1)
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}

function chkinteger(obj, msg)
{
	var re = /^[^a-z|^A-Z]+$/;

	if (!re.test(obj.value))
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}

function chkconfirm(obj1, obj2, msg)
{
	if (obj1.value != obj2.value)
	{
		alert(msg);
		obj2.focus();
		return false;
	}
	return true;
}

function chkcheckbox(obj, msg)
{
	var num = 0;

	for (i=0; i <3; i++) 
	{
		if (obj[i].checked)
		{
			num = num +1;
		}
	}

	if (num > 2)
	{
		alert(msg);
		return false;
	}
	return true;
}

function chkradio(obj, msg)
{
	var num = 0;

	for (var i=0; i <obj.length; i++) 
	{
		if (obj[i].checked)
		{
			num = num +1;
		}
	}
	if (num == 0)
	{
		alert(msg);
		return false;
	}
	return true;
}


function chkpulldown()
{
	var chkisNull = arguments[0];
	var obj = arguments[1];
	var msg = arguments[2]	

	if (chkisNull == null || chkisNull == true)
	{
		chkisNull = true;
	}
	else
	{
		chkisNull = false;
	}
	if (chkisNull)
	{
		if (obj.options.value == "" )
		{
			alert(msg);
			return false;
		}
	}
	else
	{
		if (obj.options.value != "")
		{
			return false;
		}
	}
	return true;
}

function PopImage(pointTO, label, width, height)
{
	iWidth = parseInt(width);
	iHeight = parseInt(height);

	var thisImage = new Image(); thisImage.src=pointTO;
	handle = window.open("",label,"width="+width+",height="+height+",top=0,left=0,toolbar=no,location=no,menubar=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no");
	handle.document.write("<TITLE>Educational Technologies Limited</TITLE><BODY leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><IMG SRC="+thisImage.src+"></BODY>");
	handle.document.close();
	handle.window.resizeTo(iWidth,iHeight);
	handle.focus();
}

function changeLang(lang)
{
	if (location.href.indexOf("#") != -1)
	{
		location1 = location.href.substring(0, location.href.indexOf("#"));
		location2 = parent.content.location.href.substring(0, location.href.indexOf("#"));
		location3 = parent.footer.location.href.substring(0, location.href.indexOf("#"));
	}
	else
	{
		location1 = location.href;
		location2 = parent.content.location.href;
		location3 = parent.footer.location.href;
	}

	if (location1.indexOf("/en/") != -1)
	{
		if (lang == "b5")
		{
			location.replace(location1.replace(/\/en\//,"/b5/"));
			parent.content.location.replace(location2.replace(/\/en\//,"/b5/"));
			parent.footer.location.replace(location3.replace(/\/en\//,"/b5/"));
		}
		else if(lang == "gb")
		{
			location.replace(location1.replace(/\/en\//,"/gb/"));
			parent.content.location.replace(location2.replace(/\/en\//,"/gb/"));
			parent.footer.location.replace(location3.replace(/\/en\//,"/gb/"));
		}
	}
	else if (location1.indexOf("/b5/") != -1)
	{
		if (lang == "en")
		{
			location.replace(location1.replace(/\/b5\//,"/en/"));
			parent.content.location.replace(location2.replace(/\/b5\//,"/en/"));
			parent.footer.location.replace(location3.replace(/\/b5\//,"/en/"));
		}
		else if (lang == "gb")
		{
			location.replace(location1.replace(/\/b5\//,"/gb/"));
			parent.content.location.replace(location2.replace(/\/b5\//,"/gb/"));
			parent.footer.location.replace(location3.replace(/\/b5\//,"/gb/"));
		}
	}
	else if (location1.indexOf("/gb/") != -1)
	{
		if (lang == "en")
		{
			location.replace(location1.replace(/\/gb\//,"/en/"));
			parent.content.location.replace(location2.replace(/\/gb\//,"/en/"));
			parent.footer.location.replace(location3.replace(/\/gb\//,"/en/"));
		}
		else if (lang == "b5")
		{
			location.replace(location1.replace(/\/gb\//,"/b5/"));
			parent.content.location.replace(location2.replace(/\/gb\//,"/b5/"));
			parent.footer.location.replace(location3.replace(/\/gb\//,"/b5/"));
		}
	}
}