function xstooltip_findPosX(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) 
  {
    while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
  // alert (curleft);
    return curleft;
}


function xstooltip_findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
	//alert (curtop);
	return curtop;
}


function xstooltip_show(tooltipId, parentId, posX, posY)
{
    it = document.getElementById(tooltipId);
    
    if ((it.style.top == '' || it.style.top == 0) 
        && (it.style.left == '' || it.style.left == 0))
    {
        // need to fixate default size (MSIE problem)
        //it.style.width = it.offsetWidth + 'px';
        //it.style.height = it.offsetHeight + 'px';
        
        img = document.getElementById(parentId); 
    
        // if tooltip is too wide, shift left to be within parent 
        //if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
        //if (posX < 0 ) posX = 0; 
        
        x = xstooltip_findPosX(img) + posX ;
        y = xstooltip_findPosY(img) + posY ;
       
	   // x =  posX ;
       // y =  posY ;

       
        it.style.top = y + 'px';
        it.style.left = x + 'px';

        it.style.top = '100px';
        it.style.left = '100px';


		//alert(it.style.top);
       // alert(it.style.left);

        
    }
    
    it.style.visibility = 'visible'; 
}


function xstooltip_hide(id)
{
	it = document.getElementById(id); 
	it.style.visibility = 'hidden';
	/*var t=setTimeout("it.style.visibility = 'hidden'",5000);*/
}

function wi(it,ln,or)
{
document.write("<input id="+it+" name="+it+" type=text size="+ln+" maxlength=50 title='"+or+" Field'  onfocus=change_x('"+it+"','#000000','#ffcc66') onmouseover=change_x('"+it+"','#000000','#ffcc66')  onblur=change_x('"+it+"','#CC3300','#92CDCD')  onmouseout=change_x('"+it+"','#CC3300','#92CDCD') />")
}	

function wi2(it,ln,or)
{
document.write("<input id="+it+" name="+it+" type=text size="+ln+" maxlength=50 title='"+or+" Field'  onfocus=change_x('"+it+"','#000000','#ffcc66');xstooltip_show('tooltip_"+it+"') onmouseover=change_x('"+it+"','#000000','#ffcc66');xstooltip_show('tooltip_"+it+"')  onblur=change_x('"+it+"','#CC3300','#92CDCD');xstooltip_hide('tooltip_"+it+"')  onmouseout=change_x('"+it+"','#CC3300','#92CDCD');xstooltip_hide('tooltip_"+it+"') />")
}	


function wiv(it,ln,or,col)
{
document.write("<input id="+it+" name="+it+" type=text value='"+col+"' size="+ln+" maxlength=50 title='"+or+" Field'  onfocus=change_x('"+it+"','#000000','#ffcc66') onmouseover=change_x('"+it+"','#000000','#ffcc66')  onblur=change_x('"+it+"','#CC3300','#92CDCD')  onmouseout=change_x('"+it+"','#CC3300','#92CDCD') />");
}

function wiarea(it,columns,rows,or)
{
document.write("<textarea id="+it+" name="+it+" rows="+rows+" cols="+columns+" value='' title='"+or+" Field'  onfocus=change_x('"+it+"','#000000','#ffcc66') onmouseover=change_x('"+it+"','#000000','#ffcc66')  onblur=change_x('"+it+"','#CC3300','#92CDCD')  onmouseout=change_x('"+it+"','#CC3300','#92CDCD')></textarea>");
}



function retImg()
{
	return("<img src='images/njaasc"+(Math.floor(Math.random()*17))+".jpg' style='height:125px;left:500px;'>");
}

function retImgold()
{
	return("<div id='main-section' style=background-image:url('images/bg"+(Math.floor(Math.random()*5))+".gif');>");
}

function display_error(msg)
{
	alert(msg);
}


function change_color(id,c)
{
    it = document.getElementById(id);
    it.style.color = c; 
    it.style.borderWidth = "10px"; 
}

function change_x(id,cl,c)
{
    it = document.getElementById(id);
	var label_id=it.id+"_Label";
	//alert (label_id);
    labelx = document.getElementById(label_id);
	labelx.style.color=cl;
	//it.style.border="1px solid #f00";
	it.style.background=c;
}

function xstooltip_show(id)
{
    it = document.getElementById(id);
    it.style.visibility = 'visible'; 
}

function xstooltip_hide(id)
{
    it = document.getElementById(id); 
    it.style.visibility = 'hidden'; 
}

function cleanup_search(thisform)
{
for (i=0; i<thisform.elements.length; i++)
	{
		var fld = thisform.elements[i].value;
		while (fld.indexOf("'") >-1) 
		{
			var fld = fld.replace("'","");
		}
		while (fld.indexOf('"') >-1) 
		{
			var fld = fld.replace('"','');
		}
		thisform.elements[i].value=fld;
	if (thisform.elements[i].value=="Enter Search Term")
	{ 
	alert("Please enter your search term in the box.");
	return false;
	}
}	
}

  


function confirmit(msg) {
	var answer = confirm(msg)
	if (answer){
		return true;
	}
	else{
		return false;
	}
}




function validate_allfields(thisform,conf)
{
for (j=0; j<thisform.elements.length; j++)
	{
		var fld = thisform.elements[j].value;
		var nme = thisform.elements[j].name;
		
		
		while (fld.indexOf("'") >-1) 
			{
			var fld = fld.replace("'","");
			}

		while (fld.indexOf('"') >-1) 
			{
			var fld = fld.replace('"','');
			}

		thisform.elements[j].value=fld;

		if (thisform.elements[j].title.substr(0,8)=="Required")
			{
			if (fld.length==0)
				{	
				alert( nme + " is a required field");
				thisform.elements[j].focus();
				return false;
				}
			}
		
		 
	/*	if (nme=="Website")
			{	
			 
			if (fld.length>0)
				{
				if (validateWWW(fld)=='invalid')
					{
					thisform.elements[j].focus();
					return false;
					}
				}
			}*/

		if ( (nme=="Email_Address") || (nme=="Email") )
			{	
			if (fld.length>0)
				{
					if (validateEmail(fld)=='invalid')
						{
					thisform.elements[j].focus();
					return false;
					}
				}
			}
	}


if (conf.length>0)
{
var agree=confirm(conf);
if (agree)
	return true ;
else
	return false ;
}


}

// Email Validation Javascript
// copyright 23rd March 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function validateEmail(addr)
{
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++)
	{
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1)
	   {
		  alert('Email address contains invalid character(s).');
		  return "invalid";
	   }
	}
	for (i=0; i<addr.length; i++) 
	{
	   if (addr.charCodeAt(i)>127) 
	   {
		  alert("Email address contains invalid character(s).");
		  return "invalid";
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) 
	{
	   alert('Email address must contain an @');
	   return "invalid";
	}
	if (atPos == 0) 
	{
	   alert('Email address must not start with @');
	   return "invalid";
	}
	if (addr.indexOf('@', atPos + 1) > - 1) 
	{
	   alert('Email address must contain only one @');
	   return "invalid";
	}
	if (addr.indexOf('.', atPos) == -1) 
	{
	   alert('Email address must contain a period in the domain name');
	   return "invalid";
	}
	if (addr.indexOf('@.',0) != -1) 
	{
	   alert('Period must not immediately follow @ in email address');
	   return "invalid";
	}
	if (addr.indexOf('.@',0) != -1)
	{
	   alert('Period must not immediately precede @ in email address');
	   return "invalid";
	}
	if (addr.indexOf('..',0) != -1) 
	{
	   alert('Two periods must not be adjacent in email address');
	   return "invalid";
	}

}

function validateWWW(addr) 
{	
	 
	var pieces=addr.split('.');
	if (pieces[0]!="www")
	{
		alert("Website address must start with www");
		return "invalid";
	}
	if (pieces.length<3)
	{
		alert("Website address must be in the format - www.xxxxx.yyy");
		return "invalid";
	}

}


function validate_confirm(thisform, msg, req)
{
var newvalue = thisform.newvalue.value;
var oldvalue = thisform.oldvalue.value;
for (i=0; i<thisform.elements.length; i++)
	{
	var fld = thisform.elements[i].value;
	var nme = thisform.elements[i].name;
	while (fld.indexOf("'") >-1) 
		{
		var fld = fld.replace("'","");
		}

	while (fld.indexOf('"') >-1) 
		{
		var fld = fld.replace('"','');
		}

	thisform.elements[i].value=fld;

	if (fld.length==0 && req==1)
		{	
			alert("You must provide a value for this field");
			thisform.elements[i].focus();
			thisform.elements[i].value=oldvalue;
			return false;
		}

	}
	
	if (newvalue == oldvalue)
	{
		alert("This value has not changed. There is nothing to update!");
			thisform.newvalue.focus();
			return false;
	}
	
	
	var agree=confirm(msg);
	if (agree)
		return true ;
	else
		thisform.newvalue.value=oldvalue;
		return false ;
}



function validate_listserv(thisform)
{
var cmts = thisform.comments.value;
if (cmts.length>5000)
	{	
		alert("Please limit your input to 5000 characters.");
		thisform.comments.focus();
		return false;
	}
 
for (i=0; i<thisform.elements.length; i++)
	{
	var fld = thisform.elements[i].value;
	var nme = thisform.elements[i].name;
	while (fld.indexOf("'") >-1) 
		{
		var fld = fld.replace("'","");
		}

	while (fld.indexOf('"') >-1) 
		{
		var fld = fld.replace('"','');
		}

	thisform.elements[i].value=fld;

	if (fld.length==0)
		{	
			alert("All fields are required on this form.");
			thisform.elements[i].focus();
			return false;
		}
	}
}



function confirm_it(msg)
{
var agree=confirm(msg);
if (agree)
	return true ;
else
	return false ;
}


function confirm_position(thisform)
{

for (i=2; i<thisform.elements.length; i++)
{
	var fld = thisform.elements[i].value;


	while (fld.indexOf("'") >-1) 
	{
		var fld = fld.replace("'","");
	}

	while (fld.indexOf('"') >-1) 
	{
		var fld = fld.replace('"','');
	}

	thisform.elements[i].value=fld;
}

var fld=thisform.position.value;
if (fld.length==0)
	{
		alert("Position Title is a required field");
		thisform.position.focus();
		return false;
	}

var fld=thisform.location.value;
if (fld.length==0)
	{	
		alert("Location is a required field");
		thisform.location.focus();
		return false;
	}

var fld=thisform.physician.value;
if (fld.length==0)
	{	
		alert("Physician/Group Name is a required field");
		thisform.physician.focus();
		return false;
	}

var fld=thisform.contact.value;
if (fld.length==0)
	{	
		alert("Contact Name is a required field");
		thisform.contact.focus();
		return false;
	}

var fld=thisform.job_description.value;
if (fld.length==0)
	{	
		alert("Job Description is a required field");
		thisform.job_description.focus();
		return false;
	}

var fld1=thisform.phone.value;
var fld2=thisform.fax.value;
var fld3=thisform.email.value;
if (fld1.length==0 && fld2.length==0 && fld3.length==0)
	{	
		alert("At least one of Phone, Fax or Email must be provided");
		thisform.phone.focus();
		return false;
	}

}


function validate_contact(thisform)
{

for (i=2; i<thisform.elements.length; i++)
{
	var fld = thisform.elements[i].value;


	while (fld.indexOf("'") >-1) 
	{
		var fld = fld.replace("'","");
	}

	while (fld.indexOf('"') >-1) 
	{
		var fld = fld.replace('"','');
	}

	thisform.elements[i].value=fld;
}

var fld=thisform.A_Name.value;
if (fld.length==0)
	{
		alert("Name is a required field");
		thisform.a_name.focus();
		return false;
	}

var fld=thisform.G_Comments.value;
if (fld.length==0)
	{	
		alert("Comments are required");
		thisform.g_comments.focus();
		return false;
	}


}


function jobbankalert()
{alert ("The Job Bank chairperson will fax to you any and all resumes received from a variety of sources.  Additionaly, upon notifying the chairperson of a job opening in your practice/facility, the chairperson will send out notices of this opening to a variety of sources.  This is just another way, we as PAHCOM chapter members network with each other.  The job bank can save you the costly expense of advertising for an employee.  REMEMBER, THIS BENEFIT IS FOR CHAPTER MEMBERS ONLY.  'PAHCOM SHARES KNOWLEDGE' ")
}

function searchhelp()
{alert ("Search term can be a single word, partial word or multiple words.  Do not include any spaces or symbols (ie single or double quotes, asterisk, plus signs etc).  If you have any questions, please email the webmaster at webmaster@pahcomnj.com")
}


function validate_membersearch(thisform)
{

var searchterm=thisform.spec.value;

if (searchterm.length==0)
{alert("Please enter a valid search term");return false};

var invalidsingle=searchterm.indexOf("'");
if (invalidsingle>-1)
{alert("Invalid search term - No quotation marks allowed");return false};

var invaliddouble=searchterm.indexOf('"');
if (invaliddouble>-1)
{alert("Invalid search term - No quotation marks allowed");return false};


//var invalidspace=searchterm.indexOf(' ');
//if (invalidspace>-1)
//{alert("Invalid search term - No spaces allowed.    Search term can only be a single word.");return false};

}

function validate_newssearch(thisform)
{

var searchterm=thisform.search.value;

if (searchterm.length==0)
{alert("Please enter a valid search term");return false};

var invalidsingle=searchterm.indexOf("'");
if (invalidsingle>-1)
{alert("Invalid search term - No quotaion marks allowed");return false};

var invaliddouble=searchterm.indexOf('"');
if (invaliddouble>-1)
{alert("Invalid search term - No quotation marks allowed");return false};


//var invalidspace=searchterm.indexOf(' ');
//if (invalidspace>-1)
//{alert("Invalid search term - No spaces allowed.   Search term can only be a single word.");return false};

}




function redir()
{
	location = 'http://www.pahcomnj.com';
}

function scrollnews(cliptop) 
{



var blank = "http://www.your-web-site-address-here.com/blank.gif";

topedge = 190;  // location of news box from top of page
leftedge = 350;  // location of news box from left edge
boxheight = 50;  // height of news box
boxwidth = 20;  // width of news box
scrollheight = 240; // total height of all data to be scrolled

if (document.layers) {
newsDiv = document.news;
newsDiv.clip.top = cliptop;
newsDiv.clip.bottom = cliptop + boxheight;
newsDiv.clip.left = 0;
newsDiv.clip.right = boxwidth + leftedge;
newsDiv.left = leftedge;
newsDiv.top = topedge - cliptop;
}
else {
newsDiv = news.style;
newsDiv.clip = "rect(" + cliptop + "px " + (boxwidth + leftedge) + "px " + (cliptop + boxheight) + "px 0px)";
newsDiv.pixelLeft = leftedge;
newsDiv.pixelTop = topedge - cliptop;
}
cliptop = (cliptop + 1) % (scrollheight + boxheight);
newsDiv.visibility='visible';
setTimeout("scrollnews(" + cliptop + ")", 150);
}

function gggover()
	{document.ggg.src='images/ggggray.gif'}

function gggback()
	{document.ggg.src='images/gggred.gif'}

function homeover()
	{document.home.src='bkimages/bk2homeover.gif'}


	


function preload()
{
bgpics = new Array;
for (i=0; i<6;i++)
 {
	bgpics[i]=new Image();
 } 
	
bg[0].src="sponsors/sponsorpics/sponsor0.gif";
bg[1].src="sponsors/sponsorpics/sponsor1.gif";
bg[2].src="sponsors/sponsorpics/sponsor2.gif";
bg[3].src="sponsors/sponsorpics/sponsor3.gif";
bg[4].src="sponsors/sponsorpics/sponsor4.gif";

}

function popUp(url)
{
mywindow = window.open (url,"","location=0,status=0,scrollbars=0, width=800,height=300");
} 

function message(msg)
{
alert(msg);
}
	
function scrollnews(cliptop) 
{



var blank = "http://www.your-web-site-address-here.com/blank.gif";

topedge = 190;  // location of news box from top of page
leftedge = 350;  // location of news box from left edge
boxheight = 50;  // height of news box
boxwidth = 20;  // width of news box
scrollheight = 240; // total height of all data to be scrolled

if (document.layers) {
newsDiv = document.news;
newsDiv.clip.top = cliptop;
newsDiv.clip.bottom = cliptop + boxheight;
newsDiv.clip.left = 0;
newsDiv.clip.right = boxwidth + leftedge;
newsDiv.left = leftedge;
newsDiv.top = topedge - cliptop;
}
else {
newsDiv = news.style;
newsDiv.clip = "rect(" + cliptop + "px " + (boxwidth + leftedge) + "px " + (cliptop + boxheight) + "px 0px)";
newsDiv.pixelLeft = leftedge;
newsDiv.pixelTop = topedge - cliptop;
}
cliptop = (cliptop + 1) % (scrollheight + boxheight);
newsDiv.visibility='visible';
setTimeout("scrollnews(" + cliptop + ")", 150);
}


function buildCal(m, y, cM, cH, cDW, cD, eventdate, eventtitle, dayname, dte, brdr){
var mn=['January','February','March','April','May','June','July','August','September','October','November','December'];
var dim=[31,0,31,30,31,30,31,31,30,31,30,31];

var oD = new Date(y, m-1, 1); //DD replaced line to fix date bug when current day is 31st
oD.od=oD.getDay()+1; //DD replaced line to fix date bug when current day is 31st

var todaydate=new Date() //DD added
var scanfortoday=(y==todaydate.getFullYear() && m==todaydate.getMonth()+1)? todaydate.getDate() : 0 //DD added
var eventdate=new Date(eventdate) //DD added
var scanforevent=(y==eventdate.getFullYear() && m==eventdate.getMonth()+1)? eventdate.getDate() : 0 //DD added

/*
var eventdate=new Date() //DD added
eventdate=04/26/2007
var scanforevent=(y==eventdate.getFullYear() && m==eventdate.getMonth()+1)? eventdate.getDate() : 0 //DD added
*/
//document.write(eventdate);
dim[1]=(((oD.getFullYear()%100!=0)&&(oD.getFullYear()%4==0))||(oD.getFullYear()%400==0))?29:28;
var t='<div class="'+cM+'"><table class="'+cM+'" cols="7" cellpadding="0" border="'+brdr+'" cellspacing="0"><tr align="center">';
t+='<td colspan="7" align="center" class="'+cH+'">'+mn[m-1]+' - '+y+'</td></tr><tr align="center">';
for(s=0;s<7;s++)t+='<td class="'+cDW+'">'+"SMTWTFS".substr(s,1)+'</td>';
t+='</tr><tr align="center">';
for(i=1;i<=42;i++){
var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : '&nbsp;';
if (x==scanfortoday) //DD added
x='<span id="today" title="Today is '+dayname+', '+dte+'">'+x+'</span>' //DD added
if (x==scanforevent) //DD added
x='<span id="event"><a href="events.asp" title="Next Meeting: '+ mn[m-1]+' '+x+',' + y +' '+eventtitle+'">'+x+'</a></span>' //DD added
t+='<td class="'+cD+'">'+x+'</td>';
if(((i)%7==0)&&(i<36))t+='</tr><tr align="center">';
}
return t+='</tr></table></div>';
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function xstooltip_show(id)
{
    it = document.getElementById(id);
    it.style.visibility = 'visible'; 
}


function xstooltip_hide(id)
{
    it = document.getElementById(id); 
    it.style.visibility = 'hidden'; 
}

