image1=new Image(20,20)
image1.src="/images/side-left.gif";
image2=new Image(30,30)
image2.src="/images/side-right.gif";
var checkpars = '';
var thediv = '';


function UpdateDynamicCredits(a) {
//alert(a);
a = parseInt(a);
var b = Math.floor(a / 110);
var c = a - (b * 10);
var d = c * 0.99
var e = a 
//alert(e);
document.getElementById("dynamic_credits").innerHTML = a+" ("+(b*10)+" Free)";
document.getElementById("dynamic_cost").innerHTML = "$"+Math.round(d*100)/100;
document.getElementById("dynamic_price").innerHTML = "$"+Math.round(d / a *100)/100;
}

function changeNotificationStatus(id,new_status) {

if (new_status == 1)
var notification = "<input type=checkbox value=1 checked onclick=\"changeNotificationStatus('"+id+"',0); return false;\" style=float:left;> <div style=width:25px;color:green;float:left;><b>ON</b></div>";
else
var notification = "<input type=checkbox value=1 onclick=\"changeNotificationStatus('"+id+"',1); return false;\" style=float:left;> <div style=width:25px;color:red;float:left;><b>OFF</b></div>";

document.getElementById("notify"+id).innerHTML = notification;

var pars = "id="+id+"&new_status="+new_status+"&remote_func=changeNotificationStatus";
var url = "/AJAXfunctions.php";
new Ajax.Request(url,{method:'post',parameters:pars});

}



function getMP3items(artist,singles,start) {
document.getElementById("Amp3").innerHTML = "<center><br><br><br><img src =/images/progress_bar.gif width=190 height=14 border=0><br>loading...</center>";

if (start)
window.location.hash = '#mp3top';

starttime=new Date().getTime();
var pars = "artist="+artist+"&singles="+singles+"&start="+start+"&remote_func=getMP3items";
var url = "/AJAXfunctions.php";
new Ajax.Updater('Amp3', url,{evalScripts:true, method:'post',parameters:pars,onComplete:updateCartButtons});




}


function playTrack(unique,mid) {
var pars = "unique="+unique+"&mid="+mid+"&remote_func=convertGibberish";
var url = "/quickAJAX.php";
new Ajax.Request(url,{method:'post',parameters:pars,onSuccess: soundStart});
}

function soundStart(resp) {
var response = resp.responseText;
var data = response.split('t1t1u4');
playSound(data[2],data[1]);
thisMovie("flash_player").loadSound(data[0]);

}


function openAlbum(row,media_id) {
var albumDiv = "mp3space"+row;
var rows = 0;

	while(++rows <= 5) {
	if (rows == row)
	document.getElementById("row"+row+"album").style.color = "red";
	else
	document.getElementById("row"+row+"album").style.color = "";
	}


var pars = "media_id="+media_id+"&remote_func=openAlbum";
var url = "/AJAXfunctions.php";
new Ajax.Updater(albumDiv, url,{evalScripts:true, method:'post',parameters:pars});
}



function deleteTrack(trackname,nicename,media_id) {

var udpateDiv = "file"+media_id;

if (confirm("Delete "+nicename+"?")) {
var pars = "trackname="+trackname+"&remote_func=deleteTrack";
var url = "/AJAXfunctions.php";
new Ajax.Updater(udpateDiv, url,{evalScripts:true, method:'post',parameters:pars});
}
else
alert('CANCELLING');

}


function select_all(obj)

{ var text_val=eval(obj);

text_val.focus();

text_val.select();

if (!document.all) return; // IE only

r= text_val.createTextRange();
}

function replaceSushis(sushi,media_id) {
var lightup = sushi;
var output = '';

	while(lightup) {
	output += "<img src=/images/star-gold.png style=\"width:18px;height:18px;border:0;margin-left:1px;\">";
	lightup--;
	}

	while(++sushi <= 5) {
	output += "<img src=/images/star-white.png style=\"width:18px;height:18px;border:0;margin-left:1px;\">";
	}

document.getElementById("allsushis"+media_id).innerHTML = output;
}

function sushiRankDisplay(sushi,media_id) {
var lightup = sushi;
	while(lightup) {
	document.getElementById("sushi"+media_id+lightup).src = "/images/star-gold.png";
	lightup--;
	}

	while(++sushi <= 5) {
	document.getElementById("sushi"+media_id+sushi).src = "/images/star-white.png";
	}
}

function sushiRankHover(sushi,voted,media_id) {
if (voted)
	document.getElementById("voteline"+media_id).innerHTML = "You already voted";
	else
	{
		switch(sushi) {
		case 5:
		document.getElementById("voteline"+media_id).innerHTML = "Amazing!";
		break;

		case 4:
		document.getElementById("voteline"+media_id).innerHTML = "Great";
		break;

		case 3:
		document.getElementById("voteline"+media_id).innerHTML = "Normal";
		break;

		case 2:
		document.getElementById("voteline"+media_id).innerHTML = "Subpar";
		break;

		case 1:
		document.getElementById("voteline"+media_id).innerHTML = "Sucks!";
		break;
		}
	}
}


function deleteVote(media_id) {
var deleteok = confirm("Your vote will be deleted first. Is this okay?");
if (deleteok)
location.href = "/pages/edit_vote/"+media_id;
else
return false;
}

function recordSushiVote(media_id,sushis) {
if (!sushis)
alert ("You must choose a rank.");
else
{

window.open("/recordSushiVote.php?page=recordvote&var1="+media_id+"&var2="+sushis,"sushivote","menubar=no,width=350,height=240,toolbar=no");
}

}


function sushiRankMouseout(media_id,total_votes) {
var rankings = (total_votes == 1) ? total_votes + " rating" : total_votes + " ratings";
var div = "voteline"+media_id;

if (total_votes > 0)
document.getElementById(div).innerHTML = "<a href=\"/pages/votes/" + media_id + "\" style=font-size:10pt;color:black;>"+rankings+"</a>";
else
document.getElementById(div).innerHTML = rankings;

}




/*   dw_banners.js   version date: May 2005  */

/*************************************************************************
  This code is from Dynamic Web Coding at dyn-web.com
  Copyright 2001-5 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

dw_Banner.restartDelay = 500; // delay onmouseout to restart rotation
dw_Banners={};function dw_Banner(id,delay,bMouse){this.id=id;this.delay=delay;this.items=[];this.ctr=0;this.timer=null;dw_Banners[this.id]=this;this.animString="dw_Banners."+this.id;if(bMouse)dw_Banner.setMouseEvents(this.id);};dw_Banner.prototype.addItem=function(sHtml){this.items[this.items.length]=sHtml;};dw_Banner.prototype.rotate=function(){clearTimeout(this.timer);this.timer=null;if(!dw_Banner.ready)return;var el=document.getElementById(this.id);if(el&&typeof el.innerHTML!="undefined"){el.innerHTML=this.items[this.ctr];if(this.ctr<this.items.length-1)this.ctr++;else this.ctr=0;this.timer=setTimeout(this.animString+".rotate()",this.delay);}};dw_Banner.setMouseEvents=function(id){var el=document.getElementById(id);if(el){el.onmouseover=dw_Banner.pause;el.onmouseout=dw_Banner.resume;}};dw_Banner.pause=function(){var curObj=dw_Banners[this.id];if(curObj){clearTimeout(curObj.timer);curObj.timer=null;}};dw_Banner.resume=function(e){e=e?e:window.event;var toEl=e.relatedTarget?e.relatedTarget:e.toElement;if(this!=toEl&&!dw_contained(toEl,this)){var curObj=dw_Banners[this.id];if(curObj)curObj.timer=setTimeout(curObj.animString+".rotate()",dw_Banner.restartDelay);}};function dw_contained(oNode,oCont){if(!oNode)return;while(oNode=oNode.parentNode)if(oNode==oCont)return true;return false;};var imageHandler={path:"",imgs:[],preload:function(){for(var i=0;arguments[i];i++){var img=new Image();img.src=this.path+arguments[i];this.imgs[this.imgs.length]=img;}}};eval('\x64\x77\x5f\x42\x61\x6e\x6e\x65\x72\x2e\x72\x65\x61\x64\x79\x3d\x74\x72\x75\x65\x3b');

browser_name = navigator.appName;
browser_version = parseFloat(navigator.appVersion); 
if (browser_name == "Netscape" && browser_version >= 3.0) { roll = 'true'; }
else if (browser_name == "Microsoft Internet Explorer" && browser_version >= 3.0) { roll = 'true'; }
else { roll = 'false'; }
function msover1(img,ref) { if (roll == 'true') { document.images[img].src = ref; } }
function msout1(img,ref)  { if (roll == 'true') { document.images[img].src = ref; } }

// sound related functions

var no_update = '';


function sendLoginLink(url) {

alert('You must be logged in to add to your cart.');
//parent.window.location='/forum/ucp.php?mode=login&redirect='+url;

}


function sendLoginPopup (a, b, c, d){
var topStr = (screen.availHeight/2)-61;
var leftStr = (screen.availWidth/2)-150;
day = new Date();
id = day.getTime();

if (d != 'LOGIN')
alert('You must be logged in.');

var URL = "/LogInPopUp.php?b_var2="+a+"&b_var3="+b+"&blank="+id+"&refer="+parent.location;
parent.window.location=URL;
/*
document.getElementById("blankdiv").innerHTML = URL + "<br>" + id;
var windowPars = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=300,left="+leftStr+",top="+topStr;
window.open(URL,id,windowPars);
return false;
*/
}

function openArtistTab(tab,artist_id) {
if (document.getElementById('A'+tab).innerHTML == '<!-- nothing here -->')
{
document.getElementById('A'+tab).innerHTML = "<center><br><br><br><img src =/images/progress_bar.gif width=190 height=14 border=0><br>loading...</center>";
reloadOneField('A'+tab,artist_id,tab);
}
shiftOpen(tab);
return false;
}; // end of function: openArtistTab


function reloadOneField(thediv,theid,thefield) {
var pars = "theid=" + theid + "&thefield=" + thefield + "&remote_func=reloadOneField";
var url = "/AJAXfunctions.php";
new Ajax.Updater(thediv, url,{evalScripts:true, method:'post',parameters:pars});
}



function shiftOpen(div) {

var divlist = document.getElementById("alldivs").innerHTML;

var alldivs = divlist.split(',');

	for (i=0; i<alldivs.length; ++i) {
	var cur_div = alldivs[i];
		if (cur_div == div)
		{
		document.getElementById(cur_div).style.display='block';
		document.getElementById(cur_div + "btn").style.backgroundColor='#c5c5c5';
		document.getElementById(cur_div + "btn").style.borderBottom='1px #c5c5c5 solid';
		}
		else
		{
		document.getElementById(cur_div).style.display='none';
		document.getElementById(cur_div + "btn").style.backgroundColor='#F8F8F8';
		document.getElementById(cur_div + "btn").style.borderBottom='1px #333333 solid';
		}
	} // for
}


function shiftOpenPress(div) {

var alldivs = new Array("latest_news","releases","articles","interviews","more_info")

	for (i=0; i<alldivs.length; ++i) {
	var cur_div = alldivs[i];
	
		if (cur_div == div)
		{
		document.getElementById("A"+cur_div).style.display='block';
		document.getElementById(cur_div + "btn").style.backgroundColor='#c5c5c5';
		document.getElementById(cur_div + "btn").style.borderBottom='1px #c5c5c5 solid';
		}
		else
		{
		document.getElementById("A"+cur_div).style.display='none';
		document.getElementById(cur_div + "btn").style.backgroundColor='#F8F8F8';
		document.getElementById(cur_div + "btn").style.borderBottom='1px black solid';
		}
	} // for
}



function availNotice(resp) {

if (resp.responseText != 'GOOD')
{
scroll(0,0);
alert(resp.responseText);
return false;
}
else
{
submitFormValues('plan_manager')
// $('submissionForm').onsubmit='';
// $('submissionForm').submit();
}
}


function callFailed(resp)
{
  alert("Call failed: " + resp.responseText);

}

function checkPlanFormInput() {
  var edit_current = document.getElementById("edit_current").value;
  var plan_name = document.getElementById("plan_name").value;
  var plan_display_name = document.getElementById("plan_display_name").value;
  var plan_description = document.getElementById("plan_description").value;
  var plan_months = document.getElementById("plan_months").value;
  var plan_days = document.getElementById("plan_days").value;
  var promo_first_day = document.getElementById("promo_first_day").value;
  var promo_last_day = document.getElementById("promo_last_day").value;
  
  if (!plan_name || !plan_display_name)
  {
    alert("Please complete all fields.");
    return false;
  }
/*
	if (un.length < 3 || un.length > 25)
	{
	    alert("Username must be between 3 and 25 characters.");
	    return false;
	}
*/
if (plan_name.match('[^a-zA-Z0-9_-]'))
  {
    alert("Plan name contains illegal characters.");
    return false;
  }

if (!promo_first_day.match('(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])') && promo_first_day != '0000-00-00')  {
    alert("First Day Available must be in 0000-00-00 format.");
    return false;
  }

if (!promo_last_day.match('(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])') && promo_last_day != '0000-00-00')  {
    alert("Last Day Available must be in 0000-00-00 format.");
    return false;
  }

checked = 0;
if (edit_current)
submitFormValues('plan_manager')
else
{
  var pars = "plan_name="+plan_name+"&plan_display_name="+plan_display_name;
  var url = "/checkPlanName.php";
new Ajax.Request(url, {method:'post',parameters:pars,onComplete:availNotice, onFailure:callFailed});
}
}


function popUp(URL,height,width) {

if (!height)
height = 400;

if (!width)
width = 600;

day = new Date();
id = day.getTime();
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
myvote = window.open(URL, id, "width="+width+"px,height="+height+"px,left="+left+",top="+top+",toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1"+ ",screenX=" + left + ",screenY=" + top);
//myvote.resizeTo(400,300);
//myvote.moveTo(100,100);
}


function opSoundDEMO(soundDiv,popvers,action) {
if (document.getElementById("course")) {
var course = document.getElementById("course").innerHTML
var less = document.getElementById("less").innerHTML
var section = document.getElementById("area").innerHTML
}

var sdata = soundDiv.split('_');
var id = sdata[0];

if (document.getElementById("sound_data") == null)
{
var theBody = document.getElementsByTagName('body')[0];
var data = document.createElement("DIV");
data.innerHTML = "<div id=\"sound_data\" style=\"display:none;\"></div>";
document.body.appendChild(data);
}

if (document.getElementById("nowopen") == null)
{
var theBody = document.getElementsByTagName('body')[0];
var data2 = document.createElement("DIV");
data2.innerHTML = "<div id=\"nowopen\" style=\"display:none;\"></div>";
document.body.appendChild(data2);
}

var url = '/soundPopUpDEMO.php';
var params = 'soundDiv=' + soundDiv + '&course=' + course + '&less=' + less + '&section=' + section + '&popvers=' + popvers + '&action=' + action;
var lastsound = document.getElementById("sound_data").innerHTML;

document.getElementById("sound_data").innerHTML = soundDiv;
var thediv = "op" + soundDiv;
var thedivSP = "sp" + soundDiv;
var lastdiv = 'op' + lastsound;
var movediv = 'move' + lastsound;
var lastParentDiv = document.getElementById('sp' + lastsound);
var current = document.getElementById(thediv).innerHTML;

	if (current && !action)
	document.getElementById(thediv).innerHTML = "";
	else
	{
	document.getElementById(thediv).innerHTML = "<img src =/online/pages/images/sound-loader.gif width=43 height=11 border=0>";
		if (lastsound && lastParentDiv)
		{
		lastParentDiv.innerHTML = "<table cellpadding=0 cellspacing=0 border=0 style=position:absolute;z-index:1000; id=\""+movediv+"\"><tr><td id=\""+lastdiv+"\"></td></tr></table>";
		new Draggable(movediv);
		}
	var ajax = new Ajax.Updater(thediv,url,{method: 'post', parameters: params});
	}

} // end of function: opSoundDEMO (openSound)




function opSound(soundDiv,popvers,action) {
if (document.getElementById("course")) {
var course = document.getElementById("course").innerHTML
var less = document.getElementById("less").innerHTML
var section = document.getElementById("area").innerHTML
}

var sdata = soundDiv.split('_');
var id = sdata[0];

if (document.getElementById("sound_data") == null)
{
var theBody = document.getElementsByTagName('body')[0];
var data = document.createElement("DIV");
data.innerHTML = "<div id=\"sound_data\" style=\"display:none;\"></div>";
document.body.appendChild(data);
}

if (document.getElementById("nowopen") == null)
{
var theBody = document.getElementsByTagName('body')[0];
var data2 = document.createElement("DIV");
data2.innerHTML = "<div id=\"nowopen\" style=\"display:none;\"></div>";
document.body.appendChild(data2);
}

var url = '/soundPopUp2.php';
var params = 'soundDiv=' + soundDiv + '&course=' + course + '&less=' + less + '&section=' + section + '&popvers=' + popvers + '&action=' + action;
var lastsound = document.getElementById("sound_data").innerHTML;

document.getElementById("sound_data").innerHTML = soundDiv;
var thediv = "op" + soundDiv;
var thedivSP = "sp" + soundDiv;
var lastdiv = 'op' + lastsound;
var movediv = 'move' + lastsound;
var lastParentDiv = document.getElementById('sp' + lastsound);
var current = document.getElementById(thediv).innerHTML;

	if (current && !action)
	document.getElementById(thediv).innerHTML = "";
	else
	{
	document.getElementById(thediv).innerHTML = "<img src =/online/pages/images/sound-loader.gif width=43 height=11 border=0>";
		if (lastsound && lastParentDiv)
		{
		lastParentDiv.innerHTML = "<table cellpadding=0 cellspacing=0 border=0 style=position:absolute;z-index:1000; id=\""+movediv+"\"><tr><td id=\""+lastdiv+"\"></td></tr></table>";
		new Draggable(movediv);
		}
	var ajax = new Ajax.Updater(thediv,url,{method: 'post', parameters: params});
	}
openSoundEditor(id,thediv);
} // end of function: opSound (openSound)





function openSoundEditor(id,theOPENdiv) {
var pars = "FLD_id="+id+"&theOPENdiv="+theOPENdiv+"&remote_func=quickSoundEditor";
var url = "/AJAXfunctions.php";
new Ajax.Updater('soundedit', url,{evalScripts:true, method:'post',parameters:pars});
}

function newpage() {
theurl = document.getElementById("newpage").value;
if (theurl)
parent.location=theurl;
}


function flipDiv(div1,div2) {
var div1 = document.getElementById(div1);
var div2 = document.getElementById(div2);

	if (div1.style.display == 'block')
	{
	div1.style.display = 'none';
	div2.style.display = 'block'; 
	}
	else
	{
	div1.style.display = 'block';
	div2.style.display = 'none'; 
	}
}


function toggleDiv2(div){
var theDiv = document.getElementById(div);

if (theDiv.style.display != 'block')
theDiv.style.display = 'block';
else
theDiv.style.display = 'none';
}

function versionList(thediv,vers,soundDiv,info) {

if (info == '')
var params = 'theVers=' + vers + "&soundDiv=" + soundDiv + "&thediv=" + thediv;
else
var params = 'theVers=' + vers + "&soundDiv=" + soundDiv + "&info="+info+"&script=changeLessVers" + "&thediv=" + thediv;

var url = '/versionList.php';
var ajax = new Ajax.Updater(thediv,url,{evalScripts:true,method: 'get', parameters: params,onComplete:toggleDiv2(thediv)});
}


function getVersions(versionDiv,currentVers,popvers,changeThisDiv,is_pop) {
var params = 'currentVers=' + currentVers + "&versionDiv=" + versionDiv + "&is_pop=" + is_pop + "&popvers=" + popvers + "&changeThisDiv="+changeThisDiv;

var url = '/getVersions.php';
var ajax = new Ajax.Updater(versionDiv,url,{evalScripts:true,method: 'get', parameters: params,onComplete:toggleDiv2(versionDiv)});
}


function switchVersionXXX(changeThisDiv,vers,popvers) {

switch (vers) {
case 'mix':
var disp_vers = 'Progressive'
break

case 'romaji':
var disp_vers = 'Romaji'
break

case 'hira':
var disp_vers = 'Hiragana Only'
break

case 'hirakata':
var disp_vers = 'Hiragana / Katakana'
break

case 'kanji':
var disp_vers = 'Kanji Plus'
break

}

var rawData = document.getElementById(changeThisDiv + "_raw").value;

var url = '/switchVersion.php';
var params = 'changeThisDiv=' + changeThisDiv + "&vers="+vers + "&popvers="+popvers + "&raw=" + rawData;
var ajax = new Ajax.Updater(changeThisDiv,url,{evalScripts:true,method: 'get', parameters: params});
}

function switchVersion(changeThisDiv,vers,popvers,is_popup) {

switch (vers) {
case 'mix':
var disp_vers = 'Progressive'
break

case 'romaji':
var disp_vers = 'Romaji'
break

case 'hira':
var disp_vers = 'Hiragana Only'
break

case 'hirakata':
var disp_vers = 'Hiragana / Katakana'
break

case 'kanji':
var disp_vers = 'Kanji Plus'
break

}

if (is_popup)
{
opSound(changeThisDiv,vers,'');
}
else
{
var rawData = document.getElementById(changeThisDiv + "_raw").value;

var url = '/switchVersion.php';
var params = 'changeThisDiv=' + changeThisDiv + "&vers="+vers + "&popvers="+popvers + "&raw=" + rawData;
var ajax = new Ajax.Updater(changeThisDiv,url,{evalScripts:true,method: 'get', parameters: params});

}
}



function updateOpen(clicked) {
var current_open = document.getElementById("nowopen").innerHTML;
document.getElementById("nowopen").innerHTML = clicked;
}




function changeHighlightOnly(linkCourse,clicked) {
var loadedLinks = parent.frames["menu-url"].document.getElementById("loadedLinks").innerHTML;

var links = loadedLinks.split(",");

	for (i=0;i<links.length;i++)
	{
	var thelink = links[i];
		if (thelink)
		{
			if (clicked == thelink)
			{
			parent.frames["menu-url"].document.getElementById(thelink).style.background = "url(/online/pages/images/course"+linkCourse+"box_midS.png)";
			}
			else
			parent.frames["menu-url"].document.getElementById(thelink).style.background = "";
		}
	}

} // end of function: changeHighlightOnly


function encodeUrl(s) {
return encodeURIComponent(s).replace(/%20/, '+').replace(/(.{0,3})(%0A)/g,function(m, p1, p2) {return p1+(p1=='%0D'?'':'%0D')+p2;});
};

function reload(frame) {
parent.frames[frame].location.reload(true);
}

function loadWindows(link)
{
// parent.frames["menu-url"].location='/online/pages/staff/YJ5.multiMiniSoundLookup.php';
parent.frames["lesson-url"].location=link;
};

function changeAdminLock(user_id,lock) {
var vers = document.getElementById("vers").innerHTML;
var course = document.getElementById("course").innerHTML;
var less = document.getElementById("less").innerHTML;
var area = document.getElementById("area").innerHTML;

var pars = "theid="+user_id+"&lock="+lock+"&remote_func=changeAdminLock";
var url = "/AJAXfunctions.php";
new Ajax.Updater('lessonMenu',url,{evalScripts:true, method:'post',parameters:pars});
alert ("Turning Admin_Lock to: '" + lock + "' for User Id: " + user_id);
parent.location='/online2/YesJapan5.0.php?course='+course+'&less='+less+'&rinku='+area;

}


function changeMenu(opendiv) {
var notSelColor = "#B9B9B9";
var selColor = parent.frames["menu-url"].document.getElementById("coursecolor").innerHTML;

switch (opendiv) {
case "pics":
parent.frames["menu-url"].document.getElementById("pics").style.display = "block";
parent.frames["menu-url"].document.getElementById("picslink").style.backgroundColor = selColor;

parent.frames["menu-url"].document.getElementById("easysound").style.display = "none";
parent.frames["menu-url"].document.getElementById("easysoundlink").style.backgroundColor = notSelColor;

if (parent.frames["menu-url"].document.getElementById("links"))
{
parent.frames["menu-url"].document.getElementById("links").style.display = "none";
parent.frames["menu-url"].document.getElementById("linkslink").style.backgroundColor = notSelColor;
}
break;

case "easysound":
parent.frames["menu-url"].document.getElementById("pics").style.display = "none";
parent.frames["menu-url"].document.getElementById("picslink").style.backgroundColor = notSelColor;

parent.frames["menu-url"].document.getElementById("easysound").style.display = "block";
parent.frames["menu-url"].document.getElementById("easysoundlink").style.backgroundColor = selColor;

if (parent.frames["menu-url"].document.getElementById("links"))
{
parent.frames["menu-url"].document.getElementById("links").style.display = "none";
parent.frames["menu-url"].document.getElementById("linkslink").style.backgroundColor = notSelColor;
}
break;

case "links":
parent.frames["menu-url"].document.getElementById("pics").style.display = "none";
parent.frames["menu-url"].document.getElementById("picslink").style.backgroundColor = notSelColor;

parent.frames["menu-url"].document.getElementById("easysound").style.display = "none";
parent.frames["menu-url"].document.getElementById("easysoundlink").style.backgroundColor = notSelColor;

parent.frames["menu-url"].document.getElementById("links").style.display = "block";
parent.frames["menu-url"].document.getElementById("linkslink").style.backgroundColor = selColor;
break;
}

}


function closeQuestion(id,type) {
var pars = "id="+id+"&type=" + type + "&remote_func=closeQuestion";
var url = "/AJAXfunctions.php";
setTimeout(parent.location='/pages/dave/',2000);
new Ajax.Updater('closed', url,{method:'post',parameters:pars});
}


function markAsKnownBug(id) {
var pars = "id="+id+ "&remote_func=markAsKnownBug";
var url = "/AJAXfunctions.php";
setTimeout(parent.location='/online/pages/?page=kanako',2000);
new Ajax.Updater('closed', url,{method:'post',parameters:pars});
}


function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
return(h+":"+m+":"+s);
}

function checkTime(i)
{
if (i<10)
  {
  i="0" + i;
  }
return i;
}

function showMessage(message,color) {
	if (parent.frames["menu-url"].document.getElementById("messageArea"))
	{
	var box = parent.frames["menu-url"].document.getElementById("messageArea");
	var text = parent.frames["menu-url"].document.getElementById("messageText");
	text.innerHTML = startTime() +"<br>"+ message;
	box.style.display = 'block';
	box.style.border = '2px';
	box.style.borderColor = color;
	box.style.borderStyle = 'solid';
	}
}


function logOutUser(cookie,returnpage) {
var params = "sid="+cookie+"&remote_func=logOutUser";
var url = '/AJAXfunctions.php';
new Ajax.Request(url,{method:'post',parameters:params});
alert("You have been logged out.");
parent.location = returnpage;
};

function resetFrontPage() {
var params = "remote_func=resetFrontPage";
var url = '/AJAXfunctions.php';
new Ajax.Request(url,{method:'post',parameters:params});
getPage('bbforums');
}

// sound related functions


function makeCall(str,mid)
  {
	thisMovie("flash_player").silenceSounds(str);
	document.getElementById("b"+mid).src = "/ikons/control_play_blue.png";
	document.getElementById("l"+mid).onclick = function() {playTrack(str,mid);};

  }


function makeCall_ORIGINAL(surl,mid)
  {
	document.getElementById("soundPlayerDESU").innerHTML="";
	document.getElementById("b"+mid).src = "/ikons/control_play_blue.png";
	document.getElementById("l"+mid).onclick = function() {playSound_ORIGINAL(surl,mid);};
  }



function makeClearCall(str,mid)
  {
     thisMovie("flash_player").clearAllSounds(str);
  }


function makeAddCall(str)
  {
     thisMovie("flash_player").addSound(str);
  }


function makePlayCall(str)
  {
     thisMovie("flash_player").playSound(str);
  }


function makeIntervalCall(str)
  {
     thisMovie("flash_player").setPauseInterval(str);
  }


function makeArrayCall(arr)
  {
     thisMovie("flash_player").loadSoundArray(arr);
  }


function playSound(str,mid)
{
var current_mid = document.getElementById("current_mid").innerHTML;
var current_str = document.getElementById("current_str").innerHTML;

if (current_mid)
{
document.getElementById("sample"+current_mid).innerHTML = "<a onclick=\"playTrack('"+current_str+"','"+current_mid+"'); return false;\" id=\"l"+current_mid+"\" style=\"cursor:pointer\"><img src=\"/ikons/control_play_blue.png\" border=0 id=b"+current_mid+"></a>";
}

document.getElementById("sample"+mid).innerHTML = "<a onclick=\"makeCall('"+str+"','"+mid+"'); return false;\" id=\"l"+mid+"\" style=\"cursor:pointer\"><img src=\"/ikons/control_play_magenta.png\" border=0 id=b"+mid+"></a>";

document.getElementById("current_mid").innerHTML = mid;
document.getElementById("current_str").innerHTML = str;


// old name = makeLoadCall
if (document.getElementById("flashPlayer") == null)
{
var flashPlayer = document.createElement("DIV");
flashPlayer.innerHTML = "<div id=\"flashPlayer\" style=\"display:inline;\"></div>";
document.body.appendChild(flashPlayer);

document.getElementById("flashPlayer").innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="flash_player" align="middle" height="1" width="1"> <param name="allowScriptAccess" value="always"><param name="startVolume" value="30"><param name="movie" value="/!MP3playSpeaker4JF.swf?startVolume=30"><param name="quality" value="high"><param name="scale" value="exactfit"><param name="wmode" value="transparent"><param name="bgcolor" value="#ffffff"><embed src="/!MP3playSpeaker4JF.swf?startVolume=30" quality="high" scale="exactfit" wmode="transparent" bgcolor="#ffffff" name="flash_player" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" height="1" width="1"> </object>';

}
}


function playSound_ORIGINAL(surl,mid) {

var current_mid = document.getElementById("current_mid").innerHTML;

if (current_mid) {
document.getElementById("sbutton"+current_mid).innerHTML = "<a onclick=\"playSound_ORIGINAL('"+surl+"','"+current_mid+"'); return false;\" id=\"l"+current_mid+"\" style=\"cursor:pointer\"><img src=\"/ikons/control_play_blue.png\" border=0 id=b"+current_mid+"></a>";
}

document.getElementById("current_mid").innerHTML = mid;

document.getElementById("sbutton"+mid).innerHTML = "<a onclick=\"makeCall_ORIGINAL('"+surl+"','"+mid+"'); return false;\" id=\"l"+mid+"\" style=\"cursor:pointer\"><img src=\"/ikons/control_play_magenta.png\" border=0 id=b"+mid+"></a>";


if (document.getElementById("soundPlayerDESU") == null)
{
var player = document.createElement("DIV");
player.innerHTML = "<div id=\"soundPlayerDESU\" style=\"display:block;\" style=height:75px;width:200px;color:gray;>HERE IS THE PLAYER</div>";
document.body.appendChild(player);
}

document.getElementById("soundPlayerDESU").innerHTML="<embed src='"+surl+"' hidden=true autostart=true loop=false>";

}

function makeSimpleLoadCall(str)
  {
     thisMovie("flash_player").loadSimpleSound(str);
  }


function makeLoadXMLCall(str)
  {
     thisMovie("flash_player").loadSoundXML(str);
  }


function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}


function nt(id,course,vers,box_length,easyword,kanri,random,u_id,action,course,vers) {
if(id) {
var url = '/soundPopUp2.php';
var params = 'id=' + id + '&u=' + u_id + '&action=' + action + '&course=' + course + '&vers=' + vers+ '&random=' + random + '&easyword=' + easyword + '&box_length=' + box_length;

var thediv = 'op' + random;

var ajax = new Ajax.Updater(thediv,url,{evalScripts:true,method: 'post', parameters: params});
}
} // end: nt




function apply_add_ajax_search() {

		// Find the search box in the DOM
		var theElement = document.getElementById('sound_search');
		
		// Create a function for when the user presses a key
		theElement.onkeyup = function(){ search_delay_sounds(this); };
}


function search_delay_pictures(element) {

	// Create a function to get the search results
	var func = function() { getPictures(0); };

	// Check to see if there is already a timeout and if so...
	// ...cancel it and create a new one
	if ( element.zid ) {
		clearTimeout(element.zid);
	}
	element.zid = setTimeout(func,500);

}


function getPictures(start) {
var search = document.getElementById("search").value;
search = search.replace("%","P_ERCENT");

var url = '/AJAXfunctions.php';
var params = 'search=' + search + "&start=" + start + "&remote_func=searchPictures";
var thediv = "pictures";
document.getElementById(thediv).style.display="block";
var ajax = new Ajax.Updater(thediv,url,{method: 'post', parameters: params});
}


function searchSite(element) {
	// Create a function to get the search results
	var func = function() { getResults(0); };

	// Check to see if there is already a timeout and if so...
	// ...cancel it and create a new one
	if ( element.zid ) {
		clearTimeout(element.zid);
	}
	element.zid = setTimeout(func,500);

}


function getResults(start) {
var search = document.getElementById("search").value;
search = ued_encode(search);

var url = '/AJAXfunctions.php';
var params = 'search=' + search + "&start=" + start + "&remote_func=searchSite";
var thediv = "results";
document.getElementById(thediv).style.display="block";
var ajax = new Ajax.Updater(thediv,url,{method: 'post', parameters: params});
}

function lessonHelpMenu(var4,div) {

if (document.getElementById(div).style.display == "block")
document.getElementById(div).style.display = "none";
else
{
var params = 'var4=' + var4 + "&div=" + div;
var thediv = div;

var url = '/lessonHelpMenu.php';
var ajax = new Ajax.Updater(thediv,url,{evalScripts:true,method: 'get', parameters: params});

document.getElementById(div).style.display = "block";
}
}




function refreshPage(course,less,rinku) {
parent.document.location = "/online2/YesJapan5.0.php?course="+course+"&less="+less+"&rinku="+rinku;
}


function copy(thediv) {
inElement = document.getElementById(thediv);
  if (inElement.createTextRange) {
    var range = inElement.createTextRange();
    if (range && BodyLoaded==1)
      range.execCommand('Copy');
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="/online/pages/staff/_clipboard.swf" FlashVars="clipboard='+inElement.innerHTML+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}



function changeButton(id,btn1,btn2) {
var current = document.getElementById(id).src;
if (current == btn1)
document.getElementById(id).src = btn2;
else
document.getElementById(id).src = btn1;
}


function closeDiv(div) {
document.getElementById(div).style.display = "none";
}


function openCloseDiv(div) {
if (document.getElementById(div).style.display == 'none')
document.getElementById(div).style.display = "block";
else
document.getElementById(div).style.display = "none";
}


function submitFormValues(page,looking) {

if (typeof looking == "undefined")
looking = "";

var str = '';
var elem = document.getElementById('submissionForm').elements;
for(var i = 0; i < elem.length; i++)
{
if (elem[i].type == 'radio' || elem[i].type == 'checkbox')
	{
	if (elem[i].checked)
	str += elem[i].name +"YJSP"+elem[i].value+"YJCM";
	}
	else
	{
	str += elem[i].name +"YJSP"+elem[i].value+"YJCM";
	}
}

str = ued_encode(str);
var pars = "vars1=form&vars2="+str+"&page="+page+"&looking="+looking;

var url = "/getPage.php";

document.getElementById("pagecontent").innerHTML = "<br><br><br><img src =/images/progress_bar.gif width=190 height=14 border=0><br>processing now...";
new Ajax.Updater('pagecontent', url,{evalScripts:true, method:'post',parameters:pars});
}


function embedVideo(clip,close)
{
var div = "clip"+clip;
var url = "/embedYouTube.php?clip="+clip+"&close="+close;
new Ajax.Updater(div, url,{evalScripts:true});
}

function popup(url, width, height)
{
	window.open(url.replace(/&amp;/g, '&'), '_popup', 'HEIGHT=' + height + ',resizable=yes,scrollbars=yes, WIDTH=' + width);
	return false;
}


function textCounter(countthis,cntfield,maxlimit) {
var display = document.getElementById(cntfield);
var field = document.getElementById(countthis);

if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
display.innerHTML = maxlimit - field.value.length;
}



function recordMediaVote(media_id,user_id) {
var sushis = document.getElementById('sushis').value;
var comments = document.getElementById('comments').value;
if (!sushis)
alert ("You must choose a rank.");
else
{
// alert (media_id + " ----> " + user_id + " ----> " + sushis + " ----> " + comments);
var pars = "page=recordvote&var1="+media_id+"&var2="+sushis+"&var3="+comments+"&var4="+user_id;
var url = "/recordMediaVote.php";
new Ajax.Updater('voteform', url,{evalScripts:true, method:'get',parameters:pars});
}

}

function changePage(page,page_num) {
var junban = document.getElementById('junban').value;
var showtype =  document.getElementById('showtype').value;
var pars = "page="+page+"&var1="+junban+"&var2="+page_num+"&var3="+showtype;

var url = "/getPage.php";
document.getElementById("pagecontent").innerHTML = "<br><br><br><img src =/images/progress_bar.gif width=190 height=14 border=0><br>loading page...";
new Ajax.Updater('pagecontent', url,{evalScripts:true, method:'post',parameters:pars});
}

function checkRadios(junban) {
if (junban)
var toSelect = "CHK"+junban;
else
var toSelect = "CHKnewest";

document.getElementById(toSelect).checked = "true";
}

function displayProgressBar(div) {
var progress="<img src=/images/progress_bar.gif border=0><br>Updating files and database records...";
document.getElementById(div).innerHTML = progress;
}


function editProfile(picker_id) {
// picker_id	picker_name	picker_profile	picker_avatar
var div = "profile" + picker_id;
var pars = "picker_id=" + picker_id + "&remote_func=editProfile";
var url = "/AJAXfunctions.php";
new Ajax.Updater(div, url,{evalScripts:true, method:'post',parameters:pars});
}



function editProfileUpdate(picker_id) {
displayProgressBar('profilesave');
var div = "profile" + picker_id;
var picker_name = ued_encode(document.getElementById("picker_name" + picker_id).value);
var picker_profile = ued_encode(document.getElementById("picker_profile" + picker_id).value);

var pars = "picker_id=" + picker_id + "&picker_profile=" + picker_profile + "&picker_name=" + picker_name + "&remote_func=editProfileUpdate";
var url = "/AJAXfunctions.php";
new Ajax.Updater(div, url,{evalScripts:true, method:'post',parameters:pars});
} // end of function: editProfileUpdate


function editProfileAdd(picker_id) {
displayProgressBar('profilesave');
var div = "profile" + picker_id;
var picker_name = ued_encode(document.getElementById("picker_name" + picker_id).value);
var picker_profile = ued_encode(document.getElementById("picker_profile" + picker_id).value);

var pars = "picker_id=" + picker_id + "&picker_profile=" + picker_profile + "&picker_name=" + picker_name + "&remote_func=editProfileAdd";
var url = "/AJAXfunctions.php";
new Ajax.Updater(div, url,{evalScripts:true, method:'post',parameters:pars});
} // end of function: editProfileAdd


function editProfileCancel(picker_id) {
var pars = "picker_id="+picker_id+"&remote_func=editProfileCancel";
var url = "/AJAXfunctions.php";
var div = "profile" + picker_id;
new Ajax.Updater(div, url,{evalScripts:true, method:'post',parameters:pars});
} // end of function: editProfileCancel


function removeAlbum(media_id) {
var div = "album" + media_id;
var pars = "media_id=" + media_id + "&remote_func=removeAlbum";
var url = "/AJAXfunctions.php";

var albumButton = document.getElementById("albumButton" + media_id);
albumButton.src = '/images/btn-add-album-purpledark.png';
albumButton.onclick=function(){addAlbum(media_id);};

new Ajax.Updater(div, url,{evalScripts:true, method:'post',parameters:pars});
}


function completeAlbum(media_id) {
var div = "album" + media_id;
var pars = "media_id=" + media_id + "&no_update=1&refresh_cart=1&remote_func=addAlbum";
var url = "/AJAXfunctions.php";
new Ajax.Updater(div, url,{evalScripts:true, method:'post',parameters:pars});
}



function addAlbum(media_id) {
var div = "album" + media_id;
var pars = "media_id=" + media_id + "&remote_func=addAlbum";
var url = "/AJAXfunctions.php";

var albumButton = document.getElementById("albumButton" + media_id);
albumButton.src = '/images/btn-remove-album-purpledark.png';
albumButton.onclick=function(){removeAlbum(media_id);};

new Ajax.Updater(div, url,{evalScripts:true, method:'post',parameters:pars});
}




function getPage(page,var1,var2,var3,var4,user_id,theuser,debug,looking) {
// alert(user_id);
var pars = "page="+page+"&var1="+var1+"&var2="+var2+"&var3="+var3+"&var4="+var4+"&theuser="+theuser+"&user_id="+user_id+"&debug="+debug+"&looking="+looking;
var url = "/getPage.php";
document.getElementById("pagecontent").innerHTML = "<br><br><br><img src =/images/progress_bar.gif width=190 height=14 border=0><br>loading page...";
new Ajax.Updater('pagecontent', url,{evalScripts:true, method:'post',parameters:pars});
}



function updateCart(response,media_id) {

}; // end of function: updateCart




function addCart(media_id,is_album,action) {
// alert (media_id + " ----> " + id + " ----> " + action);
// alert('addCart: ' +media_id+ '('+action+')');
var button = document.getElementById("trackButton"+media_id);

if (button.src == '/images/cart-remove-purpledark.png')
button.src = '/images/cart-add-purpledark.png';
else
button.src = '/images/cart-remove-purpledark.png';

if (!media_id)
{
alert('ERROR: Media Id is missing.');
}


var pars = "media_id="+media_id+"&is_album="+is_album+"&action="+action;
var url = "/add-remove-track.php";
new Ajax.Updater('blankdiv',url, {evalScripts:true,method:'post',parameters:pars,onComplete:function(response){processButton(response)}});


}; // end of function: addCart



function processButton(response) {

var results = response.responseText.split(':');

var status = results[0];
var media_id = results[1];

// alert(status + ' ' + media_id);

switch(status) {
case "no_media_id":
alert('Please use the \'Remove Album\' button.');
return false;
break;

case "login_required":
sendLoginPopup(media_id,media_id,'','');
return false;
break;

case "is_album":
alert('Please use the \'Remove Album\' button.');
return false;
break;

case "added":
var button = document.getElementById("trackButton"+media_id);
var incart = document.getElementById("mycart").innerHTML;
button.src = '/images/cart-remove-purpledark.png';
document.getElementById("mycart").innerHTML = parseInt(incart) + 1;
return false;
break;

case "deleted":
var button = document.getElementById("trackButton"+media_id);
var incart = document.getElementById("mycart").innerHTML;
button.src = '/images/cart-add-purpledark.png';
document.getElementById("mycart").innerHTML = parseInt(incart) - 1;
return false;
break;
}

}; // end of function: processButton



function updateMediaCart(u_id,id,media_id,action,is_album) {
// alert (media_id + " ----> " + id + " ----> " + action);
var button = document.getElementById("trackButton"+media_id);

if (!u_id || !media_id)
{
alert('ERROR: User Id or Media Id is missing.');
}

if (action == 'REMOVE'){
button.src = '/images/cart-add-purpledark.png';
button.onclick=function(){updateMediaCart(u_id,id,media_id,'ADD',is_album);};
}
else
{
button.src = '/images/cart-remove-purpledark.png';
button.onclick=function(){updateMediaCart(u_id,id,media_id,'REMOVE',is_album);};
}

var pars = "media_id="+media_id+"&action="+action+"&user_id="+u_id+"&is_album="+is_album+"&id="+id;

if (no_update != 1)
updateCartNumbers(u_id,action);

var url = "/updateMediaCart.php";
new Ajax.Updater(id,url,{evalScripts:true, method:'post',parameters:pars});
}




function updateMediaCartQuick(u_id,id,media_id,action,is_album) {
//alert (media_id + " ----> " + id + " ----> " + action);

if (!u_id || !media_id)
{
alert('ERROR: User Id or Media Id is missing.');
}

var pars = "media_id="+media_id+"&action="+action+"&user_id="+u_id+"&is_album="+is_album+"&id="+id;

var url = "/updateMediaCart.php";

new Ajax.Updater(id,url,{evalScripts:true, method:'post',parameters:pars});

}







function updateCartNumbers(u_id,action) {
var incart = document.getElementById("mycart").innerHTML;
if (action == 'REMOVE')
document.getElementById("mycart").innerHTML = parseInt(incart) - 1;

if (action == 'ADD')
document.getElementById("mycart").innerHTML = parseInt(incart) + 1;

}

function updateUserCredits(u_id) {
var pars = "u_id="+u_id+"&remote_func=updateUserCredits";
var url = "/AJAXfunctions.php";
new Ajax.Updater('usercredits', url,{method:'post',parameters:pars});
};



function downloadTrack(mid,record_id) {
if (record_id > 0)
{
var thediv = ""+record_id;
var button = "dlbutton"+record_id;
}
else
{
var thediv = ""+mid;
var button = "dlbutton"+mid;
}

// document.getElementById(thediv).innerHTML = '<img src=/images/preparing.gif height=21>';

document.getElementById(button).src = '/images/preparing.gif';

var dothis = "parent.processframe"+mid+".location = '/download.php?mid="+mid+"&ext=mp3'";
eval(dothis);

checkpars = "mid="+mid+"&record_id="+record_id;

downloadLoop();

};


function updateCartButtons(page,user_id) {
var d=new Date().getTime();
var diff = d - starttime;

if (page != 'mymusic') {
var pars = "user_id="+user_id;
new Ajax.Request('/media_id_in_cart.php', {evalScripts:true,method:'post',parameters:pars,onComplete:function (resp) {
var tracks = resp.responseText.split(',');
//alert(tracks);
for(var i=0;i<tracks.length; i++) {
var button = document.getElementById("trackButton"+tracks[i]);
if (button != null)
button.src = '/images/cart-remove-purpledark.png';
}

}})
}
var tm=new Date(diff);
var hours=tm.getUTCHours();
var minutes=tm.getUTCMinutes();
var seconds=tm.getUTCSeconds(); 

var rendertime = minutes +":"+seconds;

if (document.getElementById("rendertime") != null)
document.getElementById("rendertime").innerHTML = rendertime;


}; // end of function: updateCartButtons


function downloadAlbum(mid,record_id) {
if (record_id > 0)
{
var thediv = ""+record_id;
var button = "dlbutton"+record_id;
}
else
{
var thediv = ""+mid;
var button = "dlbutton"+mid;
}


// document.getElementById(thediv).innerHTML = '<img src=/images/preparing.gif height=21>';
document.getElementById(button).src = '/images/preparing.gif';



var pars = "mid="+mid+"&ext=zip";
var url = "/downloadAlbum.php";


var dothis = "parent.processframe"+mid+".location = '/downloadAlbum.php?mid="+mid+"&ext=zip'";
eval(dothis);

checkpars = "mid="+mid+"&record_id="+record_id;

downloadLoop();
};


function downloadLoop() {
setInterval("new Ajax.Request('/downloadStatus.php', {method:'post',parameters:checkpars,onComplete:function (resp) {checkDownloadStatus(resp)}})",'30000')
}

function checkDownloadStatus(resp) {
var results = resp.responseText.split(':');

	if (results[0] == '1')
	{
	document.getElementById(results[1]).src = '/images/cart-complete.png';
	}
	else
	{
	document.getElementById(results[1]).src = '/images/preparing.gif';
	downloadLoop(checkpars,thediv);
	}
}




function downloadSingles() {
document.getElementById("singles").src = '/images/preparing.gif';
parent.processframe.location = "/downloadSingles.php?ext=zip";

};

function displayURL(url) {
new Ajax.Updater('pagecontent', url);
}

function calcHeight()
{
  //find the height of the internal page
  var the_height=document.getElementById('mainframe').contentWindow.document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('mainframe').height=the_height+100;
}

//ued_encode() will take an array as its argument and return the data encoded in UED format - as a string.
//http://www.openjs.com/scripts/data/ued_url_encoded_data/
function ued_encode(arr,current_index) {
	var query = ""
	if(typeof current_index=='undefined') current_index = '';

	if(typeof(arr) == 'object') {
		var params = new Array();
		for(key in arr) {
			var data = arr[key];
			var key_value = key;
			if(current_index) {
				key_value = current_index+"["+key+"]"
			}

			if(typeof(data) == 'object') {
				if(data.length) { //List
					for(var i=0;i<data.length; i++) {
						params.push(key_value+"[]="+ued_encode(data[i],key_value)); //:RECURSION:
					}
				} else { //Associative array
					params.push(ued_encode(data,key_value)); //:RECURSION:
				}
			} else { //String or Number
				params.push(key_value+"="+encodeURIComponent(data));
			}
		}
		query = params.join("&");
	} else {
		query = encodeURIComponent(arr);
	}

	return query;
}

var qstart = 0;
var sqstart = 0;
var cstart = 0;

function moreQuestions(updown,reset) {

if (reset == 1)
qstart = 0;
else
{
if (updown == 'down')
qstart = qstart - 10;
else
qstart = qstart + 10;
}

var div = 'questions';

var pars = "start="+qstart+"&ajax=1&remote_func=askTeacherQuestions";
var url = "/AJAXfunctions.php";

new Ajax.Updater(div, url,{method:'post',parameters:pars,onComplete: reloadMoreQuestions(qstart)});
}




