// JavaScript Document
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
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_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];}}
}

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];}
}

function copyInfo2(chk){
  if (chk.checked == 1) {
	   document.getElementById("First_Name_Contact").value = document.getElementById("First_Name_Planner").value;
	   document.getElementById("Last_Name_Contact").value = document.getElementById("Last_Name_Planner").value;
	   document.getElementById("eMail_Contact").value = document.getElementById("eMail_Planner").value;
  }
}

function termCheck(chk) {
	if (chk.checked == 1)
		{
			 document.getElementById("Submit").disabled = false;
		}
}

function copyInfo(chk){
  if (chk.checked == 1) {
  document.getElementById("First_Name_Publication").value = document.getElementById("First_Name_Contact").value;
  document.getElementById("Last_Name_Publication").value = document.getElementById("Last_Name_Contact").value;
  document.getElementById("Company_Publication").value = document.getElementById("Company_Contact").value;
  document.getElementById("Address1_Publication").value = document.getElementById("Address1_Contact").value;
  document.getElementById("Address2_Publication").value = document.getElementById("Address2_Contact").value;
  document.getElementById("City_Publication").value = document.getElementById("City_Contact").value;
  document.getElementById("State_Publication").value = document.getElementById("State_Contact").value;
  document.getElementById("Zip_Publication").value = document.getElementById("Zip_Contact").value;
  document.getElementById("Phone_Publication").value = document.getElementById("Phone_Contact").value;
  document.getElementById("FAX_Publication").value = document.getElementById("FAX_Contact").value;
  }
 }
 
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function boothPrice() {
	 document.getElementById("Price").value = document.getElementById("ExhibitPackage").value;
	 document.getElementById("BoothSizeCurrent").value = '10 x 10';
	 document.getElementById("boothSize").value = '10 x 10';
	 
	 var select_list_field = document.getElementById('ExhibitPackage');
	 var select_list_selected_index = select_list_field.selectedIndex;
		
	 var text = select_list_field.options[select_list_selected_index].text;
	 var value = select_list_field.value;
	 
	 if (select_list_field.options[select_list_selected_index].text == 'Island') {
		 	document.getElementById("boothSize").disabled = true;
			document.getElementById("BoothSizeCurrent").value = '20 x 20';
	 }
	else if (select_list_field.options[select_list_selected_index].text == 'Exhibitor Plus'){
		document.getElementById("boothSize").disabled = false;
	}
	else if (select_list_field.options[select_list_selected_index].text == 'Exhibitor'){ 
		document.getElementById("boothSize").disabled = false;
	}
	else if (document.getElementById("ExhibitPackage").value == '0'){
		document.getElementById("boothSize").disabled = false;
	}
}

function calcTickets(){
	count = +document.getElementById("Tickets").value;
	
	if (count != 0) {
	TicketPrice = count * 25;
	}
	else if (count == 0) {
		TicketPrice = 0;
	}
	subTotal = +document.getElementById("Price").value + TicketPrice;
	
	document.getElementById("Price").value = subTotal;
	
}

function resetPrice() {
	document.getElementById("Tickets").value = '0';
	document.getElementById("public").value = '0';
	document.getElementById("Price").value = document.getElementById("ResetPrice").value;
	
}

function calcbooth(){
	size = document.getElementById("boothSize").value;
	
	
	if (size == '10 x 10')
		{
			priceNew = document.getElementById("ExhibitPackage").value;
		}
	else if (size == '10 x 20')
		{
			price = +document.getElementById("ExhibitPackage").value;
			priceNew = price + price;
		}
	else if (size == '10 x 30')
		{
			price = +document.getElementById("ExhibitPackage").value;
			priceNew = price + (price * 2);
		}
	else if (size == '10 x 40')
		{
			price = +document.getElementById("ExhibitPackage").value;
			priceNew = price + (price * 3);
		}
	else if (size == '10 x 50')
		{
			price = +document.getElementById("ExhibitPackage").value;
			priceNew = price + (price * 4);
		}
	 document.getElementById("Price").value = priceNew;
	 document.getElementById("BoothSizeCurrent").value = size;
}



function addEvent(elm, evType, fn, useCapture){if(elm.addEventListener){elm.addEventListener(evType, fn, useCapture);return true;}else if (elm.attachEvent){var r = elm.attachEvent('on' + evType, fn);return r;}else{elm['on' + evType] = fn;}}
			var newWindow = null;

			function closeWin(){
				if (newWindow != null){
					if(!newWindow.closed)
						newWindow.close();
				}
			}

			function popUpWin(url, type, strWidth, strHeight){

				closeWin();

				type = type.toLowerCase();

				if (type == "fullscreen"){
					strWidth = screen.availWidth;
					strHeight = screen.availHeight;
				}
				var tools="";
				if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
				if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
				newWindow = window.open(url, "newWin", tools);
				newWindow.focus();
			}

			function doPopUp(e)
			{
			//set defaults - if nothing in rel attrib, these will be used
			var t = "standard";
			var w = "780";
			var h = "580";
			//look for parameters
			attribs = this.rel.split(" ");
			if (attribs[1]!=null) {t = attribs[1];}
			if (attribs[2]!=null) {w = attribs[2];}
			if (attribs[3]!=null) {h = attribs[3];}
			//call the popup script
			popUpWin(this.href,t,w,h);
			//cancel the default link action if pop-up activated
			if (window.event) 
				{
				window.event.returnValue = false;
				window.event.cancelBubble = true;
				} 
			else if (e) 
				{
				e.stopPropagation();
				e.preventDefault();
				}
			}

			function findPopUps()
			{
			var popups = document.getElementsByTagName("a");
			for (i=0;i<popups.length;i++)
				{
				if (popups[i].rel.indexOf("popup")!=-1)
					{
					// attach popup behaviour
					popups[i].onclick = doPopUp;
					// add popup indicator
					if (popups[i].rel.indexOf("noicon")==-1)
						{
						popups[i].style.backgroundImage = "url(pop-up.gif)";
						popups[i].style.backgroundPosition = "0 center";
						popups[i].style.backgroundRepeat = "no-repeat";
						popups[i].style.paddingLeft = "15px";
						}
					// add info to title attribute to alert fact that it's a pop-up window
					popups[i].title = popups[i].title + " [Opens in pop-up window]";
					}
				}
			}

			addEvent(window, "load", findPopUps, false);
			
			
			
function calcPub() { 
	cost = +document.getElementById("public").value;
	
	
	subTotal = +document.getElementById("Price").value + cost;
	
	document.getElementById("Price").value = subTotal;
}

function changeText(){
	 if (document.getElementById("Elect").value  == "Yes") {
		 document.getElementById("Electrical").innerHTML = '<input type="checkbox" name="tele-cpu" id="tele-cpu"> Television or Laptop<br /><input name="lighting4Less" type="checkbox" value="lighting4Less" id="lighting4Less"> Exhibit Lighting (less than 4 individual lights)<br /><input name="lighting4More" type="checkbox" value="lighting4More" id="lighting4More"> Exhibit Lighting (more than 4 individual lights)<br /><input name="motorSmall" type="checkbox" value="motorSmall" id="motorSmall"> Small motor (1 horse power/10 amps or less)<br /><input name="motorBig" type="checkbox" value="motorBig" id="motorBig"> Bigger motor (requires more than 10 amps to run)<br /> <input name="electOther" type="checkbox" value="1" id="electOther"> Other: <input name="electOtherDefined" type="text" id="electOtherDefined"><br /><input name="" type="submit" value="Next">';
	 }
	
}
