/*/20100908150457/public/javascripts/lang/en/editor_viewer.js built Wed Sep 08 17:06:11 +0200 2010 - last modified 2010-09-08 16:08:46*/
try{var Property=Class.create();
Property.handlePropertyNode=function(a,b){$("input[type=text]",b).rememberFocus().each(function(d,f){var e=f.name;
f.value=a[e];
var c=statusController;
$(f).change(function(){var g=a.validate(e,f.value);
if(g){f.value=a[e];
c.message(g,"error")
}})
});
$("input[type=checkbox]",b).each(function(c,e){var d=e.name;
e.checked=a[d];
$(e).change(function(){a.validate(d,e.checked)
})
})
};
Property.prototype={initialize:function(a){this.xml=a;
this.radioCounter=0;
this.checkboxCounter=0;
this.inputCounter=0;
this.optionCounter=0
},getDefault:function(){var data={};
var val;
$(this.xml[0].childNodes).each(function(i,n){if(n.nodeType==1&&$(n).attr("name")&&$(n).attr("default")){try{eval("val="+$(n).attr("default"));
data[$(n).attr("name")]=val
}catch(ex){dbg.error("Can't get property default value for "+$(n).attr("name")+" with "+$(n).attr("default"))
}}});
return data
},toNode:function(c){var a=this;
var b=$("<p></p>");
$(this.xml[0].childNodes).each(function(g,j){if(j.nodeType==1&&(!$(j).attr("plans")||$(j).attr("plans").split(",").include(v.planid.toString()))){var d=$("<"+($(j).attr("node")||"div")+"/>");
var e=$(j).attr("help");
if(e){HelpTag(e.replace(/\&apos;/g,"'")).appendTo(d)
}var h=$(j).attr("title");
if(h){$("<span>"+h+" </span>").appendTo(d)
}var f=propertyConverter["convert"+j.tagName.capitalize()].call(propertyConverter,c,$(j));
if(f.defaultAction&&$(j).attr("default_action")=="true"){a.defaultAction=f.defaultAction
}if(f.node){d.append($(f.node))
}b.append(d)
}});
return b
},defaultAction:function(){}}
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/helpers/property",exp)
},window.dbg?0:1000)
}try{var Content=Class.create();
Content.prototype={initialize:function(a){this.htmlText=a
},toNode:function(cpt){var self=this;
var node=$("<div class='componentBody'>"+this.htmlText+"</div>");
node.find("[uitype=editor],[uitype=captcha]").each(function(i,n){eval("self._convert"+$(n).attr("uitype").capitalize()+"(cpt,$(n))")
});
return node
},_convertEditor:function(b,a){a.mousedown(function(){return false
}).click(function(c){if(b.page.selectCpt(b)){editorController.select(b,a)
}})
},_convertCaptcha:function(c,b){var a=Math.random();
b.append("<img width=110 height=36 src=/simple_captcha/simple_captcha?simple_captcha_key="+a+" captcha_key="+a+" class='captcha_img'><input type='text' maxlength='3' name='captcha' class='captcha_field'>")
}}
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/helpers/content",exp)
},window.dbg?0:1000)
}try{var UI={initialize:function(){},loadDefault:function(){},onDisplay:function(a){},onSelect:function(){},onDeselect:function(){},onPropertyChanged:function(){},advancedProperties:function(){},onMoveZStart:function(){},onMoveZStop:function(){},onMoveStart:function(){},onMove:function(){},onMoveStop:function(){},onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},onRemove:function(){},onEdit:function(){this.component.propertyDefaultAction()
},onShow:function(){},onSave:function(){},onHide:function(){},onHashChange:function(){}}
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/components/ui",exp)
},window.dbg?0:1000)
}try{var ComponentType=Class.create();
ComponentType.prototype={initialize:function(dom,class_name){dom=$(dom);
this.metadata=dom.find("metadata");
if(""!=$.trim(dom.find("style").text())){var f=$("head").prepend("<style class='"+this.metadata.find("name").text()+"'>"+dom.find("style").text()+"</style>").find("style:last");
if($.browser.safari){f.append(" ")
}}eval(dom.find("script").text());
dom.find("includes link").each(function(){$(document.createElement("link")).attr({type:"text/css",rel:"stylesheet",media:"screen"}).prependTo($("head")).attr("href",$(this).attr("href"))
});
this.help=this.metadata.find("help").text().replace(/\&apos;/g,"'");
this.width=100;
this.height=100;
var max=this.metadata.find("max");
if(max[0]){this.max={fg:parseInt(max.attr("fg")),bg:parseInt(max.attr("bg"))}
}var size=this.metadata.find("size");
if(size[0]){var w=size.attr("width");
var h=size.attr("height");
if(w){this.width=w
}if(h){this.height=h
}}this.content=new Content(dom.find("content").text());
this.properties=new Property(dom.find("properties"));
this.counter=0
},getCounter:function(){return this.counter++
}}
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/model/component_type",exp)
},window.dbg?0:1000)
}try{var UI_List={};
var ComponentTypeFileController=Class.create();
ComponentTypeFileController.prototype={initialize:function(a,b){this.component_type=a;
this.lang=b;
this.status="not_loaded";
this.waiting_list=new Array()
},fileLoad:function(b){if(versionController){versionController.bindButtons(false)
}if(this.status=="not_loaded"){this.status="loading";
var a=this;
this.waiting_list.push(b);
$.ajax({type:"GET",url:"/javascripts/application/components/"+this.lang+"/"+this.component_type.class_name+".xml",dataType:"xml",name:sprintf("Downloading %s blocks",this.component_type.title.capitalize()),cache:false,success:function(c){a.fileReceived(c)
},error:function(d,c){statusController.message(sprintf("%s block could not be downloaded.<br/>Please check your Internet connection and try again.",a.component_type.title.toLowerCase()).capitalize(),"warning",10000,5);
a.extendFail()
}})
}else{if(this.status=="loading"){this.waiting_list.push(b)
}else{this.extendUi(b)
}}},fileReceived:function(c){var b=new ProgressController(sprintf("Loading %s blocks",this.component_type.title.capitalize()));
Object.extend(this.component_type,new ComponentType(c,this.component_type.class_name));
var a=Class.create();
Object.extend(a.prototype,UI);
Object.extend(a.prototype,UI_List[this.component_type.class_name]);
UI_List[this.component_type.class_name]=a;
this.status="loaded";
while(this.waiting_list.length>0){this.extendUi(this.waiting_list.pop())
}b.update(100)
},extendUi:function(b){b.component_type=this.component_type;
var a=this;
setTimeout(function(){b.ui=new UI_List[a.component_type.class_name](b);
b.ui.component=b;
b.uiExtended();
if(versionController){versionController.bindButtons(true)
}},0)
},extendFail:function(){while(this.waiting_list.length>0){var a=this.waiting_list.pop();
if(!a.id){a.page.rmCpt(a)
}}this.status="not_loaded";
if(versionController){versionController.bindButtons(true)
}}}
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/controllers/component_type_file_controller",exp)
},window.dbg?0:1000)
}try{var ComponentTypeController=Class.create();
ComponentTypeController.prototype={initialize:function(c,d){this.lang=d;
var a=this;
this.file_controller_list=new Array();
for(var b=0;
b<c.length;
b++){this.file_controller_list.push(new ComponentTypeFileController(c[b],this.lang))
}this.cpt_width=55
},extendUi:function(a){for(var b=0;
b<this.file_controller_list.length;
b++){if(this.file_controller_list[b].component_type.id==a.component_type_id){this.file_controller_list[b].fileLoad(a);
break
}}},showCptName:function(d,a){var e=d.offset();
var c=($.browser.msie&&$.browser.version.substring(0,1)=="6")?0:$().scrollTop();
var b=($.browser.msie&&$.browser.version.substring(0,1)=="6")?0:$().scrollLeft();
$("#cpttp_t").html(a).css({top:e.top+50-c,left:e.left-this.cpt_width-b}).show()
},hideCptName:function(){$("#cpttp_t").hide()
},fillList:function(e){var l=0,j=[{s:"starter",h:"Starter blocks",n:$("#cpttp_s"),c:0},{s:"premium",h:"Premium and Pro blocks",n:$("#cpttp_p"),c:0}];
var k=e.find(".list").empty();
if(k.length==0){k=$("<div class='list'></div>").appendTo(e);
j.each(function(c){["tl","tr","br","bl","b","l","r"].each(function(o){$("<div class='"+o+"'></div>").prependTo(c.n)
});
c.n.prepend($('<img src="http://st0.sitew.org/images/icons/drop.png?1272384009" class="close" title="Hide the block list"/>').click(function(){$(this).parent().slideUp("fast")
}))
})
}j.each(function(c){c.n.hide().find(".cpttp_menu_content").empty();
c.p=$("<span class='showMenu' href='#'><img class='icon' src='/images/packages/icons/"+c.s+"/48.png'/></a></span>").prepend(HelpTag(c.h))
});
var h=$(window).width(),g=this.cpt_width,n=45,b=480,d=160,i=40,a=30;
var f=Math.floor((h-(b+d))/g)-1;
var m=this;
this.file_controller_list.each(function(t){var s=t.component_type;
var c=$("<span class='addComponent' href='#'><img class='icon' src='/images/types/"+s.class_name+"/48.png'/></span>");
if(s.pack==0&&l<f){l+=1;
c.appendTo(k)
}else{var q=s.pack==0?0:1;
j[q].c+=1;
c.appendTo(j[q].n.find(".cpttp_menu_content"))
}c.addClass("clickable").prepend(HelpTag(s.description));
c.hover(function(){m.showCptName(c,s.title)
},function(){m.hideCptName()
});
if(v.planid<s.pack){c.mousedown(function(){if(s.pack==1){statusController.message(sprintf("You need to %s\u003Cb\u003Eupgrade\u003C/b\u003E%s your website to have access to the \u003Cb\u003EPremium and Pro blocks\u003C/b\u003E...","<a href='http://www.sitew.com/My-websites?upgrade=1' target=_blank>","</a>"),"warning")
}else{statusController.message(sprintf("You need to %s\u003Cb\u003Eupgrade\u003C/b\u003E%s your website to have access to the \u003Cb\u003EPro blocks\u003C/b\u003E...","<a href='http://www.sitew.com/My-websites?upgrade=2' target=_blank>","</a>"),"warning")
}}).find("img.icon").enableImg(false).after("<img src='http://st2.sitew.org/images/icons/locked.png?1272384009' style='position:absolute;bottom:0;left:25px'>");
return
}if(!($.browser.msie&&$.browser.version.substring(0,1)=="6")){c=c.find("img.icon")
}var x={x:0,y:0};
var u;
var r=null,y;
var w=document.documentElement;
var o;
if(!$.browser.msie){o=function(z){y.left=z.pageX+"px";
y.top=z.pageY+"px"
}
}else{o=function(z){y.left=z.clientX+w.scrollLeft+"px";
y.top=z.clientY+w.scrollTop+"px";
return false
}
}var p=function(B){r.remove();
$().unbind("mouseup",p);
$().unbind("mousemove",o);
var A=jQuery.iUtil.getPosition($("#pages")[0]);
var z={x:B.pageX-A.x,y:B.pageY-A.y};
if(B.clientY>100){v.getSelectedPage().addCpt(s.id,z)
}else{if(B.pageY==u.y&&B.pageX==u.x){v.getSelectedPage().addCpt(s.id)
}}};
c.mousedown(function(z){editorController.deselect();
r=$(this).clone().appendTo($("body")).css({position:"absolute","z-index":10000});
y=r[0].style;
u={x:z.pageX,y:z.pageY};
o(z);
$().mousemove(o);
$().mouseup(p);
return false
})
});
j.each_with_index(function(o,c){if(c.c>0){c.p.bind((v.planid<o)?"click":"mouseover",function(){j.each(function(s){if(c.n!=s.n){s.n.hide()
}});
if(c.n.is(":hidden")){var q=0,p=0,r=0;
q=$(this).offset().left-$(window).scrollLeft()-c.c*g/2-i/2;
q=(q>b)?q:b;
p=c.c*g;
if(h-(b+i*2)<p){var p=Math.floor((h-(b+i*2))/g)*g;
q=b
}r=Math.ceil(c.c/(p/g))*n;
if(q>=g&&r>=n&&q!=Infinity&&r!=Infinity){c.n.css({left:q,width:p,height:r}).slideDown("fast");
if($.browser.msie&&$.browser.version.substring(0,1)=="6"){c.n.attr("style","left:expression(documentElement.scrollLeft+body.scrollLeft + "+q+"+ 'px');width:"+p+"px")
}c.n.find(".l, .r").height(r-a);
c.n.find(".b").width(p)
}else{statusController.message("Your browser is not large enough.\u003Cbr\u003EEnlarge the window to see the block list.","warning",3000)
}}})
}else{c.p.hover(function(){m.showCptName(c.p,c.h)
},function(){m.hideCptName()
})
}});
if(j[0].c>0){l+=1;
j[0].p.appendTo(k)
}j[1].p.appendTo(k);
l+=1;
if(j[1].c==0){j[1].p
}k.width(l*this.cpt_width)
}}
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/controllers/component_type_controller",exp)
},window.dbg?0:1000)
}try{var ComponentController=Class.create();
ComponentController.prototype={initialize:function(b){this.component=b;
this.node=b.node;
this.selectHandleEnabled=false;
$("#cpt_ctrl_tools").children().clone().appendTo(this.node);
if(this.component.component_type.class_name=="UI_Menu"){this.node.find("span.upper,span.downer").remove()
}this.cptOver=this.node.find("div.cptOver").addClass("invisible");
if(this.component.component_type.class_name=="UI_Menu"){this.cptOver.hide();
this.addSelectHandle("all")
}this.editBtn=this.node.find("table.editBtn").hide();
this.gotoBg=this.node.find("div.gotoBg").hide();
this.cptSelected=this.node.find("div.cptSelected");
this.cptCtrl=this.node.find("div.Ctrl").hide();
this.pageList=$("#cptCopy");
this.resizeSelectedBackground();
this.node.find("span.selecter").append(HelpTag("<h3>Block actions</h3>"+sprintf("\u003Cb\u003EMove\u003C/b\u003E Drag drop it from a part of its area or use %s or Arrow keys<br/>","<img src='http://st0.sitew.org/images/icons/move.gif?1202744559'/> ")+"\u003Cb\u003EResize\u003C/b\u003E Use anchors surrounding it or Ctrl key + Arrows<br/>\u003Cb\u003EDeselect\u003C/b\u003E Click on an empty area of the page.<br/>"+sprintf("\u003Cb\u003EEdit\u003C/b\u003E Click on the pen %s in the center of the block or in this toolbar.<br/>","<img src='http://st2.sitew.org/images/icons/edit_orig.gif?1205425728'/>")+sprintf("\u003Cb\u003EDuplicate\u003C/b\u003E Click on the button %s to duplicate the block.<br/>","<img src='http://st1.sitew.org/images/icons/clone.gif?1205425728'/>")+"\u003Cb\u003EChange options\u003C/b\u003E Use the properties displayed on the bottom left of the screen.<br/>"+sprintf("\u003Cb\u003EChange layer\u003C/b\u003E %s raises to top, %s lowers to background.<br/>","<img src='http://st3.sitew.org/images/icons/raise.gif?1202740007'/>","<img src='http://st3.sitew.org/images/icons/lower.gif?1202740007'/>")+sprintf("\u003Cb\u003EDelete\u003C/b\u003E %s or Del key.","<img src='http://st1.sitew.org/images/icons/trash16.gif?1219751217'/>")));
var f=this.component;
var a=this;
this.node.find(".cptOver, .editBtn, span.mover").mousedown(function(g){if(f.page.selectCpt(f)){jQuery.iDrag.draginit.apply(this,[g])
}return false
});
this.node.mousedown(function(g){f.page.version.eventTargetSelected=g.target
});
this.node.find("span.upper").addClass("clickable").mouseup(function(g){f.page.moveToTop(f);
return true
});
this.node.find("span.downer").addClass("clickable").mouseup(function(){f.page.moveToBottom(f);
return true
});
this.node.mousedown(function(){a.pageList.hide()
});
this.node.mouseup(function(){a.pageList.hide()
});
this.node.find("span.cloner").addClass("clickable").click(function(){if(f.component_type.class_name=="UI_Menu"){a.copyTo(v.page_bg)
}else{var h=$.iUtil.getPosition(this);
var g=$.iUtil.getSize(this);
a.pageList.css({top:h.y+g.hb,left:h.x+g.wb-a.pageList.width()});
editorController.deselect();
var e=$("ul",a.pageList).empty();
$("<li>Current page</li>").appendTo(e).mouseup(function(){a.copyTo(f.page);
a.pageList.hide();
return false
});
if(f.page!=v.page_bg){$("<li class='break'>Background page</li>").appendTo(e).mouseup(function(){a.copyTo(v.page_bg);
a.pageList.hide();
return false
})
}v.pages_fg.each(function(i){if(f.page!=i){$("<li>"+i.name+"</li>").appendTo(e).mouseup(function(){a.copyTo(i);
a.pageList.hide();
return false
})
}});
e.find("li:even").css({"background-color":"white"});
a.pageList.show();
return false
}});
this.node.find("span.remover").addClass("clickable").mousedown(function(){return false
}).mouseup(function(){if(confirm("Do you really want to remove this block?")){f.page.rmCpt(f);
return true
}});
this.node.Draggable({zIndex:10000,ghosting:false,scrollBottomLimit:20,scrollTopLimit:65+20,snapDistance:5,containment:"#body",handle:".cptOver, .editBtn, span.mover",onStart:function(){f.page.setHeight(10000);
f.moveStart()
},onStop:function(){f.moveStop()
},onDrag:function(e,g){f.move(e,g)
}});
this.node[0].dragCfg.dhe.unbind("mousedown",jQuery.iDrag.draginit);
$("#dragHelper").css("overflow","visible");
this.node.Resizable({onStart:function(){f.resizeStart();
f.page.setHeight(10000)
},onResize:function(e,g){f.resize();
a.resizeSelectedBackground();
return{sizes:e,position:g}
},onStop:function(){var n={width:f.W(),height:f.H()};
var g={top:f.Y(),left:f.X()};
var h=jQuery.iUtil.getPosition(a.node[0]);
var e=jQuery.iUtil.getSize(a.node[0]);
var i=$("#body")[0];
var m=jQuery.iUtil.getPosition(i);
var k=jQuery.iUtil.getSize(i);
var j=h.y-g.top;
var l=h.x-g.left;
if(h.y<m.y){h.y=m.y
}if(h.x<m.x){h.x=m.x
}if(h.y+e.h>m.y+k.h){e.h=m.y+k.h-h.y
}if(h.x+e.w>m.x+k.w){e.w=m.x+k.w-h.x
}h.y-=j;
h.x-=l;
f._setXYZWH({x:h.x,y:h.y,w:e.w,h:e.h});
f.resizeStop();
a.resizeSelectedBackground()
},handlers:{ne:this.node.find("div.NE"),nw:this.node.find("div.NW"),se:this.node.find("div.SE"),sw:this.node.find("div.SW")},minWidth:1,minHeight:1,maxWidth:3000,maxHeight:5000,minTop:0,minLeft:0,maxRight:5000,maxBottom:20000,scrollBottomLimit:20,scrollTopLimit:65+20});
this.node.hover(function(){if(f.page.selectedCpt!=f&&f.component_type.class_name!="UI_Menu"){a.cptOver.removeClass("invisible");
if(!f.page.selectable){a.cptOver.addClass("unselectable");
a.editBtn.hide();
a.gotoBg.show()
}else{a.gotoBg.hide();
a.editBtn.show();
a.cptOver.attr({title:""})
}}},function(){if(f.page.selectedCpt!=f){a.cptOver.addClass("invisible").removeClass("unselectable");
a.editBtn.hide().removeClass("unselectable")
}a.gotoBg.hide();
f.node.css("cursor","auto")
});
var d=function(){f.edit();
a.editBtn.hide();
a.cptOver.hide()
};
this.editBtn.find("img").hover(function(){a.editBtn.addClass("mouseover")
},function(){a.editBtn.removeClass("mouseover")
}).mouseup(d);
try{this.editBtn.dblclick(d)
}catch(c){dbg.error("editBtn.dblclick error",c)
}this.node.find("span.editer").addClass("clickable").mouseup(d)
},enable:function(a){if(a){this.cptCtrl.show();
this.resizeSelectedBackground();
this.cptOver.removeClass("invisible unselectable");
this.editBtn.show();
this.gotoBg.hide();
sigCtl.emit("ComponentController.enable",this.node)
}else{editorController.deselect();
this.pageList.hide();
this.cptCtrl.hide();
if(this.component.component_type.class_name!="UI_Menu"){this.cptOver.show().addClass("invisible")
}this.editBtn.hide()
}this.displaySelectHandle(!a)
},setAspectRatio:function(a){this.node[0].resizeOptions.ratio=a
},resizeSelectedBackground:function(){var a=this.component.W();
var b=this.component.H();
this.cptSelected.width(a).height(b);
this.cptOver.width(a).height(b);
this.editBtn.width(a).height(b);
var c=Math.min(a,b);
if(c>512){c=256
}else{if(c>256){c=128
}else{if(c>128){c=64
}else{if(c>64){c=32
}else{c=16
}}}}this.editBtn.find("img").attr({src:"/images/edit/edit_"+c+".jpg"})
},addSelectHandle:function(a){if(a=="linux"){if((new String(navigator.platform)).search("Linux|X11")!=-1){this.selectHandleEnabled=true;
this.displaySelectHandle(true)
}}else{if(a=="all"){this.selectHandleEnabled=true;
this.displaySelectHandle(true)
}}},displaySelectHandle:function(b){if(this.selectHandleEnabled){if(!this.selectHandleNode){var a=this;
this.selectHandleNode=$('<a class="selectHandle" href="#"><img src="http://st0.sitew.org/images/icons/select.png?1272384009" border="0"/></a>').appendTo(this.node).mousedown(function(d){var c=a.component;
c.page.selectCpt(c);
return false
})
}if(b&&this.component.page.selectable){this.selectHandleNode.show()
}else{if(b&&(this.component.component_type.class_name=="UI_Menu")){this.selectHandleNode.show()
}else{this.selectHandleNode.hide()
}}}},copyTo:function(a){this.component.deselect();
this.component.clone(a)
}}
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/controllers/component_controller",exp)
},window.dbg?0:1000)
}try{var ProgressController_={progress_objects:{},object_id:0,busy:function(){return this.last_shown!=null
},last_shown:null};
var ProgressController=Class.create();
ProgressController.prototype={initialize:function(a){this.id=ProgressController_.object_id;
ProgressController_.progress_objects[this.id]=this;
this.name=a;
ProgressController_.object_id+=1;
this.update(0);
this.paused=false
},update:function(a,i){this.paused=false;
this.progress=a;
var h=0;
var b;
var c=0;
var f=101;
var e;
for(b in ProgressController_.progress_objects){var g=ProgressController_.progress_objects[b].progress;
if(g<f){f=g;
e=b
}h+=g;
c+=1
}if(h==100*c){statusController.progressMessage("Done",100);
ProgressController_.progress_objects={};
ProgressController_.last_shown=null;
sigCtl.emit("Progress.allFinished")
}else{if(ProgressController_.last_shown==null){sigCtl.emit("Progress.begin",JSON_.stringify(ProgressController_))
}if(a<100&&!i){ProgressController_.last_shown=this.id
}else{if(ProgressController_.last_shown==null||ProgressController_.progress_objects[ProgressController_.last_shown].progress>=100){ProgressController_.last_shown=e
}}try{statusController.progressMessage(ProgressController_.progress_objects[ProgressController_.last_shown].name,h/c)
}catch(d){dbg.error("progress message error ",ProgressController_,this.id,d.toString(),h/c)
}}}};
setInterval(function(){for(var a in ProgressController_.progress_objects){if(!ProgressController_.progress_objects[a].paused){ProgressController_.progress_objects[a].update(ProgressController_.progress_objects[a].progress+(100-ProgressController_.progress_objects[a].progress)/30,true)
}}},400)
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/controllers/progress_controller",exp)
},window.dbg?0:1000)
}try{var ModelTransfer={type:"POST",dataType:"json",error_to_json:true,cache:false};
var Model=Class.create();
Model.prototype={initialize:function(){this.type="Model"
},m_get:function(){var a=this;
$.ajax(Object.extend({url:"/json/get",name:"Loading page",data:{type:this.type,id:this.id},success:function(b){if(b.access_denied){a.showing=false;
a.requestSent=false;
secCtrl.popup();
return false
}else{a.showing=true;
a.requestSent=true;
a.getCallback(b)
}}},ModelTransfer))
},m_copy:function(c,d,a){var b=this;
$.ajax(Object.extend({url:"/json/copy"+c,name:"Copy in progress",data:d,success:function(e){b.getCallback(e);
if(a){a(b)
}}},ModelTransfer))
},getCallback:function(b){if(!b.errors){if(b.attributes){for(var c in b.attributes){this[c]=b.attributes[c]
}}for(var d in b){if(d!="attributes"){if(!b[d]){this[d]=null
}else{if(b[d].constructor==Array){for(var a=0;
a<(b[d].length);
a++){this[d].push(new window[d.capitalize()](this));
this[d][this[d].length-1].getCallback(b[d][a])
}}else{this[d]=new window[d.capitalize()](this);
this[d].getCallback(b[d])
}}}}}else{sigCtl.emit("Model.error",{action:"get",errors:b.errors,item:this})
}if(this.loaded){this.loaded()
}},m_post:function(){var a=this;
$.ajax(Object.extend({url:"/json/post",name:"Updating items",data:Object.extend({type:this.type,id:this.id},this.to_json()),success:function(b){return a.postCallback(b)
}},ModelTransfer))
},postCallback:function(a){if(this.saveChildren){this.saveChildren()
}if(!a.success){sigCtl.emit("Model.error",{action:"post",errors:a.errors,item:this});
this.setHasChanged();
return false
}},m_delete:function(b){if(this.id){var a=this;
$.ajax(Object.extend({url:"/json/delete",name:"Deleting removed items",data:{type:this.type,id:this.id},success:function(c){a.deleteCallback(c);
b(c)
}},ModelTransfer))
}},deleteCallback:function(a){if(!a.success){sigCtl.emit("Model.error",{action:"delete",errors:a.errors,item:this})
}},m_put:function(b){var a=this;
if(!b){b=this.to_json()
}$.ajax(Object.extend({url:"/json/put",name:"Saving new items",data:Object.extend({type:this.type},b),success:function(c){return a.putCallback(c)
}},ModelTransfer))
},putCallback:function(a){if(a.success){this.id=a.id;
if(a.idserver){this.idserver=a.idserver
}if(this.saveChildren){this.saveChildren()
}}else{sigCtl.emit("Model.error",{action:"put",errors:a.errors,item:this});
this.setHasChanged();
return false
}},save:function(){if(this.id){if(this.hasChanged){this.m_post();
this.hasChanged=false
}else{return false
}}else{this.m_put()
}return true
}}
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/model/model",exp)
},window.dbg?0:1000)
}try{var Page=Class.create();
Object.extend(Page.prototype,new Model);
Object.extend(Page.prototype,{initialize:function(){},pageInit:function(a){this.version=a;
this.type="Page";
this.cpts=new Array();
this.cptToDelete=new Array();
this.selectedCpt=null;
this.requestSent=false;
this.selectable=true;
this.nbr_components=0;
this.nbrComponentsDisplayed=0;
this.hasChanged=false;
this.level=0;
this.order=0;
this.myheight=0;
this.showing=false;
this.node=$("#pages")
},create:function(){this.requestSent=true
},show:function(){var a=this;
if(!this.showing){this.showing=true;
this.loadComponents(function(){a.display()
})
}},to_json:function(){var a={name:this.name,version_id:this.version.id,order:this.order,level:this.level,security:JSON_.stringify(this.security),pageid:this.pageid};
if(this.seo){a.seo=JSON_.stringify(this.seo)
}return a
},toJSON:function(){return{type:"page",name:this.name,version_id:this.version.id,id:this.id,cpts:this.cpts}
},loadComponents:function(a){if(a){this.postLoading=a
}if(this.nbr_components>0){if(!this.requestSent){this.requestSent=true;
this.m_get()
}else{if(this.extended){this.cptsDisplayed()
}this.loaded()
}}else{this.requestSent=true;
this.cptsDisplayed();
this.loaded()
}},addCpt:function(d,b){if(!v.selectedPageFg){$("#bg_wng_msg").highlight(2000)
}else{if(d==5&&this.selectable){return v.page_bg.addCpt(d,b)
}}this.setHasChanged();
var a=new Cpts(this);
push_origin={function_name:"page.addcpt",type_id:d};
this.pushCpt(a);
a.setStartupXYZWH=b;
a.create(d);
return a
},pushCpt:function(a){if(a.id&&this.cpts.find(function(b){return b.id==a.id
})){dbg.error("Pushing a cpt already present",{cpt_pushed:a,version:v,push_origin:push_origin})
}this.cpts.push(a);
this.nbr_components+=1;
return a
},rmCpt:function(c){this.deselectCpt();
this.nbr_components-=1;
this.nbrComponentsDisplayed-=1;
if(this.countType){this.countType[c.component_type_id]-=1
}var b=JSON_.stringify_safe(this.cpts);
var a=this.cpts.length;
this.cpts.remove(c);
if(a!=this.cpts.length+1){dbg.error("Error removing component",{cpts_before_remove:b,cpts:this.cpts,cpt_to_remove:c})
}if(this.cpts.indexOf(c)>=0){dbg.error("Cpt still present in list after remove",{cpts:this.cpts,index:this.cpts.indexOf(c),cpt_to_remove:c,cpts_before_remove:b})
}if(c.id&&this.cpts.find(function(d){return c.id==d.id
})){dbg.error("Cpt with same id exist after remove",{cpts:this.cpts,cpt_to_remove:c,cpts_before_remove:b})
}c.remove();
if(c.id){this.cptToDelete.push(c)
}this.setHasChanged();
this.version.checkHeight()
},selectCpt:function(b){var a=this;
if(b.component_type.class_name=="UI_Menu"){a=v.selectedPageFg||this
}if(!a.selectable&&v.selectedPageFg){$("#bgPage").highlight();
statusController.message("This block is on the background.\u003Cbr\u003EClick on the \u003Ci\u003EBackground\u003C/i\u003E button on the left to modify it.","warning")
}else{if(b!=a.selectedCpt){if(a.selectedCpt){a.selectedCpt.deselect()
}a.selectedCpt=b;
b.select();
propertyController.show(b)
}}return a.selectable
},deselectCpt:function(){if(this.selectedCpt){this.selectedCpt.deselect()
}this.selectedCpt=null;
propertyController.show(this)
},cptDisplayed:function(a){this.nbrComponentsDisplayed+=1;
if(this.nbrComponentsDisplayed==this.nbr_components){this.cptsDisplayed()
}},cptsDisplayed:function(){this.extended=true;
this.version.checkHeight();
this.showing=false;
if(this.getClass()=="page_bg"){sigCtl.emitVariable("PageBg.shown")
}sigCtl.emit("Page.shown",this)
},loaded:function(){if(this.postLoading){this.postLoading();
this.postLoading=null
}if($.browser.msie&&$.browser.version<8){setTimeout(function(){if(v.mode=="editor"){$("#pages").hide(1).show(1)
}},0)
}},saveChildren:function(){var a=this;
this.cptToDelete.each(function(b){b.m_delete(function(c){if(c.success){a.cptToDelete.remove(b)
}else{a.setHasChanged();
return false
}})
});
this.cpts.each(function(b){b.save()
})
},remove:function(){this.hide();
for(var a=this.cpts.length-1;
a>=0;
a--){this.cpts[a].remove()
}delete this.cpts
},zOnTop:function(){var a=0;
for(var b=this.cpts.length-1;
b>=0;
b--){if(a<this.cpts[b].Z()){a=this.cpts[b].Z()
}}if(a>=this.maxZIndex-1){a=this.setAllZIndeces().max
}if(a==0){return(this.maxZIndex-this.minZIndex)/2+this.minZIndex
}else{return a
}},moveToTop:function(b){var a=this.zOnTop();
if(b.Z()!=a){b.setXYZWH({z:this.zOnTop()+2})
}},moveToBottom:function(b){var a=b.Z();
for(var d=this.cpts.length-1;
d>=0;
d--){if(a>this.cpts[d].Z()){a=this.cpts[d].Z()
}}if(a!=b.Z()){if(a<=this.minZIndex+2){a=this.setAllZIndeces().min
}b.setXYZWH({z:(a-2)})
}},setAllZIndeces:function(){this.cpts.sort(function(d,c){return d.Z()-c.Z()
});
var a=(this.maxZIndex-this.minZIndex)/2+this.minZIndex-this.cpts.length;
for(var b=0;
b<this.cpts.length;
b++){this.cpts[b].setXYZWH({z:a});
a+=2
}return{min:this.cpts[0].Z(),max:this.cpts[this.cpts.length-1].Z()}
},display:function(){for(var a=this.cpts.length-1;
a>=0;
a--){this.cpts[a].node.show();
this.cpts[a].ui.onShow()
}},hide:function(){for(var a=this.cpts.length-1;
a>=0;
a--){this.cpts[a].node.hide();
this.cpts[a].ui.onHide()
}if(this.selectedCpt){this.selectedCpt.deselect()
}this.selectedCpt=null
},height:function(){return this.myheight
},setHeight:function(c){this.node.height(c);
var b=$().scrollTop();
$("#pageContainer").height(c);
$().scrollTop(b);
if(isIE6){$("#body").hide().show()
}},setSecurity:function(a){this.security=a;
this.setHasChanged()
},setHasChanged:function(){this.hasChanged=true;
this.version.setHasChanged()
},checkHeight:function(){var a=0;
this.cpts.each(function(d){if(!d.node.is(":visible")){return
}var b=d.Y()+d.H();
if(b>a){a=b
}});
this.myheight=a;
return a
},checkWidth:function(){var a=0;
this.cpts.each(function(f){var d=f.component_type.class_name;
var b=f.X();
var e=b+f.W()-400;
if(Math.abs(b-400)>a){a=Math.abs(b-400)
}if(e>a){a=e
}});
return a
},checkType:function(b){var a=this.getTypeMax(b);
if(a||a==0){this.countType=this.countType||{};
this.countType[b.component_type_id]=(this.countType[b.component_type_id]+1)||1;
if(this.countType[b.component_type_id]>a){statusController.message(sprintf("This block can not be added (this page can not contain more than %d).\u003Cbr\u003EPlease add this block on another page...",a),"warning",5000,5);
this.rmCpt(b);
return false
}}return true
}});
var Pages_fg=Class.create();
Object.extend(Pages_fg.prototype,new Page);
Object.extend(Pages_fg.prototype,{initialize:function(a){this.visible=true;
this.pageInit(a);
this.maxZIndex=10000;
this.minZIndex=5000;
this.security={};
this.cptUrl=null;
this.cptTitle=null
},clone:function(a){var b=new Pages_fg(a);
b.create();
this.cpts.sort(function(d,c){return d.Z()-c.Z()
});
this.cpts.each(function(d){d.clone(b)
});
b.nbr_components=0;
return b
},getClass:function(){return"page_fg"
},getHash:function(a,b){b=b||this.cptUrl;
var c=this.name.to_alphanumeric()+"."+this.pageid;
if(!a&&b){c+=b
}return c
},getUrl:function(a,b){b=b||this.cptUrl;
return"/"+this.getHash(a,b)+((!a&&b)?"":".htm")
},getTitle:function(){if(this.cptTitle){return this.cptTitle
}else{if(this.seo&&this.seo.title&&this.seo.title!=""){return this.seo.title
}else{return this.name
}}},setCptUrl:function(a,b){if(this.cptUrl!=a){this.cptUrl=a;
if(b){this.cptTitle=b
}v.setHash(this)
}},getStatName:function(){return(this.cptUrl?this.name+this.cptUrl:this.name)
},validate:function(a,b){switch(a){case"name":if(this.name==b){return
}else{if(b==""){return"Name cannot be empty."
}else{this.name=b;
sigCtl.emit("Page.name.changed");
this.setHasChanged();
return
}}break;
case"security":this.setSecurity(b);
break
}},getPropertyNode:function(){if(!this.propertyNode){this.propertyNode=$("#page_property").clone();
this.propertyNode.HandleHelpTooltip();
Property.handlePropertyNode(this,this.propertyNode)
}return this.propertyNode
},getIcon:function(a){return"http://st0.sitew.org/images/icons/page16.png?1201252313"
},getName:function(){return"Page"
},getTypeMax:function(a){if(a.component_type&&a.component_type.max){return a.component_type.max.fg
}else{return null
}},previous:function(){var a=null;
var b=0;
while(!a&&b<v.pages_fg.length){if(this.version.pages_fg[b]==this){a=b
}b++
}if(a>0){return this.version.pages_fg[a-1]
}else{return null
}},parentPage:function(){var a=this.previous();
while(a!=null&&a.level>=this.level){a=a.previous()
}return a
}});
var Page_bg=Class.create();
Object.extend(Page_bg.prototype,new Page);
Object.extend(Page_bg.prototype,{initialize:function(a){this.pageInit(a);
this.maxZIndex=5000;
this.minZIndex=0
},getClass:function(){return"page_bg"
},getPropertyNode:function(){return this.version.getPropertyNode()
},displayHandles:function(){for(var a=this.cpts.length-1;
a>=0;
a--){if(this.cpts[a].ctrl){this.cpts[a].ctrl.displaySelectHandle(true)
}}},getIcon:function(a){return"http://st3.sitew.org/images/icons/cubepage16.png?1201252313"
},getName:function(){return"Background page"
},getTypeMax:function(a){if(a.component_type&&a.component_type.max){return a.component_type.max.bg
}else{return null
}}})
}catch(exp){setTimeout(function(){dbg.error(exp.message.toString()+" Exception in application/model/page",exp)
},window.dbg?0:1000)
}if(window.page_log==undefined){window.page_log=[]
}window.page_log.push([new Date(),"Executed aggregated file editor_viewer"]);
if(window.js_list){js_list.push("editor_viewer")
};