/*
This software is allowed to use under GPL or you need to obtain Commercial or Enterise License
to use it in not GPL project. Please contact sales@dhtmlx.com for details
*/
scheduler.toPDF=function(x,f,m,n){function g(c){return c.replace(html_regexp,"")}function j(c){c=parseFloat(c);return isNaN(c)?"auto":100*c/(o+1)}function t(c){c=parseFloat(c);return isNaN(c)?"auto":100*c/k}function q(c){var a="";if(scheduler.matrix&&scheduler.matrix[scheduler._mode])c=c[0].childNodes;for(var b=0;b<c.length;b++)a+="\n<column><![CDATA["+g(c[b].innerHTML)+"]]\></column>";o=c[0].offsetWidth;return a}function y(c,a){for(var b=parseInt(c.style.left),d=0;d<scheduler._cols.length;d++)if(b-=
scheduler._cols[d],b<0)return d;return a}function z(c,a){for(var b=parseInt(c.style.top),d=0;d<scheduler._colsS.heights.length;d++)if(scheduler._colsS.heights[d]>b)return d;return a}function w(c){for(var a="",b=c.firstChild.rows,d=0;d<b.length;d++){for(var e=[],h=0;h<b[d].cells.length;h++)e.push(b[d].cells[h].firstChild.innerHTML);a+="\n<row height='"+c.firstChild.rows[d].cells[0].offsetHeight+"'><![CDATA["+g(e.join("|"))+"]]\></row>";k=c.firstChild.rows[0].cells[0].offsetHeight}return a}function A(c){var a=
"<data profile='"+c+"'";m&&(a+=" header='"+m+"'");n&&(a+=" footer='"+n+"'");a+=">";a+="<scale mode='"+scheduler._mode+"' today='"+scheduler._els.dhx_cal_date[0].innerHTML+"'>";if(scheduler._mode=="agenda"){var b=scheduler._els.dhx_cal_header[0].childNodes[0].childNodes;a+="<column>"+g(b[0].innerHTML)+"</column><column>"+g(b[1].innerHTML)+"</column>"}else if(scheduler._mode=="year")for(var b=scheduler._els.dhx_cal_data[0].childNodes,d=0;d<b.length;d++)a+="<month label='"+g(b[d].childNodes[0].innerHTML)+
"'>",a+=q(b[d].childNodes[1].childNodes),a+=w(b[d].childNodes[2]),a+="</month>";else{a+="<x>";b=scheduler._els.dhx_cal_header[0].childNodes;a+=q(b);a+="</x>";var e=scheduler._els.dhx_cal_data[0];if(scheduler.matrix&&scheduler.matrix[scheduler._mode]){a+="<y>";for(d=0;d<e.firstChild.rows.length;d++)a+="<row><![CDATA["+e.firstChild.rows[d].cells[0].innerHTML+"]]\></row>";a+="</y>";k=e.firstChild.rows[0].cells[0].offsetHeight}else if(e.firstChild.tagName=="TABLE")a+=w(e);else{for(e=e.childNodes[e.childNodes.length-
1];e.className.indexOf("dhx_scale_holder")==-1;)e=e.previousSibling;e=e.childNodes;a+="<y>";for(d=0;d<e.length;d++)a+="\n<row><![CDATA["+g(e[d].innerHTML)+"]]\></row>";a+="</y>";k=e[0].offsetHeight}}a+="</scale>";return a}function r(c,a){return(window.getComputedStyle?window.getComputedStyle(c,null)[a]:c.currentStyle?c.currentStyle[a]:null)||""}function B(){var c="",a=scheduler._rendered;if(scheduler._mode=="agenda")for(var b=0;b<a.length;b++)c+="<event><head>"+g(a[b].childNodes[0].innerHTML)+"</head><body>"+
g(a[b].childNodes[2].innerHTML)+"</body></event>";else if(scheduler._mode=="year"){a=scheduler.get_visible_events();for(b=0;b<a.length;b++){var d=a[b].start_date;if(d.valueOf()<scheduler._min_date.valueOf())d=scheduler._min_date;for(;d<a[b].end_date;){var e=d.getMonth()+12*(d.getFullYear()-scheduler._min_date.getFullYear())-scheduler.week_starts._month,h=scheduler.week_starts[e]+d.getDate()-1;c+="<event day='"+h%7+"' week='"+Math.floor(h/7)+"' month='"+e+"'></event>";d=scheduler.date.add(d,1,"day");
if(d.valueOf()>=scheduler._max_date.valueOf())break}}}else for(b=0;b<a.length;b++){var f=j(a[b].style.left),i=j(a[b].style.width),l=t(a[b].style.top),m=t(a[b].style.height),n=a[b].className.split(" ")[0].replace("dhx_cal_",""),o=scheduler.getEvent(a[b].getAttribute("event_id")),h=o._sday,s=o._sweek;if(scheduler._mode!="month"){if(scheduler.matrix&&scheduler.matrix[scheduler._mode])h=0,s=a[b].parentNode.parentNode.parentNode.rowIndex,i+=j(10);else{i+=j(i*20/100);f-=j(20-f*20/100);if(a[b].parentNode==
scheduler._els.dhx_cal_data[0])continue;f+=j(a[b].parentNode.style.left);f-=j(51)}if(scheduler._mode=="timeline"){var q=k;k=180;l=t(a[b].style.top);k=q}}else m=parseInt(a[b].offsetHeight),l=parseInt(a[b].style.top)-22,h=y(a[b],h),s=z(a[b],s);c+="\n<event week='"+s+"' day='"+h+"' type='"+n+"' x='"+f+"' y='"+l+"' width='"+i+"' height='"+m+"'>";if(n=="event"){c+="<header><![CDATA["+g(a[b].childNodes[1].innerHTML)+"]]\></header>";var u=p?r(a[b].childNodes[2],"color"):"",v=p?r(a[b].childNodes[2],"backgroundColor"):
"";c+="<body backgroundColor='"+v+"' color='"+u+"'><![CDATA["+g(a[b].childNodes[2].innerHTML)+"]]\></body>"}else u=p?r(a[b],"color"):"",v=p?r(a[b],"backgroundColor"):"",c+="<body backgroundColor='"+v+"' color='"+u+"'><![CDATA["+g(a[b].innerHTML)+"]]\></body>";c+="</event>"}return c}function C(){var c="</data>";return c}var o=0,k=0,p=!1;f=="fullcolor"&&(p=!0,f="color");f=f||"color";html_regexp=RegExp("<[^>]*>","g");var l=(new Date).valueOf(),i=document.createElement("div");i.style.display="none";document.body.appendChild(i);
i.innerHTML='<form id="'+l+'" method="post" target="_blank" action="'+x+'" accept-charset="utf-8" enctype="application/x-www-form-urlencoded"><input type="hidden" name="mycoolxmlbody"/> </form>';document.getElementById(l).firstChild.value=A(f).replace("\u2013","-")+B()+C();document.getElementById(l).submit();i.parentNode.removeChild(i);grid=null};
