﻿// JScript File

function CMSOnKey()
{
    if(event.keyCode==13)
   {
   CMS_Search();
   } 
}


function CMS_Search()
{
   var Firstname = $('SearchName').value;
   var Surname = $('SearchSur').value; 
   //var Practice = $('PracticeAreas').options[$('PracticeAreas').selectedIndex].text;
   var Practice = $('PracticeAreas').selectedIndex;
   JSCallBack("../admin/cmspeoplesearch.aspx?firstname=" + Firstname + "&surname=" + Surname + "&type=N&practice=" + Practice,"resultspane"); 
   $('resultspane').show();
   $('ResultsHeader').show();
}

function Show_Profile(ContentID)
{
    location.replace("ProfileEdit.aspx?contentid=" + ContentID);
}

//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 + ')');
   //alert(jobj.Name); 
  HideSearch();
  $('ResultsHeader').hide(); 
  $('resultspane').hide();
  $('id22textareabackground').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(jobj.Biog + "<p>&nbsp;</p><input type='button' onclick='Showall()' value='Search Again' />");
}

function HideSearch()
{
   $('introduction').toggle();
   $('NameSearch').toggle();
   //$('LocationSearch').toggle();
   $('PracticeSearch').toggle();
}
function Showall()
{
 $('profileimage').hide();
 $('id22textareabackground').hide();
 $('panel').style.top = "223px";
 $('pageheading').update("People Finder");
 HideSearch();
 $('profilespace').hide();
 $('biography').hide();
 $('ResultsHeader').show(); 
 $('resultspane').show();
}
