function CloseAlert()
{
    javascript:opacity('alert', 100, 0, 175);
    setTimeout("HideContent('alert');",175);
}
function CloseAlert2()
{
    javascript:opacity('alert2', 100, 0, 175);
    setTimeout("HideContent('alert2');",175);
}
function CloseAlert3()
{
    javascript:opacity('alert3', 100, 0, 175);
    setTimeout("HideContent('alert3');",175);
}
function CloseAlert4()
{
    javascript:opacity('alert4', 100, 0, 175);
    setTimeout("HideContent('alert4');",175);
}
function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}
function toggle(elementid) {
	var theItem = $(elementid);

	if( theItem.style.display == "none")	{
		new Effect.BlindDown(theItem, {duration: 0.5});
	}else{
		new Effect.BlindUp(theItem, {duration: 0.5});
	}
}

function hideLoader(loader, target) {
	new Effect.Fade($(loader), {duration: 0.5});
	new Effect.BlindDown($(target));
}

var g_USER_AGENT = getAgent();
// return NN4, NN5(Netscape 6+, Mozilla 1+?), IE4, IE5(IE5+), Unknown
function getAgent(){
  	var userAgent = navigator.userAgent;
  	var charIndex;
  	var majorVersion;
		
  	charIndex = userAgent.indexOf("MSIE");
  	if(charIndex){
		majorVersion = userAgent.charAt(charIndex + 4 + 1);
		if(majorVersion > 4){
		  return("IE5");
		}
		else if(majorVersion == 4){
		  return("IE4");
		}
		}
		
		charIndex = userAgent.indexOf("Mozilla");
		majorVersion = userAgent.charAt(charIndex + 7 + 1);
		if(majorVersion > 4){
		return("NN5");
		}
		else if(majorVersion == 4){
		return("NN4");
		}
		
		return("Unknown");
		}

function getWindowYOffset(){
  	if(g_USER_AGENT == "IE5" || g_USER_AGENT == "IE4"){
		return document.body.scrollTop;
		}else if(g_USER_AGENT == "NN5" || g_USER_AGENT == "NN4"){
		return window.pageYOffset;
		}else{
		return 0;
		}
		}
		
		var waitTimer;
		function jumpTo(dstY, srcY, scrollRate, waitMillSec) {
		if(waitTimer){
		clearTimeout(waitTimer);
		}
		if( ! dstY || dstY < 0 ){
		dstY = 0;
		}
		if( ! srcY ){
		srcY = 0 + getWindowYOffset();
		}
		if( ! scrollRate ){
		scrollRate = 6;
		}
		if( ! waitMillSec ){
		waitMillSec = 20;
		}
		
		srcY += (dstY - getWindowYOffset()) / scrollRate;
		if(srcY < 0){
		srcY = 0;
		}
		posY = Math.floor(srcY);
		window.scrollTo(0, posY);
		
		if(posY != dstY){
		waitTimer = setTimeout("jumpTo("+ dstY +", "+ srcY +", "+ scrollRate +", "+ waitMillSec +")", waitMillSec);
		}
		else if(posY == dstY){
		clearTimeout(waitTimer);
		}
		else if(posY < 1){
		window.scroll(0, 0);
		}
		}
		
function backUp(){
	  jumpTo(0, 0, 7, 14);
		}
function hidediv(divId){
var arr = document.getElementById(divId)
if ( arr!= null ) {
arr.style.display = (arr.style.display == 'none')? 'block':'none';
}
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 