if (/msie/i.test (navigator.userAgent)) //only override IE
{
	document.nativeGetElementById = document.getElementById;
	document.getElementById = function(id)
	{
		var elem = document.nativeGetElementById(id);
		if(elem)
		{
			//make sure that it is a valid match on id
			if(elem.attributes['id'].value == id)
			{
				return elem;
			}
			else
			{
				//otherwise find the correct element
				for(var i=1;i<document.all[id].length;i++)
				{
					if(document.all[id][i].attributes['id'].value == id)
					{
						return document.all[id][i];
					}
				}
			}
		}
		return null;
	};
}


function focusSelect(id){
 if(document.getElementById(id)){
  document.getElementById(id).focus();
  if(document.getElementById(id).select=='function')
   document.getElementById(id).select();
 }
}

function showLogin(){
 document.getElementById('loginhtml').style.visibility='visible';
 document.getElementById('loginhide').style.visibility='hidden';
 document.login.email.focus();
}

function validateEmail(input){
 var str = document.getElementById(input).value;
 var filter = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
 if(!filter.test(str)){
  focusSelect(input);
  return false;
 }
}

function sendToAFriend(){
 document.sendtofriend.submit();
}

function createCookie(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 getCookie(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 initSearch(){
 var searchid=document.getElementById("add_search");
 if(getCookie('customsearchinstall')!="1"&&getCookie('customsearchhide')!="1")
  searchid.style.display="block";
}

function addSearch(item){
 window.sidebar.addSearchEngine('http://gojoin.com/includes/xml/search/opensearch.xml','http://images.gojoin.com/images/layout/default/favicon.ico','goJoin.com Search','General');
 searchClose();
 createCookie('customsearchinstall',1,'30');
// open("http://gojoin.com/search/thank-you","_blank");
}

function searchClose(){
 var searchid=document.getElementById("add_search");
 searchid.style.display = "none";
 createCookie('customsearchhide',1,'0.05');
}

function checkSearchVal(m){
 if(!m)
  var m='Enter Event Name, Sport or Location';
 var t=document.getElementById('eventsinput');
 if(!t || t.value=='' || t.value==m){
  t.className="lighttext";
  t.value=m;
 }else
  t.className="";
}

function checkEnter(e){ //e is event object passed from function invocation
 var characterCode // literal character code will be stored in this variable
 if(e && e.which){ //if which property of event object is supported (NN4)
  e = e
  characterCode = e.which //character code is contained in NN4's which property
 }
 else{
  e = event
  characterCode = e.keyCode //character code is contained in IE's keyCode property
 }
 if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
  document.forms[0].submit() //submit the form
  return false
 }
 else{
  return true
 }
}

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
var ddmenuitemzindex	= 0;
function mopen(id)
{	
 mcancelclosetime();
 if(ddmenuitem)
  ddmenuitem.style.visibility = 'hidden';
 if(ddmenuitemzindex)
  ddmenuitemzindex.style.zIndex = 0;
 ddmenuitem = document.getElementById(id);
 ddmenuitem.style.visibility = 'visible';
 ddmenuitemzindex = document.getElementById(id+'zindex');
 ddmenuitemzindex.style.zIndex = 500;
}
function mclose(){
 if(ddmenuitem)
  ddmenuitem.style.visibility = 'hidden';
 if(ddmenuitemzindex)
  ddmenuitemzindex.style.zIndex = 0;
}
function mclosetime(){
 closetimer = window.setTimeout(mclose, timeout);
}
function mcancelclosetime(){
 if(closetimer){
  window.clearTimeout(closetimer);
  closetimer = null;
 }
}
document.onclick = mclose; 