// JScript File

// new window popup

// status  The status bar at the bottom of the window. 
// toolbar  The standard browser toolbar, with buttons such as Back and Forward. 
// location  The Location entry field where you enter the URL. 
// menubar  The menu bar of the window 
// directories  The standard browser directory buttons, such as What's New and What's Cool 
// resizable Allow/Disallow the user to resize the window. 
// scrollbars  Enable the scrollbars if the document is bigger than the window 
// height Specifies the height of the window in pixels. (example: height='350') 
// width  Specifies the width of the window in pixels. 


function ShowPopUpDialog(url, height, width) {
    var args = 'location=0, toolbar=0, status=0, menubar=0, height = ' + height + 'px, width = ' + width + 'px'
    window.open(url, 'Openherd', args, true);
}


//Function that picks which search box to display on page load.
function pickSearchOnLoad()
{
if (dropdown = document.getElementById('ddl_SearchBox')) 
    {
        var search = getCookie('AeSearch');
           switch(search){
                   case 'imports': 
                       setCookie('AeSearch', 'imports', '1');
                       SearchViewState('search-imports', 'search-afs', 'search-hs');
                       dropdown.selectedIndex = 1;
                       break;
                   case 'hs': 
                       setCookie('AeSearch', 'hs', '1');
                       SearchViewState('search-hs', 'search-imports', 'search-afs'); 
                       dropdown.selectedIndex = 2;
                       break;
                   default : 
                       setCookie('AeSearch', 'afs', '1');
                       SearchViewState('search-afs', 'search-hs', 'search-imports'); 
                       dropdown.selectedIndex = 0;
                       break;
                   }
     }
}

// Picks which search box to display based on the drop down selection
function pickSearch()
{
   if (dropdown = document.getElementById('ddl_SearchBox')) 
   { 
       var myindex  = dropdown.selectedIndex
       var SelValue = dropdown.options[myindex].value
       
       if (!(SelValue==null))
       {
           switch(SelValue){
           case 'imports': 
               setCookie('AeSearch', 'imports', '1');
               SearchViewState('search-imports', 'search-afs', 'search-hs');
               break;
           case 'afs': 
               setCookie('AeSearch', 'afs', '1');
               SearchViewState('search-afs', 'search-hs', 'search-imports'); 
               break;
           case 'hs': 
               setCookie('AeSearch', 'hs', '1');
               SearchViewState('search-hs', 'search-imports', 'search-afs'); 
               break;
           default: break;
           }
       }
   }
}


// js used to set the default button on search boxes
function KeyDownHandler(btn)
{
 if (button = document.getElementById(btn)) 
   { 
        // process only the Enter key
        if (event.keyCode == 13)
        {
            // cancel the default submit
            event.returnValue=false;
            event.cancel = true;
            // submit the form by programmatically clicking the specified button
            button.click();
        }
   }
}

//Allways shows id1 and make the following ids visibility: hidden
function SearchViewState(id1, id2, id3)
{      
  if (el1 = document.getElementById(id1)) 
    {
    el1.style.display = 'block';
 	}
  if (el2 = document.getElementById(id2)) 
    {
	el2.style.display = 'none';
	} 
  if (el3 = document.getElementById(id3)) 
    {
	el3.style.display = 'none';
	}
}

//Generic Function to creat cookies
function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
} 

//Generic Function to read cookies
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}


//Function ShowHide is used on the AboutAE page to change the view state of the questions.
function show_hide(id, id2) 

{
    var show
    if (el = document.getElementById(id)) 
    {
	if (null==show) show = el.style.display=='none';
	el.style.display = (show?'':'none');
		
	if (el.style.display == '') document.getElementById(id2).src = "/images/viewhide-arrow1.gif";
	if (el.style.display == 'none') document.getElementById(id2).src = "/images/viewhide-arrow0.gif";
	}
}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Used to hide/show divs on mouse over at cursor position
//////////////////////////////////////////////////////////////////////////////////////////////////

function HideContent(d) {
    if (d.length < 1) { return; }
    document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
    if (d.length < 1) { return; }
    var dd = document.getElementById(d);
    dd.style.display = "block";
}

function ReverseContentDisplay(d) {
    if (d.length < 1) { return; } var dd = document.getElementById(d);
    if (dd.style.display == "none") {
        dd.style.display = "block";
    }
    else { dd.style.display = "none"; }
}


//////////////////////////////////////////////////////////////////////////////////////////////////
// End
//////////////////////////////////////////////////////////////////////////////////////////////////
