
/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by - filename.js -
 */

/* - ++resource++seo_custommetatags.js - */
// http://www.packing.ru/portal_javascripts/++resource++seo_custommetatags.js?original=1
customMetaTagsFunctions=new Object()
customMetaTagsFunctions.getInputOrSelect=function(node){var inputs=node.getElementsByTagName("input");if(inputs.length>0){return inputs[0]}
var selects=node.getElementsByTagName("select");if(selects.length>0){return selects[0]}
return null}
customMetaTagsFunctions.getWidgetRows=function(currnode){tbody=this.getParentElementById(currnode,"datagridwidget-tbody");return this.getRows(tbody)}
customMetaTagsFunctions.getRows=function(tbody){var rows=new Array()
child=tbody.firstChild;while(child!=null){if(child.tagName!=null){if(child.tagName.toLowerCase()=="tr"){rows=rows.concat(child)}}
child=child.nextSibling}
return rows}
customMetaTagsFunctions.autoInsertRow=function(e){var currnode=window.event?window.event.srcElement:e.currentTarget;var tbody=this.getParentElement(currnode,"TBODY");var rows=this.getRows(tbody);var lastRow=rows[rows.length-1];var thisRow=this.getParentElementById(currnode,"datagridwidget-row");if(rows.length-1==(thisRow.rowIndex)){var newtr=this.createNewRow(lastRow);lastRow.parentNode.insertBefore(newtr,lastRow);this.updateOrderIndex(tbody)}}
customMetaTagsFunctions.addRowAfter=function(currnode){var tbody=this.getParentElementById(currnode,"datagridwidget-tbody");var thisRow=this.getParentElementById(currnode,"datagridwidget-row");var newtr=this.createNewRow(thisRow);thisRow.parentNode.insertBefore(newtr,thisRow);this.updateOrderIndex(tbody)}
customMetaTagsFunctions.addRow=function(id){var tbody=document.getElementById("datagridwidget-tbody-"+id);var rows=this.getRows(tbody);var lastRow=rows[rows.length-1];var oldRows=rows.length;var newtr=this.createNewRow(lastRow);newNode=lastRow.parentNode.insertBefore(newtr,lastRow);this.updateOrderIndex(tbody)}
customMetaTagsFunctions.createNewRow=function(tr){var tbody=this.getParentElementById(tr,"datagridwidget-tbody");var rows=this.getRows(tbody);var lastRow=rows[rows.length-1];var newtr=document.createElement("tr");newtr.setAttribute("id","datagridwidget-row");newtr.setAttribute("class","datagridwidget-row");child=lastRow.firstChild;while(child!=null){newchild=child.cloneNode(true);newtr.appendChild(newchild);child=child.nextSibling}
return newtr}
customMetaTagsFunctions.removeFieldRow=function(node){var row=this.getParentElementById(node,'datagridwidget-row');var tbody=this.getParentElementById(node,'datagridwidget-tbody');tbody.removeChild(row)}
customMetaTagsFunctions.moveRowDown=function(currnode){var tbody=this.getParentElementById(currnode,"datagridwidget-tbody");var rows=this.getWidgetRows(currnode);var row=this.getParentElementById(currnode,"datagridwidget-row");if(row==null){alert("Couldn't find DataGridWidget row");return}
var idx=null
for(var t=0;t<rows.length;t++){if(rows[t]==row){idx=t;break}}
if(idx==null)
return;if(idx+2==rows.length){var nextRow=rows.item[0]
this.shiftRow(row,nextRow)} else{var nextRow=rows[idx+1]
this.shiftRow(nextRow,row)}
this.updateOrderIndex(tbody)}
customMetaTagsFunctions.moveRowUp=function(currnode){var tbody=this.getParentElementById(currnode,"datagridwidget-tbody");var rows=this.getWidgetRows(currnode);var row=this.getParentElementById(currnode,"datagridwidget-row");if(row==null){alert("Couldn't find DataGridWidget row");return}
var idx=null
for(var t=0;t<rows.length;t++){if(rows[t]==row){idx=t;break}}
if(idx==null)
return;if(idx==0){var previousRow=rows[rows.length-1]
this.shiftRow(row,previousRow)} else{var previousRow=rows[idx-1];this.shiftRow(row,previousRow)}
this.updateOrderIndex(tbody)}
customMetaTagsFunctions.shiftRow=function(bottom,top){bottom.parentNode.insertBefore(bottom,top)}
customMetaTagsFunctions.updateOrderIndex=function(tbody){var xre=new RegExp(/^orderindex__/)
var idx=0;var cell;var rows=this.getRows(tbody);for(var i=0;i<rows.length-1;i++){for(var c=0;(cell=rows[i].getElementsByTagName('INPUT').item(c));c++){if(cell.getAttribute('id')){if(xre.exec(cell.id)){cell.value=idx}}
this.updateRadioButtonGroupName(this.getParentElement(cell,"TR"),idx);idx++}}}
customMetaTagsFunctions.updateRadioButtonGroupName=function(row,newIndex){var cell;var xre=new RegExp(/^radio/)
var xre2=new RegExp(/^checkbox/)
for(var c=0;(cell=row.getElementsByTagName('INPUT').item(c));c++){if(cell.getAttribute('type')){var type=cell.getAttribute('type');if(xre.exec(type)||xre2.exec(type)){var name=cell.getAttribute("NAME")
if(name==null) continue;var baseLabel=name.substring(0,name.lastIndexOf("."));cell.setAttribute("NAME",baseLabel+"."+newIndex)}}}}
customMetaTagsFunctions.getParentElement=function(currnode,tagname){tagname=tagname.toUpperCase();var parent=currnode.parentNode;while(parent.tagName.toUpperCase()!=tagname){parent=parent.parentNode;if(parent.tagName.toUpperCase()=="BODY")
return null}
return parent}
customMetaTagsFunctions.getParentElementById=function(currnode,id){id=id.toLowerCase();var parent=currnode.parentNode;while(true){var parentId=parent.getAttribute("id");if(parentId!=null){if(parentId.toLowerCase().substring(0,id.length)==id) break}
parent=parent.parentNode;if(parent.tagName.toUpperCase()=="BODY")
return null}
return parent}

/* - ++resource++plonetruegallery-portlet.js - */
// http://www.packing.ru/portal_javascripts/++resource++plonetruegallery-portlet.js?original=1
(function($){$.fn.imagesLoaded=function(callback){var elems=this.filter('img'),len=elems.length;elems.bind('load',function(){if(--len<=0){callback.call(elems,this)}}).each(function(){if(this.complete||this.complete===undefined){var src=this.src;this.src='#';this.src=src}})};
function set_controls_position(container){var width=container.find('img').width();var left=(width/2)-43;container.find('div.gallery-portlet-controls').css("left",left)}
function get_image(link){var linkele=link[0];if(linkele.active!=undefined&&linkele.active){return}
linkele.active=true;var container=link.parents('dl.applied-portlet-gallery');var controls=link.parents('div.gallery-portlet-controls');var portlet_item=link.parents('dd.portletItem');var next=controls.find('span.next a');var prev=controls.find('span.prev a');var img=container.find('img');$.ajax({url:'@@get-image-for-gallery-portlet',data:link.attr('href').split('?')[1],type:'GET',success: function(data,results){eval("var json="+data);var newimg=document.createElement('img');newimg.src=json.src;newimg.width=img.width();newimg=$(newimg);newimg.css('display','none');portlet_item.css('height',img.height());img.fadeOut(1000, function(){img.replaceWith(newimg);newimg.imagesLoaded(function(){portlet_item.animate({height:$(this).height()},500,'linear');$(this).fadeIn(1000, function(){linkele.active=false})},newimg)
var linked=newimg.parent()
linked.attr('href',json['image-link']);linked.attr('title',json['title']);linked.attr('alt',json['description']);next.attr('href',next.attr('href').split('?')[0]+'?'+json['next-url']);prev.attr('href',prev.attr('href').split('?')[0]+'?'+json['prev-url']);set_controls_position(container)})}})}
function get_timeout_ele(portlet){if(portlet.hasClass('portletItem')){portlet=portlet.parent()}
return portlet.find("input.timeout_id")}
function get_timeout_id(portlet){var timeout_id=get_timeout_ele(portlet);if(timeout_id.size()==0){return 0}else{return parseInt(timeout_id.attr('value'))}}
function set_timeout_id(portlet,val){var timeout_id=get_timeout_ele(portlet);if(timeout_id.size()==0){portlet.append('<input type="hidden" name="timeout_id" class="timeout_id" value="'+val+'" />')}else{timeout_id.attr('value',val)}}
function perform_play(portlet){portlet.find('span.next a').trigger('click');set_timeout_id(portlet,setTimeout(function(){perform_play(portlet)},5000))}
function play(portlet){portlet.find('span.play-pause').addClass('timed');set_timeout_id(portlet,setTimeout(function(){perform_play(portlet)},5000))}
function pause(portlet){clearTimeout(get_timeout_id(portlet));portlet.find('span.play-pause').removeClass('timed')}
$(document).ready(function(){$('dl.portletGallery span.next a,dl.portletGallery span.prev a').click(function(){get_image($(this));return false});$('dl.portletGallery span.play-pause').css({'display':'inline'});var portlets=$('dl.portletGallery');portlets.addClass('applied-portlet-gallery');portlets.each(function(){var portlet=$(this);set_controls_position(portlet);if(portlet.hasClass('timed')){play(portlet)}else{pause(portlet)}});$('dl.portletGallery span.play-pause a').click(function(){var portlet=$(this).parent().parent().parent();if(portlet.find('span.play-pause').hasClass('timed')){pause(portlet)}else{play(portlet)}
return false});$('dl.portletGallery').hover(
function(){var controls=$(this).find('div.gallery-portlet-controls:not(.hide)');controls.fadeIn()},
function(){var controls=$(this).find('div.gallery-portlet-controls:not(.hide)');controls.fadeOut()})})})(jQuery);

