// Set Focus
function fokus(){
	try
	{
		document.frmPost.myTitle.focus();
	}
	catch(err)
	{}
}

<!-- Flip Images -->
function flipPhoto(position,smallSrc)
{
	//Get SRC
	var bigSrc = document.images['MainPhoto'].src;
	//Resize
	var resizedUp = smallSrc.replace("&w=150&h=100","&w=500&h=500&aoe=1&fltr[]=wmt|NoStrings.co.za|9|TR|000000|VERDANA.TTF|100");
	var resizedDown = bigSrc.replace("&w=500&h=500&aoe=1&fltr[]=wmt|NoStrings.co.za|9|TR|000000|VERDANA.TTF|100","&w=150&h=100");
	//Flip
	document.images['MainPhoto'].src = resizedUp;
	document.images[position].src = resizedDown;
}

// Entry Length
function entryLength(cat_id)
{
	//Title
	if(document.frmPost.myTitle.value.length < 1 || document.frmPost.myTitle.value=="Type a title for your advert here")
	{
		alert("Your advert MUST have a Title.");
		document.frmPost.myTitle.focus();
		return(false);
	}
	//Contact
	if(cat_id > 200){
		var tst1;
		tst1 = new RegExp("^0+[0-9]{9}$");
		if(!tst1.test(document.frmPost.myContact.value) && document.frmPost.myContact.value!="")
		{
			alert("You MUST provide a valid phone number.");
			document.frmPost.myContact.focus();
			return(false);
		}
		else if(document.frmPost.myContact.value.length != 10)
		{
			alert("A valid phone number is required.");
			document.frmPost.myContact.focus();
			return(false);
		}
	}
	//Content
	if(document.frmPost.myAd.value.length < 50 || document.frmPost.myAd.value.length > 3000)
	{
		alert("Adverts MUST be between 50 and 3000 characters.\nYour advert is "+document.frmPost.myAd.value.length+" character(s).\nPlease edit your advert and try again.");
		document.frmPost.myAd.focus();
		return(false);
	}
	//Email
	var tst2;
	tst2 = new RegExp("^[a-zA-Z0-9_\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$");
	if(!tst2.test(document.frmPost.myEmail.value) && document.frmPost.myEmail.value!="")
	{
		alert("Your Email Address seems to be invlaid. Please check it and try again.");
		document.frmPost.myEmail.focus();
		return(false);
	}
	else if(document.frmPost.myEmail.value=="")
	{
		alert("A valid E-mail Address is required.");
		document.frmPost.myEmail.focus();
		return(false);
	}
	document.frmPost.send.value = "Preparing... please wait";
	document.frmPost.send.disabled = true;
	document.frmPost.submit();
}

//A/C Edit Password check
function epCheck()
{
	if(document.frmPwd.oldPwd.value.length < 5 || document.frmPwd.chkPwd.value != document.frmPwd.newPwd.value)
	{
		alert("Your new password is not acceptable. Check that both new passwords match, and that you have supplied your old password.");
		document.frmPwd.oldPwd.value = "";
		document.frmPwd.newPwd.value = "";
		document.frmPwd.chkPwd.value = "";
		document.frmPwd.oldPwd.focus();
		return(false);
	}
	else if(document.frmPwd.newPwd.value=="")
	{
		alert("A new password is required.");
		document.frmPwd.newPwd.focus();
		return(false);
	}
	document.frmPwd.nxtStp.value = "Checking...";
	document.frmPwd.nxtStp.disabled = true;
	document.frmPwd.submit();
}

//A/C Creation Password check
function pCheck()
{
	if(document.frmAccount.myPwd.value.length < 5 || document.frmAccount.myPwd.value != document.frmAccount.myPwdC.value)
	{
		alert("Your password is not acceptable. Check that both passwords match.");
		document.frmAccount.myPwd.value = "";
		document.frmAccount.myPwdC.value = "";
		document.frmAccount.myPwd.focus();
		return(false);
	}
	else if(document.frmAccount.myPwd.value=="")
	{
		alert("A password is required.");
		document.frmAccount.myPwd.focus();
		return(false);
	}
	document.frmAccount.nxtStp.value = "Checking...";
	document.frmAccount.nxtStp.disabled = true;
	document.frmAccount.submit();
}

//A/C Creation Email check
function eCheck()
{
	//Email
	var tst2;
	tst2 = new RegExp("^[a-zA-Z0-9_\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$");
	if(!tst2.test(document.frmAccount.myEml.value) && document.frmAccount.myEml.value!="")
	{
		alert("Your Email Address seems to be invlaid. Please check it and try again.");
		document.frmAccount.myEml.focus();
		return(false);
	}
	else if(document.frmAccount.myEml.value=="")
	{
		alert("A valid E-mail Address is required.");
		document.frmAccount.myEml.focus();
		return(false);
	}
	document.frmAccount.nxtStp.value = "Checking...";
	document.frmAccount.nxtStp.disabled = true;
	document.frmAccount.submit();
}

// Ad Save
function adsave()
{
	document.frmAction.save.value = "Publishing... please wait";
	document.frmAction.save.disabled = true;
	window.location='scripts/post.php?save'
}

//Location Verification for Posting
function locVerify(prov,city)
{
	if(prov==0)
	{
		alert("Please select your Province in the location selector on the left.");
		return(false);
	}
	else if(city==0)
	{
		alert("Please select your City/Town in the location selector on the left.");
		return(false);
	}
	else
	{
		window.location="?post";
	}
}

function enlargePhoto(psrc,alt) {
	var resized = psrc.replace(/(w=)[0-9]{3}/,"w=700");
	resized = resized.replace(/(h=)[0-9]{3}/,"h=700");
	ovrly.dialog.show(700, 700, resized, alt, 1);
}

function myLoc(sSet){
	if(sSet==0){
		window.location = "?c=" + document.getElementById('areas').value;
	}
	else{
		window.location = "?s=" + document.getElementById('areas').value;
	}
}

function yOff() {
	var iebody = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
	//var dsocleft = document.all ? iebody.scrollLeft : pageXOffset;
	var dsoctop=document.all ? iebody.scrollTop : pageYOffset;
	return dsoctop;
}
