// JavaScript Document
// this function opens a window without any toolbars
function open_win(url,width,height) {
	window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width="+width+", height="+height)
}
function doNav(theUrl) {
	document.location.href = theUrl;
}
function ChangeColor(tableRow, highLight) {
	if (highLight) {
		tableRow.style.backgroundColor = '#9E9E9E';
		tableRow.style.cursor="pointer";
	} else {
		tableRow.style.backgroundColor = '#4B5056';
	}
}
function myFocus(element) {
   if (element.value == element.defaultValue) {
     element.value = '';
   }
 }
function myBlur(element) {
   if (element.value == '') {
     element.value = element.defaultValue;
   }
}
function pleaseWait(table,row,cell) {
	var x=document.getElementById(table).rows[row].cells;
	x[cell].innerHTML="Please Wait...";
}
function repeatDay(element) {
	if (element.checked) {
		var x=document.getElementById("repeat").rows["0"].cells;
		x["1"].innerHTML="&nbsp;&nbsp;&nbsp;Please choose the repeat day.&nbsp;&nbsp;&nbsp;<select name=\"repeat_day\" class=\"inputfield\" size=\"1\"><option>- select -</option><option value=\"0\">Sunday</option><option value=\"1\">Monday</option><option value=\"2\">Tuesday</option><option value=\"3\">Wednesday</option><option value=\"4\">Thursday</option><option value=\"5\">Friday</option><option value=\"6\">Saturday</option></select>";
	} else {
		var x=document.getElementById("repeat").rows["0"].cells;
		x["1"].innerHTML="&nbsp;";
	}
}
function registerInfo(element) {
	if (element.checked) {
		var x=document.getElementById("registerTable").rows["0"].cells;
		x["0"].innerHTML="<img src=\"images/spacer.gif\" width=\"100%\" height=\"5\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id='registerInfo'><tr><td align=\"right\" class=\"pagetext\" width='150'>Single Room:&nbsp;&nbsp;</td><td align=\"left\" class=\"pagetext\"><input type=\"text\" name='single' class='inputfield' size='20'><span class='required'>&nbsp;*</span</td></tr><tr><td colspan='2'><img src=\"images/spacer.gif\" width=\"100%\" height=\"5\"></td></tr><tr><td align=\"right\" class=\"pagetext\" width='150'>Double Room:&nbsp;&nbsp;</td><td align=\"left\" class=\"pagetext\"><input type=\"text\" name='double' class='inputfield' size='20'><span class='required'>&nbsp;*</span</td></tr><tr><td colspan='2'><img src=\"images/spacer.gif\" width=\"100%\" height=\"5\"></td></tr><tr><td align=\"right\" class=\"pagetext\" width='150'>Triple Room:&nbsp;&nbsp;</td><td align=\"left\" class=\"pagetext\"><input type=\"text\" name='triple' class='inputfield' size='20'><span class='required'>&nbsp;*</span</td></tr><tr><td colspan='2'><img src=\"images/spacer.gif\" width=\"100%\" height=\"5\"></td></tr><tr><td align=\"right\" class=\"pagetext\" width='150'>Quad Room:&nbsp;&nbsp;</td><td align=\"left\" class=\"pagetext\"><input type=\"text\" name='quad' class='inputfield' size='20'><span class='required'>&nbsp;*</span</td></tr><tr><td colspan='2'><img src=\"images/spacer.gif\" width=\"100%\" height=\"5\"></td></tr><tr><td align=\"right\" class=\"pagetext\" width='150'>Deposit:&nbsp;&nbsp;</td><td align=\"left\" class=\"pagetext\"><input type=\"text\" name='deposit' class='inputfield' size='20'><span class='required'>&nbsp;*</span</td></tr><tr><td colspan='2'><img src=\"images/spacer.gif\" width=\"100%\" height=\"5\"></td></tr><tr><td align=\"right\" class=\"pagetext\" width='150'>Deadline:&nbsp;&nbsp;</td><td align=\"left\" class=\"pagetext\"><input type=\"text\" name='deadline' class='inputfield' size='20'><span class='required'>&nbsp;*</span</td></tr><tr><td>&nbsp;</td><td align=\"left\" class=\"smalltext\">(yyyy-mm-dd)</td></tr></table>";
	} else {
		var x=document.getElementById("registerTable").rows["0"].cells;
		x["0"].innerHTML="<img src=\"images/spacer.gif\" width=\"100%\" height=\"5\">";
	}
}
function addField()
{
  var tbl = document.getElementById('registerInfo');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow - 1;

var a = tbl.insertRow(iteration)
a.innerHTML="<td align='right' class='pagetext'>Info Field:&nbsp;&nbsp;</td><td align='left' class='pagetext'>Name:&nbsp;<input type='text' name='field_name[]' id='field_name"+iteration+"' size='30' class='inputfield'>&nbsp;&nbsp;&nbsp;Size:&nbsp;<input type='text' name='size[]' id='size"+iteration+"' size='20' class='inputfield'>&nbsp;&nbsp;&nbsp;Required?&nbsp;<select name='requ[]' id='requ"+iteration+"' class='inputfield'><option>yes</option><option>no</option></select></td>"
}
function removeField()
{
  var tbl = document.getElementById('registerInfo');
  var lastRow = tbl.rows.length;
  if (lastRow > 4) tbl.deleteRow(lastRow - 2);
}
function paymentMethod() {
	var payment=document.getElementById("paymentmethod");
	if (payment.options[payment.selectedIndex].text == 'Credit Card') {
		var x=document.getElementById("payments").rows["0"].cells;
		x["0"].innerHTML='<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><img src="images/spacer.gif" width="100%" height="5" /></td></tr><tr><td align="right" class="pagetext">Credit Card #:&nbsp;&nbsp;</td><td align="left" class="required"><input type="text" name="cc" size="40" class="inputfield">&nbsp;*</td></tr><tr><td colspan="2"><img src="images/spacer.gif" width="100%" height="5" /></td></tr><tr><td align="right" class="pagetext" width="120">Exp. Date:&nbsp;&nbsp;</td><td align="left" class="required"><input type="text" name="expdate" size="15" class="inputfield">&nbsp;*</td></tr><tr><td>&nbsp;</td><td align="left" class="smalltext">(mmyy)</td></tr></table><img src="images/spacer.gif" width="100%" height="5">';
	} else if (payment.options[payment.selectedIndex].text == 'Check') {
		var x=document.getElementById("payments").rows["0"].cells;
		x["0"].innerHTML='<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><img src="images/spacer.gif" width="100%" height="5" /></td></tr><tr><td width="120">&nbsp;</td><td align="left" class="pagetext">Please send payment to:<br>3118 Nellita Road NW<br>Seabeck, WA 98380</td></tr><tr><td>&nbsp;</td><td align="left" class="smalltext">(This registration is not finished until we have received your check.  When the check has cleared, you will receive a confirmation email.)</td></tr></table><img src="images/spacer.gif" width="100%" height="5">';
	} else if (payment.options[payment.selectedIndex].text == 'Cash') {
		var x=document.getElementById("payments").rows["0"].cells;
		x["0"].innerHTML='<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><img src="images/spacer.gif" width="100%" height="5" /></td></tr><tr><td width="120">&nbsp;</td><td align="left" class="pagetext">Please send payment to:<br>3118 Nellita Road NW<br>Seabeck, WA 98380</td></tr><tr><td>&nbsp;</td><td align="left" class="smalltext">(This registration is not finished until we have received the correct payment.  You will receive a confirmation email once we have received the proper amount.)</td></tr></table><img src="images/spacer.gif" width="100%" height="5">';
	} else {
		var x=document.getElementById("payments").rows["0"].cells;
		x["0"].innerHTML='<img src="images/spacer.gif" width="100%" height="5">';
	}
}
function changeRoomSize() {
	var roomsize=document.getElementById("roomsize");
	if (roomsize.options[roomsize.selectedIndex].value == '1') {
		var price=document.getElementById("1").value;
		var x=document.getElementById("room").rows["0"].cells;
		x["1"].innerHTML='<input type="radio" name="payment" value="price">'+price+'<input type="hidden" name="price" value="'+price+'">';
	} else if (roomsize.options[roomsize.selectedIndex].value == '2') {
		var price=document.getElementById("2").value;
		var x=document.getElementById("room").rows["0"].cells;
		x["1"].innerHTML='<input type="radio" name="payment" value="price">'+price+'<input type="hidden" name="price" value="'+price+'">';
	} else if (roomsize.options[roomsize.selectedIndex].value == '3') {
		var price=document.getElementById("3").value;
		var x=document.getElementById("room").rows["0"].cells;
		x["1"].innerHTML='<input type="radio" name="payment" value="price">'+price+'<input type="hidden" name="price" value="'+price+'">';
	} else if (roomsize.options[roomsize.selectedIndex].value == '4') {
		var price=document.getElementById("4").value;
		var x=document.getElementById("room").rows["0"].cells;
		x["1"].innerHTML='<input type="radio" name="payment" value="price">'+price+'<input type="hidden" name="price" value="'+price+'">';
	} else {
		var x=document.getElementById("room").rows["0"].cells;
		x["1"].innerHTML='You must select a room size.';
	}
}
function deleteCat(cat) {
	var remove = confirm('Are you sure you want to delete this category?');
	if(remove == true) {
		doNav('products.php?action=process&section=delete_cat&id='+cat);	
	}
}
function deleteProduct(product) {
	var remove = confirm('Are you sure you want to delete this product?');
	if(remove == true) {
		doNav('products.php?action=process&section=delete&pid='+product);	
	}
}