var resContent = "";
function GetFirmContent(firmname,firmid) // this is for Firm
{
	InitXmlHttp();
	InvokeASHX("/common/include/linkedin/linkedin_get_relation.php?firmname="+firmname+"&firmid="+firmid);
	return resContent;
}
function GetLawyerContent(linkedin_userid,alid,lawyername)// this is for Lawyer
{
	InitXmlHttp();
	InvokeASHX("/common/include/linkedin/linkedin_get_relation.php?linkedin_userid="+linkedin_userid+"&lawyername="+lawyername);
	
}

function updatestats(url){
	InitXmlHttp();
	InvokeASHX(url);
}

function InitXmlHttp() {
	// Attempt to initialize xmlhttp object
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		// Try to use different activex object
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E)
		{
			xmlhttp = false;
		}
	}

	// If not initialized, create XMLHttpRequest object
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	// Define function call for when Request obj state has changed
	xmlhttp.onreadystatechange=XMLHttpRequestCompleted;
}
function InvokeASHX(resource)
{

	//resource = 'http://www.dev-lawyers4.reedref.com/common/include/linkedin/linkedin_get_relation.php';
	InitXmlHttp();
	xmlhttp.onreadystatechange= XMLHttpRequestCompleted;
	xmlhttp.open("GET",resource, true );
	xmlhttp.send(null);
}
function XMLHttpRequestCompleted()
{
	if (xmlhttp.readyState==4)
	{
		try
		{
			resContent = xmlhttp.responseText;
			fillcontent(resContent);
		}
		catch (e)
		{
			resContent = "Service Not available, please try again later";
		}
	}
}

function fillcontent(resContent){
	document.getElementById('linkedinContent').innerHTML = resContent;
}

//begin linkedin popup
//common function to find the x position of the linked in image that was clicked
function findLinkedinPosX(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
	while(1)
	{
		curleft += obj.offsetLeft;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.x)
	curleft += obj.x;
	return curleft;
}
//common function to find the y position of the linked in image that was clicked
function findLinkedinPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
	while(1)
	{
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
		break;
		obj = obj.offsetParent;
	}
	else if(obj.y)
	curtop += obj.y;
	return curtop;
}
var linkedinObj = "";
var linkedingDiv = "";
var linkedinName = "";
var linkedinPopupType = "";

//show linkedin firm popup
function showLinkedinFirmPopup(obj,div,firm)
{
	linkedinObj = obj;
	linkedinDiv = div;
	linkedinName = firm.replace("~","'");
	linkedinPopupType = "firm";
	document.getElementById('linkedinTitle').innerHTML = "<div class=\"t-12\">See Who You Know at <b>" + linkedinName + "</b></div>";

	document.getElementById('linkedinBody').innerHTML = "<br /><div align=\"center\"><img src=\"/images/ajax-loader.gif\" alt=\"\" /></div><br />";
	showLinkedinPopupControl(linkedinObj,linkedinDiv,"175");
	GetContent('firmsearch',escape(linkedinName));
}

//common function for adding the content to lawyer or firm popup
function linkedinPopup(){
	if (linkedinPopupType == "firm"){
		document.getElementById('linkedinBody').innerHTML = resContent;
	}
	if (linkedinPopupType == "lawyer"){
		document.getElementById('linkedinLawyerBody').innerHTML = resContent;
	}
	resContent = "";
}

//show linkedin lawyer popup
function showLinkedinLawyerPopup(obj,div,fn,ln,firm,em)
{
	linkedinObj = obj;
	linkedinDiv = div;
	linkedinPopupType = "lawyer";
	var popup = document.getElementById(div);
	document.getElementById('linkedinLawyerTitle').innerHTML = "<span class=\"linkedin-name\">How you're connected to " + fn + "</span>";

	document.getElementById('linkedinLawyerBody').innerHTML = "<br /><div align=\"center\"><img src=\"/images/ajax-loader.gif\" alt=\"\" /></div><br />";
	showLinkedinPopupControl(obj,div,"125");
	GetLawyerContent('lawyerprofile',fn,ln,firm,em);
}

//common function to show login popup for lawyers and firms
function showLinkedinLoginPopup(obj,div,name,returnUrl,type)
{
	var nm = name.replace("~","'");
	var popup = document.getElementById(div);
	if (type == "firm"){
		popup.className = "linkedin-firm-info";
		document.getElementById('linkedinTitle').innerHTML = "<div class=\"t-12\">See Who You Know at <b>" + nm + "</b></div>";
	} else if (type == "lawyer"){
		popup.className = "linkedin-firm-info";
		document.getElementById('linkedinTitle').innerHTML = "<div class=\"t-12\">See How You Know <b>" + nm + "</b></div>";
	}
	document.getElementById('linkedinBody').innerHTML = "<div class=\"t-12\"><a href=\"javascript: linkedinSubmit('/LinkedIn/ProcessLinkedInAuth.aspx','" + returnUrl + "')\" class=\"b t-12\" title=\"Allow\">Allow</a> <b>LexisNexis to access your LinkedIn account.</b><br><div class=\"p-t-5\"></div>Not a LinkedIn member? <a href=\"javascript: linkedinSubmit('/LinkedIn/ProcessLinkedInAuth.aspx','" + returnUrl + "')\" class=\"b t-12\" title=\"Sign up\">Sign up</a> today!</div>";
	showLinkedinPopupControl(obj,div,"175");
}

//Allow link for getting linkedin key for first time users
function linkedinSubmit(url,returnUrl)
{
	//check to see if using form fields
	if(document.getElementById("ru")){
		document.getElementById("ru").value = returnUrl;
		document.search.action = url;
		document.search.method = "get";
		document.body.style.cursor = 'wait';
		document.search.submit();
	}else{
		location.href = url + "?ra=key&ru=" + returnUrl;
	}
}

//common function that shows the popup below the image link
function showLinkedinPopupControl(obj,div,leftInset)
{
	var popup = document.getElementById(div);
	if(popup.style.display == "none")
	popup.style.display = "block";
	var nLeft = findLinkedinPosX(obj);
	if(nLeft > leftInset)
	popup.style.left = (nLeft - leftInset) + "px";
	popup.style.top = (findLinkedinPosY(obj) + 17) + "px";  //Added 15 extra pixal to make the div below the trigger
}

//common function used to hide the linked in popup
function hideLinkedinPopupControl(div)
{
	if(document.getElementById(div).style.display == "block")
	document.getElementById(div).style.display = "none";
}

//function linkedinShowHide is used for lawyer results expand/collapse feature
function linkedinShowHide(showName, hideName)
{
	document.getElementById(showName).style.display = "block";
	document.getElementById(hideName).style.display = "none";
}

<!-- Begin

// Get base url
//	url = '';
//xend = url.lastIndexOf("/") + 1;
//var base_url = url.substring(0, xend);

function do_ajax (url) {

	// credit:
	// http://www.phpit.net/article/ajax-php-without-xmlhttprequest/

	// Create new JS element

	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';

	// Send the parameters via the URL (GET method)
	jsel.src = url;
	// Append JS element (therefore executing the 'AJAX' call)
	document.body.appendChild (jsel);
}
//  End -->
function showpopup(popupid){
	document.getElementById(popupid).style.display="block";
}
function closepopup(popupid){
	document.getElementById(popupid).style.display="none";
}

/*
var i=0;
function do_ajax (url) {
i++;
// credit:
// http://www.phpit.net/article/ajax-php-without-xmlhttprequest/

// Create new JS element
//eval("var" + jsel + i);
eval('jsel' + i + '= document.createElement(\'SCRIPT\')');
eval('jsel' + i + '.type'+ '= \'text/javascript\'');
//jsel.type = 'text/javascript';

// Send the parameters via the URL (GET method)
eval('jsel' + i + '.src' + '= url');
//jsel.src = url;
// Append JS element (therefore executing the 'AJAX' call)
eval('document.body.appendChild (jsel' + i + ')');
}
*/
function open_all_divs(divid){
	
	var ar = document.getElementById(divid).getElementsByTagName("div"); //DynamicDrive.com change
		for (var i=0; i<ar.length; i++){
		// if (ar[i].className=="submenu") //DynamicDrive.com change
		alert(ar[i].style.display);
		ar[i].style.display = "block";
	}
}