var n_course;
var n_module;
var n_lesson;
var n_slide;
var swf_str = "";

var is_maximized = false;

function fixpoz(){
leftmarg=0;
topmarg=0;
if (document.body.clientWidth>800) {
leftmarg=Math.floor((document.body.clientWidth-800)/2)
}
if (document.body.clientHeight>570) {
topmarg=Math.floor((document.body.clientHeight-570)/2)
}
mainframediv.style.top=topmarg + 'px';
mainframediv.style.left=leftmarg + 'px';

//menudiv.style.right= '-200px';
}

var contentleft;
var content_timeout1;
var content_timeout2;

function showContent()
      	{ 		
   				contentleft=0;   				
   				slideContent();
   				//arrowImage.src="../common/menu_close.gif";
   				arrowImage.src=menu_close_dyn;
   				arrowImage.onclick=hideContent;
      	}
      	
 function slideContent()
      	{
      		clearTimeout(content_timeout2);
			mx_pos = parseInt(menudiv.style.right);
			ix_pos = parseInt(imagediv.style.right);
			mx_pos += 20;
			ix_pos += 20;
      		menudiv.style.right = mx_pos + 'px';
      		imagediv.style.right = ix_pos + 'px';
   			if ((mx_pos + 20 ) <= contentleft ) content_timeout1=setTimeout("slideContent()",15)
      	}
      	      	      		
function hideContent()
      {
      	contentleft=0;     	
      	//arrowImage.src="../common/menu_open.gif";
      	arrowImage.src=menu_open_dyn;
		    arrowImage.onclick=showContent;
		    unslideContent();		    
      }      
      
function unslideContent()
      {
      	clearTimeout(content_timeout1);
		mx_pos = parseInt(menudiv.style.right);
		ix_pos = parseInt(imagediv.style.right);
		mx_pos -= 20;
		ix_pos -= 20;
      	menudiv.style.right = mx_pos + 'px';
      	imagediv.style.right = ix_pos + 'px';
   		if ((mx_pos - 20 ) >= (contentleft-200) ) content_timeout2=setTimeout("unslideContent()",15)   			
      }
  
function toggle(id){
	ul = "ul" + id;
	im = "im" + id;
  ulElement = document.getElementById(ul);
  imgElement= document.getElementById(im);
    if (ulElement){
            if (ulElement.className == 'closed'){
                    ulElement.className = "open";
                    imgElement.className = "minus";
                    }else{
                    ulElement.className = "closed";
                    imgElement.className = "plus";
                    }
            }
    } 
    
function callMovie(module,lesson){
	mn_frm = window.document["mainframe"];
	mn_frm.SetVariable("n_module",module-1);	
	mn_frm.SetVariable("n_lesson",lesson);
	mn_frm.TCallFrame("_level0",1);
}

function open_comments(n_c,n_m,n_l,n_s){
	GetInformation('comments.html',500 , 350, 'UserComments', 'UserComments','no');
	n_course=n_c;
	n_module=n_m;
	n_lesson=n_l;
	n_slide=n_s;
}

function close_course()
{
	window.close()
}

function GetInformation( url, width, height, windowname, title, resizable)
{
	var options;
	if(!title)
	{
		title = windowname;
		windowname = 'KKU';
	}
	l = width/2, t = height/2;
	if(width == '*')
	{
		if (window.screen) 
		{
   			width = Math.floor(screen.availWidth-((screen.availWidth/100)*20));
   			height = Math.floor(screen.availHeight-((screen.availHeight/100)*20));
   			l = Math.floor((screen.availWidth-width)/2);
   			t = 30;
		}
	}
	else
	{
		if (window.screen) 
		{
			l = Math.floor((screen.availWidth-width)/2);
			t = Math.floor((screen.availHeight-height)/2);	
		}
	}
	options = 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable='+ resizable + ',menubar=no,width=' + width + ',height=' + height + ',top=' + t + ',left=' +l;
	win = window.open(url, windowname, options );
	win.focus()    
}

function go_http(url, wname)
{
	var ww = Math.floor(screen.availWidth) - 20;
	var wh = Math.floor(screen.availHeight)- 100;
	var options = 'toolbar=no,location=yes,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=yes,width=' + ww + ',height=' + wh + ',top= 0, left= 5';
	window.open(url, wname, options)
}


function open_gloss(str)
{
	lnk=gloss_lnk + '?' + str;
	GetInformation(lnk , 500, 350, 'Glossary', 'Glossary', "no" );
}

function open_swf(swf_file)
{
	swf_str = swf_file;
	var ww = Math.floor(screen.availWidth) - 20;
	var wh = Math.floor(screen.availHeight)- 100;
	var options = 'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=yes,width=' + ww + ',height=' + wh + ',top= 0, left= 5';
	window.open("swf_pop.html", "swf_lnk", options)
}

function open_swf2(swf_file,width, height, resizable)
{
	swf_str = swf_file;
	var ww = width;
	var wh = height;
	var options = 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=' + resizable + ',menubar=no,width=' + ww + ',height=' + wh + ',top= 0, left= 5';
	window.open("swf_pop.html", "swf_lnk", options)
}

function restore_size()
{
	window.resizeTo( 850,600 );
	window.moveTo(200,200);
	is_maximized = false;
}

function max_window()
{
	if (!is_maximized) { setTimeout("maximum_size()",200); }
	else { setTimeout("restore_size()",200); }
}

function maximum_size()
{
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
	is_maximized = true;
}

function html_pop( url, width, height, windowname, title, resizable)
{
	var options;
	if(!title)
	{
		title = windowname;
		windowname = 'KKU';
	}
	l = width/2, t = height/2;
	if(width == '*')
	{
		if (window.screen) 
		{
   			width = Math.floor(screen.availWidth-((screen.availWidth/100)*20));
   			height = Math.floor(screen.availHeight-((screen.availHeight/100)*20));
   			l = Math.floor((screen.availWidth-width)/2);
   			t = 30;
		}
	}
	else
	{
		if (window.screen) 
		{
			l = Math.floor((screen.availWidth-width)/2);
			t = Math.floor((screen.availHeight-height)/2);	
		}
	}
	options = 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable='+ resizable + ',menubar=no,width=' + width + ',height=' + height + ',top=' + t + ',left=' +l;
	win = window.open(url, windowname, options );
	win.focus()    
}