/* Browser/platform checkers */
if (navigator.userAgent.indexOf('MSIE') != -1)
{
	var isIE = true;
	var isNS = false;
	var isMoz = false;	
} 
else if (navigator.userAgent.indexOf('Netscape') != -1)
{
		var isNS = true;
		var isIE = false;
		var isMoz = false;		
}
else if (navigator.userAgent.indexOf('Mozilla') != -1)
{
		var isNS = false;
		var isIE = false;
		var isMoz = true;		
}

var isWin = navigator.userAgent.indexOf("Win") != -1;
var isMac = navigator.userAgent.indexOf("Mac") != -1;
var isUnix = navigator.userAgent.indexOf("X11") != -1;

/* Make a combo variable to identify */
var iBPmix = 0;
if (isWin)
{
	if (isIE)
	{
		iBPmix = 1;
	}
	if (isNS)
	{
		iBPmix = 2;
	}
	if (isMoz)
	{
		iBPmix = 5;
	}
}
if (isMac)
{
	if (isIE)
	{
		iBPmix = 3;
	}
	if (isNS)
	{
		iBPmix = 4;
	}
	if (isMoz)
	{
		iBPmix = 6;
	}
}

function showBig(picname, caption)
{
	var winID = window.open('/showpic.asp?pic=' + picname + '&cap=' + caption, 'bigpic', 'width=100,height=100,scrollbars=no,resizable=yes');
}

function showBigNoCap(picname)
{
	var winID = window.open('/showpic.asp?pic=' + picname, 'bigpic', 'width=100,height=100,scrollbars=no,resizable=yes');
}

function showBigNonGal(pageID, picNum)
{
	var winID = window.open('/showpic.asp?pid=' + pageID + '&pnum=' + picNum, 'bigpic', 'width=100,height=100,scrollbars=no,resizable=yes');
}

function showPopUp(page)
{
	var popUp = window.open( page, 'popup', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=yes,width=350,height=250');
}

function checkrequired( formname) {

	var pass=0, box=0, theForm;
	theForm = document.forms[formname];

	if (document.images) {
		for (i=0; i < theForm.length; i++) {
			var tempobj=theForm.elements[i];
			if (tempobj.name.substring(0,1) == "*") {
						
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&
				tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
				tempobj.selectedIndex==0)) {
					pass=1;
					break;
	      }
	    } 
		}
		
		if (pass==1) {		
			shortFieldName=tempobj.name.substring(1,30).toUpperCase();
			alert("Please make sure the "+shortFieldName+" field is properly filled in.");
			tempobj.focus();
		} else {
			theForm.submit();
		}
	}			
}

function process_imgs_links(img, caption) {
	if (isNS) { // handle NS
		document.bigimg.src = img;
		document.bigimg.alt = caption;
	} else if (isIE) { //handle IE
		document.all.bigimg.src = img;
		document.all.bigimg.alt = caption;
	} else { // Handle Mozilla
		document.getElementById("bigimg").src = img;
		document.getElementById("bigimg").alt = caption;
	}
}
function xxprocess_imgs_links(img, caption)
{
	alert(document.getElementById('bigimg').src);
}

function setFocusOn( sform, sfield) {
	var sForm = document.forms[sform];
	sForm.elements[sfield].focus();
}

function emailCheck(thisControl)
{
	var emailStr = thisControl.value
	
	if (emailStr != "") {
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null)
		{
			alert("Email address seems incorrect (check @ and .'s)")
			thisControl.select()
	  	thisControl.focus()
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]
	
		if (user.match(userPat)==null)
		{
			alert("The username doesn't seem to be valid.")
			thisControl.select()
	  	thisControl.focus()
			return false
		}
	
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null)
		{
			for (var i=1;i<=4;i++)
			{
				if (IPArray[i]>255)
				{
					alert("Destination IP address is invalid.")
					thisControl.select()
		 	 		thisControl.focus()
					return false				
				}
			}
			return true
		}
	
		var domainArray=domain.match(domainPat)
		if (domainArray==null)
		{
			alert("The domain name doesn't seem to be valid.")
			thisControl.select()
	  	thisControl.focus()
			return false		
		}
	
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
		{
			alert("The address must end in a three-letter domain, or two letter country.")
			thisControl.select()
	  	thisControl.focus()
			return false
		}
	
		if (len<2)
		{
			var errStr="This address is missing a hostname!"
			alert(errStr)
			thisControl.select()
	  	thisControl.focus()
			return false
		}
		return true;
	} else {
		return false;
	}
}