maxKeys = 200;
keysSoFar = 0;
alerted = false;
function change(what) {
    if (!alerted) alert('Make sure that your message is 200 characters or less. Otherwise your message will be truncated');
    what.value = what.value.substring(0,maxKeys-1); // chop after 200
    alerted = true;
}

function validateselect(entered,alertbox)
{
with (entered)
{
if (entered==null || entered.value=="")
{
  if (alertbox!="") 
  {
    alert(alertbox);
  }
    return false;
  }
else
  {
    return true;
   }
}
}


function validateselect2(value1,Decline,alertbox,alertbox2)
{



with (value1)
{
	if ((value1 =='Y') && (Decline == 'Y') )
	{
	  if (alertbox2!=="") 
	  {alert(alertbox2);}
 	  return false;
	}
          
 	 else
 		 { 
  		  if ((value1=='N') && (Decline == 'N') )
    			{
     			 if (alertbox!=="") 
    			   {alert(alertbox);}
    			  return false;
   			 }
                      else
                        {return true;} 
 			     
 		   }
                     return true;
}
}









function keyup(what) {
    keysSoFar++;
    if (keysSoFar > maxKeys) {
        if (!alerted) alert('Too may charaters. Please enter 200 characters or less.');
        what.value = what.value.substring(0,maxKeys-1); // chop the last typed char
        alerted = true;
    }
}

function emailvalidation(entered, alertbox)
{
// E-mail-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function formvalidationBooksDatabase(thisform)
{
with (thisform)
{
if (emailvalidation(email,"Illegal E-mail")==false) {email.focus(); return false;};
//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};
if (emptyvalidation(YourName,"Please enter your first and last name")==false) {YourName.focus(); return false;};
if (emptyvalidation(YourDayPhone,"Please enter a daytime phone" )==false) {YourDayPhone.focus(); return false;};
if (emptyvalidation(YourEveningPhone,"Please enter a evening phone" )==false) {YourEveningPhone.focus(); return false;};
if (emptyvalidation(AuthorClientID,"Please create a client id")==false) {AuthorClientID.focus(); return false;};
if (emptyvalidation(AuthorClientIDHint,"Please select a security question")==false) {AuthorClientIDHint.focus(); return false;};
if (emptyvalidation(AuthorClientIDHintAnswer,"Please give the answer to your security question")==false) {AuthorClientIDHintAnswer.focus(); return false;};
}
}


function formvalidationGetConnected(thisform)
{
with (thisform)
{
if (emptyvalidation(NameofOrganization,"Please provide the name of your organization")==false) {NameofOrganization.focus(); return false;};
if (emailvalidation(email,"Illegal E-mail")==false) {email.focus(); return false;};
//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};
if (emptyvalidation(URL,"Enter the web page on your site where sistersbrothers.com appears" )==false) {	URL.focus(); return false;};
if (emptyvalidation(PagetoPublish,"Enter the web page to list on our site" )==false) {PagetoPublish.focus(); return false;};
if (emptyvalidation(FirstName,"Enter the contact person's first name" )==false) {FirstName.focus(); return false;};
if (emptyvalidation(LastName,"Enter the contact person's last name" )==false) {LastName.focus(); return false;};
if (emptyvalidation(City,"Enter the city where your organized is formed or operated" )==false) {City.focus(); return false;};
if (validateselect(State,"Enter the state where your organization is formed or operated" )==false) {State.focus(); return false;};
if (validateselect(Country,"Enter the country where your organization is formed or operated")==false) {Country.focus(); return false;};
if (validateselect(TypeofOrganization,"Please provide organization type" )==false) {TypeofOrganization.focus(); return false;};
if (emptyvalidation(About,"Tell us about your organization in 200 characters or less" )==false) {About.focus(); return false;};
if (emptyvalidation(LinkID,"Please provide a Get Connected link id")==false) {LinkID.focus(); return false;};
if (emptyvalidation(IDHint,"Please provide a hint for your Get Connectd link id")==false) {IDHint.focus(); return false;};
}
}

function formvalidationSelectInterviewTime(thisform)
{

with (thisform)
{
var Decline = 'N';
var user_input = 'N';
//user_input = document.Validation.AgeGroup.selectedIndex;
somethingselected = thisform.appdatetimelocation.selectedIndex;
if (somethingselected > -1) 
{
user_input = 'Y';
}
if (thisform.Cannotattend.checked)
{ Decline = 'Y'; }

if (validateselect2(user_input,Decline,"You must select a session date and time or decline this invitation", "Error. You cannot schedule a session and decline at the same time. Please click Cancel to clear the form and try again." )==false)
 {Cannotattend.focus();
 return false;};
}
}

function formvalidationMemberApplicant(thisform)
{
with (thisform)
{
if (emailvalidation(email,"Illegal E-mail")==false) {email.focus(); return false;};
//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};
if (emptyvalidation(ApplicantFirstName,"Please enter your first name")==false) {ApplicantFirstName.focus(); return false;};
if (emptyvalidation(ApplicantLastName,"Please enter your last name")==false) {ApplicantLastName.focus(); return false;};
if (emptyvalidation(ApplicantMembershipID,"Please enter a Applicant id")==false) {ApplicantMembershipID.focus(); return false;};
if (emptyvalidation(ApplicantIDHint,"Please provide a security hint for your membership id")==false) {ApplicantIDHint.focus(); return false;};
false;};
}

function formvalidationSoror(thisform)
{
with (thisform)
{
//if (digitvalidation(phonenumber,"Illegal Soror Phone Number. Phone number must be all numbers.")==false) {phonenumber.focus(); return false;};
//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
if (digitvalidation(phonenumber,10,10,"You MUST enter 10 digits (area code and number) as your phone number. No dashes or special characters are allowed","You MUST enter 10 digits (area code and number) as your phone number. No dashes or special characters are allowed")==false) {phonenumber.focus(); return false;};
//if (emptyvalidation(ApplicantFirstName,"Please enter your first name")==false) {ApplicantFirstName.focus(); return false;};
//if (emptyvalidation(ApplicantLastName,"Please enter your last name")==false) {ApplicantLastName.focus(); return false;};
//if (emptyvalidation(ApplicantMembershipID,"Please enter a Applicant id")==false) {ApplicantMembershipID.focus(); return false;};
//if (emptyvalidation(ApplicantIDHint,"Please provide a security hint for your membership id")==false) {ApplicantIDHint.focus(); return false;};
false;};
}


function formvalidationguestrsvp(thisform)
{
with (thisform)
{
if (emailvalidation(email,"Illegal E-mail")==false) {email.focus(); return false;};
//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};
if (emptyvalidation(ApplicantFirstName,"Please enter your first name")==false) {ApplicantFirstName.focus(); return false;};
if (emptyvalidation(ApplicantLastName,"Please enter your last name")==false) {ApplicantLastName.focus(); return false;};
false;};
}


function valuevalidation(entered, min, max, alertbox, datatype)
{
// Value-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
  }
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{
// Digit-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
  }
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}




function emptyvalidation(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


Begin Image Box Popup

function getElementLeft(elm) 
{
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
    }
    return x;
}

function getElementTop(elm) 
{
    var y = 0;

    //set x to elm’s offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
    }

    return y;
}

function Large(obj)
{
    var imgbox=document.getElementById("imgbox");
    imgbox.style.visibility='visible';
    var img = document.createElement("img");
    img.src=obj.src;
    img.style.width='200px';
    img.style.height='200px';
    
    if(img.addEventListener){
        img.addEventListener('mouseout',Out,false);
    } else {
        img.attachEvent('onmouseout',Out);
    }             
    imgbox.innerHTML='';
    imgbox.appendChild(img);
    imgbox.style.left=(getElementLeft(obj)-50) +'px';
    imgbox.style.top=(getElementTop(obj)-50) + 'px';
}


function Out()
{
    document.getElementById("imgbox").style.visibility='hidden';
}

//End Imagebox Popup
