/***********************************************

************************************************

* LanguageCurrent version 1.00 Oct 1, 2011

************************************************

***********************************************/



//define global variables.

//operation to server
var opGlb=0;
//languge I am learning
var mylanguageGlb="";

//language I knowS
var LanguageGlb="";

//use cliboard short cut.
var useShortCutGlb= new Boolean(false);


//use onpaste shortcut
var useOnPasteGlb= new Boolean(false);

//?????
var indicator= new Boolean(false);

//userID
var UserIDGlb="";

//master language table 
//var dictionaryGlb="";

//word to save
var myWordGlb="";

//translation to save
var myTranslationGlb="";

//for drill division on and off
var myDivisionOnGlb="";

var myArrayOnGlb="";

//for edit divisio on and off

var myEditDivOnGlb="";

//for identifying edit displays
var edDisId=""

var worKpage=new Boolean(false);
//status indicator
//var myStatusGlb="";

//valid numbers array for save all
var valid= new Array();
var majorGlb = new Array();
var minorGlb  = new Array();
var assocGlb = new Array();

//Drill division arrays for turning on and off
var classDiv = new Array('classifications','classInstruct','word','opt1','opt2','opt3','hint');
var assocDiv = new Array('association','assocInstruct','assocWord','assoc1','assoc2','assoc3');



//$(function() {

	//	for(var x=0;x<11;x=x+1)
	//	{
	//	$("#word"+x).draggable();}		
//	});


    function initialize() {
     // var v = {type:'vertical'};
     // google.language.getBranding('googleL');
    }
    
    function onLoad()
    {
      
      for(var x=1;x<11;x=x+1)
		{
		//$("wordL"+x).draggable();}
		//$("#wordL"+x).draggable();}
	var name='wordL'+x
	//alert(name);
	var div=document.getElementById(name);
	//alert(div.id);    
	div.draggable();
	//document.getElementById(name).draggable();
		}
    }
	
    
  //icon presentation function.
 
function changecursor (source, type)
{
	if(type=='h')
	{
//document.getElementById("savefav").style.cursor="help";
source.style.cursor="help";
//$("#"+source).css("cursor","help");
//alert("got here");
	}
	else if(type=='m')
	{
//document.getElementById("savefav").style.cursor="help";
source.style.cursor="move";
//$("#"+source).css("cursor","move");
//alert("got here");
	}
		else if(type=='p')
	{
//document.getElementById("savefav").style.cursor="help";
//$("#"+source).css("cursor","pointer");
source.style.cursor="pointer";
//alert("got here");
	}
	else if(type=='w')
	{
//document.getElementById("savefav").style.cursor="help";
//$("#"+source).css("cursor","wait");
source.style.cursor="wait";
//alert("got here");
	}
	else if(type=='pr')
	{
//document.getElementById("savefav").style.cursor="help";
//$("#"+source).css("cursor","progress");
source.style.cursor="progress";
//alert("got here");
	}
	
	
	
	
		
}


function delayremovemesssage()
{
	

	var t=setTimeout("javascript:proceed();", 1000);	
//alert('executed');
	
}

function thenext()
{
	//hidemsg();
	//return;
}


function ChagneGlobalOption(sourceElem)
{
var theSource=document.getElementById(sourceElem);
//alert( "the global setting is " + ' ' + useShortCutGlb);

//alert("let see what is theSource  " + theSource.checked);

if(sourceElem=="shorCutbx")
{
	var theSource=document.getElementById('shorCutbx').checked;
	//alert("the soruce " + theSource);
	//var theSource=document.check.shorCutbx;
	if(theSource==true)
	{
		useShortCutGlb=true;
		//alert("changed it to Y")
	document.getElementById('Pastebx').checked=false;
	}

	else if(theSource==false)
	{
	useShortCutGlb=false;
	}
	
//alert( "the global setting is now " + ' ' + useShortCutGlb);
//75
}
else if(sourceElem=="Pastebx")
{
var theSource=document.getElementById('Pastebx').checked;
if(theSource==true)
	{
		useOnPasteGlb=true;
		useShortCutGlb=false
		document.getElementById('shorCutbx').checked=false;
	//	alert("changed global paste it to Y")
	}

	else if(theSource==false)
	{
	useOnPasteGlb=false;
	}
}
else 
{
alert("Undefined Error.  Please report to Admin");

}
}



//getting the text to translate from the cliboard I.E only
function getTextFromCliboard(sourceDisplay, targetDisplay)
{
	//alert(useShortCutGlb + " for short cut");
	//myStatusGlb=Status;
	  //get user permission or browser functionality.
	
	if (useShortCutGlb==true)
	{	
		
		//check to see if there is text in the textarea
		
		
		if(document.getElementById(sourceDisplay).value.length < 1 )
		{
			//if not pasted in
			var theText = window.clipboardData.getData('Text');
			 document.getElementById(sourceDisplay).value= theText;
			sendToGoogle(sourceDisplay, targetDisplay);
		}
		//do not paste
		else {
			
			}

	}
}



function kbrdicon(box)
{
		//alert("getting it");
	if(firstclick==false)
	{
	//load the keyboard
//	alert("loading it");
		document.getElementById("kbdFrame").src='keybrdfrm.php';
		document.getElementById("keybrd").style.visibility = 'visible';
		firstclick=true;
		
		
	}
		
	//if(box.checked==true)
	if(showing==false)
	{
		document.getElementById("keybrd").style.visibility = 'visible';
		//document.getElementById("kbframe").src="keybrdfrm.php";
		showing=true;
		
	}
	else
	{
		document.getElementById("keybrd").style.visibility = 'hidden';
		showing=false;
	}
	
}



function urlChanged(listname)
{
//load new website

//var element = $('elementID');

//alert(" this is the list2 " + listname);
var newSite=document.getElementById(listname);
//var newSite=$(listname);
var newSite_index = newSite.selectedIndex;
var text = newSite.options[newSite_index].value;
//alert("this is the selection value " + text);

text=fixurl(text);

}

function fixurl(url)
{
var urlText = url;
//alert("in " + urlText);
var prefix="http://";
//alert( prefix + "  out the same " + urlText);
var ind=urlText.indexOf(prefix);
//alert(" the ind = " + ind);
if (ind>-1)
{
//alert("out the same " + urlText);
return urlText;

}	
else
{
urlText=prefix+urlText;
//alert("out changed " + urlText);
return urlText;
}


newSite=document.getElementById('browseFrame').src=text;


//alert("this is new site " + text);
//alert(" this is the value " + value);


}
    
//add new url to favorites list
function addFavUrl()
{

var y=document.getElementById('urlList').length;
var urlCode=document.getElementById('urlname').value; 
var urldescText =document.getElementById('urldescText').value;


var newUrlOption=new Option(urldescText, urlCode); 
document.getElementById('urlList').options[y] = newUrlOption; 

document.getElementById('urlname').value="";
document.getElementById('urldescText').value="";

}


//when user changes the language selections.
/*
function langChanged(listID)
{

var list = listID.id;



if(list=="langFrom")

{  

var TfromLang="";
TfromLang = listID.value;
//alert("this is value " + list.options[list.selectedIndex].value + " text " + list.options[list.selectedIndex].text);

alert("language from changed to   " + TfromLang );

}



 if (list=="langTo" )
{  

//alert("got into to languge " +  toLanguageGlb + ' ' + list.options[list.selectedIndex].text);


Ttolanguage = listID.value;

alert("Language to changed to 278   " +Ttolanguage  );


}

//51

}
*/
//the navigation of the website
function navigate(pageRequest)
{

var newPage=$(pageRequest);
var newPage_index = newPage.selectedIndex;
var text = newPage.options[newPage_index].text;
//alert("this is the selection value " + text );

//alert("need to implement  248");
}


function logout()
{
	//alert("need to implement 254");
}

/*
function loadFile()
{

var text=document.getElementById('fileInput').value;
//alert("got the file " + text);

document.getElementById('browseFrame').src ="file:///" + text;



}
*/

function loadUrl()
{
var text=document.getElementById('urlname').value;
//alert("loading  " + text);
text=fixurl(text);
//alert("getting the url " + text );

document.getElementById('browseFrame').src =text;

}

//Add URL move start



/*

//check to make sure that no null or duplicate name was not sent
function checkDublicate(source, fieldName)
{
	
	if(source=='favSave')
{
	
//alert(" the ,aom soruce " + source);
var urlText =document.getElementById('urldesc').value;
//alert(" the urlText" + urlText);
if (urlText.length<1)
{
	alert("Please enter short description");
	return;
}

else
{
	//alert ("why are we here");
}
}
else 
	if(source=='readSave')
{
	var urlText =document.getElementById('urldescText').value;
if (urlText.length<1)
{   alert("Please enter short description")
	return;
}
}


var urlCode=document.getElementById(fieldName).value; 

if(urlCode=="http://"||urlCode=="")
{  alert("Please enter a the webpage address in the field above.")
	return;
}
	
var y=document.getElementById('urlList').length;
var sendOn=false;
var list = document.getElementById('urlList');

for(var x=0; x<y; x=x+1)
{
	var listValue=list.options[x].text;
//	alert("the list options " + listValue + " x " + x + " text " + urlText);
	if(urlText==listValue)
	{alert("This description already exists in the list. Can not save!")
		sendOn=false;
		break;
	}
	else{
		sendOn=true;
	}
}
if(sendOn==true)
{
	//alert("sending to server ");
sendToServer(source)
}
}

*/

function sendToServer(fromMe) 
  {

  //alert("got here send to 271 server" + fromMe );
var theSource=fromMe;
//alert("here is the source " + theSource);
//save word
	
if(theSource=='Save')                                                        
{
	
	//alert("should not  be using this sendToServer");
/*
//alert("got here SAVE");
var docName='saveWordToServer.php';
opGlb=1;
//mysqli->insert_id Returns the auto generated id used in the last query

	
	
	//the list of parameters that are passed in the post.
		var param="";
		param="theword=" + myWordGlb;
		param= param + "&translation=" + myTranslationGlb;
		param = param + "&languagefrom=" + TfromLang;
		param = param + "&languageto=" + Ttolanguage;
		//param = param + "&table=" + tablename;
	
	}
	
*/
//if we are saving a favorite
// moved starts here
/*
else if(theSource=='favSave')
{
//alert("got here save fav");
var urlCode=document.getElementById('urlname').value; 
var urldesc =document.getElementById('urldesc').value;
var  docName='saveUrlToServer.php';
opGlb=2;

	//the list of parameters that are passed in the post.
		var param="";
		param="url=" + urlCode;
		param= param + "&desc=" + urldesc; 
		
		
	//alert("this is param  " + param);
}
*/
//if we are saving stories
}
else if (theSource=='readSave')
{
var storyText=" ";
//alert("got here   " );

var urlStory=document.getElementById('urlname').value; 
var urlStorydesc =document.getElementById('urldescText').value;
var notesText=document.getElementById("textAndWords").value;


var docName='Savestorytoserver.php';
//alert(" the length " + notesText.length);
 if (notesText.length>1)
 {storyText=notesText;}
opGlb=3;
	var param="";
		param="url=" + urlStory;
		param= param + "&desc=" + urlStorydesc; //change utldesc
		param = param + "&userid=" + UserIDGlb;
		param = param + "&docname=" + docName;
		param = param + "&storytext=" + storyText;
	//}

}


else if(theSource=='saveButtonMajor')
	{
	//	alert("in getClassify");
  var docName='saveClasstoServer.php';
  var table='classify_main';
 var newClass=document.getElementById('newMajor').value
  // alert(d);
  
 // alert("this is the text " + newClass);
  opGlb=7;
  var param="";
  param = param + "&userid=" + UserIDGlb;
  param = param + "&table=" + table;
  param = param + "&language=" + TfromLang;
  param = param + "&newclass=" + newClass;

	}
	
	
else if(theSource=='saveButtonMinor')
	{
	//	alert("in getClassify");
  var docName='saveClasstoServer.php';
  var table='classify_secon';
 var newClass=document.getElementById('newMinor').value
  // alert(d);
  
//  alert("this is the text " + newClass);
  opGlb=7;
  var param="";
  param = param + "&userid=" + UserIDGlb;
  param = param + "&table=" + table;
  param = param + "&language=" + TfromLang;
  param = param + "&newclass=" + newClass;

	}  
	
	
		
	
	
else{
	//alert("what IAM DOING HERE  445");
	return;

    }

  // alert(" this is docName and param " + docName + " " + param + " option global" + opGlb );
	postToServer(docName, param);
	
  }

function postToServer(docName, param)
{
 //  alert("sending to server" + param + " docName " + docName);
//send post to the server using Prototyp scripts
                                     
 var url = docName;
	 $.ajax({
  type: 'POST',
  url: url,
  data: param,
  success: showResult,
   error: showError,
  dataType: 'text'
   });


	}

		

function showError() {
//	alert(" something wrong");
//var textResponse=ServerResponse.responseText;
//alert(" the resop  "  +  textResponse);

}



function showResult(ServerResponse)
{	
	
	var textResponse=ServerResponse;
//alert(" got something back "  +  textResponse);
//document.getElementById('results').innerHTML=textResponse;



if( textResponse.indexOf("Saved")>-1 || textResponse.indexOf("Duplicate")>-1 )
{
	
	
if(opGlb==1)
{
	//alert(" in opglb 1 " );
	if(worKpage==true)
	{
		//alert(" got here");
		savehere();
		
	}
	
	else
	{
		addToMylearning();
	}
 }
 
else if(opGlb==2)
{
//addFavUrl();
//alert("we are in moving forwad");

}


else if(opGlb==3)
{
addStory();


}

else if(opGlb==5)
{
//alert("processing saveall response");
	var y=0;
	for(var x=0;x<valid.length; x=x+1)
	{
		
		y=valid[x];
		myWordGlb=document.getElementById('T'+y).value;
		myTranslationGlb=document.getElementById('Res'+y).value;
		//alert("saving " + myWordGlb + " " + myTranslationGlb);
		addToMylearning();
		
	}
}


else
{
showmsg("Saved.");	
}




}

else if(textResponse.indexOf("exists")>-1)
{
	showmsg("Word already exists.");
}
}

function addStory()
{

//alert("were are here");
var y= document.getElementById('readList').length;
var urlStoryCode=document.getElementById('urlname').value; 
var urlStorydesc =document.getElementById('urldescText').value;


var newUrlOption=new Option(urlStorydesc, urlStoryCode); 
document.getElementById('readList').options[y] = newUrlOption; 

document.getElementById('urlname').value="";
document.getElementById('urldescText').value="";
}


function addToMylearning()
	{
//	var myStatus=Status;
	//{ alert("onepassed");
		
 var textExist = document.getElementById("textAndWords").value;
		 
 if ( textExist.length>=1 )
	{
	  textExist = textExist + ';' + myWordGlb + ','+ myTranslationGlb ;
	 }
	 else
		 
	 {
	 textExist = myWordGlb + ',' + myTranslationGlb ;
		  
	 }
	 
	
		document.getElementById("textAndWords").value = textExist;
		//	alert("got 176 " + myStatusGlb +  ' ' + myWordGlb +  ' ' + myTranslationGlb );				//	document.getElementById(myStatusGlb).innerHTML=myWordGlb + '( ' + myTranslationGlb + ' ) was saved.';
		//document.getElementById(myStatusGlb).innerHTML="Saved!";
		 }








  function clearTxtndTran(textArea1, translationArea1)
{
	document.getElementById(textArea1).value = "";
	document.getElementById(translationArea1).value = "";
	//document.getElementById(labelid).innerHTML = "Status:";
}
	

           



function clearTxtArea()
{

var answer = confirm("All notes and words will be deleted!. To save Cancel, then click on Save Reading");
if (answer)
{

	document.getElementById("textAndWords").value = "";
}
	
}


function two(one, two)
{
	//alert("in two"	);
	//three(one, two);
	
	
}


/*

//send request for translation to google
function sendToGoogle(sourceDisplay, targetDisplay) 
{      
//alert("were sent here" +targetDisplay );
//document.getElementById(myStatusGlb).innerHTML="Status: Translating!";
//var primaryLang="en";
//var learLang="fa";
//showmsg("Translating","run");
var text = document.getElementById(sourceDisplay).value;  
//alert(" translating from " + TfromLang);
 //  alert(document.getElementById(sourceDisplay).value);
 	//alert('translating ' + text + ' ' + ' from ' + TfromLang + ' TO ' + Ttolanguage);
        google.language.translate(text, TfromLang, Ttolanguage,   
	function(result)
{     var translated = document.getElementById("TranslationDiv");        
if (result.translation) 
{ 

//nomsg();
//got translation display it
//where to display it
//alert(document.getElementById(targetDisplay) + " " + "the result" + result.translation);
document.getElementById(targetDisplay).value= result.translation;   
//document.getElementById(myStatusGlb).innerHTML="Translated!";

        
}

})
}


function reverseToGoogle(targetDisplay, sourceDisplay)
{
	//alert("reversing " + targetDisplay + "  "+  sourceDisplay);
	
	var text = document.getElementById(sourceDisplay).value;  
	//alert("got here " + text);
	   google.language.translate(text, Ttolanguage, TfromLang,  
	function(result)
{     var translated = document.getElementById("TranslationDiv");        
if (result.translation) 
{ 

//nomsg();
//got translation display it
document.getElementById(targetDisplay).value= result.translation;   
//document.getElementById(myStatusGlb).innerHTML="Translated!";

        
}

})
	
	
	
	
	
	
}

*/
function SaveNew(textArea1, translationArea1)
{	

//alert(" got here 801");
//set up global variables theword, the translation and the status label to update.		
    
	myWordGlb = document.getElementById(textArea1).value;
	myTranslationGlb = document.getElementById(translationArea1).value;
	
	//alert("got 807 " + ' ' + myWordGlb +  ' ' + myTranslationGlb ); 
//make sure there is sometext there

	
 	if (myWordGlb.length >=1 && myTranslationGlb.length >= 1 )  
	
	
	//need to check for carriage return in the text.
	{

		//save it on the server first
		//document.getElementById(myStatusGlb).innerHTML="Saving";
		sendToServer('Save');
	}
	
	else
 {
	 alert("Word or translation is missing. Cant save");
	//document.getElementByID(myStatusGlb).innerHTML="Error in Submission";
 }
	
	
	}
	
	
	//favorites urls from the tobpar
	
function urlChanged(listname)
{
	//alert(listname);
//load new website
//var newSite=document.getElementById(listname);
//alert(newSite);
//var newSite_index = newSite.selectedIndex;
//alert(newSite_index);
var text = listname.options[listname.selectedIndex].value;
//var text = newSite.options[newSite_index].value;
//alert(" new site info " + text);
text=fixurl(text);
//alert(" new site info " + text);
//newSite=document.getElementById('browseFrame').src=text;
document.getElementById('browseFrame').src=text;

//alert("this is new site " + text);

}

function getTextonPaste(sourceDisplay, targetDisplay)
{
	//alert(useOnPasteGlb + " for short cut");
	//myStatusGlb=Status;
	  //get user permission or browser functionality.
	
	if (useOnPasteGlb==true)
	{	
		var theText = window.clipboardData.getData('Text');
	    document.getElementById(sourceDisplay).value=theText;
	  sendToGoogle(sourceDisplay, targetDisplay);
		}
	
		
		
		else {
			
			}

	
}


function clearAll()
{
	//alert("got here temp ");
	
for(var x=1; x<19; x=x+1)
{
	//var y='T'+x;
	//var z='Res'+x;
//	alert("this is " + y);
	document.getElementById('T'+x).value="";
	 document.getElementById('Res'+x).value="";
}	
}

                   
function drillNav(drill)
{
	
	var Diframe=document.getElementById('drillframe');
		if(drill=='1')
		{
	var urlToFetch = './drillListfilter.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
		}
		else if(drill=='2')
	{
		var urlToFetch = './drillAssocFilter.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
	
	else if(drill=='3')
	{
		var urlToFetch = './drilltransfilter.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
	
	
	else if(drill=='4')
	{
		var urlToFetch = './drillimagefilter.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
	
	
	else if(drill=='6')
	{
		var urlToFetch = './drillsentencefilter.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
	
	else if(drill=='7')
	{
		var urlToFetch = './drillpinyfilter.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
		
	else if(drill=='8')
	{
		var urlToFetch = './drillcombinedfilter.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}	
	
}

 
//layout50 end


//layout 40 begins


  //edit menu selctions                                  
  
  
  function editNav(editMenu)
  {
	  //showing the edit menue.
	  //this should be put in a seperate script 
// alert("got into show  " + editMenu);
	var theMenu=editMenu;
	var thisframe=document.getElementById('editframe');
//	 alert("got into show  " + editMenu + "  " + thisframe);
	
	
	if(theMenu=='20')
{
	 
	var urlToFetch = './empty.php?randNum='+ new Date().getTime();
	thisframe.src= urlToFetch;
	
}
	
	if(theMenu=='1')
{
	 
	var urlToFetch = './majorClassEdit.php?randNum='+ new Date().getTime();
	thisframe.src= urlToFetch;
	
}


	if(theMenu=='2')
	{
	
	var urlToFetch = './minorClassEdit.php?randNum='+ new Date().getTime();
	//alert(" url " + urlToFetch);
	thisframe.src= urlToFetch;
	

}
	if(theMenu=='3')
		{
	 
	var urlToFetch = './listEdit.php?randNum='+ new Date().getTime();
	thisframe.src= urlToFetch;
		}

	if(theMenu=='4')
	
	{
	var urlToFetch = './associationsEdit.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
		
	}

	if(theMenu=='5')
	{
		var urlToFetch = './wordsNoListEdit.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}
	
	if(theMenu=='6')
	{
		//alert("got list wordlist frame");
		var urlToFetch = './filterWordList.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}
	if(theMenu=='7')
	{
			var urlToFetch = './associateWords.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}
	
	if(theMenu=='8')
	{
			var urlToFetch = './filterAssoc.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}
	
	if(theMenu=='9')
	{
			var urlToFetch = './filterwordinfo.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}
	
	if(theMenu=='10')
	{
			var urlToFetch = './filterImages.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}
		
if(theMenu=='11')
	{
			var urlToFetch = './filterSentence.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}

if(theMenu=='12')
	{
			var urlToFetch = './filterAudio.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}

	
if(theMenu=='14')
	{
			var urlToFetch = './editWebsites.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}


if(theMenu=='15')
	{
			var urlToFetch = './addWord.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}	
  
  
if(theMenu=='16')
	{
			var urlToFetch = './addSentence.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}


if(theMenu=='17')
	{
			var urlToFetch = './editmyReadings.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}

	
	
if(theMenu=='18')
	{
			var urlToFetch = './editmyMultim.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}
	
	
	
if(theMenu=='19')
	{
			var urlToFetch = './categoryedit.php?randNum=' + new Date().getTime();
	thisframe.src=urlToFetch;
	}

  }
  
  
  
  function classNav(myclass)
{
	
	var Diframe=document.getElementById('classframe');
		if(myclass=='1')
		{
	var urlToFetch = './enrollinclass.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
		}
		else if(myclass=='2')
	{
		var urlToFetch = './viewclass.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
	
	else if(myclass=='3')
	{
		var urlToFetch = './viewquizzes.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
	else if(myclass=='4')
	{
		var urlToFetch = './mySchedule.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
	else if(myclass=='4')
	{
		var urlToFetch = './viewpeformance.php?randNum=' + new Date().getTime();
	Diframe.src=urlToFetch;
	}
}
  
  

  
  
//refresh iframe after words assignment to class 
//called from buildframeEdit4
  function wordsAssigned()
  {
	//aler("got here");
	  var urlToFetch = './languagecurrent/buildIframeEdit4.php?randNum=' + new Date().getTime();
	ifrme.src=urlToFetch;

  }
  
 

function updateToServer()
{
	//document.getElementById(frameID).contentWindow.document
	var lframe=document.getElementById('disframe');
	var ltable=lframe.contentWindow.getElementById('resTable');
	//alert(" got table "  + ltable.id);

if (edDisId=='1')
{	var y=0;
	var send = new Boolean(false);
	var table='classify_main';
	var param="";
	param = param + "&userid=" + UserIDGlb;
	param = param + "&table=" + table;
	param = param + "&language=" + TfromLang;
	var docName='updateClasstoServer.php';
	//alert(" major update button");
	for(var x=0; x<majorGlb.length; x=x+1)
	{
		//alert("alert major " +  document.getElementById('inputmajor'+ x).value);
		if(majorGlb[x]==document.getElementById('inputmajor'+ x).value)
		{
			//alert(" they " + majorGlb[x] + " same " + document.getElementById('inputmajor'+ x).value);
		}

	else {
		send=true;
		
		  var update=majorGlb[x];
		   var updateTo=document.getElementById('inputmajor' + x).value;
		  //if it is empty give it a code to be deleted
		  if(updateTo=="")
			  { updateTo="D010001";}
		  param = param + "&update" + y + "=" + update;
		  param = param + "&updateTo" + y + "=" + updateTo;
		  y=y+1;
		  send==true;
		}
			
	
		
				
		}
		
		if(send==true)
		{
			param= param + "&updtates=" + y;
			//alert("sending to server " + param);
			postToServer(docName, param);
	}
	
}

if (buttonId=='updButtonMinor')
{	//document.getElementById(frameID).contentWindow.document
	var lframe=document.getgElementById('disframe');
	var ltable=iframe.contentWindow.document.getElementById('resTable');
	//alert(" got table "  + ltable.id);
	
	var y=0;
	var send = new Boolean(false);
	var table='classify_secon';
	var param="";
	param = param + "&userid=" + UserIDGlb;
	param = param + "&table=" + table;
	param = param + "&language=" + TfromLang;
	var docName='updateClasstoServer.php';
	//alert(" major update button");
	for(var x=0; x<minorGlb.length; x=x+1)
	{
		//alert("alert major " +  document.getElementById('inputmajor'+ x).value);
		if(minorGlb[x]==document.getElementById('inputminor'+ x).value)
		{
			//alert(" they " + majorGlb[x] + " same " + document.getElementById('inputmajor'+ x).value);
		}

	else {
		send=true;
		
		  var update=minorGlb[x];
		   var updateTo=document.getElementById('inputminor' + x).value;
		  //if it is empty give it a code to be deleted
		  if(updateTo=="")
			  { updateTo="D010001";}
		  param = param + "&update" + y + "=" + update;
		  param = param + "&updateTo" + y + "=" + updateTo;
		  y=y+1;
		  send==true;
		}
			
	
		
				
		}
		
		if(send==true)
		{
			param= param + "&updtates=" + y;
			//alert("sending to server " + param);
			postToServer(docName, param);
	}
	
}

}

  

//http://localhost/languagecurrent/buildIframeEdit.php

//layout 40 ends

