
function Highlight_Field(control_id){
   var ITSMHighlightFieldColor = "#FFFFFF";
   var jjsfieldname = document.getElementById(control_id);
   jjsfieldname.style.backgroundColor = ITSMHighlightFieldColor;
} //end Function
//=============================================================

function No_Highlight_Field(control_id){
   var ITSMBaseFieldColor = "#F4D1A7";
   var jjsfieldname = document.getElementById(control_id);
   jjsfieldname.style.backgroundColor = ITSMBaseFieldColor;
} //end Function
//=============================================================

function toggleform(){
   var jjscheckbox = document.getElementById("cb_agree");
   var dumobj = null;
   var dumstr = null;
   var x = null;  //loop counter
   if(jjscheckbox.checked == true){
      Enable_Form();
   } else{
      Disable_Form();
   }  //end if
}  //end function
//=============================================================

function Enable_Form(){
//just enable
   var dumobj = null;

   document.getElementById("cb_agree").checked=true;

   dumobj=document.getElementById('reset');
   dumobj.disabled=false;
   dumobj.enabled=true;

   dumobj=document.getElementById('submitform');
   dumobj.disabled=false;
   dumobj.enabled=true;

}  //end function
//=============================================================

function Disable_Form(){
//just disable
   var dumobj = null;
   
   document.frmformfields.reset;
   document.getElementById("cb_agree").checked=false;

   dumobj=document.getElementById('reset');
   dumobj.disabled=true;
   dumobj.enabled=false;

   dumobj=document.getElementById('submitform');
   dumobj.disabled=true;
   dumobj.enabled=false;

}  //end function
//=============================================================

function Reset_Form(){
//clear and disable
   Disable_Form();

}  //end function
//=============================================================
/************************************checkenterkey(evt)*************/
function checkenterkey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode == 13)
{
return false;
}
else
{
 return true;
}
}

/*********************************************************/
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf('@')
dotpos=value.lastIndexOf('.')
if (apos<1||dotpos-apos<2)
 {
alert(alerttxt);
return false;
 }
else
{
return true;
}
}
}
/***********************************************************************/
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=='')
{
alert(alerttxt);
return false;
}
else
{
return true;
}
}
}
/***********************************************************************/
function check_form_fields(ctrvar)
{
var frm= document.frmformfields;
if (validate_required(frm.email,'Please make sure the Email Address field is not left blank.')==false)
{
 frm.email.focus();
return false;
}
if(validate_email(frm.email,'Please make sure that you have provided a valid email address.')==false)
{
frm.email.focus();
return false;
}
if (validate_required(frm.firstname,'Please make sure the First Name field is not left blank.')==false)
{
frm.firstname.focus();
return false;
}
if (validate_required(frm.lastname,'Please make sure the Last Name field is not left blank.')==false)
{
frm.lastname.focus();
return false;
}
if (validate_required(frm.phone,'Please make sure the Phone Number field is not left blank.')==false)
{
frm.phone.focus();
return false;
}
if (validate_required(frm.city,'Please make sure the City field is not left blank.')==false)
{
frm.city.focus();
return false;
}
if (validate_required(frm.zip,'Please make sure the Zip Code field is not left blank.')==false)
{
frm.zip.focus();
return false;
}
if (validate_required(frm.customfield3,'Please make sure the FreeAd field is not left blank.')==false)
{
frm.customfield3.focus();
return false;
}

if(ctrvar==1)
{ frm.action='http://www.goldbar.net/contactone/previewsubmittedform.php?pkformid=8916';
} else {

var CF4;
var CF5;
var CF6;
var jjsDumVar;

CF4 = document.getElementById("customfield4");
CF5 = document.getElementById("customfield5");
CF6 = document.getElementById("customfield6");

jjsDumVar = document.getElementById("IncPhone");
CF4.value =jjsDumVar.value;

jjsDumVar = document.getElementById("IncEmail");
CF5.value =jjsDumVar.value;

jjsDumVar = document.getElementById("IncWeb");
CF6.value =jjsDumVar.value;

frm.action='http://www.goldbar.net/contactone/submitcontactoneform.php?pkformid=8916';
// frm.submit();

}  //end if
return true;
}  //end function
/***********************************************************************/
function txtfield(e){  //specific to this form
//written by JJS to count the characters in the ad
var txtfield;
var rptfield;
var charmax;

txtfield = document.getElementById("customfield3");
rptfield = document.getElementById("freeadcharsleft");
charmax = 250;

if(txtfield.value.length>charmax){  //trim if too long
txtfield.value = txtfield.value.substring(0, charmax);
rptfield.value = 0;
} else{ rptfield.value = charmax - txtfield.value.length;}

}  //end function txtfield
/***********************************************************************/

