
$(document).ready(function()
{$("a.tip").cluetip({showTitle:false});$("a.tip").click(function(){return false;});$(".confirm").click(function(){return confirm("Vai tiešām vēlaties veikt šo darbību?");});$("#MessageDelete").change(function(){if($("#MessageDelete").is(":checked"))
{$(".msgchk").attr("checked","checked");}
else
{$(".msgchk").attr("checked",false);}});$(".doc_nrs input").change(function(){$("#"+$(this).attr("id").replace(/Nr/,"Type")).attr("checked",true);});});function writemail(p1,p2)
{document.write("<a href='mailto:"+p1+"@"+p2+"'>"+p1+"@"+p2+"</a>");}
function showAgreementText()
{scroll(0,0);$.ajax({url:webroot+"texts/agreement/",success:function(data){$("body").append(data);var left_px=($("body").width()-$("#agreement-box").width())/2;var top_px=($("body").height()-$("#agreement-box").height())/2;$("#agreement-box").attr("style","left:"+left_px+"px; top:"+top_px+"px");}});return false;}
function hideAgreementText(submit_form)
{$("#agreement-box").remove();$("#overlay").remove();if(submit_form)
{$(".frm").submit();}}
function changeInsured(checked)
{if(!checked)
{$("#insurance_sum_container input").attr("disabled","disabled");$("#insurance_sum_container").addClass("disabled");}
else
{$("#insurance_sum_container input").attr("disabled",false);$("#insurance_sum_container").removeClass("disabled");}}
function changeMultiparcel(v)
{if(v=="1")
{$("#IeNextAction").val("repeat");}
else
{$("#IeNextAction").val("finish");}}
function changePostPaymentAccount(account)
{$("#IePostPaymentAccount").val(account);if(account=="")
{$("#IePostPaymentAccount").removeAttr("readonly");}
else
{$("#IePostPaymentAccount").attr("readonly","readonly");}}
function checkParcelBarcode(v)
{if(v.length>12)
{$("#ParcelActivateForm").submit();}}
function addItemEntry()
{$(".item:first").clone().insertAfter(".item:last");$(".item:last input").val("");return false;}
function checkAll(container)
{$(container+" input[type='checkbox']").attr("checked",true);}
function uncheckAll(container)
{$(container+" input[type='checkbox']").attr("checked",false);}
function changePickup()
{if($("#IePickup").is(":checked")&&$("#IePickupPostalCode").val()=="LV-")
{$("#IePickupPostalCode").val($("#IeCustomPostalCode").val())}}
function changeStickerPageSize(size)
{var rows=1;var cols=1;switch(size)
{case"64x32":cols=1;rows=1;break;case"67x48":cols=3;rows=6;break;case"70x37":cols=3;rows=8;break;case"70x42":cols=3;rows=7;break;case"105x37":cols=2;rows=8;break;case"130x75":cols=1;rows=4;break;}
$.cookie("sticker_size",size,{expires:30});var html_code="";for(var n=0;n<rows;n++)
{html_code+="<option value='"+(n+1)+"'>"+(n+1)+"</option>";}
$("#StickerRow").html(html_code);var html_code="";for(var n=0;n<cols;n++)
{html_code+="<option value='"+(n+1)+"'>"+(n+1)+"</option>";}
$("#StickerCol").html(html_code);}
function changeDeleteRecipients()
{if($("#IeCheckAll").is(":checked"))
{checkAll(".num");}
else
{uncheckAll(".num");}}
function deleteRecipients()
{var count=parseInt($("#total-recipients").text());$(".num input[type='checkbox']").each(function(e){if($(this).is(":checked"))
{var element_id=$(this).attr("id");var address_id=element_id.substr(11);$("#recipient-"+address_id).remove();count--;}});$("#total-recipients").text(count);}
function checkAllByValue(val){$("input[value="+val+"]").attr("checked","checked");}
function checkCheckedDocuments(){if(typeof(doCheckCheckedDocuments)=="boolean"&&doCheckCheckedDocuments==false){return true;}
var success=true;$(".doc_chk input[type=checkbox]").each(function(i){if($(this).is(":checked")){var el=$("#"+$(this).attr("id").replace(/Type/,"Nr"));if($(el).val()==""){alert("Lūdzu, aizpildiet atzīmēto dokumenta nr");$(el).focus();success=false;return false;}}});return success;}
function printEvents(strid){var w=800;var h=600;var x=parseInt((screen.availWidth/2)-(w/2));var y=parseInt((screen.availHeight/2)-(h/2));window.open(webroot+lang+"/parcels/events/"+strid+'/print:1','events',"width="+w+",height="+h+",left="+x+",top="+y+",location=1,statusbar=1,menubar=1,toolbar=1");}