function menuClick(id)
{
	elem = document.getElementById(id);
	if(elem.style.display == 'none')
		elem.style.display = 'inline';
	else
		elem.style.display = 'none';
}

function pop_it(the_form)
{
   my_form = eval(the_form);
   window.open("", "popup", "height=750,width=900,resizable,menubar='no',toolbar,location='no',status='no',scrollbars");
   my_form.target = "popup";
   my_form.submit();
}

function setCookie(c_name,value)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+999)
	document.cookie=c_name+ "=" +escape(value)+";expires="+exdate.toGMTString()
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

var lightbox = null;
function getLightbox()
{
	if(!lightbox)
	{
		lightboxStr = getCookie("lightbox")
		if(lightboxStr)
			lightbox = lightboxStr.split(',');
		else
			lightbox = new Array(0);
	}
	if(!lightbox || lightbox == 'undefined')
	{
		lightbox = new Array(0);
	}
	return lightbox;
}

function saveLightbox()
{
	if(!lightbox)
	{
		getLightbox()
	}
	//lightboxStr = ""
	//alert('saving to cookie array' + lightbox);
	//for(i = 0; i < lightbox.length; i = i + 1)
	//{
	//	if(lightbox[i] && lightbox[i] != null && lightbox[i].length > 0 && !isNaN(lightbox[i]))
	//		lightboxStr += lightbox[i] + "|";
	//}
	//alert('saving to cookie string' + lightbox);
	setCookie("lightbox", lightbox);
}

function addToLightbox(toAdd)
{
	if(!toAdd || toAdd == null || toAdd.length <= 0 || isNaN(toAdd))
		return;
	if(!lightbox)
	{
		getLightbox()
	}
	for(i = 0; i < lightbox.length; i = i + 1)
	{
		if(lightbox[i]==toAdd)
			return;
	}
	lightbox[lightbox.length] = toAdd
	
	//alert('added ' + toAdd + ' now ' + lightbox);
	
	saveLightbox()
}

function removeFromLightbox(toAdd)
{
	if(!lightbox)
	{
		getLightbox()
	}
	found = false
	for(i = 0; i < lightbox.length; i = i + 1)
	{
		if(lightbox[i]==toAdd)
			found = true
			
		if(found)
		{
			if(i + 1 < lightbox.length)
				lightbox[i] = lightbox[i + 1]
			else
			{
				lightbox[i] = null
				lightbox.length = lightbox.length - 1
			}
		}
	}
	
	//alert('removed ' + toAdd + ' now ' + lightbox);
	
	saveLightbox()
}

function isInLightbox(toAdd)
{
	if(!lightbox)
	{
		getLightbox()
	}
	for(i = 0; i < lightbox.length; i = i + 1)
	{
		if(lightbox[i]==toAdd)
			return true;
	}
	return false
}

saveLightbox()

function checkEmail(email, msg) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email)) {
alert(msg);
return false;
}
return true;
}
