var system_dialog={handler:false,colorPicker:false,events:{touchstart:[],touchmove:[],touchend:[]},contentLock:false,pos:{start:{top:0,left:0},current:{top:0,left:0},pointer:{top:0,left:0}},buttonBackup:"",open:function(_1){
if(io.dialog.active){
io.dialog.cancel();
}
var _2=dojo.byId("dialog_controls");
io.dialog.buttonBackup=_2.innerHTML;
_1.load();
io.dialog.handler=_1;
var _3=(window.innerHeight/2);
var _4=(window.innerWidth/2);
io.dialog.lockView();
var _5=dojo.byId("dialog_contents_form");
if(_1.dialog.contents=="colorPicker"){
_5.style.height="180px";
_5.style.width="400px";
dojo.place("<div style='position: absolute; width: 100%; height: 20px; text-align: center; top: 5px; left: 0px;'><span>Velg fargen du ønsker:</span></div><div id='cpframe' style='display: block; position: absolute; top: 25px; left: 66px;'><div id='colorPicker'></div></div>",_5,"first");
io.dialog.colorPicker=new dojox.widget.ColorPicker({onChange:function(_6){
dojo.byId("colorSample").style.backgroundColor=_6;
}},"colorPicker");
var _7=dojo.query(".dojoxColorPicker","dialog_contents")[0];
var _8=dojo.query(".dojoxColorPickerHex","dialog_contents")[0];
dojo.place("<div style='margin: 2px 0px 0px 4px; width: 90px; height: 16px;white-space: nowrap;'><span style='position: relative; top: -3px;'>Gjennomsiktig</span><input id='transparency' type='checkbox' class='checkbox' name='transparency' /></div>"+"<div id='colorSample' style='position: relative; text-align: center; height: 27px; width: 90px; margin: 4px 0px 0px 3px; border: 1px dotted #404040;'><span style='position: absolute; left: 18px; top: 6px; color: #000000;'>Eksempel</span><span style='position: absolute; left: 17px; top: 5px; color: #FFFFFF;'>Eksempel</span></div>",_8,"after");
var _9=dojo.byId("colorPicker");
var _a=dojo.byId("transparency");
var _b=dojo.byId("colorSample");
if(_1.dialog.value=="transparent"){
_a.checked=true;
_9.value="#FFFFFF";
io.dialog.colorPicker.set("value","#FFFFFF");
_b.style.backgroundImage="url(layout/images/transparency.png)";
}else{
_a.checked=false;
io.dialog.colorPicker.valueNode.value=_1.dialog.value;
_b.style.backgroundColor=_1.dialog.value;
_b.style.backgroundImage="none";
}
dojo.connect(_a,"onchange",null,function(_c){
var _d=dojo.byId("colorSample");
var _e=dojo.byId("transparency");
if(_e.checked==false){
_d.style.backgroundImage="none";
}else{
_d.style.backgroundImage="url(layout/images/transparency.png)";
}
});
var _f=dojo.byId("cpframe");
var _10=dojo.byId("dialog_frame");
io.dialog.pos.current.top=_3-(_10.offsetHeight/2);
io.dialog.pos.current.left=_4-(_10.offsetWidth/2);
_10.style.top=io.dialog.pos.current.top+"px";
_10.style.left=io.dialog.pos.current.left+"px";
dojo.fadeIn({node:_10,duration:500,rate:50}).play();
io.dialog.events.touchstart.push(dojo.connect(_10,io.eventTypes.down,null,io.dialog.touchStart));
io.dialog.events.touchstart.push(dojo.connect(dojo.byId("dialog_control_save"),io.eventTypes.down,null,io.dialog.save));
io.dialog.events.touchstart.push(dojo.connect(dojo.byId("dialog_control_cancel"),io.eventTypes.down,null,io.dialog.cancel));
}
},lockView:function(){
var box=dojo.byId("controls_dialog");
box.style.height=window.innerHeight+"px";
box.style.display="block";
var _11=dojo.byId("dialog_background");
_11.style.height=window.innerHeight+"px";
if(io.dialog.contentLock==false){
dojo.fadeIn({node:_11,duration:500,rate:50}).play();
}
io.dialog.contentLock=true;
},unlockView:function(){
var _12=dojo.byId("dialog_background");
dojo.fadeOut({node:_12,duration:250,rate:50,onEnd:function(){
io.dialog.contentLock=false;
var box=dojo.byId("controls_dialog");
box.style.display="none";
}}).play();
},receive:function(_13){
var res=dojo.fromJson(_13);
var _14=dojo.byId("dialog_controls");
var _15=dojo.byId("dialog_contents_form");
_15.innerHTML=res.data;
var _16=(window.innerHeight/2);
var _17=(window.innerWidth/2);
var _18=_15.offsetHeight+_14.offsetHeight;
var _19=_15.offsetWidth;
var _1a=dojo.byId("dialog_frame");
io.dialog.pos.current.top=_16-(_1a.offsetHeight/2);
io.dialog.pos.current.left=_17-(_1a.offsetWidth/2);
_1a.style.top=io.dialog.pos.current.top+"px";
_1a.style.left=io.dialog.pos.current.left+"px";
dojo.fadeIn({node:_1a,duration:500,rate:50}).play();
io.dialog.events.touchstart.push(dojo.connect(_1a,io.eventTypes.down,null,io.dialog.touchStart));
io.dialog.events.touchstart.push(dojo.connect(dojo.byId("dialog_control_save"),io.eventTypes.down,null,io.dialog.save));
io.dialog.events.touchstart.push(dojo.connect(dojo.byId("dialog_control_cancel"),io.eventTypes.down,null,io.dialog.cancel));
},touchStart:function(_1b){
_1b=io.fixEvent(_1b);
io.dialog.pos.start.top=io.dialog.pos.current.top;
io.dialog.pos.start.left=io.dialog.pos.current.left;
io.dialog.pos.pointer=_1b.io.position.abs;
var _1c=dojo.byId("dialog_frame");
if(_1b.io.target==_1c){
io.dialog.events.touchmove.push(dojo.connect(document,io.eventTypes.move,null,io.dialog.touchMove));
io.dialog.events.touchend.push(dojo.connect(document,io.eventTypes.up,null,io.dialog.touchEnd));
if(io.dialog.contentLock){
var _1d=dojo.byId("dialog_background");
dojo.fadeOut({node:_1d,duration:500,rate:50}).play();
io.dialog.contentLock=false;
}
}
return true;
},touchMove:function(_1e){
var _1f=io.fixEvent(_1e);
var _20=_1f.io.position.abs.top-io.dialog.pos.pointer.top;
var _21=_1f.io.position.abs.left-io.dialog.pos.pointer.left;
io.dialog.pos.current.top=io.dialog.pos.start.top+_20;
io.dialog.pos.current.left=io.dialog.pos.start.left+_21;
var _22=dojo.byId("dialog_frame");
_22.style.top=io.dialog.pos.current.top+"px";
_22.style.left=io.dialog.pos.current.left+"px";
_1e.preventDefault();
return false;
},touchEnd:function(_23){
while(io.dialog.events.touchmove.length>0){
dojo.disconnect(io.dialog.events.touchmove.pop());
}
while(io.dialog.events.touchend.length>0){
dojo.disconnect(io.dialog.events.touchend.pop());
}
return false;
},save:function(){
io.dialog.handler.save();
io.dialog.close();
return false;
},cancel:function(){
io.dialog.handler.cancel();
io.dialog.close();
return false;
},close:function(){
if(io.dialog.handler){
while(io.dialog.events.touchstart.length>0){
dojo.disconnect(io.dialog.events.touchstart.pop());
}
while(io.dialog.events.touchmove.length>0){
dojo.disconnect(io.dialog.events.touchmove.pop());
}
while(io.dialog.events.touchend.length>0){
dojo.disconnect(io.dialog.events.touchend.pop());
}
if(io.dialog.colorPicker){
io.dialog.colorPicker.destroyRecursive(false);
io.dialog.colorPicker=false;
}
var _24=dojo.byId("dialog_frame");
dojo.fadeOut({node:_24,duration:250,rate:50,onEnd:function(_25){
var _26=dojo.byId("dialog_contents_form");
_26.innerHTML="";
_26.style.height="";
_26.style.width="";
var _27=dojo.byId("colorPicker");
if(_27){
_27.parentNode.removeChild(_27);
}
var _28=dojo.byId("dialog_controls");
_28.innerHTML=io.dialog.buttonBackup;
}}).play();
io.dialog.handler=false;
io.controls.update();
}
io.dialog.unlockView();
return false;
}};
io.dialog=system_dialog;


