﻿// JavaScript Document

function notloggedin() {
	alert("You need to be Registered and Logged in to use this feature.. Join Now by clicking on the log in link at the top of the website");
	$('#login_content').slideToggle();
}
function clearits()
{
var panel = document.getElementById('s');
panel.value='';
panel.focus();
} 

function clearits2()
{
var panel = document.getElementById('s');
panel.value='';
panel.focus();
} 

function clearitc()
{
var panel = document.getElementById('comment');
panel.value='';
panel.focus();
} 

function setHome()
{
   document.body.style.behavior='url(#default#homepage)';
   document.body.setHomePage(window.location.href);
}

function clearitreg()
{
var panel = document.getElementById('suburbreg');
panel.value='';
panel.focus();
}

function clearitcat()
{
var panel = document.getElementById('clearcat');
panel.value='';
panel.focus();
}

function check_blockquote1(listing_form, maxLen) 
{
if (listing_form.blockquote1.value.length > maxLen) {
listing_form.blockquote1.value = listing_form.blockquote1.value.substring(0, maxLen);
listing_form.blockchars1.value = "none";
}
else{ 
listing_form.blockchars1.value = maxLen - listing_form.blockquote1.value.length - 1;

	}
	if (listing_form.blockchars1.value < 1){ 
	listing_form.blockchars1.value = 0;
	}
	
}

function check_blockquote2(listing_form, maxLen) 
{
if (listing_form.blockquote2.value.length > maxLen) {
listing_form.blockquote2.value = listing_form.blockquote2.value.substring(0, maxLen);
listing_form.blockchars2.value = "none";
}
else{ 
listing_form.blockchars2.value = maxLen - listing_form.blockquote2.value.length - 1;

	}
	if (listing_form.blockchars2.value < 1){ 
	listing_form.blockchars2.value = 0;
	}	
}

function check_length(listing_form, maxLen)
{
if (listing_form.wpx_description.value.length > maxLen) {
listing_form.wpx_description.value = listing_form.wpx_description.value.substring(0, maxLen);
listing_form.text_num.value = "none";
}
else{ 
listing_form.text_num.value = maxLen - listing_form.wpx_description.value.length - 1;

	}
	if (listing_form.text_num.value < 1){ 
	listing_form.text_num.value = 0;
	}
	
}


function check_length01(listing_form, maxLen)
{
if (listing_form.description1.value.length > maxLen) {
listing_form.description1.value = listing_form.description1.value.substring(0, maxLen);
listing_form.chars1.value = "none";
}
else{ 
listing_form.chars1.value = maxLen - listing_form.description1.value.length - 1;

	}
	if (listing_form.chars1.value < 1){ 
	listing_form.chars1.value = 0;
	}
	
}

function check_length02(listing_form, maxLen)
{
if (listing_form.description2.value.length > maxLen) {
listing_form.description2.value = listing_form.description2.value.substring(0, maxLen);
listing_form.chars2.value = "none";
}
else{ 
listing_form.chars2.value = maxLen - listing_form.description2.value.length - 1;

	}
	if (listing_form.chars2.value < 1){ 
	listing_form.chars2.value = 0;
	}
	
}

function check_length03(listing_form, maxLen)
{
if (listing_form.description3.value.length > maxLen) {
listing_form.description3.value = listing_form.description3.value.substring(0, maxLen);
listing_form.chars3.value = "none";
}
else{ 
listing_form.chars3.value = maxLen - listing_form.description3.value.length - 1;

	}
	if (listing_form.chars3.value < 1){ 
	listing_form.chars3.value = 0;
	}
	
}

function check_length04(listing_form, maxLen)
{
if (listing_form.description4.value.length > maxLen) {
listing_form.description4.value = listing_form.description4.value.substring(0, maxLen);
listing_form.chars4.value = "none";
}
else{ 
listing_form.chars4.value = maxLen - listing_form.description4.value.length - 1;

	}
	if (listing_form.chars4.value < 1){ 
	listing_form.chars4.value = 0;
	}
	
}
function check_length05(listing_form, maxLen)
{
if (listing_form.description5.value.length > maxLen) {
listing_form.description5.value = listing_form.description5.value.substring(0, maxLen);
listing_form.chars5.value = "none";
}
else{ 
listing_form.chars5.value = maxLen - listing_form.description5.value.length - 1;

	}
	if (listing_form.chars5.value < 1){ 
	listing_form.chars5.value = 0;
	}
	
}

function check_length06(listing_form, maxLen)
{
if (listing_form.description6.value.length > maxLen) {
listing_form.description6.value = listing_form.description6.value.substring(0, maxLen);
listing_form.chars6.value = "none";
}
else{ 
listing_form.chars6.value = maxLen - listing_form.description6.value.length - 1;

	}
	if (listing_form.chars6.value < 1){ 
	listing_form.chars6.value = 0;
	}
	
}

function check_length07(listing_form, maxLen)
{
if (listing_form.description7.value.length > maxLen) {
listing_form.description7.value = listing_form.description7.value.substring(0, maxLen);
listing_form.chars7.value = "none";
}
else{ 
listing_form.chars7.value = maxLen - listing_form.description7.value.length - 1;

	}
	if (listing_form.chars7.value < 1){ 
	listing_form.chars7.value = 0;
	}
	
}

function check_length08(listing_form, maxLen)
{
if (listing_form.description8.value.length > maxLen) {
listing_form.description8.value = listing_form.description8.value.substring(0, maxLen);
listing_form.chars8.value = "none";
}
else{ 
listing_form.chars8.value = maxLen - listing_form.description8.value.length - 1;

	}
	if (listing_form.chars8.value < 1){ 
	listing_form.chars8.value = 0;
	}
	
}

function check_length09(listing_form, maxLen)
{
if (listing_form.description9.value.length > maxLen) {
listing_form.description9.value = listing_form.description9.value.substring(0, maxLen);
listing_form.chars9.value = "none";
}
else{ 
listing_form.chars9.value = maxLen - listing_form.description9.value.length - 1;

	}
	if (listing_form.chars9.value < 1){ 
	listing_form.chars9.value = 0;
	}
	
}

function check_length10(listing_form, maxLen)
{
if (listing_form.description10.value.length > maxLen) {
listing_form.description10.value = listing_form.description10.value.substring(0, maxLen);
listing_form.chars10.value = "none";
}
else{ 
listing_form.chars10.value = maxLen - listing_form.description10.value.length - 1;

	}
	if (listing_form.chars10.value < 1){ 
	listing_form.chars10.value = 0;
	}
	
}

function check_length11(listing_form, maxLen)
{
if (listing_form.description11.value.length > maxLen) {
listing_form.description11.value = listing_form.description11.value.substring(0, maxLen);
listing_form.chars11.value = "none";
}
else{ 
listing_form.chars11.value = maxLen - listing_form.description11.value.length - 1;

	}
	if (listing_form.chars11.value < 1){ 
	listing_form.chars11.value = 0;
	}
	
}

function check_speciallength(listing_form, maxLen) 
{
if (listing_form.wpx_special_offer.value.length > maxLen) {
listing_form.wpx_special_offer.value = listing_form.wpx_special_offer.value.substring(0, maxLen);
listing_form.text_numsp.value = "none";
}
else{ 
listing_form.text_numsp.value = maxLen - listing_form.wpx_special_offer.value.length - 1;

	}
	if (listing_form.text_numsp.value < 1){ 
	listing_form.text_numsp.value = 0;
	}
	
}

function check_termslength(listing_form, maxLen) 
{
if (listing_form.wpx_special_terms.value.length > maxLen) {
listing_form.wpx_special_terms.value = listing_form.wpx_special_terms.value.substring(0, maxLen);
listing_form.text_terms.value = "none";
}
else{ 
listing_form.text_terms.value = maxLen - listing_form.wpx_special_terms.value.length - 1;

	}
	if (listing_form.text_terms.value < 1){ 
	listing_form.text_terms.value = 0;
	}
	
}

function check_longlength(listing_form, maxLen)
{
if (listing_form.wpx_description2.value.length > maxLen) {
listing_form.wpx_description2.value = listing_form.wpx_description2.value.substring(0, maxLen);
listing_form.text_num2.value = "none";
}
else{ 
listing_form.text_num2.value = maxLen - listing_form.wpx_description2.value.length - 1;

	}
	if (listing_form.text_num2.value < 1){ 
	listing_form.text_num2.value = 0;
	}
	
}

function check_longlength2(listing_form, maxLen)
{
if (listing_form.wpx_description3.value.length > maxLen) {
listing_form.wpx_description3.value = listing_form.wpx_description3.value.substring(0, maxLen);
listing_form.text_num3.value = "none";
}
else{ 
listing_form.text_num2.value = maxLen - listing_form.wpx_description2.value.length - 1;

	}
	if (listing_form.text_num2.value < 1){ 
	listing_form.text_num2.value = 0;
	}
	
}

function check_dirlength(listing_form, maxLen)
{
if (listing_form.directions.value.length > maxLen) {
listing_form.directions.value = listing_form.directions.value.substring(0, maxLen);
listing_form.text_numdir.value = "none";
}
else{ 
listing_form.text_numdir.value = maxLen - listing_form.directions.value.length - 1;

	}
	if (listing_form.text_numdir.value < 1){ 
	listing_form.text_numdir.value = 0;
	}
	
}

function check_address(listing_form, maxLen)
{
if (listing_form.address.value.length > maxLen) {
listing_form.address.value = listing_form.address.value.substring(0, maxLen);
listing_form.text_numad.value = "none";
}
else{ 
listing_form.text_numad.value = maxLen - listing_form.address.value.length - 1;

	}
	if (listing_form.text_numad.value < 1){ 
	listing_form.text_numad.value = 0;
	}
	
}

function check_postal(listing_form, maxLen)
{
if (listing_form.postal.value.length > maxLen) {
listing_form.postal.value = listing_form.postal.value.substring(0, maxLen);
listing_form.text_numpost.value = "none";
}
else{ 
listing_form.text_numpost.value = maxLen - listing_form.postal.value.length - 1;

	}
	if (listing_form.text_numpost.value < 1){ 
	listing_form.text_numpost.value = 0;
	}
	
}

function check_lengthkey(listing_form, maxLen)
{
if (listing_form.wpx_keyline.value.length > maxLen) {
listing_form.wpx_keyline.value = listing_form.wpx_keyline.value.substring(0, maxLen);
listing_form.text_num_keyline.value = "none";
}
else{ 
listing_form.text_num_keyline.value = maxLen - listing_form.wpx_keyline.value.length - 1;

	}
	if (listing_form.text_num_keyline.value < 1){ 
	listing_form.text_num_keyline.value = 0;
	}
	
}







function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength){
alert('You have reached your maximum limit of characters allowed');
obj.value=obj.value.substring(0,mlength)
}
}

// textarea mce

function textarea_bold(description){
  var $tb = document.getElementById(description);
 
  if (document.selection){
    var str=document.selection.createRange().text;
    var sel=document.selection.createRange();
    sel.text="[b]"+str+"[/b]";
  }else if (typeof $tb.selectionStart != 'undefined'){
    var $before, $after, $selection;
    $before= $tb.value.substring(0, $tb.selectionStart)
    $selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd)
    $after = $tb.value.substring($tb.selectionEnd, $tb.value.length)
 
    $tb.value= String.concat($before, "[b]", $selection, "[/b]", $after)
  }
   $tb.focus();
 
}

function textarea_italic(description){
  var $tb = document.getElementById(description);
 
  if (document.selection){
    var str=document.selection.createRange().text;
    var sel=document.selection.createRange();
    sel.text="[i]"+str+"[/i]";
  }else if (typeof $tb.selectionStart != 'undefined'){
    var $before, $after, $selection;
    $before= $tb.value.substring(0, $tb.selectionStart)
    $selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd)
    $after = $tb.value.substring($tb.selectionEnd, $tb.value.length)
 
    $tb.value= String.concat($before, "[i]", $selection, "[/i]", $after)
  }
   $tb.focus();
 
}

function textarea_url(description){
  var $tb = document.getElementById(description);
 
  if (document.selection){
    var str=document.selection.createRange().text;
    var sel=document.selection.createRange();
    sel.text="[url=]"+str+"[/url]";
  }else if (typeof $tb.selectionStart != 'undefined'){
    var $before, $after, $selection;
    $before= $tb.value.substring(0, $tb.selectionStart)
    $selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd)
    $after = $tb.value.substring($tb.selectionEnd, $tb.value.length)
 
    $tb.value= String.concat($before, "[url=]", $selection, "[/url]", $after)
  }
   $tb.focus();
 
}

function textarea_h2(description){
  var $tb = document.getElementById(description);
 
  if (document.selection){
    var str=document.selection.createRange().text;
    var sel=document.selection.createRange();
    sel.text="[h]"+str+"[/h]";
  }else if (typeof $tb.selectionStart != 'undefined'){
    var $before, $after, $selection;
    $before= $tb.value.substring(0, $tb.selectionStart)
    $selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd)
    $after = $tb.value.substring($tb.selectionEnd, $tb.value.length)
 
    $tb.value= String.concat($before, "[h]", $selection, "[/h]", $after)
  }
   $tb.focus();
 
}

function textarea_youtube(description){
  var $tb = document.getElementById(description);
 
  if (document.selection){
    var str=document.selection.createRange().text;
    var sel=document.selection.createRange();
    sel.text="[youtube]"+str+"[/youtube]";
  }else if (typeof $tb.selectionStart != 'undefined'){
    var $before, $after, $selection;
    $before= $tb.value.substring(0, $tb.selectionStart)
    $selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd)
    $after = $tb.value.substring($tb.selectionEnd, $tb.value.length)
 
    $tb.value= String.concat($before, "[youtube]", $selection, "[/youtube]", $after)
  }
   $tb.focus();
 
}

function textarea_googlevideo(description){
  var $tb = document.getElementById(description);
 
  if (document.selection){
    var str=document.selection.createRange().text;
    var sel=document.selection.createRange();
    sel.text="[googlevideo]"+str+"[/googlevideo]";
  }else if (typeof $tb.selectionStart != 'undefined'){
    var $before, $after, $selection;
    $before= $tb.value.substring(0, $tb.selectionStart)
    $selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd)
    $after = $tb.value.substring($tb.selectionEnd, $tb.value.length)
 
    $tb.value= String.concat($before, "[googlevideo]", $selection, "[/googlevideo]", $after)
  }
   $tb.focus();
 
}

// EMAIL RUNTIME RENDER

//  var contact = "info&#64;harkerville.co.za"
//  var email = "info"
//  var emailHost = "harkerville.co.za"
//  document.write("<a href=" + "mail" + "to:" + email + "@" + emailHost+ ">" + contact + "</a>")
