var win = null;
var PageRedirect = true;
var onerror = handleError;
    
function disableBtn(btnID, newText) {

    var btn = document.getElementById(btnID);
    btn.disabled = true;
    btn.value = newText;
}

function handleError(msg,url,l)
{
        txt="There was an error on this page.\n\n";
        txt+="Error: " + msg + "\n";
        txt+="URL: " + url + "\n";
        txt+="Line: " + l + "\n\n";
        txt+="Click OK to continue.\n\n";
        //alert(txt);
        return true;
}    



function openWindow(url, title)
{
      try
      {
          var oWnd = window.parent.$find("RadWindowManager1").GetWindowByName("Popup");
           oWnd.SetUrl(url);
           oWnd.SetTitle(title);
           oWnd.Show();
        }
        catch(Error)
        {
        }
}

function clickButton(e, buttonid){ 
	var bt = document.getElementById(buttonid); 
	if (typeof bt == 'object'){ 
		if(navigator.appName.indexOf("Netscape")>(-1)){ 
			if (e.keyCode == 13){ 
				bt.click(); 
				return false; 
			} 
		} 
		if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
			if (event.keyCode == 13){ 
				bt.click(); 
				return false; 
			} 
		} 
	} 
} 

function bookmark(url,title)
{  
      if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) 
      {
        window.external.AddFavorite(url,title);
      } 
      else if (navigator.appName == "Netscape") 
      {
        window.sidebar.addPanel(title,url,"");
      } 
      else 
      {
        alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
      }
}

function CreateBookmarkLink(url) 
{ 
    title = document.title;
    if (window.sidebar) 
    { 
        // Mozilla Firefox Bookmark		
        window.sidebar.addPanel(title, url,"");	
    } 
    else if ( window.external ) 
    { 
        // IE Favorite		
        window.external.AddFavorite( url, title); 
    }	
    else if (window.opera && window.print) 
    { 
        // Opera Hotlist		
        return true; 
    } 
}

function NewWindow(mypage,myname,w,h,scroll,resize){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize
	if(win&&!win.closed)win.close()
	win = window.open(mypage,myname,settings)
	if(win.window.focus){win.window.focus();}
}

function CheckRedirect() 
{
	PageRedirect = false;
	return true;
}

function PopupAlertBox(sMessage)
{
	if (PageRedirect) {
		return sMessage;
	}
} 

function Hilite(name,over)
{
  if(window.document.images) 
  {
    if (over)
      window.document.images[name].src = "css/" + name + "_over.gif";
    else
      window.document.images[name].src = "css/" + name + ".gif";
  }
}

function trim(s)
{
	var l=0; var r=s.length -1;
	while(l < s.length && s[l] == ' ')
	{	l++; }
	while(r > l && s[r] == ' ')
	{	r-=1;	}
	return s.substring(l, r+1);
}

function switchText(object, baseText, eventName)
{
	if (eventName == "blur")
	{
		if (object.value == "")
		{
			object.value = baseText;
		}
	}
	else
	{
		if (trim(object.value) == trim(baseText))
		{
			object.value = '';
		}
	}
}

function toggle(a, b, oElement) {
try
{
	if (!document.getElementById) return true;
	a=document.getElementById(a);
	a.style.display=(a.style.display=='block')?'none':'block';	
	if(oElement!='')
	{
	    if(document.all)
	    {
	        oElement.innerText = (a.style.display=='block')? '<< Close':'>> More Information';
        }
        else
        {
            oElement.textContent = (a.style.display=='block')? '<< Close':'>> More Information';
        }
	}
	else
	{
	}
	}
	catch(Error)
	{
	}
	return false;
}

function toggleExpandCollapse(a, img)
{
    try
    {
	    if (!document.getElementById)
	    { 
	        return true;
	    }
	    a = document.getElementById(a);
	    a.style.display = (a.style.display=='block')?'none':'block';
	    
	    img = document.getElementById(img);
	    if(a.style.display == 'block')
	    {
	        img.src = img.src.replace('downarrow', 'backarrow');
	    }
	    else
	    {
	        img.src = img.src.replace('backarrow', 'downarrow');
	    }
	}
	catch(Error)
	{
	}
	return false;
}

function changetext(div_id, val) {
    var elm=document.getElementById(div_id); 
    if (elm != null)   elm.innerHTML=val;
    return false;
}

function replaceButtonText(buttonId, text)
{
  if (document.getElementById)
  {
    var button=document.getElementById(buttonId);
    if (button)
    {
      if (button.childNodes[0])
      {
        button.childNodes[0].nodeValue=text;
      }
      else if (button.value)
      {
        button.value=text;
      }
      else //if (button.innerHTML)
      {
        button.innerHTML=text;
      }
    }
  }
}


