﻿// JScript File

// June 2009 Aidan Hutchinson

function OnKey()
{
    if(event.keyCode==13)
   {
   Submit_Search();
   } 
}

function Submit_Search()
{
  new Effect.Shrink('peopleimage');
  new Effect.Move('panel', { x: 77, y: 540, mode: 'absolute' });
  //$('profiletitle').update("Plexus Law");
  $('toppanel').appear();
  var Firstname = $('SearchName').value;
  var Surname = $('SearchSur').value; 
  //var Practice = $('PracticeAreas').options[$('PracticeAreas').selectedIndex].text;
  var Practice = $('PracticeAreas').selectedIndex;
  JSCallBack("../peoplefinder/search.aspx?firstname=" + Firstname + "&surname=" + Surname + "&type=N&practice=" + Practice,"resultspane"); 
  $('ResultsHeader').show();
  $('resultspane').appear();
}

//function Get_Location()
//{
//   JSCallBack("../peoplefinder/search.aspx?location=" + $('Locations').selectedIndex + "&type=L","resultspane");
//}

//function Get_Practices()
//{
//var Query = $('PracticeAreas').options[$('PracticeAreas').selectedIndex].text;
//   JSCallBack("../peoplefinder/search.aspx?practice=" + Query + "&type=P","resultspane");
//}

function Show_Profile(ContentID)
{
    $('profilespace').show();
     var url = "../peoplefinder/search.aspx?contentid=" + ContentID + "&type=I";
      new Ajax.Request(url, {
            method: 'get',
                onSuccess: function(transport) {
                    // returned JSON object
                    RenderProfile(transport.responseText);
               }    
           });
}

function RenderProfile(JSONObject)
{
  var jobj = eval('(' + JSONObject + ')');
  HideSearch();
  $('toppanel').hide();
  $('ResultsHeader').hide(); 
  $('resultspane').hide();
  $('normalpanel').show();
  $('profileimage').appear();
  $('panel').style.top = "540px";
  $('pageheading').update(jobj.Name + ", " + jobj.Title);
  $('profilespace').show();
  $('biography').show();
  if (jobj.IMG == "Y"){ image = jobj.ID;} else { image = "noimage";}
  $('profileimage').src = "../media/profiles/" + image + ".jpg";
  $('profilespace').update("<table id='profile' border='0' /><td align='right'><b>Practice Area(s) :</b></td><td>" + jobj.Practice + "</td></tr><tr><td align='right'><b>Office Location :</b></td><td>" + jobj.Location + "</td></tr><tr><td align='right'><b>DDI :</b></td><td>" + jobj.DDI + "</td></tr><tr><td align='right'><b>Email Address :</b></td><td><a class='links' href='mailto:" + jobj.Email + "' />"  + jobj.Email +  "</a></td></tr></table><p>&nbsp;</p><div class='biogheader' >Biography</div>");
  $('biography').update("<div id='biogpara'>" + jobj.Biog + "</div><p>&nbsp;</p><input type='button' onclick='Showall()' value='Search Again' />");
}

function HideSearch()
{
   $('introduction').toggle();
   $('NameSearch').toggle();
   $('PracticeSearch').toggle();
}
function Showall()
{
 $('profileimage').hide();
 $('toppanel').show(); 
 $('normalpanel').hide();
 $('panel').style.top = "540px"; 
 $('pageheading').update("People Finder");
 HideSearch();
 $('profilespace').hide();
 $('biography').hide();
 $('ResultsHeader').show(); 
 $('resultspane').appear();
}

function Clear_Search()
{
 $('profileimage').hide();
 $('toppanel').fade(); 
 $('normalpanel').hide();
 $('pageheading').update("People Finder");
 $('profilespace').hide();
 $('biography').hide();
 $('ResultsHeader').hide(); 
 $('resultspane').hide();

// firefox workaround to make sure future Grow effects position correctly
 new Effect.Move('peopleimage', { x: 379, y: 483, mode: 'absolute'});
// this part works in safari, chrome, ie6, ie7 but not Opera
 new Effect.Move('panel', { x: 77, y: 223, mode: 'absolute',afterFinish:function()
                                {
                                   new Effect.Grow('peopleimage'); 
                                }
 }); 
 $('PracticeAreas').selectedIndex = 0;  
 $('SearchName').value = "";
 $('SearchSur').value = "";
}
