var ContentHeight = 300;
var TimeToSlide = 250.0;

var openAccordion = '';

function runAccordion(index)
{
  var nID = "Accordion" + index + "Content";
  if(openAccordion == nID)
    nID = '';
   
  setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'"
      + openAccordion + "','" + nID + "')", 33);
 
  openAccordion = nID;
}

function animate(lastTick, timeLeft, closingId, openingId)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
 
  var opening = (openingId == '') ? null : document.getElementById(openingId);
  var closing = (closingId == '') ? null : document.getElementById(closingId);
 
  if(timeLeft <= elapsedTicks)
  {
    if(opening != null)
      opening.style.height = ContentHeight + 'px';
   
    if(closing != null)
    {
      closing.style.display = 'none';
      closing.style.height = '0px';
    }
    return;
  }
 
  timeLeft -= elapsedTicks;
  var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);

  if(opening != null)
  {
    if(opening.style.display != 'block')
      opening.style.display = 'block';
    opening.style.height = (ContentHeight - newClosedHeight) + 'px';
  }
 
  if(closing != null)
    closing.style.height = newClosedHeight + 'px';

  setTimeout("animate(" + curTick + "," + timeLeft + ",'"
      + closingId + "','" + openingId + "')", 33);
}


function isAlphaKey(event) {
            var chCode = (event.charCode === undefined) ? event.keyCode : event.charCode;

                // returns false if a numeric character has been entered
            return (chCode < 33||(chCode > 45 && chCode < 47) /* '0' */ || (chCode > 64 /* '9' */ && chCode < 91)||(chCode > 96 && chCode < 123));
        }
		
function isNumberKey(event) {
            var chCode = (event.charCode === undefined) ? event.keyCode : event.charCode;

                // returns false if a numeric character has been entered
            return (chCode < 33||(chCode > 42 && chCode < 44) /* '0' */ || (chCode > 44 /* '9' */ && chCode < 46)||(chCode > 47 && chCode < 58));
        }


function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}


function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
  {alert(alerttxt);return false}
else {return true}
}
}


/*Function to Validate the Contact us*/

function validate_register(newsemail) 
{
  with (newsemail)
  {
	 
  if (validate_required(newsemail,"Email must be filled out!")==false)
    {newsemail.focus();return false}	
		 if (validate_email(newsemail,"Invalid Email Address!")==false)
    {newsemail.focus();return false}	
		
		
  }
} 
// JavaScript Document


/*Function to Validate Contact Us Name*/
function name_validate()
{

       var flag=0;
       var strText = document.contactus.name.value;
       if (strText!="")
       {
       var strArr = new Array();
       strArr = strText.split("");

       if(strArr[0]==" "||strArr[strText.length-1]==" ")
       {
       flag=1;
       }


       }

       if(document.contactus.name.value=="" || flag == 1 )
       {        alert("Name shouldn't contain blank space at the Begining and End!");
               document.contactus.name.value="";
               document.contactus.name.focus();
               return false;
       }
       return true;
}

/*Function to Check Contactus Email ID*/
function checkEmailid(contactus) {
if(contactus.email.value == '')
{
	alert("Email must be filled out!");
	document.contactus.email.focus();
	return false;
}
else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(contactus.email.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}

function checkEmail(myForm) {
if(myForm.newsemail.value == '')
{
	alert("Email must be filled out!");
	return false;
}
else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.newsemail.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}
