﻿// JScript File



function DoSearch(sareaId, sclasId, stypeId, spcId) {
    
    var sarea = document.getElementById(sareaId);
    var sclas = document.getElementById(sclasId);
    var stype = document.getElementById(stypeId);
    var spc = document.getElementById(spcId);
    
    var value = sarea.options[sarea.selectedIndex].value;
    var sarea_code = value.substring(0, value.indexOf(";"));

    if (sarea.selectedIndex > 0 && sclas.selectedIndex == 0 && stype.selectedIndex == 0 && spc.value.length == 0)
        document.location.href = value.substring(value.indexOf(";") + 1);
    else
        document.location.href = "/search.aspx?sarea=" + sarea_code + "&sclas=" + sclas.options[sclas.selectedIndex].value + "&stype=" + stype.options[stype.selectedIndex].value + "&spc=" + spc.value;    
    
    return false;

    /*      
    setFormMethod('get');
    setFormAction("/search.aspx");
    onSubmitAction();
    return true;
    */

}

function setFormMethod(method)
{
    if(method == "post")
    { 
        document.forms[0].method = "post";
    }
    else if(method == "get")
    {
        document.forms[0].method = "get";
    }
    
    return false;
}

function setFormAction(action)
{
    
    document.forms[0].action = action;
    
    
    return false;
}

function onSubmitAction()
{    
    if(document.forms[0].method = "get")
    {  
        document.getElementById("__VIEWSTATE").parentNode.removeChild(document.getElementById("__VIEWSTATE"));
        document.getElementById("__EVENTVALIDATION").parentNode.removeChild(document.getElementById("__EVENTVALIDATION"));
        document.getElementById("__EVENTTARGET").parentNode.removeChild(document.getElementById("__EVENTTARGET"));
        document.getElementById("__EVENTARGUMENT").parentNode.removeChild(document.getElementById("__EVENTARGUMENT"));  
    }
        
    return false;
}

function SubmitSearchOnEnterKey(sareaId, sclasId, stypeId, spcId)
{
    if (window.event && window.event.keyCode == 13)
    {
        DoSearch(sareaId, sclasId, stypeId, spcId);
    }
}



//Home page Browse

function Browse(id)
{
    var browse_select_box = document.getElementById(id);
    if(browse_select_box != null)
    {
        var value = browse_select_box.options[browse_select_box.selectedIndex].value;
            if( value == "-1")
                alert('Please select a browse method.');
                else window.location.href=value;
        
        return false;   
    }
    else return true;
}


function BrowseByValue(mode,id)
{

     var browse_select_box = document.getElementById(id);
     var value = browse_select_box.options[browse_select_box.selectedIndex].value;
        if(browse_select_box != null)
        {
            window.location.href="?mode=" + mode + "&value=" + value;            
            return false;   
        }
        else return true;
    
}

function popup(link, width, height, toolbar)
{
    var operationFailure = true;
    if (link)
    {   
        
        var screenX, screenY, topprop, leftprop,leftvar,rightvar ;
        if(navigator.appName == "Microsoft Internet Explorer")
        {
            screenY = window.screen.availHeight;
            screenX = window.screen.availWidth;
            
            
            leftvar = (screenX - width) / 2
            rightvar = (screenY - height) / 2

            leftprop = leftvar;
            topprop = rightvar;
        }
        else
        { 
            screenY = screen.height;
            screenX = screen.width;
            
            leftvar = (screenX - width) / 2
            rightvar = (screenY - height) / 2
            
            // adjust Netscape coordinates for scrolling
            leftprop = (leftvar - pageXOffset)
            topprop = (rightvar - pageYOffset)        
        }   
        
        if(toolbar)
         toolbar = "menubar=yes, ";
         else toolbar = "";
        
        //win_=window.open(link , "win_popup", "width="+newWidth+", height="+newHeight+", resizable=1, status=yes, scrollbars=1"); 
        win_=window.open(link , "win_popup", "left="+leftprop+",width="+width+",height="+height+" top="+topprop+", resizable=1, "+toolbar+" status=yes, scrollbars=1"); 
        win_.focus();
	    
        operationFailure = false;
    }
    else
    operationFailure = true;
	
    return operationFailure;
	
}


function PrintFav(url)
{
    popup(url,'670','550',true);
        
    return false;    
}

function PrintDoc()
{

    if(window.location.href.indexOf("?") == -1)
    {
        popup('?p=1','670','550',true);
        
    }
    else 
        popup(window.location.href + '&p=1','670','550',true);       
        
    return false;    
}


var nav4 = window.Event ? true : false;
function onEnterFocusOnControl_Firefox_Not_Working(e,id) {
        
    if(!e)
        var e = window.event;

   if (nav4) // Navigator 4.0x
      var whichCode = e.which
   else // Internet Explorer 4.0x
      if (e.type == "keypress") // the user entered a character
      var whichCode = e.keyCode
      
      alert(whichCode);
      
   if ( whichCode == "13") {
        if(document.getElementById(id))
        {
            document.getElementById(id).focus();
        }
        
      //document.form2.submit();
   }
}



function onEnterFocusOnControl(id)
{
    if (window.event && window.event.keyCode == 13)
    {
        if(document.getElementById(id))
        {
            document.getElementById(id).focus();
        }
    }
    
}



//Call backs

//save mode

function UpdateEnvironment(result, context) 
{

    if(result != "")
    {
        var f = new Function(result);
        f.call();
        
    }
    
    return false;
}


function GetFavoriteNotes(control_id)
{
    var control = document.getElementById(control_id)
    
    if(control)
    {   
        return escape(control.value);
    }   
}




var fav1 = document.getElementById("fav1");
var fav2, fav3, fav4, fav5, fav6, fav7, fav8, fav9, fav10, recent_searches;

function SlideMenus(count){

    //var count = <%# FavoriteCount %>;
            
    for(var i = 1; i < count;i++)
    {   
        var fav;   
            
        fav = new fx.Combo('fav'+i, {height: true, opacity: false, duration: 500});
        //if(i != 2)
        //OpenFavoriteItems 
        
        //fav.hide();    
        
        
        if(i == 1)
            fav1 = fav; 
        else if(i == 2)
            fav2 = fav;
        else if(i == 3)
            fav3 = fav;
        else if(i == 4)
            fav4 = fav;
        else if(i == 5)
            fav5 = fav;
        else if(i == 6)
            fav6 = fav;
        else if(i == 7)
            fav7 = fav;
        else if(i == 8)
            fav8 = fav;
        else if(i == 9)
            fav9 = fav;
        else if(i == 10)
            fav10 = fav;
            
        
	}
	
	recent_searches = new fx.Combo('recent_searches', {height: true, opacity: false, duration: 500});
    
    recent_searches.hide();

}



function UpdateClient(result, context)
{
    //Do something with the result here, update a field or something
    alert(result);
}

function PageUnload()
{
    //GUnload();
}
try{
_uacct = "UA-972046-1";
    urchinTracker();
    }catch(err){}