var changeLocationURL = '';

function submitWithTheValue(formID, fieldID, fieldval) {
    document.getElementById(fieldID).value=fieldval;
    document.getElementById(formID).submit();
}

function update_location(teachLocation, teachID) {
	try {
        	requestNumber = JSONRequest_safe.post(
            		changeLocationURL, 
            		{
				'location': teachLocation,
                		'teacherID': teachID
            		},
            		// Function is called when an answer arrives. 
            		function(requestNumber, result, errors) {
                	// Write the answer.
                        //alert(result.location);
            		}
        	);
	} catch(e) {
		alert(e);
	} 
    }

function goToURL() {
    var i, args=goToURL.arguments; document.returnValue = false;
    for (i=0; i<(args.length-1); i+=2) eval(args[i]+'.location="'+args[i+1]+'"');
}

function open_wind(url, win_name , fullscreeen ){
    _width=screen.width * .9;
    _height=screen.height * .9;
	
	if(fullscreeen){
		 _width=screen.width;
		_height=screen.height;
	}
	//alert("_width"+_width+" _height"+_height);
    param='scrollbars=yes,resizable=yes, left=0, top=0, width='+_width+',height='+_height ;
    //url='{% url results-quiz-analysis-whiteboard %}';
    win=window.open( url,win_name,param);
    win.focus();
}

function open_win_how_to(){
    _width=820;
    _height=620;
    param='scrollbars=yes,resizable=yes, left=110, top=110, width='+_width+',height='+_height ;
    url='http://www.yacapaca.com/upload/training/1C_4.swf';
    win=window.open( url,'How to',param);
    win.focus();
}

// for scrolled pagges
function scrollFunction(par){
 if( document.getElementById('top_area')){
  if(par!="vert"){
     document.getElementById('top_area').scrollLeft=document.getElementById('footer-div').scrollLeft;
     document.getElementById('scr_table').scrollLeft=document.getElementById('footer-div').scrollLeft;
    }else{
	     document.getElementById('left-scroll').scrollTop=document.getElementById('right-scroll').scrollTop;
         document.getElementById('scr_table').scrollTop=document.getElementById('right-scroll').scrollTop;
	  }
 }
}

function gradeScrollFunction(par){
 if( document.getElementById('top_area')){
	 //alert(document.getElementById('right-scroll').scrollTop+"  | "+document.getElementById('scr_table').scrollTop);
  if(par!="vert"){
	   document.getElementById('left-scroll').scrollTop=document.getElementById('right-scroll').scrollTop;
        document.getElementById('scr_table').scrollTop=document.getElementById('right-scroll').scrollTop;
         document.getElementById('top_area').scrollLeft=document.getElementById('scr_table').scrollLeft;

	 
     
    }else{
	     document.getElementById('left-scroll').scrollTop=document.getElementById('right-scroll').scrollTop;
         document.getElementById('scr_table').scrollTop=document.getElementById('right-scroll').scrollTop;
	  }
 }
}





var old;

function setScrollableHeight(flag){
 if( document.getElementById('top_area')){

  var hght=  Math.round(document.body.offsetHeight  );


  var  winH = hght;
	if (document.body && document.body.offsetHeight) {
	 //winW = document.body.offsetWidth;
	 winH = Math.round(document.body.offsetHeight);
	 //alert("1 "+ winH  );
	}
	if (document.compatMode=='CSS1Compat' &&
		document.documentElement &&
		document.documentElement.offsetHeight ) {
	// winW = document.documentElement.offsetWidth;
	 winH = Math.round(document.documentElement.offsetHeight );
	  //alert("2 "+ winH);
	}
	if(document.documentElement.clientHeight){
	 winH =Math.round( document.documentElement.clientHeight);
	 //alert("3 "+ winH);
	}
	if (window.innerHeight) {
	 //winW = window.innerWidth;
	 winH = Math.round(window.innerHeight);
	  //alert("4 " + winH);
	}
//alert("hght="+hght +"  winH="+ winH);

  hght=winH-450;
  if(hght<120) hght=120;



   document.getElementById('left-scroll').style.maxHeight=hght+"px";
   document.getElementById('scr_table').style.maxHeight=hght+"px";
   document.getElementById('right-scroll').style.maxHeight=hght+"px";
   
  	var useragent = navigator.userAgent.toLowerCase();
	var tt_ie = useragent.indexOf("msie") != -1 && document.all ;
   
   if(tt_ie){
      var p = document.getElementById('right-scroll');
	  if(!flag) old = p.offsetHeight;
	// alert("p.offsetHeight:"+ p.offsetHeight+ " | hght:" +hght +"old:"+old);
       if(old>hght ){   
         document.getElementById('left-scroll').style.height=hght+"px";
         document.getElementById('scr_table').style.height=hght+"px";
         document.getElementById('right-scroll').style.height=hght+"px";
	 }else{
	     document.getElementById('left-scroll').style.height=old+"px";
         document.getElementById('scr_table').style.height=old+"px";
         document.getElementById('right-scroll').style.height=old+"px";
	 }
   }

   }
}
