var oneclicktick = 0;
var oneclicktimer = 30000; // 30 seconds, change if required

function OneClick ()
{
var date = new Date();
	if (!oneclicktick || ((date.getTime() - oneclicktick ) > oneclicktimer))
	{
		oneclicktick = date.getTime();
		return true;
	}
	else
	{
		alert("This information has already been submitted\nPlease wait for the web site to respond");
		return false;
	}
	
}
function catBarChange( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#333333';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#CC3333';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#CC3333';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#CC3333';
				}
		}
	}
}
function FormChange ()
{
	tick = 0; // reset timer
}

function newWindow(newContent)
{
  winContent = window.open(newContent, 'nextWin', 'right=500, top=500,width=500,height=100, toolbar=no,scrollbars=no, resizable=no')         
}

function countchars(theText)
{
		intRemaining = 0;
		howMany = theText.value.length;
			
		if( howMany > 999 )
			theText.value = theText.value.substring(0, 999 );
		else
			document.forms.form2.counter.value = 999 - howMany;
}

function submitFormAction(vsPage,y,z){
	     	 		 
			 if (y == 'r')
			 {
			 	document.form2.action.value = y;
			 }
			 else if (y == 'u')
			 {
			 	document.form2.action.value = y;
			 }
			 else if (y == 'd')
			 {
			 	document.form2.action.value = y;
			 }
			 
			 if (z == 'I')
			 {
				document.form2.dest.value = z;
			 }
			 else if (z == 'S')
			 {
				 document.form2.dest.value = z;
			 }
			
			document.forms[0].submit();	
			
}

function submitThreadFormAction(vsPage,y,z){
	     	 		 
			 if (y == 'r')
			 {
			 	document.form2.action.value = y;
			 }
			 else if (y == 'u')
			 {
			 	document.form2.action.value = y;
			 }
			 else if (y == 'd')
			 {
			 	document.form2.action.value = y;
			 }
			 
			 if (z == 'I')
			 {
				document.form2.dest.value = z;
			 }
			 else if (z == 'S')
			 {
				 document.form2.dest.value = z;
			 }
			
			document.forms[0].submit();	
			
}

function mpMailBarChange( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#333333';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#999999';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#999999';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#999999';
				}
		}
	}
}

function mpNavBarClick( tableCellRef, navStyle, url ) {
	mpMailBarChange( tableCellRef, 0, navStyle );
	mp_goTo( url );
}

function mp_goTo( url ) {
	window.location.href = url;
}

function next()
{
	document.forms[0].next_2.value = 'true';
	document.forms[0].submit();	
}

function next3()
{
	document.forms[0].next_3.value = 'true';
	document.forms[0].submit();	
}

function next4()
{
	document.forms[0].next_4.value = 'true';
	document.forms[1].submit();	
}

function next5()
{
	document.forms[0].next_5.value = 'true';
	document.forms[0].submit();	
}

function submit5()
{
	document.forms[0].submit5.value = 'true';
	document.forms[0].submit();	
}

function confirmDelete(id)
{
  var r=confirm("Are you sure you want to delete this photo?")
  if (r==true)
  {
    deletePhoto(id);
  }
}
 
function confirmDefault(id)
{
  var r=confirm("Are you sure you want to make this photo your default photo?")
  if (r==true)
  {
    setAsDefault(id);
  }
}

function addAssocEvent()
{
var ni = document.getElementById('myAssocDiv');
var numi = document.getElementById('theAssocValue');
var num = (document.getElementById("theAssocValue").value -1)+ 2;
numi.value = num;
if (num < 2){

	var divIdName = "my"+num+"Div";
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName); 
	
	newdiv.innerHTML = "<table width=\"460\" height=\"100%\"  border=\"0\"><tr><td height=\"25\" colspan=\"2\" align=\"left\" valign=\"bottom\" class=\"style19\">Select the categories that you are willing to trade for your listing:</td></tr><tr><td width=\"50%\" height=\"25\" align=\"left\" class=\"style30\"><strong>Consumer Categories</strong></td><td width=\"50%\" align=\"left\" class=\"style30\"><strong>Business Categories</strong></td></tr><tr class=\"style27\"><td height=\"369\" valign=\"top\" class=\"style30\"><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-1\" />Antiques, Art &amp; Collectables<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-2\" />Autos &amp; Motorcycles<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-17\" />Books, CDs &amp; Movies<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-3\" />Business &amp; Office<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-4\" />Clothing &amp; Accessories<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-18\" />Colleges &amp; Universities<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-5\" />Computers &amp; Internet<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-6\" />Electronics &amp; Cameras<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-7\" />Entertainment<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-8\" />Home &amp; Garden<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-9\" />Jewelry &amp; Watches<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-10\" />Pets &amp; Animals<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-11\" />Real Estate<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-12\" />Services<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-13\" />Sports &amp; Outdoors<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-14\" />Toys, Games &amp; Hobbies<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-15\" />Travel<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"1-16\" />Other </td><td valign=\"top\" class=\"style30\"><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-1\" />Business &amp; Office<br /> <input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-2\" />Chemicals<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-3\" />Computers &amp; Internet<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-4\" />Construction<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-5\" />Consumer Goods<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-6\" />Electronics<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-7\" />Energy &amp; Mining<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-8\" />Entertainment &amp; Media<br /> <input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-9\" />Environment<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-10\" />Food &amp; Beverage<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-11\" />Forestry &amp; Agriculture<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-12\" />Industrial Supplies<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-13\" />Manufacturing &amp; Processing<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-14\" />Packaging<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-15\" />Printing &amp; Publishing<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-16\" />Professional Services <br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-17\" />Real Estate<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-18\" />Science &amp; Medicine <br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-19\" />Telecommunications<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-20\" />Textile &amp; Apparel <br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-21\" />Transportation &amp; Shipping<br /><input name=\"cat[]\" type=\"checkbox\" id=\"cat[]\" value=\"2-22\" />Other </td></tr></table>";
	
	ni.appendChild(newdiv);
	
}
}

function removeAssocEvent(divNum)
{
var numi = document.getElementById('theAssocValue');
var num = (document.getElementById("theAssocValue").value +1)-2;
numi.value = 0;
var d = document.getElementById('myAssocDiv');
var olddiv = document.getElementById(divNum);
d.removeChild(olddiv);

	
}

function noAcceptTrade(id)
{	
	document.forms[0].price_option[1].checked=true;
	removeAssocEvent(id);	
}

function selectAcceptTrade()
{	
	document.forms[0].accept_trade[1].checked=true;
	addAssocEvent();	
}

function deletePhoto(id)
{
	document.forms[0].image_id.value = id;
	document.forms[0].action_delete.value = '1';
	document.forms[0].submit();
}
function setAsDefault(id)
{
	document.forms[0].image_id.value = id;
	document.forms[0].action_set_default.value = '1';
	document.forms[0].submit();
	
}

function count()
{
var item1price = 12;
var item2price = 8;
var item3price = 10;
var item4price = 1;
var item5price = 1;
 
if (form2.option1 == null)
{
 var witem1 = 0;
}
else
{
 if (form2.option1.checked){
   var witem1 = item1price;
 } else {
   var witem1 = 0;
 }
}

if (form2.option2 == null)
{
 var witem2 = 0;
}
else
{
 if (form2.option2.checked){
   var witem2 = item2price;
 } else {
   var witem2 = 0;
 }
}

if (form2.option3 == null)
{
 var witem3 = 0;
}
else
{
 if (form2.option3.checked) {
   var witem3 = item3price;
 } else {
   var witem3 = 0;
 }
}

if (form2.option4 == null)
{
 var witem4 = 0;
}
else
{
 if (form2.option4.checked) {
   var witem4 = item4price;
 } else {
   var witem4 = 0;
 }
}

if (form2.option5 == null)
{
 var witem5 = 0;
}
else
{
 if (form2.option5.checked) {
   var witem5 = item4price;
 } else {
   var witem5 = 0;
 }
}

 document.form2.pay.value = witem1 + witem2 + witem3 + witem4 + witem5;
}