// RitterPhoto / bCOOP JavaScript
// Author : 2008/EJFIII Web Design

// Browser Brand Determination
	var isOP=false; var isIE=false; var isFF=false; var isNN=false;
	if (navigator.userAgent.indexOf("Opera")!=-1) isOP=true;
	if ((navigator.appName.indexOf("Microsoft")!=-1) && (navigator.userAgent.indexOf("Opera")==-1)) isIE=true;
	if (navigator.userAgent.indexOf("Firefox")!=-1) isFF=true;
	if ((navigator.appName.indexOf("Netscape")!=-1) && (navigator.userAgent.indexOf("Firefox")==-1)) isNN=true;

// Determine Available Screen Resolution
	function availWindow() {
		if (isIE) {
			viewWidth = document.documentElement.clientWidth;
  		}else{
   			viewWidth = window.innerWidth;
  			}
		return viewWidth;
		}

// Center Content on Screen
	function positionPresentation() {
		availWindow();
		posX = Math.floor((viewWidth-463)/2);
		document.getElementById("menu").style.left = posX+476+"px";
		document.getElementById("display").style.left = posX+"px";
		}

// Menu Tab Rollovers
	function onThumb(thumbID, onSource) {
		onSource = "images/"+onSource+"_on.jpg";
		document.getElementById(thumbID).src=onSource;
		}
	function offThumb(thumbID, offSource) {
		offSource = "images/"+offSource+"_off.jpg";
		document.getElementById(thumbID).src=offSource;
		}

//Verify Form Data
	function formVerify() {
		errorMsgClear();
		var errorCatch="";
		if (document.visitor.Name.value.length < 1) errorCatch+="A";					//error if Name empty
		if (document.visitor.Address.value.length < 3) errorCatch+="B";					//error if Address empty
		if (document.visitor.Telephone.value.length < 10) errorCatch+="C";				//error if Telephone empty
		if (document.visitor.Email.value.length < 1) errorCatch+="D";					//error if Email empty

		fieldValue=document.visitor.Email.value;
		if (fieldValue.length>0) {
			if (fieldValue.search("@") == -1) errorCatch+="D";					//error if @ not present in e-mail
			if (fieldValue.indexOf("@") < 1) errorCatch+="D";					//error if @ in first position
			if (fieldValue.charAt(fieldValue.length - 4) != ".") {
				if (fieldValue.charAt(fieldValue.length - 3) != ".") errorCatch+="D";		//error if . not placed correctly
				}			
			if (fieldValue.indexOf("@") == (fieldValue.lastIndexOf(".")-1)) errorCatch+="D";	//error if domain not present in e-mail
			}

		var n="";
		for (i=0; i < 3; i++) {
			if (document.visitor.RSVP[i].checked) n="yes";
			}
		if (n!="yes") errorCatch+="E";									//error if no checkboxes indicated
		if (document.visitor.RSVP[2].checked) {
			if (!document.visitor.RSVP[3].checked) errorCatch+="F";					//error if Exhibiting checked but not Terms
			}
									
		if (errorCatch!="") {
			for (i=0;i < errorCatch.length;i++) {
				errorCode=errorCatch.charAt(i);
				switch(errorCode) {
					case "A":
						document.getElementById("errorA").style.visibility='visible';
						break;
					case "B":
						document.getElementById("errorA").style.visibility='visible';
						break;
					case "C":
						document.getElementById("errorA").style.visibility='visible';
						break;
					case "D":
						document.getElementById("errorD").style.visibility='visible';
						break;
					case "E":
						document.getElementById("errorE").style.visibility='visible';
						break;
					case "F":
						document.getElementById("errorF").style.visibility='visible';
						break;
					default :
						document.getElementById("errorG").style.visibility='visible';
					}
				}
				document.visitor.Name.focus();
				return false;
			}
		else document.visitor.submit();	createpopUpWin();
		}

// Clear Form Error Messages
	function errorMsgClear() {
		document.getElementById("errorA").style.visibility='hidden';
		document.getElementById("errorD").style.visibility='hidden';
		document.getElementById("errorE").style.visibility='hidden';
		document.getElementById("errorF").style.visibility='hidden';
		return;
		}

// Pop Up Window Feature with Dynamically created content
	function createpopUpWin() {
		popUpWin=window.open("","coupon", "width=320px,height=420px,toolbar=0,status=0,menubar=0,scrollbars=0,resizable=1,location=0");
		popUpCode="<!DOCTYPE html PUBLIC\n'-//W3C//DTD XHTML 1.0 Transitional//EN'\n'http://www.w3.org/TR/xhtml1//DTD/xhtml1-transitional.dtd'>\n\n<html xmlns='http://www.w3.org/1999/xhtml'>\n<head>\n\n<meta http-equiv='content-type' content='text/html; charset=iso-8859-1' />\n<meta http-equiv='content-lauguage' content='en' />\n<meta http-equiv='imagetoolbar' content='no' />\n<meta name='robots' content='noindex,nofollow' />\n<meta name='author' content='EJFIIIWebDesign.com' />\n<meta name='copyright' content='EJFIIIWebDesign.com' />\n\n<title>bCOOP Reservation Coupon - The Beacon Art/Music Benefit Event</title>\n\n";
		popUpCode+="<link rel='stylesheet' href='bCOOPStyle.css' type='text/css' />\n\n</head>\n\n";
		popUpCode+="<body>\n<table cellspacing='0' cellpadding='0'>\n\t<tr>\n\t\t<td><img src='images/bCOOPticket.jpg' width='300px' height='70px' alt='' /></td>\n\t</tr>";
		popUpCode+="<tr>\n\t\t<td><br /><br />Name: "+document.visitor.Name.value+"<br />";
		if (document.visitor.Firm.value.length > 0) popUpCode+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+document.visitor.Firm.value+"<br />";
		popUpCode+="<br /><br />\n";
		var n="";
		for (i=0; i < 2; i++) {
			if (document.visitor.RSVP[i].checked) n="yes";
			}
		if (n == "yes") {
			popUpCode+="\t\t\tAttending: <br />\n";
			if (document.visitor.RSVP[0].checked) popUpCode+="\t\t\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DIA / Beacon Tour<br />\n";
			if (document.visitor.RSVP[1].checked) popUpCode+="\t\t\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b<span class='green'>COOP</span> Benefit Event<br />";
			}
		popUpCode+="<br /><br /></td>\n\t</tr><tr>\n\t\t<td class='bottom'>";
		if (document.visitor.RSVP[2].checked) {
			popUpCode+="<img src='images/exhibitorTicket.jpg' width='300px' height='48px' alt='' />";
		}else{
			popUpCode+="<img src='images/couponBottom.jpg' width='300px' height='48px' alt='' />";
			}
		popUpCode+="</td>\n\t</tr><tr>\n\t\t<td class='coupon'>Please print this coupon to speed up admittance.<br />Additional processing is required.</td>\n\t</tr>\n</table>\n\n";
		popUpCode+="<br /><center><input type='button' value='Print Coupon' onclick='window.print();' />\n<input type='button' value='Close Window' onclick='window.close();' /></center>\n\n</body></html>";
		popUpWin.document.write(popUpCode);
		popUpWin.document.close();
		}

// Set Default Window Status Message
	window.status=("bCOOP - The Beacon Art/Music Benefit Event");
