<!--
// image swapping function
function MM_findObj(n, d) { //v3.0
  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); return x;
}
/* Functions that swaps images. */
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];}
}
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;
}

/* Functions that handle preload. */
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];}}
}


// Check browser type and version
var bname = navigator.appName;
var bvers = navigator.appVersion;
bvers = parseFloat(bvers.substring(0,4));

//alert(bname+", "+bvers);

// Check the users screen resolution

if (bvers >= 4.0) {
	windowW = screen.width;
	windowH = screen.height;
	}
else {
	windowW = 640;
	windowH = 480;
}

var objPicWin, width, height, dir;

function OpenWin(width, height, file, dir) {

    width = new Number(width);
    height = new Number(height);
    dir = new String(dir);
    
    //determine X and Y coordinates
    X = (windowW - width) / 2;
    Y = (windowH - height) / 2;

	if (dir.length == 0 || dir == "undefined") {
        strURL = "/breeders/images/openimage.php?file=" + file;
	}
    else {
        strURL = "/breeders/images/openimage.php?file=" + dir + file;
    }
    
    //compensate for low resolutions
    if (width >= (windowW - 50) || height >= (windowH - 50)) {
        //compensate width
        if (width >= (windowW - 50)) {
            width = windowW - 50;
            X = 30;
        }
        //compensate height
        if (height >= (windowH - 50)) {
            height = windowH - 50;
        }
        strFeatures = "width="+width+",height="+height+",top=30,left="+X+",scrollbars";
    }
    else {
        strFeatures = "width="+width+",height="+height+",top=30,left="+X;
    }
    
    if (objPicWin == null || objPicWin.closed == true) {
        objPicWin = window.open(strURL,"PicWin",strFeatures);
        objPicWin.outerWidth = width;
        objPicWin.outerHeight = height;
        objPicWin.moveTo(X,30);
        objPicWin.focus();
	}
	else {
        objPicWin.close();
        objPicWin = window.open(strURL,"PicWin",strFeatures);
        objPicWin.outerWidth = width;
        objPicWin.outerHeight = height;
        objPicWin.moveTo(X,30);
        objPicWin.focus();
	}

}

var intSubmit = 0;
var bolSubmit = false;
/*
function fValidateForm(form) {
	var i, strErrors, bolChecked, x;
	strErrors = "";
	bolChecked = false;
	x = 0;
	
    for(i = 0; i < document.forms[form.name].length; i++)
    {
		// Validate all entries that are filled and require validation (email, phone #, etc.)
		if ((document.forms[form.name].elements[i].required == "yes" ||
			document.forms[form.name].elements[i].required == "email" || 
			document.forms[form.name].elements[i].required == "phone") && 
			document.forms[form.name].elements[i].value != "" && 
			document.forms[form.name].elements[i].type != "checkbox" && 
			document.forms[form.name].elements[i].type != "radio" )
		{
			if (document.forms[form.name].elements[i].required == "email")
			{
				// Check the email address to make sure it's valid
				if (!emailCheck (document.forms[form.name].elements[i].value, document.forms[form.name].elements[i]))
				{
					return false;
				}
			}
		}
		
		
		// Check all text boxes and select menus for values
		if ((document.forms[form.name].elements[i].required == "yes" ||
			document.forms[form.name].elements[i].required == "email" || 
			document.forms[form.name].elements[i].required == "phone") && 
			document.forms[form.name].elements[i].value == "" && 
			document.forms[form.name].elements[i].type != "checkbox" && 
			document.forms[form.name].elements[i].type != "radio" )
		{
			strErrors += "- " + document.forms[form.name].elements[i].ref + "\n";
		}
		// Check all radio button and checkbox groups for at least one selected item
		else if (document.forms[form.name].elements[i].required == "yes" && 
					(document.forms[form.name].elements[i].type == "checkbox" ||
					document.forms[form.name].elements[i].type == "radio"))
		{	
			// Loop through the groups items	
			for (x = 0; x < document.forms[form.name].elements[document.forms[form.name].elements[i].name].length; x++)
			{
				if (document.forms[form.name].elements[i+x].checked == true)
				{
					bolChecked = true;
				}
			}
			if (bolChecked == false)
			{
				strErrors += "- " + document.forms[form.name].elements[i].ref + "\n";
			}
			bolChecked = false;
			// Increment i so that it doesn't re-iterate through the rest of the items in that group
			i = i + x - 1;
		}
	}
	// Display message with list of missing fields
	if (strErrors != "") 
	{
		alert("You did not enter the following fields that are required:\n\n"+strErrors);
		return false;
	}
	// Prevent user from submitting form multiple times
	if (intSubmit == 0)
	{
		intSubmit++;
        bolSubmit = true;
		return true;
	}
	else
	{
		alert("You have already submitted this form.  Please wait for \nthe server to finish processing your submission");
		return false;
	}
}
*/
function FormCheck(form) {
var errmsg = "";
for (var i = 0; i < requiredEl.length; i++) {
    if (typeof form[requiredEl[i]] == "object") {
        var fieldName = (typeof form[requiredEl[i]].type == "undefined" && typeof form[requiredEl[i]].length != "undefined") ? form[requiredEl[i]][0] : form[requiredEl[i]];
        var fieldDisplayName = requiredStr[i].replace("_", " ");
        fieldDisplayName = (fieldDisplayName.charAt(0)).toUpperCase() + fieldDisplayName.substring(1, fieldDisplayName.length);
        if (fieldName.type.indexOf("text") != -1 && fieldName.value == "") {
            errmsg += fieldDisplayName + "\n";
        }
        if (fieldName.type.indexOf("select") != -1 && (fieldName.selectedIndex == -1 || fieldName[fieldName.selectedIndex].value == "")) {
            errmsg += fieldDisplayName + "\n";
        }
        if (fieldName.type == "radio" || fieldName.type == "checkbox") {
            if (typeof form[requiredEl[i]].length != "undefined") {
                for (var j = 0; j < form[requiredEl[i]].length; j++) {
                    if (form[requiredEl[i]][j].checked == true) {
                        break;
                    }
                    else if (j == form[requiredEl[i]].length - 1) {
                        errmsg += fieldDisplayName + "\n";
                    }
                }
            }
            else if (fieldName.checked == false) {
                errmsg += fieldDisplayName + "\n";
            }
        }
    }
}
return errmsg;
}

function CheckRequiredFields(form) {
var validateErr = "";
validateErr += FormCheck(form);
if (form.email.value != "") {
    var emailErr = emailCheck(form.email.value, form.email);
    if(emailErr != true) {
        return false;
        //validateErr += emailErr + "\n"};
    }
    if (validateErr != "") {
        alert(validateErr);
        return false;
    }
}
if (validateErr != "") {
    alert(validateErr);
    return false;
}
else {
    // Prevent user from submitting form multiple times
    if (intSubmit == 0)
    {
        intSubmit++;
        bolSubmit = true;
        return true;
    }
    else
    {
        alert("You have already submitted this form.  Please wait for \nthe server to finish processing your submission");
        return false;
    }
    //return true;
}
}

function emailCheck (emailStr, element) {
	//<!-- V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */

	var checkTLD=1;

	/* The following is the list of known TLDs that an e-mail address must end with. */

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */

	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */

	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {

		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */

		alert("Email address seems incorrect (check @ and .'s)");
		element.focus();
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).

	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			alert("This username ("+user+") in "+element.ref+" contains invalid characters.");
			element.focus();
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			alert("This domain name ("+domain+") in "+element.ref+" contains invalid characters.");
			element.focus();
			return false;
		}
	}

	// See if "user" is valid 

	if (user.match(userPat)==null) {

		// user is not valid

		alert("The username ("+user+") in "+element.ref+" doesn't seem to be valid.");
		element.focus();
		return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		// this is an IP address
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("Destination IP address ("+domain+") in "+element.ref+" is invalid!");
				element.focus();
				return false;
			}
		}
		return true;
	}

	// Domain is symbolic name.  Check if it's valid.
	 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			alert("The domain name ("+domArr[i]+") in "+element.ref+" does not seem to be valid.");
			element.focus();
			return false;
		}
	}

	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */

	if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("The address must end in a well-known domain or two letter " + "country.");
		element.focus();
		return false;
	}

	// Make sure there's a host name preceding the domain.

	if (len<2) {
		alert("This address is missing a hostname!");
		element.focus();
		return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}
//-->

