function selectedlocation(loc, cat)
{
//		if(cat != '')
//		{
//			cat="/cat/"+cat;
//		}
//		loc="/loc"+loc;
//		parent.location.href=loc+cat+"/post/";
		loc="/loc"+loc;
		cat="/cat/"+cat;	

			document.frmstep.action=loc+cat+"/post/";
			document.frmstep.cat.value=cat;
			document.frmstep.loc.value=loc;
			document.frmstep.step.value="1";
			document.frmstep.submit();

}

function selectedcategory(loc, cat)
{
		loc="/loc/"+loc;
		cat="/cat"+cat;	

			document.frmstep.action=loc+cat+"/post/";
			document.frmstep.cat.value=cat;
			document.frmstep.loc.value=loc;
			document.frmstep.step.value="2";
			document.frmstep.submit();
}
function tostep2()
{
	if(document.frmstep.loc.value !="")
	{
			document.frmstep.submit();		
	}
	else
	{
		alert('Please make a selection on a location and then proceed to the next step.');
	}
}
function backstep3(){
			document.frmstep.step.value="3";
			document.frmstep.submit();		
}
function tostep3()
{
	if(document.frmstep.cat.value !="")
	{
			document.frmstep.submit();		
	}
	else
	{
		alert('Please make a selection on a category and then proceed to the next step.');
	}
}

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
	
function tostep4()
{
	//validate all required form fields has a value.
	if(document.frmstep.title.value.trim() =="")
	{
		alert('Please enter a title for your ad.');
	}else if(document.frmstep.email.value.trim() =="")
	{		
		alert('Please enter your email address.');
	}else if(document.frmstep.confirm.value.trim() =="")
	{		
		alert('Please confirm your email address.');
	}else if(document.frmstep.email.value.trim() !=document.frmstep.confirm.value.trim())
	{		
		alert('Your email address does not match, please reenter your address correctly.');
	}else if(document.frmstep.description.value.trim() =="")
	{		
		alert('Please enter information for your ad description.');
	}else if(document.frmstep.confirmcode.value.trim() =="")
	{		
		alert('Please enter the confirmation code as displayed in the image.');
	}else if(document.frmstep.cat.value.trim() =="")
	{
		alert('Please make a selection on a category and then proceed to the next step.');
	}else if(document.frmstep.loc.value.trim() =="")
	{
		alert('Please make a selection on a location and then proceed to the next step.');
	}else if(document.frmstep.chkterms.checked==false)
	{
		alert('If you agree with our terms of use, please select the check box.');
	}
	else
	{


		if (echeck(document.frmstep.email.value)==false){
			document.frmstep.email.value=""
			document.frmstep.email.focus()
			return false
		}

			document.frmstep.submit();		
	}
}
function selecttab(i)
{
	if(i=="tab1")
	{
		document.getElementById("tab1").style.borderBottom="0px solid #ccc";
		document.getElementById("tab2").style.borderBottom="1px solid #ccc";
		document.getElementById("divcontent1").style.display='';
		document.getElementById("divcontent2").style.display='none';

	}else if(i=="tab2")
	{
		document.getElementById("tab1").style.borderBottom="1px solid #ccc";
		document.getElementById("tab2").style.borderBottom="0px solid #ccc";
		document.getElementById("divcontent1").style.display='none';
		document.getElementById("divcontent2").style.display='';
	}
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid email address.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid email address.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Please enter a valid email address.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Please enter a valid email address.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Please enter a valid email address.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Please enter a valid email address.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Please enter a valid email address.")
		    return false
		 }

 		 return true					
	}

