//----------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------
// PreviewWebParts.js
Type.registerNamespace("Sys.Preview.UI.Controls.WebParts");Sys.Preview.UI.Controls.WebParts.WebPart=function(e){Sys.Preview.UI.Controls.WebParts.WebPart.initializeBase(this,[e]);var a,b,d,c=true;this.get_allowZoneChange=function(){return c};this.set_allowZoneChange=function(a){c=a};this.get_titleElement=function(){return a};this.set_titleElement=function(b){a=b};this.get_zone=function(){return b};this.set_zone=function(a){b=a};this.get_zoneIndex=function(){return d};this.set_zoneIndex=function(a){d=a};this.initialize=function(){Sys.Preview.UI.Controls.WebParts.WebPart.callBaseMethod(this,"initialize");if(a&&b.get_webPartManager().get_allowPageDesign()&&b.get_allowLayoutChange()){var c=this.get_element();Sys.UI.DomEvent.addHandler(a,"mousedown",Function.createDelegate(this,f));a.style.cursor="move"}};function f(a){window._event=a;b.startDragDrop(this);a.preventDefault()}};Sys.Preview.UI.Controls.WebParts.WebPart.descriptor={properties:[{name:"titleElement",isDomElement:true},{name:"zone",type:Object},{name:"zoneIndex",type:Number},{name:"allowZoneChange",type:Boolean}]};Sys.Preview.UI.Controls.WebParts.WebPart.registerClass("Sys.Preview.UI.Controls.WebParts.WebPart",Sys.UI.Control);Sys.Preview.UI.Controls.WebParts.WebPartManager=function(b){Sys.Preview.UI.Controls.WebParts.WebPartManager.initializeBase(this,[b]);var a;this.get_allowPageDesign=function(){return a};this.set_allowPageDesign=function(b){a=b};this.initialize=function(){Sys.Preview.UI.Controls.WebParts.WebPartManager.callBaseMethod(this,"initialize");var a=Function.createDelegate(__wpm,__wpm.ShowHelp);__wpm.ShowHelp=function(d,c){var b;if(c==0&&!window.showModalDialog)b=1;else b=c;a(d,b)}}};Sys.Preview.UI.Controls.WebParts.WebPartManager.descriptor={properties:[{name:"allowPageDesign",type:Boolean}]};Sys.Preview.UI.Controls.WebParts.WebPartManager.registerClass("Sys.Preview.UI.Controls.WebParts.WebPartManager",Sys.UI.Control);Sys.Preview.UI.Controls.WebParts.WebPartZone=function(k){Sys.Preview.UI.Controls.WebParts.WebPartZone.initializeBase(this,[k]);var i="WebPart",d=true,g,e,b=-1,h=false,c,a;this.get_allowLayoutChange=function(){return d};this.set_allowLayoutChange=function(a){d=a};this.get_uniqueId=function(){return g};this.set_uniqueId=function(a){g=a};this.get_webPartManager=function(){return e};this.set_webPartManager=function(a){e=a};function j(d){var a=document.createElement("div");a.style.filter="progid:DXImageTransform.Microsoft.BasicImage(opacity=0.75);";a.style.opacity="0.75";a.style.position="absolute";a.style.zIndex=32000;var b=d.get_element(),c=Sys.UI.DomElement.getLocation(b);Sys.UI.DomElement.setLocation(a,c.x,c.y);a.style.display="block";a.style.width=b.offsetWidth+"px";a.style.height=b.offsetHeight+"px";a.appendChild(b.cloneNode(true));return a}this.dispose=function(){Sys.Preview.UI.Controls.WebParts.WebPartZone.callBaseMethod(this,"dispose");if(h)Sys.Preview.UI.DragDropManager.unregisterDropTarget(this)};this.initialize=function(){Sys.Preview.UI.Controls.WebParts.WebPartZone.callBaseMethod(this,"initialize");var c=this.get_element();for(var b=0;b<__wpm.zones.length;b++)if(__wpm.zones[b].zoneElement==c){a=__wpm.zones[b];break}if(e.get_allowPageDesign()&&d){Sys.Preview.UI.DragDropManager.registerDropTarget(this);h=true}};this.startDragDrop=function(a){__wpm.UpdatePositions();c=j(a);document.body.appendChild(c);Sys.Preview.UI.DragDropManager.startDragDrop(this,c,a)};this.get_dragDataType=function(){return i};this.getDragData=function(a){return a};this.get_dragMode=function(){return Sys.Preview.UI.DragMode.Copy};this.onDragStart=function(){};this.onDrag=function(){};this.onDragEnd=function(){document.body.removeChild(c)};this.get_dropTargetElement=function(){return a.webPartTable};this.canDrop=function(c,b,d){var a=d;return c==Sys.Preview.UI.DragMode.Copy&&b==i&&Sys.Preview.UI.Controls.WebParts.WebPart.isInstanceOfType(a)&&(a.get_allowZoneChange()||a.get_zone()==this)&&f()!=-1};this.drop=function(i,h,f){a.ToggleDropCues(false,b,false);var c=f;if(l(c,this,b)){var e=g,d="Drag:"+c.get_id()+":"+b;__doPostBack(e,d)}};function l(a,c,b){if(c!=a.get_zone())return true;if(b==a.get_zoneIndex()||b==a.get_zoneIndex()+1)return false;return true}this.onDragEnterTarget=function(){var c=f();a.ToggleDropCues(true,c,false);b=c};this.onDragLeaveTarget=function(){a.ToggleDropCues(false,b,false)};this.onDragInTarget=function(){var c=f();if(c!=b){a.ToggleDropCues(false,b,true);a.ToggleDropCues(true,c,true);b=c}};function f(){var b=__wpGetPageEventLocation(window._event,false);return a.GetWebPartIndex(b)}};Sys.Preview.UI.Controls.WebParts.WebPartZone.descriptor={properties:[{name:"uniqueId",type:String},{name:"webPartManager",type:Object},{name:"allowLayoutChange",type:Boolean}]};Sys.Preview.UI.Controls.WebParts.WebPartZone.registerClass("Sys.Preview.UI.Controls.WebParts.WebPartZone",Sys.UI.Control,Sys.Preview.UI.IDragSource,Sys.Preview.UI.IDropTarget);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();