/***
   Pops up window with fixed size for privacy policy.
***/
function privacyWindow() {
   features = "width=300,height=400,toolbar=no,location=no,left=5,top=5,scrollbars=no";
   newWindow = window.open( '','popWin',features );
   newWindow.document.write( "<LINK REL='stylesheet' TYPE='text/css' HREF='moxonusa.css' />" );
   newWindow.document.write( "<TITLE>Privacy Policy</TITLE><H2>Privacy Policy</H2>" );
   newWindow.document.write( "<DIV CLASS='regulartext'>" );
   newWindow.document.write( "The information we collect on our WEB site(s) or store(s) are for OUR USE ONLY " ); 
   newWindow.document.write( "and shall not be sold, lended or leased to any other individual, company, advertising, " );
   newWindow.document.write( "WEB organization for any reason." );
   newWindow.document.write( "<P>Any customer information, which we may obtain from you (our customer), " );
   newWindow.document.write( "shall be restricted to our own use for your order processing, newsletter " );
   newWindow.document.write( "or notices of our product information to you." );
   newWindow.document.write( "</DIV>" );
   newWindow.focus();
}

/***
   Pops up window with fixed size for cat breeds image.
***/
function popUpCatBreeds() {
   features = "width=660,height=160,toolbar=no,location=no,left=5,top=5,scrollbars=no";
   newWindow = window.open( './images/cat-breeds.jpg','popWin',features );
   newWindow.focus();
}


/***
   Pops up window with fixed size for dog breeds image.
***/
function popUpDogBreeds() {
   features = "width=710,height=670,toolbar=no,location=no,left=5,top=5,scrollbars=no";
   newWindow = window.open( './images/dog-breeds.jpg','popWin',features );
   newWindow.focus();
}


/***
   Pops up window with fixed size for any image passed in.
***/
function popUpWindow( imagepath ) {
   
   img = new Image;
   img.src = imagepath;
   iwidth = this.img.width+20;
   iheight = this.img.height+20;
   //features="directories=no,toolbar=no,menubar=no,location=no,screenX=5,screenY=5,scrollbars=no,resizable=no,width="+iwidth+",height="+iheight;
   features="directories=no,toolbar=no,menubar=no,location=no,left=5,top=5,scrollbars=yes,resizable=yes,width=500,height=500";
   newWindow = window.open(imagepath,'',features);
   newWindow.focus();
}


/***
   Check if the syntax of an email is valid.
***/
function validEmail( email ) {
   invalidChars = "/:,;";
   
   if ( email == "" ) {
      alert( "You must enter an email address." );
      return false;
   }
   for ( i=0; i<invalidChars.length; i++ ) {
      badChar = invalidChars.charAt( i );
      if ( email.indexOf( badChar, 0 ) > -1 ) {
         alert( "Your email address is not formatted correctly." );
         return false;  
      }  
   }  
   
   atPos = email.indexOf( "@", 1 );
   if ( atPos == -1 ) {
      alert( "Your email address is not formatted correctly." );
      return false;
   }
   if ( email.indexOf( "@", atPos+1 ) > -1 ) {
      alert( "Your email address is not formatted correctly." );
      return false;
   }
   
   periodPos = email.indexOf( ".", atPos );
   if ( periodPos == -1 ) {
      alert( "Your email address is not formatted correctly." );
      return false;  
   }
   if ( periodPos+3 > email.length ) {
      alert( "Your email address is not formatted correctly." );
      return false;  
   }
   
   return true;
}


/***
   Check if the syntax of a zip is valid.
***/
function validZip( zip ) {
   re = /\d{5}/g;
   OK = re.test( zip );
   if ( zip == "" ) {
      alert( "Please enter zip code." );
      return false;
   }
   else if ( !OK ) {
      alert( "Zip code entered is not valid." );
      return false;
   }
   return true;  
}


/***
   Check if at least one area is selected.
***/
function validStore( store ) {
   
   if ( store == "" ) {
      alert( "Please select at least one area." );
      return false;
   }
   
   return true;  
}


/***
   Check if comments are longer then 250 characters.
***/
function validComments( comments ) {

   if ( comments.length > 250 ) {
      alert( "Comments cannot be longer then 250 characters." );
      return false;
   }
   
   return true;  
}
