var WindowDefaultWidth = 800;

var ShowExitMsg = false;

function confirmExit()
{
	if (ShowExitMsg)
	{
		ShowExitMsg = false;
		return "You will need to login again.";
	}
	
	ShowExitMsg = false;
}

// Show a popup box with width and height defined
function ShowPopup(url, popupName, w, h) {
	var settingString = 'width=' + w + ', height=' + h +', location=no, menubar=no, scrollbars=yes';
	newwindow=window.open(url, popupName, settingString);
	if (window.focus) {newwindow.focus()}
	return false;
}

// Displays the div_name popup div in a location
function show_popup_withPos(div_name, button_name)
{
	var position = findPos(document.getElementById(button_name));
	show_div(div_name);
	set_div_xy(div_name,position[0],position[1]);
}

// Displays the div_name popup div in the center of the window
function show_popup(div_name)
{
	show_div(div_name);
}

// Hides the div popup
// This function should be called instead of hide_div directly because in IE
// Dropdown Lists show through divs and have to be hidden before displaying the div
// then unhidden when the box is closed
function hide_popup(div_name)
{
	hide_div(div_name);
}

// The show_div just make the div visible, it does not
// affect the layout at all.
function show_div(div_name)
{
	if(document.getElementById)
	{
		document.getElementById(div_name).style.display = "block";
	}
	else if(document.layers)
	{
		document.layers[div_name].display = "block";
	}
	else if(document.all)
	{
		document.all[div_name].style.display = "block";
	}
}

// The hide_div just makes the div invisible, it does not
// affect the layout at all.
function hide_div(div_name)
{
	if(document.getElementById)
	{
		document.getElementById(div_name).style.display = "none";
	}
	else if(document.layers)
	{
		document.layers[div_name].display = "none";
	}
	else if(document.all)
	{
		document.all[div_name].style.display = "none";
	}
}


function set_div_xy(div_name, newx, newy)
{
	if(document.getElementById)
	{

			document.getElementById(div_name).style.left = newx + "px";
			document.getElementById(div_name).style.top = newy + "px";

	}
	else if(document.layers)
	{
		document.layers[div_name].left = newx;
		document.layers[div_name].top = newy;
	}
	else if(document.all)
	{
		document.all[div_name].style.pixelLeft = newx;
		document.all[div_name].style.pixelTop = newy;
	}
}


function findPos(obj) 
{
	var iPosX = 0;
	var iPosY = 0; 
	
	var iOffsetWidth = 0;
	var iCurrentWindowWidth = document.documentElement.clientWidth;
	
	if (iCurrentWindowWidth > WindowDefaultWidth)
	{
		iOffsetWidth = (iCurrentWindowWidth - WindowDefaultWidth) / 2;
	}
	
	if (obj.offsetParent) 
	{ 
		iPosX = obj.offsetLeft; 
		iPosY = obj.offsetTop; 
		
		while (obj = obj.offsetParent) 
		{ 
			iPosX += obj.offsetLeft; 
			iPosY += obj.offsetTop; 
		} 
	}

	return [iPosX-iOffsetWidth+10,iPosY-38];
}


// Sets the display of the div
// Valid values for this are
//
//    - none      ( Prevent the display of the element                                  )
//
//    - block     ( Sets the element with a line break before and after                 )
//
//    - inline    ( Removes the line breaks from an element and                         )
//                ( forces it into a the flow of another element                         )
//
//    - list-item ( Sets the element as a line in a list                                )
//
//    - compact   ( Sets the display to compact,                                        )
//                ( running the element into the margin of the next element if possible )
//
//    - run-in    ( Sets the display to run in, making the element an inline element    )
//                ( at the beginning of the following block element                     )
//
//    - marker    ( Sets the display of an element to be a marker.                      )
//                ( For example, a bullet in a list                                     )
//
// This has been tested to work in IE6, Opera 7.23, Netscape 4.79 and Mozilla 1.6 
// This should work in IE4+, Mozilla, Netscape 6+ and possibly other versions of Opera
function div_display(div_name, display_type)
{
	if(document.getElementById)
	{
		document.getElementById(div_name).style.display = display_type;
	}
	else if(document.all)
	{
		document.all[div_name].style.display = display_type;
	}
}

function showBecomingATeacherLangPacks(div_name)
{
	HiddenAllBecomingATeacherLangPacks();

	document.getElementById(div_name).style.display = "block";
}

function CloseAllBecomingATeacherLangPacks()
{
	HiddenAllBecomingATeacherLangPacks();

	document.getElementById("divMainContents").style.display = "block";
}

function HiddenAllBecomingATeacherLangPacks()
{
	document.getElementById("divMainContents").style.display = "none";

	document.getElementById("divAfrikaans").style.display = "none";
	document.getElementById("divBulgarian").style.display = "none";
	document.getElementById("divFarsi").style.display = "none";
	document.getElementById("divFrench").style.display = "none";
	document.getElementById("divGerman").style.display = "none";
	document.getElementById("divHindi").style.display = "none";
	document.getElementById("divJapanese").style.display = "none";
	document.getElementById("divPunjabi").style.display = "none";
	document.getElementById("divRomanian").style.display = "none";
	document.getElementById("divRussian").style.display = "none";
	document.getElementById("divSimplifiedChinese").style.display = "none";
	document.getElementById("divSpanish").style.display = "none";
	document.getElementById("divTagalog").style.display = "none";
	document.getElementById("divTraditionalChinese").style.display = "none";
	document.getElementById("divUrdu").style.display = "none";
}

