document.write("<script type='text/javascript' src='http://www.languagecourse.net/ext_widget/flensed/flXHR.js'></scr"+"ipt>");

function init_award(id_school, year){
	var xmlhttp=new flensed.flXHR();
	var ts=new Date().getTime();
	
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			document.getElementById('widget_award_languagecourse_'+year).innerHTML=xmlhttp.responseText;
		}
	};
	
	xmlhttp.open("GET", "http://www.languagecourse.net/ext_widget/award.php?id_school="+id_school+"&year="+year+"&anticache="+ts, true);
	xmlhttp.send(null);	
}

function findPosition(obj){
	var ret=new Array(2);
	ret[0]=0;
	ret[1]=0;
	if (obj.offsetParent) {
		do {
			ret[0] += obj.offsetLeft;
			ret[1] += obj.offsetTop;
		} while (obj = obj.offsetParent);
		return ret;
	}
}

function openAwardDetails(year){
	var details_div=document.getElementById('award_details_wrapper_'+year);
	var widget_div=document.getElementById('award_wrapper_'+year);
	var ret=findPosition(widget_div);
	var x=ret[0];
	var y=ret[1];
	var correcting_value=document.getElementById('correcting_height').value;
	win_x=document.body.clientWidth;
	y=y-correcting_value;
	if ((win_x-x-widget_div.offsetWidth) > 675){		// we put 675 instead of details_div.offsetWidth because so far this 
		widget_div.style.backgroundImage='url(http://www.languagecourse.net/images/award_widget_big_box.png)';
		details_div.style.backgroundImage='url(http://www.languagecourse.net/images/award_widget_big_box.png)';
		details_div.style.backgroundPosition='-12px';	
		
		x=x+widget_div.offsetWidth;	
	}
	else{
		x=x-685;	
		
		widget_div.style.backgroundImage='url(http://www.languagecourse.net/images/award_widget_big_box.png)';
		details_div.style.backgroundImage='url(http://www.languagecourse.net/images/award_widget_big_box.png)';
		widget_div.style.backgroundPosition='-589px';
	}
	details_div.style.display='block';
	details_div.style.top=y+"px";
	details_div.style.left=x+"px";
}

function closeAwardDetails(year){
	var details_div=document.getElementById('award_details_wrapper_'+year);
	var widget_div=document.getElementById('award_wrapper_'+year);
	widget_div.style.backgroundImage='url(http://www.languagecourse.net/images/award_widget_small_box.png)';
	widget_div.style.backgroundPosition='0px';
	details_div.style.display='none';
}