// JS File for NW Big Game

//ramdom photo generator
var loaded = new Array();

myPix = new Array("http://www.nwbiggame.com/images/pic_01.jpg",
                   "http://www.nwbiggame.com/images/pic_02.jpg",
                   "http://www.nwbiggame.com/images/pic_03.jpg",
                   "http://www.nwbiggame.com/images/pic_04.jpg",
                   "http://www.nwbiggame.com/images/pic_05.jpg",
                   "http://www.nwbiggame.com/images/pic_06.jpg",
                   "http://www.nwbiggame.com/images/pic_07.jpg",
                   "http://www.nwbiggame.com/images/pic_08.jpg",
                   "http://www.nwbiggame.com/images/pic_09.jpg",
                   "http://www.nwbiggame.com/images/pic_10.jpg",
                   "http://www.nwbiggame.com/images/pic_11.jpg",
                   "http://www.nwbiggame.com/images/pic_12.jpg",
                   "http://www.nwbiggame.com/images/pic_13.jpg",
                   "http://www.nwbiggame.com/images/pic_14.jpg",
                   "http://www.nwbiggame.com/images/pic_15.jpg",
                   "http://www.nwbiggame.com/images/pic_16.jpg",
                   "http://www.nwbiggame.com/images/pic_17.jpg",
                   "http://www.nwbiggame.com/images/pic_18.jpg",
                   "http://www.nwbiggame.com/images/pic_19.jpg",
                   "http://www.nwbiggame.com/images/pic_20.jpg",
                   "http://www.nwbiggame.com/images/pic_21.jpg",
                   "http://www.nwbiggame.com/images/pic_22.jpg",
                   "http://www.nwbiggame.com/images/pic_23.jpg",
                   "http://www.nwbiggame.com/images/pic_24.jpg")
 imgCt = myPix.length
 
 shoshoniPix = new Array("http://www.nwbiggame.com/images/shoshoni_01.jpg",
                   "http://www.nwbiggame.com/images/shoshoni_02.jpg",
                   "http://www.nwbiggame.com/images/shoshoni_03.jpg",
                   "http://www.nwbiggame.com/images/shoshoni_04.jpg")
 shoshoniCt = shoshoniPix.length
 
function choosePic()
{
  if (document.images)
     {
      randomNum = Math.floor ((Math.random() * imgCt))
      document.myPicture.src = myPix[randomNum]
      }
}

function shoshoniPic()
{
  if (document.images)
     {
      randomNum = Math.floor ((Math.random() * shoshoniCt))
      document.shoshoniPicture.src = shoshoniPix[randomNum]
      }
}


// added to pop a new window for the PDF
function newWin(destFile) {
    var w = window.screen.availWidth - 10;
    var h = window.screen.availHeight - 60;
    a = window.open("", "R", "status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width="+w+",height="+h+",left=0,top=0"); 
	a.location = destFile;
	a.focus();
}

function val_forward(name, femail, toemail) {
	//alert('name is: '+name+', femail is: '+femail+' ,toemail is: '+toemail);
	if (name.length < 6){
		alert('You must include a full name (at least 6 characters)!'); 
		return false;
	}
	else {
		if (femail.length < 7){
			alert('You must enter YOUR email address (at least 7 characters)!'); 
			return false;
		}
		else {
			if (toemail.length < 7){
				alert('You must enter RECIPIENTS email address (at least 7 characters)!'); 
				return false;
			}
			else{
				return true;
			}
		}
	}
}

function val_contactus(fname, lname, email) {
	//alert('fname is: '+fname+', lname is: '+lname+' ,email is: '+email);
	if (fname.length < 2){
		alert('You must include a first name with at least 2 characters!'); 
		return false;
	}
	else {
		if (lname.length < 2){
			alert('You must include a last name with at least 2 characters!'); 
			return false;
		}
		else {
			if (email.length < 7){
				alert('You must enter an email address!'); 
				return false;
			}
			else{
				return true;
			}
		}
	}
}

function val_subscribe(fname, lname, email) {
	//alert('fname is: '+fname+', lname is: '+lname+' ,email is: '+email);
	if (fname.length < 2){
		alert('You must include a first name  (at least 2 characters)!'); 
		return false;
	}
	else {
		if (lname.length < 2){
			alert('You must include a last name (at least 2 characters)!'); 
			return false;
		}
		else {
			if (email.length < 7){
				alert('You must enter an email address (at least 7 characters)!'); 
				return false;
			}
			else{
				return true;
			}
		}
	}
}

function val_top10(stateid, categoryid, harvestid, roundscore, eighthscore, county, yeartaken, hname, picfile) {
	//alert('stateid is: '+stateid+ ' category is: '+categoryid+ ' harvestid is: '+harvestid+ ' roundscore is: '+roundscore+ ' eighthscore is: '+isNaN(eighthscore)+ ' county is: '+county+ ' yeartaken is: '+yeartaken+ ' hname is: '+hname+ ' picfile is: '+picfile);
	//+', lname is: '+lname+' ,email is: '+email     
	//return false;
	var startofname = picfile.lastIndexOf("\\");	
	if (picfile.indexOf(" ",startofname) > 0){
		alert('You can not submit images that have a space in the name, please remame the file without spaces!'); 
		return false;
	}
	else {
		if (stateid == 0){
			alert('You must select a State!'); 
			return false;
		}
		else {
			if (categoryid == 0){
				alert('You must select a Category!'); 
				return false;
			}
			else {
				if (harvestid == 0){
					alert('You must select a Harvest Method!'); 
					return false;
				}
				else {
					if (county.length < 4){
						alert('You must type in a County Name with at least 4 characters!'); 
						return false;
					}
					else {
						if (hname.length < 4){
							alert('You must type in the Hunters Name with at least 4 characters!'); 
							return false;
						}
						else {
							if (roundscore == 0 || isNaN(roundscore)){
								alert('You must enter a Numeric Round Score with no spaces!'); 
								return false;
							}
							else {
								if (eighthscore == "" || isNaN(eighthscore)){
									alert('You must enter a Numeric Eighth Score with no spaces, or a zero!'); 
									return false;
								}
								else {
									if (yeartaken == 0 || isNaN(yeartaken) || yeartaken.length < 4){
										alert('You must enter a 4 digit, Numeric, Year Taken with no spaces!'); 
										return false;
									}
									else{
										return true;
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

function val_hh(compid, tourid, stateid, categoryid, harvestid, roundscore, eighthscore, county, yeartaken, hname) {
	//alert('stateid is: '+stateid+ ' category is: '+categoryid+ ' harvestid is: '+harvestid+ ' roundscore is: '+roundscore+ ' eighthscore is: '+isNaN(eighthscore)+ ' county is: '+county+ ' yeartaken is: '+yeartaken+ ' hname is: '+hname+ ' picfile is: '+picfile);
	//return false;
	
	if (compid == 0){
		alert('You must select a Competition Group!'); 
		return false;
	}
	else {
		if (tourid == 0){
			alert('You must select a Tour Event!'); 
			return false;
		}
		else {
			if (stateid == 0){
				alert('You must select a State!'); 
				return false;
			}
			else {
				if (categoryid == 0){
					alert('You must select a Category!'); 
					return false;
				}
				else {
					if (harvestid == 0){
						alert('You must select a Harvest Method!'); 
						return false;
					}
					else {
						if (county.length < 4){
							alert('You must type in a County Name with at least 4 characters (UNKNOWN if not known)!'); 
							return false;
						}
						else {
							if (hname.length < 4){
								alert('You must type in the Hunters Name with at least 4 characters!'); 
								return false;
							}
							else {
								if (roundscore == 0 || isNaN(roundscore)){
									alert('You must enter a Numeric Round Score with no spaces!'); 
									return false;
								}
								else {
									if (eighthscore == "" || isNaN(eighthscore)){
										alert('You must enter a Numeric Eighth Score with no spaces, or a zero!'); 
										return false;
									}
									else {
										if (yeartaken == 0 || isNaN(yeartaken) || yeartaken.length < 4){
											alert('You must enter a 4 digit, Numeric, Year Taken with no spaces (9999 if not known)!'); 
											return false;
										}
										else{
											return true;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

function val_fp(stateid, categoryid, harvestid, county, yeartaken, fname, lname, fpemail, fieldstory, caption, picfile, action) {
	//alert('stateid is: '+stateid+ ' category is: '+categoryid+ ' harvestid is: '+harvestid+ ' roundscore is: '+roundscore+ ' eighthscore is: '+isNaN(eighthscore)+ ' county is: '+county+ ' yeartaken is: '+yeartaken+ ' hname is: '+hname+ ' picfile is: '+picfile);
	//+', lname is: '+lname+' ,email is: '+email     
	//return false;
		
	//if action is add from public or admin, then make sure there is an image being sent
	//if action is update from admin, no new picture is needed
	if (action == 'Add'){
		if (picfile.length < 4){
			alert('You must browse and select an image to send!'); 
			return false;
		}
	}
	
	
	//find the position of the last backslash in picfile name
	var startofname = picfile.lastIndexOf("\\");
	//from position of last backslash in picfile name, look for spaces in file name
	if (picfile.indexOf(" ",startofname) > 0){
		alert('You can not submit images that have a space in the name, please remame the file without spaces!'); 
		return false;
	}
	else {
		if (stateid == 0){
			alert('You must select a State!'); 
			return false;
		}
		else {
			if (categoryid == 0){
				alert('You must select a Category!'); 
				return false;
			}
			else {
				if (harvestid == 0){
					alert('You must select a Harvest Method!'); 
					return false;
				}
				else {
					if (county.length < 4){
						alert('You must enter a County Name with at least 4 characters!'); 
						return false;
					}
					else {
						if (yeartaken == 0 || isNaN(yeartaken) || yeartaken.length < 4){
							alert('You must enter a 4 digit, Numeric, Year Taken with no spaces!'); 
							return false;
						}
						else {
							if (fname.length < 2){
								alert('You must enter the Hunters First Name with at least 2 characters!'); 
								return false;
							}
							else {
								if (lname.length < 3){
									alert('You must enter the Hunters Last Name with at least 3 characters!'); 
									return false;
								}
								else {
									if (fpemail.length < 7){
										alert('You must enter the Hunters Email Address with at least 7 characters!'); 
										return false;
									}
									else {
										if (fieldstory.length < 25){
											alert('You must enter a story about the field photo, with at least 25 characters!'); 
											return false;
										}
										else {
											if (caption.length < 10){
												alert('You must enter a caption about the field photo , with at least 10 characters!'); 
												return false;
											}
											else{
												return true;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

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];}
}
