$(function(){
$("#regnew").submit(function(){$("#regwarn").slideUp("fast"); 

if($("#rg_fname").val()=='') {$("#regwarn").html('Please enter your first name').slideDown("slow"); $("#rg_fname").focus(); return false;}
if($("#rg_lname").val()=='') {$("#regwarn").html('Please enter your last name').slideDown("slow"); $("#rg_lname").focus(); return false;}
if($("#rg_bname").val()=='') {$("#regwarn").html('Please enter a business name').slideDown("slow"); $("#rg_bname").focus(); return false;}
if($("#rg_address").val()=='') {$("#regwarn").html('Please include your street address').slideDown("slow"); $("#rg_address").focus(); return false;}
if($("#rg_suburb").val()=='') {$("#regwarn").html('Please include your suburb').slideDown("slow"); $("#rg_suburb").focus(); return false;}
if($("#rg_post").val()=='') {$("#regwarn").html('Please include your postcode').slideDown("slow"); $("#rg_post").focus(); return false;}
if($("#rg_phone").val()=='' && $("#rg_mobile").val()=='') {$("#regwarn").html('Please include at least one contact number').slideDown("slow"); $("#rg_phone").focus(); return false;}
if($("#rg_fax").val()=='') {$("#regwarn").html('Please enter your fax number').slideDown("slow"); $("#rg_fax").focus(); return false;}
if($("#rg_email").val()=='') {$("#regwarn").html('Please enter your email address').slideDown("slow"); $("#rg_email").focus(); return false;}
if($("#rg_member").val()=='') {$("#regwarn").html('Please include your industry membership number').slideDown("slow"); $("#rg_member").focus(); return false;}
if($("#rg_email").val()=='') {$("#regwarn").html('Please enter your email address').slideDown("slow"); $("#rg_email").focus(); return false;}
if(!$("#rg_accept:checked").val()) {$("#regwarn").html('You must agree to the Terms of Use').slideDown("slow"); return false;}});

$("#newlist").submit(function(){$("#regwarn").slideUp("fast"); 

if($("#l_lname").val()=='') {$("#regwarn").html('Please enter the last name of the buyer').slideDown("slow"); $("#l_lname").focus(); return false;}
if($("#l_fname").val()=='') {$("#regwarn").html('Please enter the first name of the buyer').slideDown("slow"); $("#l_fname").focus(); return false;}
var lcwrk = $("#l_phw").val(); var lchom = $("#l_phh").val(); var lcmob = $("#l_phm").val(); var lcemail = $("#l_email").val();
if((lcwrk=='' || lchom=='') && (lcwrk=='' || lcmob=='') && (lcwrk=='' || lcemail=='') && (lchom=='' || lcmob=='') && (lcemail=='' || lcmob=='') && (lcemail=='' || lchom=='') ) {$("#regwarn").html('Please enter at least two contact details for the buyer').slideDown("slow"); $("#l_phw").focus(); return false;}
if(!$("#rg_authord:checked").val()) {$("#regwarn").html('You must have client authorisation before submitting').slideDown("slow"); return false;};
if($("#l_state").val()=='') {$("#regwarn").html('Please enter the state of the buyer').slideDown("slow"); $("#l_range").focus(); return false;}
if($("#l_region").val()=='') {$("#regwarn").html('Please enter the region of the buyer preference').slideDown("slow"); $("#l_range").focus(); return false;}
if($("#b_contact").val()=='') {$("#regwarn").html('Please enter your name').slideDown("slow"); $("#b_contact").focus(); return false;}
var bcwrk = $("#b_phw").val(); var bchom = $("#b_phh").val(); var bcmob = $("#b_phm").val(); var bcemail = $("#b_email").val();
if((bcwrk=='' || bchom=='') && (bcwrk=='' || bcmob=='') && (bcwrk=='' || bcemail=='') && (bchom=='' || bcmob=='') && (bcemail=='' || bcmob=='') && (bcemail=='' || bchom=='') ) {$("#regwarn").html('Please enter at least two contact details').slideDown("slow"); $("#b_phw").focus(); return false;}
if($("#b_amt").val()=='') {$("#regwarn").html('Please enter the buyer pre-approval amount').slideDown("slow"); $("#b_amt").focus(); return false;}
if($("#b_exp").val()=='') {$("#regwarn").html('Please enter the pre-approval expiry date').slideDown("slow"); $("#b_exp").focus(); return false;}
});


$("#l_state").change(function(){$("#o_region").slideUp("fast"); $("#o_suburbs").slideUp("fast"); $("#burbdrop").slideUp("fast"); $.get("/modules/cog.php", {brksid:$("#l_state").val()}, function(data){$("#o_region").html(data).slideDown("fast");}); return false; });
$("#l_region").livequery('change', (function(){$("#burbdrop").slideUp("fast"); $.get("/modules/cog.php", {brkreg:$("#l_region").val()}, function(data){$("#o_suburbs").html(data).slideDown("fast");}); return false; }));

$("#l_state_pc").change(function(){$("#o_region_pc").slideUp("fast"); $("#o_suburbs_pc").slideUp("fast"); $("#o_suburbs_pc").slideUp("fast"); $.get("/modules/cog.php", {state_pc:$("#l_state_pc").val()}, function(data){$("#o_region_pc").html(data).slideDown("fast");}); return false; });
$("#l_region_pc").livequery('change', (function(){$("#o_suburbs_pc").slideUp("fast"); $.get("/modules/cog.php", {l_region_pc:$("#l_region_pc").val()}, function(data){$("#o_suburbs_pc").html(data).slideDown("fast");}); return false; }));

$("#ptype").livequery('change', (function(){
if($("#ptype").val()=='5'){$(".ptypeno").slideUp("fast");}else{$(".ptypeno").slideDown("fast");}}));

$("#enqfrm").submit(function(){if($("#enq_fname").val() == ''){alert("Please fill in your first name");$("#enq_fname").focus();return false;}if($("#enq_lname").val() == ''){alert("Please fill in your last name");$("#enq_lname").focus();return false;}if($("#enq_number").val() == ''){alert("Please enter a contact number");$("#enq_number").focus();return false;}});

if($("#hfine").val()){$("#searchrest").addClass("hide");}

$("#rg_select").change(function(){$.get("/modules/cog.php", {rg_select:$("#rg_select").val()}, function(data){$("#burbdrop").html(data); $("#burbln").slideDown("fast");}); return false;});
$("#sid").change(function(){$.get("/modules/cog.php", {sid:$("#sid").val()}, function(data){$("#burbdrop").html(''); $("#regdrop").html(data); }); return false;});
$("#rg_select").livequery('change', function(){$.get("/modules/cog.php", {rg_select:$("#rg_select").val()}, function(data){$("#burbdrop").html(data); $("#burbln").slideDown("fast");}); return false;});
$("#viewall").click(function(){if($("#viewall:checked").val()){$("#searchrest").slideDown("slow");$("#hfine").val('1');}else{$("#searchrest").slideUp("slow");$("#hfine").val('0');}});

$("#frmaddpcode").submit(function(){$("#workranim").fadeIn("fast"); $.get("/modules/cog.php", {addpc:$("#addpcode").val()}, function(data){$("#workranim").fadeOut("fast"); $("#fdbkaddnewpc").fadeOut("slow").html(data).fadeIn("slow"); }); $("#pctorm").append('<option value="'+$("#addpcode").val()+'">'+$("#addpcode").val()+'</option>'); $("#addpcode").val('').select(); return false; });
$("#frmaddprange").submit(function(){$("#workranim").fadeIn("fast"); $.get("/modules/cog.php", {addpca:$("#addpca").val(), addpcz:$("#addpcz").val()}, function(data){$("#workranim").fadeOut("fast"); $("#fdbkaddnewpc").fadeOut("slow").html(data).fadeIn("slow"); }); var lastpc = $("#addpcz").val(); var firstpc = $("#addpca").val(); if($("#addpca").val()!='' && $("#addpcz").val()!=''){if($("#addpca").val()>$("#addpcz").val()){var lastpc = $("#addpca").val(); var firstpc=$("#addpcz").val();}for(var i=firstpc;i<=lastpc;i++) {$("#pctorm").append('<option value="'+$("#addpcode").val()+'">'+i+'</option>'); }}; $("#addpcode").val('').select(); return false; });

$("#frmpc").submit(function(){$("#workranim").fadeIn("fast"); $.get("/modules/cog.php", {pcrm:$("#pctorm").val()}, function(data){$("#pctorm :selected").remove(); $("#workranim").fadeOut("fast"); $("#fdbkaddnewpc").fadeOut("slow").html(data).fadeIn("slow"); }); $("#addpcode").val('').select(); return false; });
$("#frmprange").submit(function(){$("#workranim").fadeIn("fast"); $.get("/modules/cog.php", {rmpca:$("#rmpca").val(), rmpcz:$("#rmpcz").val()}, function(data){$("#workranim").fadeOut("fast"); $("#fdbkaddnewpc").fadeOut("slow").html(data).fadeIn("slow"); }); var lastpc = $("#rmpcz").val(); var firstpc = $("#rmpca").val(); if(($("#rmpca").val()!='') && ($("#rmpcz").val()!='')){if($("#rmpca").val()>$("#rmpcz").val()){var lastpc = $("#rmpca").val(); var firstpc=$("#rmpcz").val();}for(var i=firstpc;i<=lastpc;i++) {$("#pctorm option[value='"+i+"']").remove(); }}; $("#addpcode").val('').select(); $("#rmpca").val(''); $("#rmpcz").val(''); return false; });

$("#addpcode").select(function(){$.get("/modules/cog.php", {updpc:"1"}, function(data){$("#cntwatch").html(data); }); return false; });

$("#chgpasswd").submit(function(){$("#workranim").fadeIn("fast"); $("#chgpwd").attr("disabled","disabled"); $.post("/modules/cog.php", {pwd0:$("#pwd0").val(), pwd1:$("#pwd1").val(), pwd2:$("#pwd2").val()}, function(data){$("#workranim").fadeOut("fast"); $("#feedbk").html(data).fadeIn("slow"); }); pwd0:$("#pwd0").val(''); pwd1:$("#pwd1").val(''); pwd2:$("#pwd2").val(''); $("#chgpwd").removeAttr("disabled"); pwd0:$("#pwd0").focus(); return false; });
$("#udetails").submit(function(){$("#workranim").fadeIn("fast"); $("#btnupd").attr("disabled","disabled"); var mydetails = $("#udetails").serialize(); $.post("/modules/cog.php", mydetails, function(data){$("#workranim").fadeOut("fast"); $("#feedbk").html(data).fadeIn("slow"); }); $("#btnupd").removeAttr("disabled"); return false; });

$("#leadwant").click(function(){$.get("/modules/cog.php", {ldd:$("#leaded").val()}, function(data){$("#intocart").fadeOut("fast").html(data).fadeIn("fast");}); return false;});

$("#alertme").click(function(){$.get("/modules/cog.php", {tck:"1", alerton:$("#alertme").attr("checked")}, function(data){$("#zzz").html(data).addClass("flag").fadeIn("fast").fadeOut("fast").fadeIn("slow"); return false;});});

$("#unm").focus();
$("#b_exp").datepicker({dateFormat: 'yy-mm-dd'});

$(".coption").click(function(){var chosen_ln = $(this).val();$("#amount").val($("#creditcost_" + chosen_ln).val()); $("#item_name").val('Pre-approved credits: ' + $("#credlabel_" + chosen_ln).val());$("#custom").val($("#custom_agent").val() + ':' + $("#credtk_" + chosen_ln).val());});


});

function pop(newin){window.open(newin,'park','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=450');}