﻿// page_classified_ad_submission.jsp.js

//Script to count the number of chracters left for the text counter

  function CountLeft(field, count, max) 
  { 
  // if the length of the string in the input field is greater than the max value, trim it  
  if (field.value.length > max) 
  {
    field.value = field.value.substring(0, max); 
   
  }
  else 
     // calculate the remaining characters   
     count.value = max - field.value.length; 
     // if the maximum character is reached in the input fields then this will alert a message
     if(count.value == 0)
      alert('Please note you have reached the maximum allowed characters for this field');
  } 
  
// function to open a popup 
var newwindow;
function PopupWindow(e)
{
      newWindow = window.open("http://www.cpa2biz.com/Content/media/PRODUCER_CONTENT/generic_template_content/classifieds_example.jsp","NewWindow","width=750,height=800,resizable=yes," + "scrollbars=yes,location=no,toolbar=no");
      newWindow.focus();
}

// function to open  any specified url in a popup  
    
var newwindow1;
function Popup_Window(url)
{
	newwindow1=window.open(url,"NewWindow","width=750,height=800,resizable=yes," + "scrollbars=yes,location=no,toolbar=no");
	//if (window.focus) {newwindow.focus()}
    newwindow1.focus();
        
}
// To make sure the counter has the right value on page reload
function CheckCounterValue()
{
    var headline_length= document.getElementById("cad_headline").value.length;
    var bodytext_length= document.getElementById("cad_submission_body_text").value.length;
    document.getElementById("cad_counter1").value=60-headline_length;
    document.getElementById("cad_submission_counter2").value=400-bodytext_length;
        
 }

// alert maximum characters are reached
function AlertMsg(field,max)
{
if (field.value.length >= max) 
  {
    alert('Please note you have reached the maximum allowed characters for this field');
    field.value = field.value.substring(0, max); 
   
  }
 
}

