// JavaScript Document

function openClose(tag)
{
Obj = document.getElementById(tag).style;
   if (Obj.display=='none') {Obj.display = '';}
   else {Obj.display = 'none';}
}
function setLargeTooltipMoz(tag)
{
Obj = document.getElementById(tag).style;
Obj.width='270px';
Obj.height='270px';
}
function setSmallTooltipMoz(tag)
{
Obj = document.getElementById(tag).style;
Obj.width='170px';
Obj.height='170px';
}
function checkemail(field){
 var testresults
 var str=field
 var filter=/^.+@.+\..{2,3}$/

 if (filter.test(str))
    testresults=true
 else {
    testresults=false
}
 return (testresults)
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function formatUSPhone(input)
{
	var phonePattern = /^(\d\d\d)(\d\d\d)(\d\d\d\d)$/;
	var phonePatternShort = /^(\d\d\d)(\d\d\d\d)$/;
	var match;
	input.value = input.value.replace(/\s/g, "");
	input.value = input.value.replace(/\(/g, "");
	input.value = input.value.replace(/\)/g, "");
	input.value = input.value.replace(/\-/g, "");
	input.value = input.value.replace(/\\/g, "");
	input.value = input.value.replace(/\//g, "");
	if ((match = phonePattern.exec(input.value))){
		input.value = '(' + match[1] + ') ' + match[2] + '-' + match[3];
	}
	else if ((match = phonePatternShort.exec(input.value))){
		input.value = '(   ) ' + match[1] + '-' + match[2];						
	}
}			
function checkemail(field){
 var testresults
 var str=field
 var filter=/^.+@.+\..{2,3}$/

 if (filter.test(str))
    testresults=true
 else {
    testresults=false
}
 return (testresults)
}
function setEventData(loc,ymd)
{
url = window.location.href;
if (url.search("event.php") == -1)
{top.location.href="event.php";}
loc = document.getElementById(loc);
slashpos = url.search("/");
pageloc = url.substr(0,slashpos);
newloc = pageloc + '/module/event/calendar_day.php?YMD=' + ymd;
loc.src = newloc;
}
function adjustIFrameSize(iframe)
{
	if ( iframe.contentDocument ) // firefox
		{
		iframe.height = iframe.contentDocument.height +30;
		}
	else // IE
		{
		iframe.style.height = iframe.contentWindow.document.body.scrollHeight;
		}
}

