path="";
if (search==1)
{
	path="../";
}

/***********************************************
//Preload de los botones del header
/***********************************************/
if (document.images)
{
  pic01= new Image();pic01.src=path+"gfx/candao2.gif"; 
  pic02= new Image();pic02.src=path+"gfx/menu_A2.jpg"; 
  pic03= new Image();pic03.src=path+"gfx/menu_B2.jpg"; 
}

/***********************************************
//Escribe el menu principal
/***********************************************/
function menuOver(id,state,side)
{
	if (state==1)
	{
		document.getElementById(id).style.color="#ffffff";
		if (side=="A") document.getElementById(id).style.backgroundImage="url("+path+"gfx/menu_A2.jpg)";
		if (side=="B") document.getElementById(id).style.backgroundImage="url("+path+"gfx/menu_B2.jpg)";
	}
	if (state==0)
	{
		if (side=="A")
		{
			document.getElementById(id).style.color="#305e14";
			document.getElementById(id).style.backgroundImage="url("+path+"gfx/menu_A1.jpg)";;
		}
		
		if (side=="B")
		{
			document.getElementById(id).style.color="#53207d";
			document.getElementById(id).style.backgroundImage="url("+path+"gfx/menu_B1.jpg)";;
		}
	}
}

function subMenu_slideIn(id)
{
	c=setInterval('slide_in("table_'+id+'")',10)
}

function subMenu(id,action,level)
{
	if (action==1)
	{
		document.getElementById('submenu_'+id).style.visibility='visible';
		document.getElementById('table_'+id).style.left=-300
		if (level==2) document.getElementById('table_'+id).style.left=0
	}

	if (action==0)
	{ 
		document.getElementById('submenu_'+id).style.visibility='hidden';
		document.getElementById('table_'+id).style.left=0
		clearInterval(c)
	}
}

function slide_in(id)
{
	if (document.getElementById(id).offsetLeft<0) document.getElementById(id).style.left=document.getElementById(id).offsetLeft+20;
	document.getElementById(id).style.zIndex+=100
}

function menu(mlock, host)
{
	document.write('<div style="position:relative;top:-20px">');
	if (mlock == "1") 
	{
		document.write('<div align=center id=lock style="position:relative;top:7px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:stop(); dochangeLockMode(0)" style="text-decoration:none" onfocus=this.blur()><img src="'+path+'gfx/candao.gif" border=0 align=absmiddle><font size=1 color=#C6ACDC>&nbsp; menu locked</a></div>');
	}
	else
	{
		document.write('<div align=center id=lock style="position:relative;top:7px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:stop(); dochangeLockMode(1)" style="text-decoration:none" onfocus=this.blur()><img src="'+path+'gfx/candao2.gif" border=0 align=absmiddle><font size=1 color=#C6ACDC>&nbsp; menu unlocked</a></div>');
	} 

	document.write('<a href="'+path+'index.php" onfocus=this.blur()><img src="'+path+'gfx/menu_top_main.gif" width="144" height="75" border="0"></a><br>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'index.php\'">						<tr><td align=center id="menu_a01" background="'+path+'gfx/menu_A1.jpg" style="color:#305e14" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_a01\',1,\'A\')" onmouseout="menuOver(\'menu_a01\',0,\'A\')">&nbsp;<font size=1><b>HOME</b></td></tr></table>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'aboutus.php\'">						<tr><td align=center id="menu_a02" background="'+path+'gfx/menu_A1.jpg" style="color:#305e14;font-weight:bold;font-size:10px;padding-left:7px" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_a02\',1,\'A\'); subMenu_slideIn(\'aboutus\'); subMenu(\'aboutus\',1,1)" onmouseout="menuOver(\'menu_a02\',0,\'A\');subMenu(\'aboutus\',0,1)">ABOUT US</td></tr></table>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'programsandservices.php\'">			<tr><td align=center id="menu_a03" background="'+path+'gfx/menu_A1.jpg" style="color:#305e14;font-weight:bold;font-size:10px;padding-left:7px" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_a03\',1,\'A\'); subMenu_slideIn(\'pands\'); subMenu(\'pands\',1,1)"   onmouseout="menuOver(\'menu_a03\',0,\'A\');subMenu(\'pands\',0,1)"  >PROGRAMS & SERVICES</td></tr></table>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'events.php\'">						<tr><td align=center id="menu_a05" background="'+path+'gfx/menu_A1.jpg" style="color:#305e14" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_a05\',1,\'A\')" onmouseout="menuOver(\'menu_a05\',0,\'A\')">&nbsp;<font size=1><b>SIGNATURE EVENTS</b></td></tr></table>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'aboutus_photogallery.php\'">		<tr><td align=center id="menu_a06" background="'+path+'gfx/menu_A1.jpg" style="color:#305e14" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_a06\',1,\'A\')" onmouseout="menuOver(\'menu_a06\',0,\'A\')">&nbsp;<font size=1><b>PHOTO GALLERY</b></td></tr></table>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'talkaboutepilepsy.php\'">			<tr><td align=center id="menu_a07" background="'+path+'gfx/menu_A1.jpg" style="color:#305e14" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_a07\',1,\'A\')" onmouseout="menuOver(\'menu_a07\',0,\'A\')">&nbsp;<font size=1><b>TALK ABOUT EPILEPSY</b></td></tr></table>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'getinvolved_donation.php\'">		<tr><td align=center id="menu_a08" background="'+path+'gfx/menu_A1.jpg" style="color:#305e14" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_a08\',1,\'A\')" onmouseout="menuOver(\'menu_a08\',0,\'A\')">&nbsp;<font size=1><b>DONATE</b></td></tr></table>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'contact.php\'">						<tr><td align=center id="menu_a09" background="'+path+'gfx/menu_A1.jpg" style="color:#305e14" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_a09\',1,\'A\')" onmouseout="menuOver(\'menu_a09\',0,\'A\')">&nbsp;<font size=1><b>CONTACT US</b></td></tr></table>');
	document.write('<img src="'+path+'gfx/menuA_bot.gif" width="144" height="19" style="margin-bottom:10px">');
	document.write('<img src="'+path+'gfx/menu_top_epilepsy.gif" width="144" height="23"><br>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'aboutepilepsy_about.php\'">			<tr><td align=center id="menu_b01" background="'+path+'gfx/menu_B1.jpg" style="color:#53207d;font-weight:bold;font-size:10px;padding-left:7px" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_b01\',1,\'B\'); subMenu_slideIn(\'epilepsy\');  subMenu(\'epilepsy\',1,1)"  onmouseout="menuOver(\'menu_b01\',0,\'B\');subMenu(\'epilepsy\',0,1)"> ABOUT EPILEPSY</td></tr></table>');
	document.write('<table cellpadding=0 cellspacing=0 width=144 height=22 onclick="location.href=\''+path+'aboutepilepsy_resources.php\'">		<tr><td align=center id="menu_b02" background="'+path+'gfx/menu_B1.jpg" style="color:#53207d;font-weight:bold;font-size:10px;padding-left:7px" onmouseover="this.style.cursor=\'pointer\';menuOver(\'menu_b02\',1,\'B\'); subMenu_slideIn(\'resources\'); subMenu(\'resources\',1,1)" onmouseout="menuOver(\'menu_b02\',0,\'B\');subMenu(\'resources\',0,1)">RESOURCES</td></tr></table>');
	document.write('<img src="'+path+'gfx/menu_bot.gif" width="144" height="27"><br>');
	document.write('</div>');
}

/////////////////////////////////////////////////

function header_toolbox(color,url)
{
	document.write('<table border=0 style="position:absolute;top:10px;left:0px" id=elsearch cellpadding=0 cellspacing=0>');
	document.write('	<tr>');
	document.write('		<td>&nbsp;</td>');
	document.write('		<td width=1000>');
	document.write('			<table border=0 cellpadding=0 cellspacing=0>');
	document.write('				<tr>');
	document.write('					<td width=770></td>');
	if (color=="green")
	{
		document.write('					<td width=1><input id=search type=text size=20 name=searchgreen class=searchtxtgreen onKeyPress="enterKey(event)"></td>');
		document.write('					<td align=left>&nbsp;<input type=button value=search class=searchbtngreen onclick=search() onfocus=this.blur()></td>');
	}

	else
	{
		document.write('					<td width=1><input id=search type=text size=20 name=search class=searchtxt onKeyPress="enterKey(event)"></td>');
		document.write('					<td align=left>&nbsp;<input type=button value=search class=searchbtn onclick=search() onfocus=this.blur()></td>');	
	}

	document.write('				</tr>');
	document.write('				<tr>');
	document.write('					<td></td>');
	document.write('					<td colspan=2 align=right style="padding-top:10px">');
	document.write('						<!-- AddThis Button BEGIN -->');
	document.write('						<div class="addthis_toolbox addthis_default_style" style="font-size:10px;position:relative;left:-2px">');
	document.write('						<a href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4cf55f4f0d9e97fe" class="addthis_button_compact" style="text-decoration:none;color:#555555">Share</a>');
	document.write('						<a class="addthis_button_facebook"></a>');
	document.write('						<a class="addthis_button_twitter"></a>');
	document.write('						<a class="addthis_button_myspace"></a>');
	document.write('						<a class="addthis_button_email"></a>');
	document.write('						&nbsp;&nbsp;<a href="'+url+'?print=1" target="_blank"><img src="gfx/icon_print.png" border=0></a>');
	document.write('						</div>');
	document.write('						<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cf55f4f0d9e97fe"></script>');
	document.write('						<!-- AddThis Button END -->');
	document.write('					</td>');
	document.write('				</tr>');
	document.write('			</table>');
	document.write('		</td>');
	document.write('		<td>&nbsp;</td>');
	document.write('	</tr>');
	document.write('</table>');

	document.getElementById('elsearch').style.width="100%";
}

///////////////////////////////////////////////
function search()
{
	query=document.getElementById('search').value;
	if (query)
	{
		document.location.href='phpdig/search.php?template_demo=simple.html&query_string='+query;
	}

}


function enterKey(e)
{
     var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if (key == 13)
          search();
}

/////////////////////////////////////////////////

var slideInUse = new Array();

function Slide(objId, options) {
	this.obj = document.getElementById(objId);
	this.duration = 1;
	this.height = parseInt(this.obj.style.height);

	if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
	if(this.options.duration) { this.duration = this.options.duration; }
		
	this.up = function() {
		this.curHeight = this.height;
		this.newHeight = '1';
		if(slideInUse[objId] != true) {
			var finishTime = this.slide();
			window.setTimeout("Slide('"+objId+"').finishup("+this.height+");",finishTime);
		}
	}
	
	this.down = function() {
		this.newHeight = this.height;
		this.curHeight = '1';
		if(slideInUse[objId] != true) {
			this.obj.style.height = '1px';
			this.obj.style.display = 'block';
			this.slide();
		}
	}
	
	this.slide = function() {
		slideInUse[objId] = true;
		var frames = 30 * duration; // Running at 30 fps

		var tIncrement = (duration*1000) / frames;
		tIncrement = Math.round(tIncrement);
		var sIncrement = (this.curHeight-this.newHeight) / frames;

		var frameSizes = new Array();
		for(var i=0; i < frames; i++) {
			if(i < frames/2) {
				frameSizes[i] = (sIncrement * (i/frames))*4;
			} else {
				frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
			}
		}
		
		for(var i=0; i < frames; i++) {
			this.curHeight = this.curHeight - frameSizes[i];
			window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
		}
		
		window.setTimeout("delete(slideInUse['"+objId+"']);",tIncrement * i);
		
		if(this.options.onComplete) {
			window.setTimeout(this.options.onComplete, tIncrement * (i-2));
		}
		
		return tIncrement * i;
	}
	
	this.finishup = function(height) {
		this.obj.style.display = 'none';
		this.obj.style.height = height + 'px';
	}
	
	return this;
}



function changeopacity( id, opacity )
{
	var object = document.getElementById(id).style;
	object.visibility="visible";
	object.opacity = ( opacity / 100 );
	object.MozOpacity = ( opacity / 100 );
	object.KhtmlOpacity = ( opacity / 100 );
	object.filter = "alpha(opacity=" + opacity + ")";
}
