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

(function(c){var a=function(){};a.prototype=c.extend(a.prototype,{name:"ImportExport",options:{msgImportWarning:"Please choose a file first!"},initialize:function(b,e){this.options=c.extend({},this.options,e);var a=this;b.find("div.uploadbox").each(function(){var b=c(this).find("input.filename");c(this).find('input[name^="import-"]').bind("change",function(){b.val(this.value)});c(this).find("button.upload").bind("click",function(){b.val()==""?alert(a.options.msgImportWarning):submitbutton("import")})});
b.find("a.exporter-link").each(function(){var a=c(this);a.bind("click",function(){b.find('input[name="exporter"]').val(a.attr("id"));submitbutton("importfrom")})});b.find("button.export").bind("click",function(){var c=b.find('input[name="format"]');c.val("raw");b.find('input[name="exporter"]').val("zoo2");submitbutton("doexport");c.val("html")})}});c.fn[a.prototype.name]=function(){var b=arguments,e=b[0]?b[0]:null;return this.each(function(){var d=c(this);if(a.prototype[e]&&d.data(a.prototype.name)&&
e!="initialize")d.data(a.prototype.name)[e].apply(d.data(a.prototype.name),Array.prototype.slice.call(b,1));else if(!e||c.isPlainObject(e)){var f=new a;a.prototype.initialize&&f.initialize.apply(f,c.merge([d],b));d.data(a.prototype.name,f)}else c.error("Method "+e+" does not exist on jQuery."+a.name)})}})(jQuery);
(function(c){var a=function(){};a.prototype=c.extend(a.prototype,{name:"Import",options:{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.",msgNameWarning:"Please choose a name column.",task:"doimport"},initialize:function(b,a){this.options=c.extend({},this.options,a);var d=this;this.form=b;b.find("fieldset.frontpage, fieldset.categories").each(function(){var b=c(this);
b.find('input[name^="import-"]').bind("change",function(){c(this).is(":checked")?b.find("div.assign-group").show():b.find("div.assign-group").hide()})});b.find("fieldset.items").each(function(){var b=c(this);b.find("select.type").bind("change",function(){var a=c(this),e=RegExp("\\["+a.val()+"\\]$");b.find("li.assign select.assign").each(function(){c(this).attr("name").match(e)?c(this).show():c(this).hide()})})});c("#submit-button").bind("click",function(){d.options.task!="doimportcsv"&&d.hasDuplicateSelectedAssignments()?
alert(d.options.msgWarningDuplicate):d.options.task=="doimportcsv"&&!d.hasNameAssigned()?alert(d.options.msgNameWarning):(!d.hasUnassignedTypes()||confirm(d.options.msgSelectWarning))&&submitbutton(d.options.task)})},hasNameAssigned:function(){var b=!1;this.form.find("div.assign-group").each(function(){var a=RegExp("\\["+c(this).find("select.type").val()+"\\]$");c(this).find("select.assign").each(function(){c(this).attr("name").match(a)&&c(this).val()=="_name"&&(b=!0)})});return b},hasUnassignedTypes:function(){var b=
!1;this.form.find("select.type").each(function(){c(this).val()==""&&(b=!0)});return b},hasDuplicateSelectedAssignments:function(){var b=!1;this.form.find("div.assign-group").each(function(){var a=c(this).find("select.assign");for(i=0;i<a.length;i++)for(j=i+1;j<a.length;j++)if(value_a=c(a.get(i)).val(),value_b=c(a.get(j)).val(),value_a!=""&&value_a!="_category"&&value_a==value_b){b=!0;return}});return b}});c.fn[a.prototype.name]=function(){var b=arguments,e=b[0]?b[0]:null;return this.each(function(){var d=
c(this);if(a.prototype[e]&&d.data(a.prototype.name)&&e!="initialize")d.data(a.prototype.name)[e].apply(d.data(a.prototype.name),Array.prototype.slice.call(b,1));else if(!e||c.isPlainObject(e)){var f=new a;a.prototype.initialize&&f.initialize.apply(f,c.merge([d],b));d.data(a.prototype.name,f)}else c.error("Method "+e+" does not exist on jQuery."+a.name)})}})(jQuery);
