

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//Character left function
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit)
	field.value = field.value.substring(0, maxlimit);
	else {
	InputObj = document.getElementById(countfield);
	InputObj.innerHTML = maxlimit - field.value.length;
	}
}

function paypal_validation(){
	 if(document.paypalfrm.varUserName.value == "")
		 {
		 alert("Please enter your name");
		 document.paypalfrm.varUserName.focus();
		 return false;
		 }
	 if(document.paypalfrm.varUserEmail.value == "")
	   {
		 alert("Please enter your Email");
		 document.paypalfrm.varUserEmail.focus();
		 return false;
	    }
	if (!validateEmail(document.paypalfrm.varUserEmail.value,1,1)) 
		{
		document.paypalfrm.varUserEmail.focus();
		return false;
		}	
	if(document.paypalfrm.fltAmount.value == "")
		 {
		 alert("Please enter the amount");
		 document.paypalfrm.fltAmount.focus();
		 return false;
		 }
		
		recordvalue = document.paypalfrm.fltAmount.value ;
		if((recordvalue == "")  || (recordvalue == 0) || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0)  ){
			alert ("Please enter the valid donation amount.");
			document.paypalfrm.fltAmount.focus();
			return false;
		}
		
}
 var submitcount=0;
   function checkSubmit() {

      if (submitcount == 0)
      {
      submitcount++;
      document.Surv.submit();
      }
   }


function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
      if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {wordcounter++}  // Counts the spaces while ignoring double spaces, usually one in between each word.
      if (wordcounter > 350) {field.value = field.value.substring(0, x);}
      else {
		  InputObj = document.getElementById(countfield);
	InputObj.innerHTML = maxlimit - wordcounter;
	
		  //countfield.value = maxlimit - wordcounter;
		  }
      }
   }


/*window.onload=function(){
MM_preloadImages('images/1-1.jpg','images/mission1.jpg','images/company1.jpg','images/oyl1.jpg','images/friends1.jpg','images/news1.jpg','images/3-3.jpg','images/4-4.jpg','images/_10.jpg','images/past1.jpg','images/6-6.jpg','images/7-7.jpg','images/photos1.jpg','images/video1.jpg','images/11-11.jpg','images/support1.jpg','images/donor1.jpg','images/8-8.jpg','images/9-9.jpg');
}
*/
//Email Validation Script
function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}
function poplinks(url)
{
	newwindow=window.open(url,'ImageDisplay','height=600,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus();}
}
 //Function phone validation Script
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone)
{
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

//script validation for date 
function date_valid(dateissue,dateissue2){
	var stdate=dateissue.split("/");
	var enddate=dateissue2.split("/");
	var prostdate = new Date();
	prostdate.setFullYear(stdate[2]);
	prostdate.setMonth(stdate[0]-1);
	prostdate.setDate(stdate[1]);
	
	var proenddate = new Date();
	proenddate.setFullYear(enddate[2]);
	proenddate.setMonth(enddate[0]-1);
	proenddate.setDate(enddate[1]);
	
	var startingdate = prostdate.getTime();
	var endingdate = proenddate.getTime();

	if(startingdate > endingdate)
	{
		return false;
	}
	return true;
}

function frmaction(){
	if (document.frm_mailing.YMLP11.value == "") 
			{
				alert ("Please enter the name");
				document.frm_mailing.YMLP11.focus();
				return false;
			}
	if (document.frm_mailing.YMLP00.value == "") 
			{
				alert ("Please enter the email");
				document.frm_mailing.YMLP00.focus();
				return false;
			}
	if (!validateEmail(document.frm_mailing.YMLP00.value,1,1)) 
		{
		document.frm_mailing.YMLP00.focus();
		return false;
		}		
	if (document.frm_mailing.YMLP22.value == "") 
			{
				alert ("Please enter the zip");
				document.frm_mailing.YMLP22.focus();
				return false;
			}	
			
	document.frm_mailing.YMLP1.value = document.frm_mailing.YMLP11.value;
	document.frm_mailing.YMLP0.value = document.frm_mailing.YMLP00.value;
	document.frm_mailing.YMLP2.value = document.frm_mailing.YMLP22.value;
	document.frm_mailing.YMLP3.value = document.frm_mailing.YMLP33.value;
	
	document.frm_mailing.YMLP11.value = "";
	document.frm_mailing.YMLP00.value = "";
	document.frm_mailing.YMLP22.value = "";
	document.frm_mailing.YMLP33.value = "";
	return true;
}

//validation for investors

function login_validate(){
		var email	= document.frmLogin.txtEmail.value;
		if (email == "") 
		{
			alert ("Please enter the email address");
			document.frmLogin.txtEmail.focus();
			return false;
		}
		
		if (!validateEmail(email,1,1)) 
		{
		document.frmLogin.txtEmail.focus();
		return false;
		}
		
		if (document.frmLogin.txtPassword.value == "") 
		{
			alert ("Please enter the password");
			document.frmLogin.txtPassword.focus();
			return false;
		}
		if (document.frmLogin.txtMember.value == "") 
		{
			alert ("Please select the action");
			document.frmLogin.txtMember.focus();
			return false;
		}
}

function frm_mail()
{
document.frmInventors.action="inventorregistration.php";
document.frmInventors.submit();
return true;
}
function PayPal(){
	window.location = "https://www.paypal.com/cgi-bin/webscr";

}



//validation for inventoremail

function inventoremail_validate(){
	
		var email	= document.frmInventorEmail.txtToEmail.value;
		if (email == "") 
		{
			alert ("Please enter the email address");
			document.frmInventorEmail.txtToEmail.focus();
			return false;
		}
		
		if (!validateEmail(email,1,1)) 
		{
		document.frmInventorEmail.txtToEmail.focus();
		return false;
		}
		
		if (document.frmInventorEmail.txtSubject.value == "") 
		{
			alert ("Please enter the subject");
			document.frmInventorEmail.txtSubject.focus();
			return false;
		}
		
		if (document.frmInventorEmail.txtMessage.value == "") 
		{
			alert ("Please enter the message");
			document.frmInventorEmail.txtMessage.focus();
			return false;
		}
}

//winning bids

function bids_validate()
{
	if(document.frmInventorEmail.txtBidAmount.value == "")
	{
		alert ("Please enter the bids amount");
		document.frmInventorEmail.txtBidAmount.focus();
		return false;
	}
	
	if(document.frmInventorEmail.txtMessage.value == "")
	{
		alert ("Please enter the Comments");
		document.frmInventorEmail.txtMessage.focus();
		return false;
	}
}
function contactus_validation()
{
	if(document.frm_contact.varFirstName.value == "")
	{
		alert ("Please enter the name");
		document.frm_contact.varFirstName.focus();
		return false;
	}
	if(document.frm_contact.varEmail.value == "")
	{
		alert ("Please enter the Email");
		document.frm_contact.varEmail.focus();
		return false;
	}
	if (!validateEmail(document.frm_contact.varEmail.value,1,1)) 
	{
	document.frm_contact.varEmail.focus();
	return false;
	}	
	if(document.frm_contact.intZipcode.value == "")
	{
		alert ("Please enter the Zipcode");
		document.frm_contact.intZipcode.focus();
		return false;
	}
	
}

function winbids_validate()
{
	if(document.frmWinning.radWinningBids.checked == false)
	{
		alert ("Please choose the winning bids");
		return false;
	}
}

function poplinks(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function popup(url)
{
	newwindow=window.open(url,'ImageDisplay','height=550,width=730,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function popservices(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function popmessage(url)
{
	newwindow=window.open(url,'ImageDisplay','height=450,width=500,left=200,top=300,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function frm_feed()
{
	if(document.addfeedback.feedback.value == "")
	{
		alert ("Please enter your Feedback");
		document.addfeedback.feedback.focus();
		return false;
	}
return true;	
}

function frm_comment()
{
	if(document.addcomments.comments.value == "")
	{
		alert ("Please enter your Comments");
		document.addcomments.comments.focus();
		return false;
	}
return true;
}
function search_all()
{
  document.form.action="searchresult.php";
  document.form.submit();
  return true;
}
function SearchAll_validation()
{
	 if(document.Search_All.Search_All.value == "")
	{
		alert ("Please enter keyword to search");
		document.Search_All.Search_All.focus();
		return false;
	}
}
function appvalidation(){
		if (document.frm_app.name.value == "") 
		{
			alert ("Please enter the Name");
			document.frm_app.name.focus();
			return false;
		}
		if (document.frm_app.address.value == "") 
		{
			alert ("Please enter the Address");
			document.frm_app.address.focus();
			return false;
		}
		
		var email	= document.frm_app.email.value;
		if (email == "") 
		{
			alert ("Please enter the email address");
			document.frm_app.email.focus();
			return false;
		}
		
		if (!validateEmail(email,1,1)) 
		{
		document.frm_app.email.focus();
		return false;
		}
		
	
}


function oylymlcontact()
{   
	if (document.yml.YMLP0.value == "") 
	{
		alert ("Please enter the email address.");
		document.yml.YMLP0.focus();
		return false;
	}
	if(!validateEmail(document.yml.YMLP0.value,1,1))
	{
	   document.yml.YMLP0.focus();
	   return false;
	}
    if (document.yml.YMLP1.value == "") 
	{
		alert ("Please enter the name.");
		document.yml.YMLP1.focus();
		return false;
	}
 if (document.yml.YMLP2.value == "") 
	{
		alert ("Please enter the Zipcode.");
		document.yml.YMLP2.focus();
		return false;
	}
	 if (document.yml.YMLP3.value == "") 
	{
		alert ("Please enter the Address.");
		document.yml.YMLP3.focus();
		return false;
	}
}

