// function for jump menu drop downs
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// very simple change image function
function changeImg(img, src) {
	document.images[img].src = src;
}

// generic function to pop open a window with a certain url, width, and height
function popWindow(url, width, height) {

	x = (640 - width)/2;
	y = (480 - height)/2;

	if (screen) {
		y = (screen.availHeight - height)/2;
		x = (screen.availWidth - width)/2;
	}

	win = window.open(url, "popreserve", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+",screenX="+x+",screenY="+y+",top="+y+",left="+x);
	win.focus();

	return(false);

}

function PopWin(URL,Name,Features) {
                window.open(URL,Name,Features);
        }

function echeck(str) {

                var at="@"
                var dot="."
                var lat=str.indexOf(at)
                var lstr=str.length
                var ldot=str.indexOf(dot)
                if (str.indexOf(at)==-1){
                   alert("Invalid Email Address")
                   return false
                }

                if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
                   alert("Invalid Email Address")
                   return false
                }

                if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
                    alert("Invalid Email Address")
                    return false
                }

                 if (str.indexOf(at,(lat+1))!=-1){
                    alert("Invalid Email Address")
                    return false
                 }

                 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
                    alert("Invalid Email Address")
                    return false
                 }

                 if (str.indexOf(dot,(lat+2))==-1){
                    alert("Invalid Email Address")
                    return false
                 }

                 if (str.indexOf(" ")!=-1){
                    alert("Invalid Email Address")
                    return false
                 }

                 return true
        }

function ValidateForm(){
        var emailID=document.frmNewsletter.Email

        if ((emailID.value==null)||(emailID.value=="")){
                alert("Please Enter Your Email Address")
                emailID.focus()
                return false
        }
        if (echeck(emailID.value)==false){
                emailID.value=""
                emailID.focus()
                return false
        }
        return true
}

function ValidateForm2(){
        var emailID=document.frmDownloadCPP.Email

        if ((emailID.value==null)||(emailID.value=="")){
                alert("Please Enter Your Email Address")
                emailID.focus()
                return false
        }
        if (echeck(emailID.value)==false){
                emailID.value=""
                emailID.focus()
                return false
        }
        return true
}

function ValidateForm3(){
        var emailID=document.frmNewsletterSubmit.Email

        if ((emailID.value==null)||(emailID.value=="")){
                alert("Please Enter Your Email Address")
                emailID.focus()
                return false
        }
        if (echeck(emailID.value)==false){
                emailID.value=""
                emailID.focus()
                return false
        }
        return true
}

function checkform( send )
{
var d = document.send;       
  if (d.Your_Name.value == "") {
        alert( "Please enter your name." );
        d.Your_Name.focus();
        return false;
  }
 
 if (d.friendsname.value == "") {
        alert( "Please enter your friends name." );
        d.friendsname.focus();
        return false;
  }
 if (d.Email.value == "") {
        alert( "Please enter your email address." );
        d.Email.focus();
        return false;
  }
 
 if (d.femail.value == "") {
        alert( "Please enter your friends email address." );
        d.femail.focus();
        return false;
  }
  
 if (echeck(d.Email.value)==false){
                d.Email.value="";
                d.Email.focus();
                return false;
        }
 
 if (echeck(d.femail.value)==false){
                d.femail.value="";
                d.femail.focus();
                return false;
        }
 return true;
}

function checkContact( contactUs )
{
var d = document.contactUs;
  if (d.realname.value == "") {
        alert( "Please enter your name." );
        d.realname.focus();
        return false;
  }

 if (d.Email.value == "") {
        alert( "Please enter your email address." );
        d.Email.focus();
        return false;
  }

 if (d.phone.value == "") {
        alert( "Please enter your phone number." );
        d.phone.focus();
        return false;
  }

 if (d.subject2.value == "") {
        alert( "Please enter a subject." );
        d.subject2.focus();
        return false;
  }

 if (d.message.value == "") {
        alert( "Please enter a message." );
        d.message.focus();
        return false;
  }
 
 if (echeck(d.Email.value)==false){
                d.Email.value="";
                d.Email.focus();
                return false;
        }

 return true;
}

function checkFeedback ( feedBack )
{
var d = document.feedBack;
  if (d.firstname.value == "") {
        alert( "Please enter your first name." );
        d.firstname.focus();
        return false;
  }

 if (d.lastname.value == "") {
        alert( "Please enter your last name." );
        d.lastname.focus();
        return false;
  }

 if (d.email.value == "") {
        alert( "Please enter your email address." );
        d.email.focus();
        return false;
  }

 if (d.comment.value == "") {
        alert( "Please enter a comment." );
        d.comment.focus();
        return false;
  }

 if (echeck(d.email.value)==false){
                d.email.value="";
                d.email.focus();
                return false;
        }

 return true;
}
