﻿

 function PersonDetailsModalPop(id) {
         
         var dt = new Date();
         
            showPopWin('persondetails.aspx?id=' + id + '&nocache=' + dt, 400, 450, null);
         }


 function PersonAdminEdit(id) {
         
            parent.frames[1].location.href='edit_tree_item.aspx?id=' + id;
         }




function TreeNodeClick(arg, theimage, cookiename)	{var eSrc =  document.getElementById(arg);//eSrc.style.display = (eSrc.style.display == 'block' ? 'none' : 'block');        if (theimage.src.indexOf('plus.gif') > 0)         {                            eSrc.style.display = 'block';                                                //the opening status of the Tree will be saved in a cookie                    if (readCookie(cookiename)==null)                    {                        setCookie(cookiename, '_' + arg + '_', 1);                                      }                    else                    {                    //cookie is already created so add the new family id to it                                                                                                var existing_states = readCookie(cookiename)                                                                        if (existing_states.indexOf('_' + arg + '_') == -1)                        {                            setCookie(cookiename, existing_states + '_' + arg + '_', 1);                        }                    }                                theimage.src = '../images/minus.gif'       }        else        {                eSrc.style.display = 'none';                //remove the state from the cookie        var existing_states = readCookie(cookiename)                if (existing_states != null && existing_states.length > 0)            {setCookie(cookiename, replace(existing_states, '_' + arg + '_', ''),1);}                                       theimage.src = '../images/plus.gif';                }}function replace(string,text,by) {

// Replaces text with by in string

var strLength = string.length, txtLength = text.length;

if ((strLength == 0) || (txtLength == 0)) return string;



var i = string.indexOf(text);

if ((!i) && (text != string.substring(0,txtLength))) return string;

if (i == -1) return string;



var newstr = string.substring(0,i) + by;



if (i+txtLength < strLength)

       newstr += replace(string.substring(i+txtLength,strLength),text,by);



return newstr;

}function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

