/* Copyright (C) 2007 - 2010 YOOtheme GmbH, YOOtheme License (http://www.yootheme.com/license) */

Zoo.ImportExport=new Class({initialize:function(b){this.setOptions({msgImportWarning:"Please choose a file first!"},b);var a=this;$("configuration-importexport").getElement('input[name="import-xml"]').addEvent("change",function(){$("filename").value=this.value});$("configuration-importexport").getElement("button.upload").addEvent("click",function(){$("filename").getValue()==""?alert(a.options.msgImportWarning):submitbutton("import")});$("configuration-importexport").getElements("a.exporter-link").each(function(c){c.addEvent("click",
function(){$("configuration-importexport").getElement('input[name="exporter"]').value=c.getProperty("id");submitbutton("importfrom")})});(b=$("configuration-importexport").getElement("button.export"))&&b.addEvent("click",function(){var c=$("configuration-importexport").getElement('input[name="format"]');c.value="raw";$("configuration-importexport").getElement('input[name="exporter"]').value="zoo2";submitbutton("doexport");c.value="html"})}});Zoo.ImportExport.implement(new Options);
Zoo.Import=new Class({initialize:function(b){this.setOptions({msgSelectWarning:"You didn't assign all item types. Items of these types will not be imported. Do you want to proceed anyway?",msgWarningDuplicate:"There are duplicate assignments. Do you still want to proceed?"},b);var a=this;this.form=$("configuration-import");(this.frontpage=this.form.getElement("fieldset.frontpage"))&&this.frontpage.getElement('input[name="import-frontpage"]').addEvent("change",function(){if(a.frontpage.getElement("div.assign-group"))this.getValue()?
a.frontpage.getElement("div.assign-group").setStyle("display",null):a.frontpage.getElement("div.assign-group").setStyle("display","none")});(this.categories=this.form.getElement("fieldset.categories"))&&this.categories.getElement('input[name="import-categories"]').addEvent("change",function(){if(a.categories.getElement("div.assign-group"))this.getValue()?a.categories.getElement("div.assign-group").setStyle("display",null):a.categories.getElement("div.assign-group").setStyle("display","none")});this.form.getElements("fieldset.items").each(function(c){c.getElement("select.type").addEvent("change",
function(){var f=this;c.getElements("li.assign").each(function(d){if(d=d.getElements("select.assign")){var g=new RegExp("\\["+f.getValue()+"\\]$");d.each(function(e){e.setStyle("display",e.getProperty("name").match(g)?"block":"none")})}})})});$("submit-button").addEvent("click",function(){if(a.hasDuplicateSelectedAssignments())alert(a.options.msgWarningDuplicate);else a.hasUnassignedTypes()&&!confirm(a.options.msgSelectWarning)||submitbutton("doimport")})},hasUnassignedTypes:function(){var b=this.form.getElements("select.type");
if(b)for(i=0;i<b.length;i++)if(b[i].value=="")return true;return false},hasDuplicateSelectedAssignments:function(){var b=this.form.getElements("div.assign-group");if(b)for(k=0;k<b.length;k++){var a=b[k].getElements("select.assign");if(a)for(i=0;i<a.length;i++)for(j=i+1;j<a.length;j++)if(a[i].value!=""&&a[i].value==a[j].value)return true}return false}});Zoo.Import.implement(new Options); 
