$(function(){jQuery.validator.addMethod("legal_char",function(c,b){return !/\W/.test(c)},"This field contains illegal characters.");$("#addNewDirForm").validate();function a(){var d=$.format($("#branch_template").val());var b=parseInt($("#branches_totals").val());var c=$("#branches_totals").val();$(d(b++)).appendTo("#main_branch_block");c++;$("#branches_totals").val(c)}$("#addBranchtBlockLink").click(a);$(".addTelephone").click(function(){var b=parseInt($(this).attr("id"));addTelephone(b)});$("#comments_dialog").dialog({autoOpen:false,bgiframe:true,resizable:true,modal:true,width:640,height:370,overlay:{backgroundColor:"#000",opacity:0.5}});$("#cities").change(function(){$("#areas").attr("disabled","disabled");var b=$(this).val();$.ajax({url:_HTTP_PATH+"/ajax/get_districts.php",type:"POST",dataType:"html",data:"city_id="+b,success:function(c){$("#area_span").html(c)}})})});function makeDelete(c){var a=c.split("_");if(a[0]=="c"){var b=confirm("You will Delete the Directory category with all directories under it (if have).. Are you sure?");if(b){window.location="?mod=dir_delete&type=category&id="+a[1]}}else{if(a[0]=="g"){var b=confirm("You will Delete this Directory with it's branches .. Are you sure?");if(b){window.location="?mod=dir_delete&type=dir&id="+a[1]}}}}function doDelete(d,a,e,c){var b=confirm("Are you sure you want to delete this???");if(b){$.ajax({url:"../ajax/directories_delete.php",type:"POST",dataType:"html",data:"table="+d+"&id_field="+a+"&id="+e,success:function(f){$("#"+c).remove()}})}}function addTelephone(c){c=parseInt(c);var a=parseInt($("#tel"+c+"_num").val())+1;var d=parseInt($("#existing_tel_num"+c).val());if(d>0&&a<=d){var b=a+d-1}else{var b=a}$("#tel"+c+"_num").before("<div id='tel"+c+"_"+b+"'><div class='light_blue_title' style='width:160px;float:left;'>Telephone "+b+"</div><div style='padding:5px;'><input type='text' name='telephone"+c+"_"+b+"'  value=''> <img src='../images/delete.png' onclick='$(\"#tel"+c+"_"+b+"\").remove();' style='cursor:pointer' alt='Delete Telephone' title='Delete Telephone'></div><div style='clear:both'></div>");$("#tel"+c+"_num").val(b)}function getAreas(c,b,a){$("#"+c).html("<center><img src='"+_HTTP_PATH+"/images/ajax-loader-small.gif'></center>");$.ajax({url:"../ajax/getAreas.php",type:"POST",dataType:"html",data:"city_id="+$("#"+b).val()+"&area_name="+a,success:function(d){$("#"+c).html(d)}})}function getComments(a){$.ajax({url:"../ajax/get_comments.php",type:"POST",dataType:"html",data:"branch_id="+a,success:function(b){$("#comments_dialog").html(b)}});$("#comments_dialog").dialog("open")}function getDistricts(b,a){$.ajax({url:"../ajax/get_districts.php",type:"POST",dataType:"html",data:"city_id="+b+"&area_id="+a,success:function(c){$("#area_span").html(c);searchDirectory()}})}function searchDirectory(){$(function(){var d=$("#cities").val();var b=$("#areas").val();var c=$("#type").val();var a=$("#keyword").val();$("#output_div").html("<center> <img src='../images/ajax-loader.gif' border='0'></center>");$.ajax({url:"../ajax/get_directories.php",type:"POST",dataType:"html",data:"cities="+d+"&areas="+b+"&type="+c+"&keyword="+a,success:function(e){$("#output_div").html(e)}})})};
