
//----------------------------------------------------------------------
//-- Useful Page Functions
//----------------------------------------------------------------------

function JS_Utils_GetParent ( objElement )
{
	 if ( objElement.parentElement ) { return objElement.parentElement };
	 if ( objElement.parentNode ) { return objElement.parentNode };
	 if ( objElement.parent ) { return objElement.parent };
	 return;
}

function JS_Utils_ShowHide ( objElement, bShow )
{
	if ( objElement )
	{
		if ( bShow == null )
		{
			if ( objElement.style.display == "none" ) objElement.style.display = "block";
			else objElement.style.display = "none";
		}
		else
		{
			if ( bShow ) 	objElement.style.display = "block";
			else objElement.style.display = "none";
		}
	}
}

//----------------------------------------------------------------------
//-- String Functions
//----------------------------------------------------------------------

function JS_Utils_Trim(s)
{
	return s.replace(/^\s+|\s+$/g,"");
}

function JS_Utils_LeftTrim(s)
{
	return s.replace(/^\s+/,"");
}

function JS_Utils_RightTrim(s)
{
	return s.replace(/\s+$/,"");
}

//----------------------------------------------------------------------
//-- Open Window
//----------------------------------------------------------------------

function JS_Utils_OpenWindow ( mypage, myname, w, h, scroll )
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',noresize'
	win = window.open(mypage, myname, winprops);
}

//----------------------------------------------------------------------
//-- Font size and cookie
//----------------------------------------------------------------------

function JS_Utils_ChangeFontSize ( nSize )
{
	switch ( nSize )
	{
		case 1 :
			document.body.style.fontSize = "70%";
			break;
			
		case 2 :
			document.body.style.fontSize = "80%";
			break;
			
		case 3 :
			document.body.style.fontSize = "90%";
			break;
			
		default :
			document.body.style.fontSize = "70%";
			break;
	}
	
	JS_Cookie_Create ( "IntrainingFontSize", nSize, 30 );
}

function JS_Utils_LoadFontSize ()
{
	nSize = Number ( JS_Cookie_Read ( "IntrainingFontSize" ) );
	JS_Utils_ChangeFontSize ( nSize );
}

//----------------------------------------------------------------------
//----------------------------------------------------------------------



