// JavaScript Document

function jObj( ObjID ){
	if (document.getElementById) { return(document.getElementById( ObjID )); }	// IE5, IE6, IE7, NetScape6, Opera, Firefox
	else { if (document.all) {return(document.all[ ObjID ]); }                  // puto IE4, y algo de IE5
		   else { BrVersion = parseInt(navigator.appVersion);							
	       		if ((navigator.appName.indexOf('Netscape')!=-1)&&(BrVersion==4)) { return (document.layers[ ObjID ]); }
		 	}  // puto NetScape4
	} 
}

function jPty( ObjID, Parametro, Valor  ){
		Obj= jObj( ObjID );
		eval( "Obj."+ Parametro +"='"+ Valor +"'" );
}

function jCss( ObjID, Parametro, Valor  ){
		Obj= jObj( ObjID );
		eval( "Obj.style."+ Parametro +"='"+ Valor +"'" );
}

function jDivOn(ObjID){
	Obj = jObj(ObjID);
	Obj.style.display ="block";
}

function jDivOff(ObjID){
	Obj = jObj(ObjID);
	Obj.style.display ="none";
}

function jPageWidth() {
	return window.innerWidth!=null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body!=null ? document.body.clientWidth : null;
} 

function jPageHeight() {
	return  window.innerHeight!=null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body!=null? document.body.clientHeight : null;
} 

function jPosLeft() {
	 return typeof window.pageXOffset!='undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
} 

function jPosTop() {
	 return typeof window.pageYOffset!='undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
} 

function jPosRight() {
	 return jsPosLeft()+jsPageWidth();
} 

function jPosBottom() {
	return jsPosTop()+jsPageHeight();
}

//--------------------------------------------------------  function locales ----------------------
//-------------------------------------------------------------------------------------------------


function ChangeFont(size){
		if (size==1) { jCss("Text","fontSize","100%"); }
		if (size==2) { jCss("Text","fontSize","120%"); }
		if (size==3) { jCss("Text","fontSize","140%"); }
}

function ShowPopUp(n){
	TPos = jPosTop()+30;
	LPos = jPageWidth()/2-400;
	jCss('PopUp'+n,'left',LPos+'px');
	jCss('PopUp'+n,'top',TPos+'px');
	jDivOn('PopUp'+n);
}

//-------------------------------------------------------------- Menu Functions
//
//  MENU TOP BAR: 
//  to show the main menu    		ShowMenu( Popup-active )
//	to create a PopUpMenu use 		CreatePopUp( namepopup, imagen-in-menu, imagen-rollover, popup-height-pixels, page-to-link )
//	to create an option on popup 	CreateOption( label-in-popup, page-to-link )
//	to finish the PopUp creation	ClosePopUp()
//	to separate with |				SpacePopUp()
//

function ShowMenu(){
	CreatePopUp('PopAbout','About',330,330,								'index_page.php?page=about0' );
	CreateOption('Our History',											'index_page.php?page=about1');		
	ClosePopUp();
	SpacePopUp(391);

	CreatePopUp('PopProgs','Programs&nbsp;&amp;&nbsp;Services',396,396,	'index_page.php?page=programs0' );
	CreateOption('Friendly Visiting',									'index_page.php?page=programs1');  
	CreateOption('Shop & Escort Service',								'index_page.php?page=programs2');		
	CreateOption('Health Advocacy',										'index_page.php?page=programs3');		
	CreateOption('Intergenerational Program',							'index_page.php?page=programs4');		
	CreateOption('Social Opportunities',								'index_page.php?page=programs5');		
	ClosePopUp();
	
	SpacePopUp(573);
	CreatePopUp('PopSeniors','Seniors',578,578,							'index_page.php?page=seniors0' );
	ClosePopUp();
	
	SpacePopUp(652);
	CreatePopUp('PopGetInvolve','Get&nbsp;Involved',656,656,			'index_page.php?page=getinvol0' );
	CreateOption('Success Stories',										'index_page.php?page=getinvol1');	
	CreateOption('Applications',										'index_page.php?page=getinvol2');		
	CreateOption('Forms',												'index_page.php?page=getinvol3');		
	ClosePopUp();
	
	SpacePopUp(769);
	CreatePopUp('PopDonate','Donate',774,774,							'index_page.php?page=donate0' );
	ClosePopUp();
	
	SpacePopUp(843);
	CreatePopUp('PopEvents','Events',848,848,							'index_page.php?page=events0' );
	CreateOption('Newsletters',											'index_page.php?page=events1');		
	CreateOption('Photo Gallery',										'index_page.php?page=events2');		 
	ClosePopUp();
	
	SpacePopUp(916);
	CreatePopUp('PopContact','Contact',920,870, 						'index_page.php?page=contact0' );
	CreateOption('FAQ',													'index_page.php?page=contact1');		 
	CreateOption('Program Staff',										'index_page.php?page=contact2');		 
	ClosePopUp();
}
function CreatePopUp( PopName,  PopTitle, Pox1, Pox2, PopLink  ){
	var StHtm = "";
	StHtm = StHtm + "<a id=X"+PopName+" class='menu_links' href='"+PopLink+"' ";
	StHtm = StHtm + " onmouseover=\"jCss('"+PopName+"','display','block'); \" ";
	StHtm = StHtm + " onmouseout =\"jCss('"+PopName+"','display','none'); \" >"+PopTitle+"</a>"; 
	StHtm = StHtm + "<div id='"+PopName+"' class='menu_popup' ";
	StHtm = StHtm + " onmouseover=\"jCss('"+PopName+"','display','block'); \" ";
	StHtm = StHtm + " onmouseout =\"jCss('"+PopName+"','display','none'); \" >"; 
	document.write ( StHtm );
	Pos = jPageWidth()>1000 ? (jPageWidth()-1000)/2 : 10;
	PoM = Pos+Pox1; PoP = Pos+Pox2;
	jCss("X"+PopName,'left',PoM+'px');
	jCss(PopName,'left',PoP+'px');
}
function CreateOption( OptionName, OptionLink ){
	document.write ("<a class='menu_drop' href='"+OptionLink+"'>"+OptionName+"</a>" );
}
function ClosePopUp(){
	document.write ("</div>" );
}
function SpacePopUp(PopX){
	Pos = jPageWidth()>1000 ? (jPageWidth()-1000)/2 : 10;
	Pos = Pos+PopX;
	document.write ( "<div class='menu_space' style='left:"+Pos+"px;'><img src='images/pic-dotted.jpg'></div>" );
}

//-------------------------------------------------------------- SlideShow rutine

function runSlideShow(){
	if (SlideProc) {  
		   if (SlidePlay) j = j + 1;
		   if ( j>p ) j = 0;  if ( j<0 ) j = p;
		   if (preLink[j]!="") {
			   jCss("LinkSlide","display","block");
			   jPty("LinkSlide","href",preLink[j]);
		   } else jCss("LinkSlide","display","none");
		   if (document.all){
			  document.images.SlideShow.style.filter="blendTrans(duration=2)";
			  document.images.SlideShow.style.filter="blendTrans(duration=FadeDuration)";
			  document.images.SlideShow.filters.blendTrans.Apply();
		   }
		   document.images.SlideShow.src = preLoad[j].src;
		   if (document.all){  document.images.SlideShow.filters.blendTrans.Play();	   }
		   if (SlidePlay) t = setTimeout('runSlideShow()', SlideSpeed);
	}
}
function HomeSlide( n, imag, alink ){
	p=n-1;
	preLink[p] = alink; 
    preLoad[p] = new Image();  
	preLoad[p].src = 'homes/'+imag;
}
function nextSlide() { j=j+1; SlidePlay=false; SlideProc=true; jPty('btPlay','src','images/pic-navplay.jpg'); runSlideShow();}
function prevSlide() { j=j-1; SlidePlay=false; SlideProc=true; jPty('btPlay','src','images/pic-navplay.jpg'); runSlideShow(); }
function playSlide() { SlidePlay = !(SlidePlay); SlideProc=SlidePlay;  
							jPty('btPlay','src',SlidePlay?'images/pic-navpause.jpg':'images/pic-navplay.jpg'); runSlideShow();}


//-------------------------------------------------------------- Actions HomePage

function DefineAction(Title,Texto,alink){
  		document.write('<div class="MidBox">');
        document.write('<div class="Aquo">&nbsp;&nbsp;</div>');
        document.write('<a href="'+alink+'">');
		document.write('<b>'+Title+'</b><br />'+Texto);
        document.write('</a></div>');
}


