﻿var vars=typeof DefinedVars!="undefined"?DefinedVars:null,$dialog,$logindialog,$confirmdialog,Channel="W",locals={PopCategory:{Clicked:0,LastValue:"0",Parameters:{}},ErrorCss:"ui-state-error",RunningStyle:"run-link",TopMenu:{Item:0,Timeout:500,Closetimer:0,Ddmenuitem:0},LoginRedirect:true,PagerCurrentTxn:""},cookies={login:"tep_da74ed39a45e"};
$(document).ready(function(){if($("#hLogin").length){$("#hLogin").click(function(){ShowLogin(true)});$("#popup_change_email").live("click",function(){$("#popup_email").val("").SetEnabled();$("#popup_email").focusEnd();$(this).hide();$("#popup_remember_me,#popup_remember_me_text").show()})}$("#translate_back_org").length&&$("#translate_back_org").click(function(){window.location.href=TopVars.Url});$(".jsddm > li").bind("mouseover",jsddm_open);$(".jsddm > li").bind("mouseout",jsddm_timer)});
function Ajax_Lib_Response(a){switch(a.proc){case "MembershipLogin":if(IsOK(a.json))locals.LoginRedirect?GoUrl("account.aspx"):$logindialog.dialog("close");break;case "CategoryPop":Pop_Category(a);break;case "CategoryGetSub":CategoryGetSub(a);break;case "CategorySearch":CategorySearch(a)}}
function Ajax_Request(a){a.params.TicketID=$("#TicketID").val();a.params.Channel=Channel;$.ajax({type:"POST",async:GetDefined(a.async,true),url:sprintf("%s/tool.aspx/%s",TopVars.AppDomainAppVirtualPath,a.proc),data:JSON.stringify(a.params),contentType:"application/json; charset=utf-8",dataType:"json",beforeSend:function(){process_start(a.obj)},success:function(b){process_stop(a.obj);if(IsDefined(a.htmlvar)&&a.htmlvar)Ajax_Response({proc:a.proc,obj:a.obj,params:a.params,json:b.d});else IsDefined(a.libtxn)?
Ajax_Lib_Response({proc:a.proc,json:!IsDefined(a.getobject)?Response_Get(b):Response_Object_Get(b),obj:a.obj}):Ajax_Response({proc:a.proc,json:IsDefined(a.getobject)&&a.getobject?Response_Object_Get(b):Response_Get(b),obj:a.obj,params:a.params})},error:function(b){ShowError(b.responseText);process_stop(a.obj)}})}function Response_Get(a){return Parse_Eval((a.hasOwnProperty("d")?a.d:a).split("while(1);")[1])}function Response_Object_Get(a){return(a.hasOwnProperty("d")?a.d:a).split("while(1);")[1]}
function Parse_Eval(a){return IsDefined(JSON)&&typeof JSON.parse==="function"?JSON.parse(a):eval("("+a+")")}
function Upload(a){if(a.obj.length)a.obj.uploadify({uploader:"media/uploader/uploadify.swf",buttonText:a.text,cancelImg:"media/uploader/cancel.png",script:"upload.ashx",fileExt:IsDefined(a.fileExt)?a.fileExt:"*.jpg;*.gif;*.png",fileDesc:IsDefined(a.fileDesc)?a.fileDesc:"Images",sizeLimit:"1024000",scriptData:a.scriptData,auto:a.auto,multi:a.multi,simUploadLimit:1,width:110,height:32,onSelect:UploadOnSelect,onComplete:UploadOnComplete,onError:UploadOnError,onAllComplete:UploadOnAllComplete})}
function UploadOnSelect(a){var b=$("#"+a.target.id).uploadifySettings("scriptData");b.wtr=$("#chkWatermark").is(":checked");b.hq=$("#chkHighResolution").is(":checked");if(b.type.Equals(MyVars.PicTypes.CertificatePicture)){b.cerdesc=$("#certificate_description").val();b.puid=$("#hdnProductUID").val()}$("#"+a.target.id).uploadifySettings("scriptData",b)}function UploadOnAllComplete(){}
function UploadOnError(a,b,c,e){a=sprintf("[ %s - %s ] Error Occured",e.type,e.info);var d;switch(e.info){case 902:d=TopVars.Translate.Error_Occured;break;case 910:d=TopVars.Translate.NoRecordFound;break;case 911:d=TopVars.Translate.DeleteBeforeUpload;break;case 912:d=TopVars.Translate.SaveBeforeUpload;break;case 913:d=TopVars.Translate.Not_Suitable_Membership;break;case 914:d=TopVars.Translate.SaveBeforeCertificateUpload;break;case 915:d=TopVars.Translate.MaxPictureBatchUploadExceed}if(IsDefined(d))a=
sprintf("[ %s ] %s",e.info,d);ShowError(a)}function process_start(a){$(a).attr("disabled","disabled");$(a).addClass(locals.RunningStyle)}function process_stop(a){$(a).removeAttr("disabled");$(a).removeClass(locals.RunningStyle)}
function ShowLogin(a){locals.LoginRedirect=a;$logindialog=$("<div></div>").html('<div id="dialog-form" ><form><fieldset><label for="email">Email</label><input type="text" autocomplete="off" id="popup_email" value="" class="text ui-widget-content ui-corner-all" /><label for="password">Password</label><input type="password" autocomplete="off" id="popup_password" value="" class="text ui-widget-content ui-corner-all" /><table><tr><td><input type="checkbox" checked id="popup_remember_me" class="" > <span class="small-info" id="popup_remember_me_text">Remember Me</span> <a id="popup_change_email" href="javascript:;" title="Change Email" style="display:none"><span class="small-info">Change Email</span></a></td><td>&nbsp;|&nbsp;</td><td><a href="javascript:;" onclick="GoUrl(\'forgot-password\')" title="Forgot Password" id="popup_forgot-password"><span class="small-info" title="Click here if you forgot your password !">Forgot Password</span></a></td></tr></table></fieldset></form></div>').dialog({autoOpen:false,modal:true,
resizable:false,title:"Login Account",buttons:{Join:function(){GoUrl("join-us")},Cancel:function(){$(this).remove()},Ok:function(){Ajax_Request({obj:this,proc:"MembershipLogin",libtxn:true,params:{data:{email:$("#popup_email").val(),password:$("#popup_password").val(),remember:$("#popup_remember_me").is(":checked")?1:0}}})}}});$logindialog.dialog("open");$("#popup_password").bind("keypress",function(b){if(b.keyCode==13){DialogBtns($logindialog,2).click();return false}});a=CookieGet(cookies.login);
if(IsNull(a))$("#popup_email").focusEnd();else{$("#popup_email").val(a).SetDisabled();$("#popup_password").focusEnd();$("#popup_remember_me,#popup_remember_me_text").hide();$("#popup_change_email").show();$("#popup_remember_me").attr("checked","checked")}}
function ShowConfirmation(a){var b=sprintf(IsDefined(a.onlytext)&&a.onlytext?'<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>%s</p>':"%s",a.message),c={};c[TopVars.Translate.Cancel]=function(){$(this).remove()};c[TopVars.Translate.Ok]=function(){IsDefined(a.libtxn)&&a.libtxn?ConfirmationOkLib(a):ConfirmationOk(a)};$confirmdialog=$("<div></div>").html(b).dialog({autoOpen:true,modal:true,resizable:false,title:a.title,buttons:c});DialogBtns($confirmdialog,0).focus()}
function ConfirmationOkLib(a){IsDefined($confirmdialog)&&$confirmdialog.remove();switch(a.proc){case "CategoryRemove":for(var b=$("#"+locals.PopCategory.Parameters.textCategory),c={values:[]},e=b.data("category").values,d=e.length,f=0;f<d;f++)a.params.id!=e[f].id&&c.values.push({id:e[f].id,text:e[f].text});b.data("category",c);a.obj.slideUp(300,function(){a.obj.remove()})}}function ShowPopUp(a,b){PopUpDialog(a,b)}function ShowInfo(a){PopUpDialog(a,{title:TopVars.Translate.Info})}
function ShowError(a){PopUpDialog(a,{title:TopVars.Translate.Error})}function PopUpDialog(a,b){var c={},e={autoOpen:false,modal:true,resizable:false,title:b.title,buttons:c};if(IsDefined(b.width))e.width=b.width;c[TopVars.Translate.Ok]=function(){$(this).remove()};$dialog=$("<div></div>").html(sprintf("<span class='message'>%s</span>",a)).dialog(e);$dialog.dialog("open");DialogBtns($dialog,0).focus()}function GetDefined(a,b){return IsDefined(a)?a:b}
function IsDefined(a){return typeof a!="undefined"}function IsNull(a){return a==""||a==null}function IsEmpty(a){return a.val().length==0}function IsObject(a){return typeof a=="object"}
function IsOK(a){var b=false;switch(a.response){case 0:b=true;ClearErrorFields();break;case 3:ShowError(TopVars.Translate.NoRecordFound);break;case 99:ShowLogin(false);break;default:var c;ClearErrorFields();if(IsDefined(a.records)){c=[];a=a.records;for(var e=a.length,d,f=0;f<e;f++){IsNull(a[f].description)||(c[f]="<li>"+a[f].description+"</li>");if(IsNull(a[f].field))IsNull(a[f].error)||(c[f]="<li>"+a[f].error+"</li>");else{d=$(sprintf("#%s",a[f].field));d.length||(d=$(sprintf("[column_name='%s']",
a[f].field)));d.length||(d=$(sprintf("[id$='_%s']",a[f].field)));d.length&&d.addClass(locals.ErrorCss)}}c='<ul class="ul-error-list">'+c.join("")+"</ul>"}else c=a.response_text;ShowError(c)}return b}
function FillStructure(a){var b=IsDefined(a)?a:{};$(":input[type!=button][type!=hidden]").each(function(){if(!IsNull($(this).attr("column_name"))&&!IsDefined($(this).attr("async")))b[$(this).attr("column_name")]=this.type.Equals("checkbox")?$(this).is(":checked")?TopVars.Yes:TopVars.No:$(this).val()});return b}function CalcCheckBoxGroup(a){var b=0;$(sprintf("%s input:checkbox",a)).each(function(){b+=$(this).is(":checked")?parseInt(this.value):0});return b}
function ClearErrorFields(){$(":input").removeClass(locals.ErrorCss)}function span(a){return sprintf("<span>%s</span>",a)}function p(a){return sprintf("<p>%s</p>",a)}function td(a){return sprintf("<td>%s</td>",a)}function sprite(a){return sprintf("<span class='sprite sprite-%s'></span>",a)}function text2html(a){return a.ReplaceAll("\r\n","<br/>").ReplaceAll("\n","<br/>")}function msgicon(a){return a==TopVars.No?'<span class="sprite sprite-msg-unread"></span>':"&nbsp;"}
function strong(a){return sprintf("<strong>%s</strong>",a)}function MaxLength(a,b){$(a).maxlength({maxCharacters:typeof b!=="undefined"?b:3E3,statusText:TopVars.Translate.CharLeft,statusClass:"maxlength"})}function FancyBox(){$("a.image-larger").fancybox({overlayOpacity:0.9,overlayColor:"#FFF",type:"image"})}
function PrettyPhoto(){$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:"normal",padding:40,opacity:0.5,showTitle:true,allowresize:true,counter_separator_label:"/",theme:"light_rounded",callback:function(){}})}function Zoom1(){$(function(){$("img.jqzoom").jqueryzoom({xzoom:275,yzoom:275,offset:10})})}
function Zoom2(){$(function(){$(".jqzoom").jqzoom({zoomWidth:375,zoomHeight:280,xOffset:20,yOffset:0,lens:true,title:true,preloadText:"Loading zoom",showEffect:"show",hideEffect:"fadeout",fadeoutSpeed:"slow",position:"right"})})}function GetMessageIcon(a){return a==TopVars.Yes?"":sprite("msg-unread")}function ScrollDown(a){$("html,body").animate({scrollTop:a.offset().top},3E3)}function ClearDataFields(){$(":input[type!=button][type!=hidden]").val("")}
function AutoComplete(a,b,c){$(a).autocomplete({source:sprintf(TopVars.AppDomainAppVirtualPath+"/autocomplete.aspx?type=%s%s",b,IsDefined(c)?"&extprm="+c:""),minLength:3,delay:2,select:function(e,d){$(a).attr("a_c",d.item.id);$(a).data("a_c",d.item.id);$(a).trigger("autocomplete-select",d.item.id)}})}function AshxCnvrt(a){return a.ReplaceAll("+","\u00c6").ReplaceAll("=","\u00d1")}function DialogBtns(a,b){return a.parents(".ui-dialog:first").find(".ui-dialog-buttonpane button")[b]}
function SetCaptcha(){$("#captcha").length&&UpperCase("#captcha")}function ButtonSetValue(a){return $("#"+$(sprintf("#%s label[aria-pressed='true']",a)).attr("for")).attr("pfilter")}Array.prototype.addrow=function(a,b){this.push(a);this[a]=b};String.prototype.Equals=function(a){return this==a};String.prototype.StrExists=function(a){return this.indexOf(a)>=0};String.prototype.DecodeHtml=function(){return this.ReplaceAll("&amp;","&").ReplaceAll("&lt;","<").ReplaceAll("&gt;",">")};
String.prototype.imgts=function(){return this+"?ts="+(new Date).getTime()};String.prototype.ReplaceAll=function(a,b){for(var c=this;a!=null&&b!=null&&c.indexOf(a)!=-1;)c=c.replace(a,b);return c};String.prototype.IsMatch=function(a){return this.match(RegExp(a))!=null};String.prototype.StripValue=function(a){return this.substring(this.indexOf(a)+1)};
$.fn.focusEnd=function(){return this.each(function(){if(this.style.display!="none")if($.browser.msie){$(this).is(":visible")&&this.focus();var a=this.createTextRange();a.collapse(false);a.select()}else{this.setSelectionRange(this.value.length,this.value.length);$(this).is(":visible")&&this.focus()}})};$.fn.SetEnabled=function(){$(this).removeAttr("disabled")};$.fn.SetDisabled=function(){$(this).attr("disabled","disabled")};function str_repeat(a,b){for(var c=[];b>0;)return c.join("")}
function sprintf(){for(var a=0,b,c=arguments[a++],e=[],d,f,g,h="";c;){if(d=/^[^\x25]+/.exec(c))e.push(d[0]);else if(d=/^\x25{2}/.exec(c))e.push("%");else if(d=/^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(c)){if((b=arguments[d[1]||a++])==null||b==undefined)throw"Too few arguments.";if(/[^s]/.test(d[7])&&typeof b!="number")throw"Expecting number but found "+typeof b;switch(d[7]){case "b":b=b.toString(2);break;case "c":b=String.fromCharCode(b);break;case "d":b=parseInt(b);
break;case "e":b=d[6]?b.toExponential(d[6]):b.toExponential();break;case "f":b=d[6]?parseFloat(b).toFixed(d[6]):parseFloat(b);break;case "o":b=b.toString(8);break;case "s":b=(b=String(b))&&d[6]?b.substring(0,d[6]):b;break;case "u":b=Math.abs(b);break;case "x":b=b.toString(16);break;case "X":b=b.toString(16).toUpperCase()}if(/[def]/.test(d[7])){h=b>=0?d[2]?"+":"":"-";b=Math.abs(b)}f=d[3]?d[3]=="0"?"0":d[3].charAt(1):" ";g=d[5]-String(b).length-h.length;f=d[5]?str_repeat(f,g):"";e.push(h+(d[4]?b+f:
f+b))}else throw"Huh ?!";c=c.substring(d[0].length)}return e.join("")}function SwitchUrl(a,b,c){GoUrl(TopVars.FileName+"?"+ReplaceUrl(a,b,c))}function ReplaceUrl(a,b,c){a=getUrlVars(a);for(var e=a.length,d=[],f=0;f<e;f++){var g=a[f];d.push(sprintf("%s=%s",g,a[g]))}d.push(sprintf("%s=%s",b,c));return d.join("&")}function GoUrl(a,b){window.location.href=!IsDefined(b)?sprintf("%s/%s",TopVars.AppDomainAppVirtualPath,a):a}
function getUrlVars(a){var b=[],c,e=TopVars.Url.slice(TopVars.Url.indexOf("?")+1).split("&"),d=e.length;if(TopVars.Url.indexOf("?")>=0)for(var f=0;f<d;f++){c=e[f].split("=");if(IsDefined(a)&&$.inArray(c[0],a)<0){b.push(c[0]);b[c[0]]=c[1]}}return b}function getUrlParams(a,b){for(var c=[],e,d=a.slice(a.indexOf("?")+1).split("&"),f=d.length,g=0;g<f;g++){e=d[g].split("=");if(!IsDefined(b)||IsDefined(b)&&$.inArray(e[0],b)<0){c.push(e[0]);c[e[0]]=e[1]}}return c}
function getAjaxUrlVars(a){var b=[],c;c=window.location.href;var e=c.slice(c.indexOf("#")+1).split("&"),d=e.length;if(c.indexOf("#")>=0)for(var f=0;f<d;f++){c=e[f].split("=");IsDefined(a)||(a=[""]);if(!IsNull(c[0])&&$.inArray(c[0],a)<0){b.push(c[0]);b[c[0]]=c[1]}}return b}
function jsddm_open(){jsddm_canceltimer();jsddm_close();locals.TopMenu.Ddmenuitem=$(this).find("ul").eq(0).css("visibility","visible");locals.TopMenu.Item=$(this);$(this).find("ul").eq(0).addClass("zindex_set");$(this).addClass("top_back_color")}function jsddm_close(){locals.TopMenu.Ddmenuitem&&locals.TopMenu.Ddmenuitem.css("visibility","hidden");$(locals.TopMenu.Item).removeClass("top_back_color")}
function jsddm_timer(){locals.TopMenu.Closetimer=window.setTimeout(jsddm_close,locals.TopMenu.Timeout)}function jsddm_canceltimer(){if(locals.TopMenu.Closetimer){window.clearTimeout(locals.TopMenu.Closetimer);locals.TopMenu.Closetimer=null}}
function CategoryPopup(a){var b=$("#"+a.textCategory),c=$("#"+a.buttonCategorySearch),e=$("#"+a.buttonCategorySelect),d=$("#"+a.buttonCategoryClear);$("#"+a.CategorySearchList);locals.PopCategory.Parameters=a;if(c.length!=0){b.data("category",a.data);b.bind("keypress",function(f){if(f.keyCode==13){c.click();return false}});c.click(function(){Ajax_Request({obj:this,proc:"CategorySearch",params:{data:{catname:b.val()}},libtxn:true})})}if(e.length!=0){e.click(function(){Ajax_Request({obj:this,proc:"CategoryPop",
params:{data:{}},getobject:true,libtxn:true})});$("#CatMenu_1,#CatMenu_2,#CatMenu_3,#CatMenu_4,#CatMenu_5").live("click",function(){locals.PopCategory.Clicked=parseInt(this.id.StripValue("_"));locals.PopCategory.LastValue=$(this).val();for(var f=CtgSelectedItem($(this).val()),g=locals.PopCategory.Clicked+1;g<=5;g++){var h=$(sprintf("#CatMenu_%d",g));h.empty();!f.Last&&g==locals.PopCategory.Clicked+1?h.show():h.hide()}h=$(sprintf("#%s option:selected",this.id));Ajax_Request({obj:this,proc:"CategoryGetSub",
params:{data:{ctgid:$(h).val().split("~")[0],channel:Channel}},libtxn:true})})}d.length!=0&&d.click(function(){b.data("category",{id:0,text:""});b.val("")});$(sprintf("#%s > li",locals.PopCategory.Parameters.CategoryList)).live("mouseover",function(){$(this).addClass("cursor_pointer");$(this).find("span").show()});$(sprintf("#%s > li",locals.PopCategory.Parameters.CategoryList)).live("mouseout",function(){$(this).removeClass("cursor_pointer");$(this).find("span").hide()});$(sprintf("#%s > li > a",
locals.PopCategory.Parameters.CategorySearchList)).live("click",function(){Category_Add({obj:$(this),detail:{list:true,add:true},id:this.id,text:$(this).text()})});$(sprintf("#%s > li > span > a",locals.PopCategory.Parameters.CategoryList)).live("click",function(){ShowConfirmation({obj:$(this).parents("li"),proc:"CategoryRemove",message:TopVars.Translate.Sure_Delete,libtxn:true,title:TopVars.Translate.Confirmation,params:{id:$(this).attr("delcategory")}})})}
function Pop_Category(a){var b={};b[TopVars.Translate.Cancel]=function(){Reset_Pop_Category();$(this).remove()};b[TopVars.Translate.Ok]=function(){var c=$(this);CtgSelectedItem(locals.PopCategory.LastValue).Last?Category_Add({obj:c,detail:{popup:true,add:true},id:CtgSelectedItem(locals.PopCategory.LastValue).Id,text:$("#category_info_row").html().DecodeHtml()}):ShowError(TopVars.Translate.Please_Select_Last_Level)};$("<div></div>").html(a.json).dialog({modal:true,bgiframe:true,title:TopVars.Translate.Select_Category,
width:800,buttons:b,resizable:false,zIndex:9999,close:function(){$(this).remove()}})}function CategoryGetSub(a){for(var b=[],c=IsDefined(a.json.records)?a.json.records:a.json.rows,e=0;e<a.json.item_count;e++)b.push(sprintf('<option value="%s~%s" title="%3$s">%3$s</option>',c[e].ctgid,c[e].last_level,c[e].catname));$(sprintf("#CatMenu_%d",locals.PopCategory.Clicked+1)).empty().append(b.join(""));$("#category_info_row").html(a.json.reserved1)}
function CategorySearch(a){var b=IsDefined(a.json.records)?a.json.records:a.json.rows,c=$("#"+locals.PopCategory.Parameters.CategorySearchList);c.empty();if(a.json.item_count!=0)for(var e=0;e<a.json.item_count;e++)c.append(sprintf("<li><a id='%s' href='javascript:;'>%s</a></li>",b[e].ctgid,b[e].path));else ShowError(TopVars.Translate.NoRecordFound)}
function Category_Add(a){var b={id:a.id,text:a.text},c=$("#"+locals.PopCategory.Parameters.textCategory),e=c.data("category"),d;if(locals.PopCategory.Parameters.multi){d=e.values.length;for(var f=0;f<d;f++)if(b.id==e.values[f].id){ShowError(TopVars.Translate.Category_Already_Exist);return}a.obj.parents("li").slideUp(300,function(){a.obj.parents("li").remove()});$("#"+locals.PopCategory.Parameters.textCategory).val("");d=sprintf("<li>%s <span style='display:none'><a href='javascript:;' delcategory='%s'>%s</a></span></li>",
a.text,a.id,TopVars.Translate.Delete);$("#ulCategoryList li").length?$(d).insertBefore($("#ulCategoryList li:first")):$("#ulCategoryList").append(d);d={values:[]};if(IsDefined(e))d=e;d.values.push(b);b=d}else{$("#"+locals.PopCategory.Parameters.CategorySearchList).empty();$("#"+locals.PopCategory.Parameters.textCategory).val(a.text);b=b}if(a.detail.popup){Reset_Pop_Category();a.obj.remove()}c.data("category",b)}
function Reset_Pop_Category(){locals.PopCategory.Clicked=0;locals.PopCategory.LastValue="0"}function CtgSelectedItem(a){a=a.split("~");var b={};b.Id=a[0];b.Last=a.length==2&&a[1].Equals("1");return b}function Filter_Top_Category(){$("#top_category").change(function(){SwitchUrl(["top_category","page"],"top_category",$("#top_category option:selected").val())})}
function ClueTip(a){IsDefined($.cluetip)&&$(a).cluetip({cluetipClass:"jtip",arrows:true,dropShadow:false,sticky:true,clickThrough:true,mouseOutClose:true,closePosition:"title",ajaxCache:false,height:"auto",closeText:'<img src="images/cluetip/cross.png" alt="close" />',hoverIntent:{sensitivity:1,interval:250,timeout:250},ajaxProcess:function(b){return b=$(b).not("style, meta, link, script, title")}})}function ClueTipSmallInfo(){$("a.cluetip").cluetip({splitTitle:"|",showTitle:false})}
function CookieGet(a){return $.cookie(a)}function CookieSet(a,b,c){var e={path:"/",expires:1},d=new Date;d.setTime(d.getTime()+c*24*60*60*1E3);e.expires=d;$.cookie(a,b,e)}function CookieRemove(a){$.cookie(a,null,{})}function UpperCase(a){$(a).bestupper()}function Numeric(a){$(a).numeric()}function DatePicker(a){$(a).datepicker({dateFormat:"dd/mm/yy",showButtonPanel:true,changeMonth:true,changeYear:true})}
function PriceFormat(a){$(a).priceFormat({prefix:"",thousandsSeparator:",",centsSeparator:".",limit:9,centsLimit:2})}
function SetPager(a){var b=IsDefined(a.getobject)&&a.getobject?"1":"0";locals.PagerCurrentTxn=a.txn;if(MyVars.RecordCount!=0&&MyVars.RecordCount>MyVars.PerPage){var c=MyVars.PagerIndex*MyVars.PerPage<0?0:MyVars.PagerIndex*MyVars.PerPage,e=MyVars.PerPage+MyVars.PagerIndex*MyVars.PerPage>MyVars.RecordCount?MyVars.RecordCount:MyVars.PerPage+MyVars.PagerIndex*MyVars.PerPage;$("#ajaxpagertop,#ajaxpagerbottom").html(sprintf("<div>%s %s %d - %d / %s</div>",sprintf("<a href='javascript:;' onclick='MyVars.PagerIndex--;Ajax_Request_Pager(this);return false;' txn='%s' getobject='%s'>%s</a>",
a.txn,b,TopVars.Translate.Previous),sprintf("<a href='javascript:;' onclick='MyVars.PagerIndex++;Ajax_Request_Pager(this);return false;' txn='%s' getobject='%s'>%s</a>",a.txn,b,TopVars.Translate.Next),c,e,MyVars.RecordCount));$("#ajaxpagertop,#ajaxpagerbottom").css("display","block")}else $("#ajaxpagertop,#ajaxpagerbottom").css("display","none")}
function Ajax_Request_Pager(a){var b=$(a).attr("txn"),c=$(a).attr("getobject");if(MyVars.PagerIndex*MyVars.PerPage>=MyVars.RecordCount)MyVars.PagerIndex=0;else if(MyVars.PagerIndex<0)MyVars.PagerIndex=Math.ceil(MyVars.RecordCount/MyVars.PerPage)-1;Ajax_Request({obj:$(a),proc:b,params:{data:Get_Pager_Prm(b),Offset:MyVars.PagerIndex*MyVars.PerPage,Count:MyVars.PerPage},getobject:c.Equals("1")})}function PagerRow(a){return sprintf("<tr>%s</tr>",a)}
function ShowPagerResult(a){$("#RecordList").html(sprintf("<table>%s</table>",MyVars.Pager.Array.join(""))).show();SetPager(a)}
function CompanyUpdate(a,b){var c={},e=0,d=[],f=$("#txtcategories").data("category").values,g=f.length;c=FillStructure(b);$("#chkMarketList input:checkbox").each(function(){e+=$(this).is(":checked")?parseInt(this.value):0});c.main_market=e;c.options=$("[column_name='options']").is(":checked")?1:0;for(var h=0;h<g;h++)d[h]=f[h].id;c.ctgactype=d.join(" ");Ajax_Request({obj:a,proc:"CompanyUpdate",params:{data:c}})}
function ProductUpdate(a,b){var c={},e=IsDefined($("#ProductAdd").val())&&$("#ProductAdd").val().Equals("1");c=FillStructure(b);c.payment_term=CalcCheckBoxGroup("#chkPaymentTermList");c.c_payment_term=CalcCheckBoxGroup("#chkCampaignPaymentTerm");c.options=$("[column_name='options']").is(":checked")?1:0;c.category=$("#category").data("category").id;c.uid=$("#hdnProductUID").val();Ajax_Request({obj:a,proc:sprintf("Product%s",e?"Insert":"Update"),params:{data:c}})}
function BuyingLeadUpdate(a,b){var c={},e=IsDefined($("#BuyingLeadAdd").val())&&$("#BuyingLeadAdd").val().Equals("1");c=FillStructure(b);c.category=$("#category").data("category").id;c.uid=$("#hdnBuyingLeadUID").val();Ajax_Request({obj:a,proc:sprintf("BuyingLead%s",e?"Insert":"Update"),params:{data:c}})}function IsTest(){return IsDefined(TopVars.IsTest)&&TopVars.IsTest.Equals("1")}
function TextBoxACSet(a,b,c){if($(a).is(":visible")){$(a).val(c);$(a).attr("a_c",b);$("#"+$(a).attr("empty")).removeClass("nodisplay")}}function CaptchaReGenerate(a){process_start(a.obj);$("[id$='Captcha']").attr("src",sprintf("CaptchaReGenerate.ashx?refresh=1%s",IsDefined(a.small)&&a.small?"&small=1":"").imgts());process_stop(a.obj)};
