// Swap all links on the page with an MSPLink, disable 
// by adding "var disableMSPLinks=1;" to the page
//
/* THIS CODE MUST REMAIN AT THE TOP OF THE DOCUMENT!
if(!MySpace.Application.keyDisabled("MSPLinksConvertAll")){
  var changeLinksHrefRegex = new RegExp(/(\.|^)(myspace|msplinks)\.com$/i);
  var changeLinksProtocolRegex = new RegExp(/javascript:/i);
  for(var i = 0; i < document.links.length; i ++){ 
    var l = document.links[i];
    if(   !changeLinksProtocolRegex.test(l.protocol) && !changeLinksHrefRegex.test(l.hostname) && l.hostname.toLowerCase() != "localhost"){
      l["oldHref"]=l.href;
      l.href="http://www.msplinks.com/" + l.href;
      l.onmousemove = function(){
       try{window.status=this["oldHref"];}catch(ex){}
      }
    }
  }
}*/

Type.registerNamespace("MySpace.Utils.Media");
MySpace.Utils.Media.loadStaticContent = function() {
    // Images
    var a_imgs =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)("img");
    for(var i = 0 ; i < a_imgs.length ; i++){
        if( _proxy_jslib_handle(a_imgs, (i), 0, 0).getAttribute("source")){
	         _proxy_jslib_assign('',  _proxy_jslib_handle(a_imgs, (i), 0, 0), 'src', '=', (  _proxy_jslib_handle(a_imgs, (i), 0, 0).getAttribute("source")));
        }
    }
    
    // Flash Objects
    var a_objs =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)("object");
    if(a_objs){
        for(var i = 0 ; i < a_objs.length ; i++){
            if( _proxy_jslib_handle(a_objs, (i), 0, 0).getAttribute("movie")){
                
                var url =  _proxy_jslib_handle(a_objs, (i), 0, 0).getAttribute("movie");
                
                try{//Try loading it using activeX method
                     _proxy_jslib_handle( _proxy_jslib_handle(a_objs, (i), 0, 0), 'LoadMovie', '', 1, 0)(0,url);
                    var disableAutoPlay =  _proxy_jslib_handle(a_objs, (i), 0, 0).getAttribute("disableAutoPlay");
                    if(disableAutoPlay == undefined || disableAutoPlay == ""){
                         _proxy_jslib_handle(a_objs, (i), 0, 0).Play();
                    }
                    continue;
                }catch(e){
                }
                //Failed loading using activeX, continue loading by replacing the object
                
                var height =  _proxy_jslib_handle(a_objs, (i), 0, 0).getAttribute("height");
                var width =  _proxy_jslib_handle(a_objs, (i), 0, 0).getAttribute("width");
                var vars = "";
                var prms =  _proxy_jslib_handle( _proxy_jslib_handle(a_objs, (i), 0, 0), 'getElementsByTagName', '', 1, 0)("param");
                for(var x = 0 ; x < prms.length ; x++){
                    try{
                        if( _proxy_jslib_handle(prms, (x), 0, 0).getAttribute("name").toLowerCase() === "flashvars"){
                            vars =  _proxy_jslib_handle(prms, (x), 0, 0).getAttribute("value");
                            break;
                        }
                    }catch(e){
                    }
                }
                
                
                var so = new (SWFObject)(url, "obj"+Math.random(), width, height, "8", "#FFFFFF");
                
                if(vars){
                    var keyvalue = vars.split(/\&/);
                    for(var v = 0 ; v < keyvalue.length ; v++){
                        var kv =  _proxy_jslib_handle(keyvalue, (v), 0, 0).split("=");
                        if(kv.length == 2)
                            so.addVariable(kv[0],kv[1]);
                    }
                }
                
                var wrapper = document.createElement("div");
                 _proxy_jslib_handle(a_objs, (i), 0, 0).parentNode.insertBefore(wrapper, _proxy_jslib_handle(a_objs, (i), 0, 0));
                 _proxy_jslib_handle(so, 'write', '', 1, 0)(wrapper);
                 _proxy_jslib_handle(a_objs, (i), 0, 0).parentNode.removeChild( _proxy_jslib_handle(a_objs, (i), 0, 0));
            }
        }
    }
}

try{
    if(!MySpace.Application.keyDisabled("JS_ProfilePageStaticMediaPreloader"))
    {
        MySpace.Utils.Media.loadStaticContent();
    }
}catch(e){
}


Type.registerNamespace("MySpace.UI");

Date.prototype.addMilliseconds = function(value) {
	/// <param name="value" type="Number" integer="true"></param>
	this.setTime(this.getTime() +  _proxy_jslib_handle(null, 'value', value, 0, 0));return this;
}
Date.prototype.addSeconds = function(value) {
	/// <param name="value" type="Number" integer="true"></param>
	this.addMilliseconds( _proxy_jslib_handle(null, 'value', value, 0, 0)*1000);return this;
}
Date.prototype.addMinutes = function(value) {
	/// <param name="value" type="Number" integer="true"></param>
	this.addMilliseconds( _proxy_jslib_handle(null, 'value', value, 0, 0)*60000);return this;
}
Date.prototype.addHours = function(value) {
	/// <param name="value" type="Number" integer="true"></param>
	this.addMilliseconds( _proxy_jslib_handle(null, 'value', value, 0, 0)*3600000);return this;
}
Date.prototype.addDays = function(value) {
	/// <param name="value" type="Number" integer="true"></param>
	this.setDate(this.getDate()+ _proxy_jslib_handle(null, 'value', value, 0, 0));return this;
}
Date.prototype.addMonths = function(value) {
	/// <param name="value" type="Number" integer="true"></param>
	this.setMonth(this.getMonth()+ _proxy_jslib_handle(null, 'value', value, 0, 0));return this;
}
Date.prototype.addYears = function(value) {
	/// <param name="value" type="Number" integer="true"></param>
	this.setFullYear(this.getFullYear()+ _proxy_jslib_handle(null, 'value', value, 0, 0));return this;
}

//
MySpace.UI.hideElements = function(tagNames, TorF) {
	/// <param name="value" type="Array" elementType="String"></param>
	/// <param name="TorF" type="Boolean"></param>
	for(var j=0;j<tagNames.length;j++){
		var t =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)( _proxy_jslib_handle(tagNames, (j), 0, 0));
		for(var i=0;i<t.length;i++){ _proxy_jslib_handle(t, (i), 0, 0).style.visibility = TorF? "hidden" : "";}
	}
}
//Generic window overlay
MySpace.UI._Overlay = function(element) {
	/// <param name="element" domElement="true"></param>
	 _proxy_jslib_handle(document, 'body', '', 0, 0).appendChild(element);
	MySpace.UI._Overlay.initializeBase(this,[element]);
}
MySpace.UI._Overlay.prototype = {
	_interval: null,_fadeIn: false,_opacity: 0,_max: 60,_fadeDelegate:null,_resizeHandler:null, _step:20,
	show: function() {MySpace.UI.hideElements(["iframe","object","embed","select"],true);this._fade(true);},
	hide: function() {MySpace.UI.hideElements(["iframe","object","embed","select"],false);this._fade(false);},

	add_fadeComplete:function(handler) {
		/// <param name="fadeIn" type="Boolean"></param>
		this.get_events().addHandler("fadeComplete", handler);
	},
	remove_fadeComplete:function(handler) {
		/// <param name="fadeIn" type="Boolean"></param>
		this.get_events().removeHandler("fadeComplete", handler);
	},

	initialize:function() {
		var element = this.get_element();
		element.id = "window_overlay";
		element.style.zIndex = "100000";
		element.style.width = "100%";
		this.set_opacity(0);
		Sys.UI.DomElement.setLocation(element,0,0);
		this._setHeight();
		this._resizeHandler = Function.createDelegate(this, this._setHeight);
		$addHandler(window, "resize", this._resizeHandler);
	},
	_setHeight: function() {
		var a= _proxy_jslib_handle(document, 'body', '', 0, 0).scrollHeight;//scrolled content
		var b=document.documentElement.clientHeight;//no scroll
		var c=document.documentElement.scrollHeight;//ie7 friendly
		a = ((a>c)?a:c);
		this.get_element().style.height=((a>b)?a:b)+"px";
	},
	_fade: function(fadeIn) {
		/// <param name="fadeIn" type="Boolean"></param>
		this._fadeIn = fadeIn;
		if(fadeIn) {this._element.style.visibility='visible'; this._element.style.display='';} else {this._element.style.visibility='hidden'; this._element.style.display='none'; }
		if(!this._fadeDelegate)this._fadeDelegate = Function.createDelegate(this,this._tick);
		this._interval =  _proxy_jslib_handle(window, 'setInterval', '', 1, 0)(this._fadeDelegate, 100);
	},
	_tick: function() {
		if(!this._interval) return;
		var increase = this._step;
		if(!this._fadeIn) increase*=-1;
		var newOpacity = this._opacity + increase;
		if(newOpacity<0) newOpacity = 0;
		else if(newOpacity>this._max) newOpacity = this._max;
		this.set_opacity(newOpacity);
		if(newOpacity<=0 || newOpacity>=this._max){
			window.clearInterval(this._interval);
            var fadeComplete = this.get_events().getHandler("fadeComplete");
            if (fadeComplete) fadeComplete(this, Sys.EventArgs.Empty);
		}
	},
	get_opacity:function() {return this._opacity;},
	set_opacity: function(value) {
		/// <param name="value" type="Number" integer="true"></param>
		this._opacity =  _proxy_jslib_handle(null, 'value', value, 0, 0);
		var s = this.get_element().style;
		s.opacity =  _proxy_jslib_handle(null, 'value', value, 0, 0)*.01;
		s.filter = "alpha(opacity="+ _proxy_jslib_handle(null, 'value', value, 0, 0)+")";
		if( _proxy_jslib_handle(null, 'value', value, 0, 0)===0) this.set_visible(false);
	},
	dispose:function() {
		$removeHandler(window, "resize", this._resizeHandler);
		this._fadeDelegate=null;
		MySpace.UI._Overlay.callBaseMethod(this, 'dispose');
	}
}
MySpace.UI._Overlay.registerClass('MySpace.UI._Overlay', Sys.UI.Control);
window.get_overlay = function() {if(!window._overlay)window._overlay=$create(MySpace.UI._Overlay,null,null,null,document.createElement("div"));return window._overlay;};



MySpace.UI._Popup = function(element) {
	/// <param name="element" domElement="true"></param>
	this._box = element.firstChild;
	MySpace.UI._Popup.initializeBase(this,[element]);
}
MySpace.UI._Popup.prototype = {
	_box:null,
	_state:null,
	_defaultButton:null,
	_callback:null,
	_globalCss:null,
	_top:null,
	_left:null,
	
	get_top: function() {return this._top;},
	set_top: function(value) {this._top =  _proxy_jslib_handle(null, 'value', value, 0, 0);},
	
	get_left: function() {return this._left;},
	set_left: function(value) {this._left =  _proxy_jslib_handle(null, 'value', value, 0, 0);},

	get_state: function() {return this._state;},
	set_state: function(value) {this._state =  _proxy_jslib_handle(null, 'value', value, 0, 0);},

	get_title: function() {return  _proxy_jslib_handle(this._box.childNodes[1], 'innerHTML', '', 0, 0);},
	set_title: function(value) { _proxy_jslib_assign('', this._box.childNodes[1], 'innerHTML', '=', (  _proxy_jslib_handle(null, 'value', value, 0, 0)));},

	get_content: function() {return  _proxy_jslib_handle(this._box.childNodes[2], 'innerHTML', '', 0, 0);},
	set_content: function(value) {if (typeof( _proxy_jslib_handle(null, 'value', value, 0, 0)) === 'object') {this._box.childNodes[2].appendChild( _proxy_jslib_handle(null, 'value', value, 0, 0));} else { _proxy_jslib_assign('', this._box.childNodes[2], 'innerHTML', '=', (  _proxy_jslib_handle(null, 'value', value, 0, 0)));}},

	get_callback: function() {return this._callback;},
	set_callback: function(value) {this._callback =  _proxy_jslib_handle(null, 'value', value, 0, 0);},

	add_button: function(text, isDefault) {
		var b=document.createElement("input");
		b.type="button";
		 _proxy_jslib_assign('', b, 'value', '=', (text));
		if(isDefault)
			this._defaultButton = b;
		$addHandlers(b,{click:this._buttonClick},this);
		this._box.lastChild.appendChild(b);
		return b;
	},

 	show: function(callBack) {
		if(MySpace.UI._Popup._activePopup)throw "A Popup is already active.";
		if(callBack)this._callback = callBack;
		window.get_overlay().show();
		
		// control popup position through property settings
		if (this._top !== null && this._left !== null){
			 _proxy_jslib_assign('', this._element.style, 'top', '=', ( this._top + 'px'));
			this._element.style.left = this._left + 'px';
		}
		
		this._element.style.display='';
		this._element.style.visibility='visible';
		var exclude = MySpace.Utils.Selector.query("iframe,object,embed,select", this._element);
		for (var i=0;i<exclude.length;i++) { _proxy_jslib_handle(exclude, (i), 0, 0).style.visibility='';}
		if(this._defaultButton)this._defaultButton.focus();
		MySpace.UI._Popup._activePopup = this;
		
		if (this._globalCss !== null){
			// add the style to fix the popup position
			this._top = (this._top == null ? this._element.offsetTop : this._top);							
			this._globalCss.addRule('.popup_wrapper', 'top:expression( (ignoreMe = document.body.scrollTop + ' + this._top + ') + "px" )');		
		}
	},
	_hide: function() {
		window.get_overlay().hide();
		this._element.style.display='none';
		MySpace.UI._Popup._activePopup=null;
		
		if (this._globalCss !== null)
			this._globalCss.removeRule(this._globalCss.rules.length-1);
	},
	_buttonClick: function(e) {
		this._hide();
		var cb=this._callback;
		if(cb)cb(this, e);
	},
	initialize: function() {
		var element = this.get_element();
		//element should always have a parent because it should have been created by a template
		element.parentNode.removeChild(element);
		 _proxy_jslib_handle(document, 'body', '', 0, 0).appendChild(element);
		this._box.firstChild.isCancel=true; //red-x
		$addHandlers(this._box.firstChild,{click:this._buttonClick},this);
		MySpace.UI._Popup.callBaseMethod(this, 'initialize');
		
		if (typeof(window.pageXOffset) === 'undefined'){
			for (var i = 0; i < document.styleSheets.length; i++){				
				if (/global(\d)*(\.debug)*\.css/.test( _proxy_jslib_handle( _proxy_jslib_handle(document.styleSheets, (i), 0, 0), 'href', '', 0, 0))){					
					this._globalCss =  _proxy_jslib_handle(document.styleSheets, (i), 0, 0);					
				}
			}
		}
	},
	dispose: function() {
		var buttons = this._box.lastChild.childNodes;
		for(var i=0;i<buttons.length;i++)
			$clearHandlers( _proxy_jslib_handle(buttons, (i), 0, 0));
		MySpace.UI._Popup.callBaseMethod(this, 'dispose');
	}
}
MySpace.UI._Popup.registerClass('MySpace.UI._Popup', Sys.UI.Control);
MySpace.UI._Popup._activePopup=null;

MySpace.UI.Popup=function() {throw "Cannot instantiate static class.";}
MySpace.UI.Popup.create=function(content, title, callback) {
	/// <param name="content" type="String"></param>
	/// <param name="title" type="String"></param>
	/// <param name="callback" type="Function" mayBeNull="true" optional="true"></param>
	/// <returns type="MySpace.UI.Popup"></returns>
	var temp=document.createElement("div");	
     _proxy_jslib_assign('', temp, 'innerHTML', '=', ("<div class='popup_wrapper' style='z-index:1000001;left:0px;width:100%;display:none;visibility:hidden;'><div class='popup_box'><a class='popup_x'></a><div class='popup_title'></div><div class='popup_content'></div><div class='popup_buttons'></div></div></div>"));
	return $create(MySpace.UI._Popup,{title:title, content: _proxy_jslib_handle(null, 'content', content, 0, 0), callback:callback},null,null,temp.firstChild);
}

MySpace.UI.Popup.generic = function(message, buttonText, callback) {
	/// <param name="message" type="String"></param>
	/// <param name="buttonText" type="String"></param>
	/// <param name="callback" type="Function" mayBeNull="true" optional="true"></param>
	/// <returns type="MySpace.UI.Popup"></returns>
	var template = document.createElement("div");
	var p = MySpace.UI.Popup.create(message,MySpaceRes.Common.Attention);
	p.add_button(buttonText);
	 _proxy_jslib_assign('', template, 'innerHTML', '=', (message));
	p.show(callback);
	return p;
}
MySpace.UI.Popup.alert = function(message, callback) {
	/// <param name="message" type="String"></param>
	/// <param name="callback" type="Function" mayBeNull="true" optional="true"></param>
	new (MySpace.UI.Popup.generic)(message,MySpaceRes.Common.Ok,callback);
}
MySpace.UI.Popup.confirm = function(message, callback) {
	/// <param name="message" type="String"></param>
	/// <param name="callback" type="Function" mayBeNull="true" optional="true"></param>
	var p=new (MySpace.UI.Popup.generic)(message,MySpaceRes.Common.Yes,callback);
	p.add_button(MySpaceRes.Common.No);
}
MySpace.UI.Popup.registerClass('MySpace.UI.Popup');



MySpace.WebRequest=function() {throw "Cannot instantiate static class.";}
MySpace.WebRequest.invoke = function(path, useGet, params, onSuccess, onFailure, userContext, timeout) {
	/// <param name="path" type="String"></param>
	/// <param name="useGet" type="Boolean"></param>
	/// <param name="params"></param>
	/// <param name="onSuccess" type="Function" mayBeNull="true" optional="true"></param>
	/// <param name="onFailure" type="Function" mayBeNull="true" optional="true"></param>
	/// <param name="userContext" mayBeNull="true" optional="true"></param>
	/// <returns type="Sys.Net.WebRequest"></returns>
	if (!params) params = {};
	var request = new (Sys.Net.WebRequest)();
	if (!useGet) {
		if(typeof params==="string")
		var body = (typeof params!=="string")? Sys.Serialization.JavaScriptSerializer.serialize(params) : params;
		if ( _proxy_jslib_handle(null, 'body', body, 0, 0) === "{}")  body= _proxy_jslib_assign_rval('', 'body', '=', ( ""), body);
		request.set_body( _proxy_jslib_handle(null, 'body', body, 0, 0));
	}
	request.set_url(Sys.Net.WebRequest._createUrl(path, (useGet)?params:{}));

	request.add_completed(onComplete);
	if (timeout && timeout > 0) request.set_timeout(timeout);
	request.invoke();

	function onComplete(response, eventArgs) {
		if (response.get_responseAvailable()) {
			var statusCode = response.get_statusCode();

			var result = null;
			try {
				var contentType = response.getResponseHeader("Content-Type");
				if (contentType.startsWith("application/json"))
					result = response.get_object();
				else if (contentType.startsWith("text/xml"))
					result = response.get_xml();
				else result = response.get_responseData();
			} catch (ex) {}

			//handle errors
			if ((statusCode < 200) || (statusCode >= 300)) {
				if (onFailure) {
					if (!result) {
						result = new (Sys.Net.WebServiceError)(false , "WebRequest failed for an unknown reason.", "", "");
					}
					result._statusCode = statusCode;
					onFailure(result, userContext);
				}
				else {//dev doesn't want to handle the error, just alert it
					var error;
					if (result)
						error = result.get_exceptionType() + "-- " + result.get_message();
					else error = response.get_responseData();
					window.alert("WebRequest Failed: "+error);
				}
			}
			else if (onSuccess) {
				onSuccess(result, userContext);
			}
		}
		else {
			var msg;
			if (response.get_timedOut()) msg = "WebRequest timed out.";
			else msg = "WebRequest failed for an unknown reason.";

			if (onFailure) onFailure(new (Sys.Net.WebServiceError)(response.get_timedOut(), msg, "", ""), userContext);
			else alert(msg);
		}
	}
	return request;
}
MySpace.WebRequest.registerClass('MySpace.WebRequest');



MySpace.CMS=function() {throw "Cannot instantiate static class.";}
MySpace.CMS.cache={};
MySpace.CMS.getContent=function(placementId, callback, context) {
	/// <param name="placementId" type="Number"></param>
	/// <param name="callback" type="Function" mayBeNull="true" optional="true"></param>
	/// <param name="context" type="Object" mayBeNull="true" optional="true"></param>
	var cacheItem= _proxy_jslib_handle(MySpace.CMS.cache, (placementId), 0, 0);
	if(cacheItem && new (Date)() < cacheItem.expire) {
		callback(cacheItem.response);
		return null;
	}

	MySpace.WebRequest.invoke("/Modules/Common/HttpHandlers/CMS.ashx", false, "placementId="+placementId, _onComplete, null, context, 0);
	
	function _onComplete(response, eventArgs) {
		var expire = new (Date)();
		expire.setTime(expire.getTime()+120000);//2 minute cache
		 _proxy_jslib_assign('', MySpace.CMS.cache, (placementId), '=', ( {response:response,expire:expire}));
		if(callback) callback(response, eventArgs);
	}
	return null;
}
MySpace.CMS.track=function(id) {
	/// <param name="id" type="String"></param>
	MySpace.WebRequest.invoke("/Modules/Common/HttpHandlers/CMSClick.ashx?_i="+id, true, null, null, Function.emptyFunction, null, 0);
}
MySpace.CMS.registerClass('MySpace.CMS');



if(!MySpace.Util){ MySpace.Util=function() {throw "Cannot instantiate static class.";} }
MySpace.Util.get_profileId=function() {
	var rs = "i";
	var urls =  _proxy_jslib_handle(document, 'URL', '', 0, 0);
	urls =  _proxy_jslib_handle(urls, 'replace', '', 1, 0)(/'/g,"");
	var el = "friendID";
	var re = new (RegExp)( "\\?[\\w\\W]*"+ el +"=([^\\&\\?#]*)", rs);
	var arr = re.exec(urls);
	if(!arr) {
		elg = "groupID";
		var red = new (RegExp)( "\\?[\\w\\W]*"+ elg +"=([^\\&\\?#]*)", rs);
		arr = red.exec(urls);
	}
	if(arr && arr.length>1)
		return arr[1];
	else {
		var expr = /\/([\w]*)$/i;
		arr = expr.exec(urls);
			if(arr && arr.length>1) {
				return arr[1].toLowerCase();
			} else {
				return '';
			}
	}
}
MySpace.Util.registerClass('MySpace.Util');


//Sitewide implimentations of global controls
if(typeof MySpace.Cookies.MSCulture!=='undefined'){
	var d = new (Date)();
	
	if(typeof updateClientTimeZone !== 'undefined')
	{
	    if(updateClientTimeZone == 1)
	        MySpace.Cookies.MSCulture.get_values().timeZone=(d.getTimezoneOffset()/-60);
	}
    
	
	MySpace.Cookies.save(MySpace.Cookies.MSCulture,".myspace.com",new (Date)().addDays(7));
}

MySpace.CultureSwitchPrompt=function() {throw "Cannot instantiate static class.";}
MySpace.CultureSwitchPrompt.getContent=function(culture, callback, context) {
	/// <param name="culture" type="String"></param>
	/// <param name="callback" type="Function" mayBeNull="true" optional="true"></param>
	/// <param name="context" type="Object" mayBeNull="true" optional="true"></param>		
	MySpace.WebRequest.invoke("/Modules/Common/HttpHandlers/CultureSwitch.ashx", false, "culture="+culture+"&userid="+MySpace.ClientContext.UserId, _onComplete, null, context, 0);
	
	function _onComplete(response, eventArgs) {
		if(callback) callback(response, eventArgs);
	}
	return null;
}
MySpace.CultureSwitchPrompt.registerClass('MySpace.CultureSwitchPrompt');


MySpace.UI.Header=function() {throw "Cannot instantiate static class.";}
MySpace.UI.Header.languageLinkClick=function(culture, domain, index) {
	/// <param name="culture" type="String"></param>
	/// <param name="domain" type="String"></param>
	/// <param name="index" type="Number"></param>
	MySpace.CultureSwitchPrompt.getContent(culture, _contentRetrieved);
	function _contentRetrieved(content) {
        var cspContent = Sys.Serialization.JavaScriptSerializer.deserialize( _proxy_jslib_handle(null, 'content', content, 0, 0));                                          
        var p=MySpace.UI.Popup.create('',''); 
         _proxy_jslib_assign('', p._element, 'innerHTML', '=', ( "<div class='popup_box2'><a class='popup_ex'></a><div class='popup_title'></div><div class='popup_content2'></div><div class='popup_buttons'></div></div>"));
        p._box = p._element.firstChild;
        p.set_content( _proxy_jslib_handle(cspContent, 'content', '', 0, 0));
        p.set_title(cspContent.header);                                          
        p.add_button(cspContent.continuebtn);
        p.add_button(cspContent.cancelbtn, true).isCancel=true;
        p.set_state({culture:culture, domain: _proxy_jslib_handle(null, 'domain', domain, 0, 0)});
        p.addCssClass("popupChangeLanguage");
        p.show(_popupCallback);		
	}
	function _popupCallback(sender, args) {		
	    var state=sender.get_state();    
		if(args.target.isCancel) {//clicked cancel
		    MySpace.Cookies.MSCulture.get_values().PreferredCulturePending= _proxy_jslib_handle(culture, 'replace', '', 1, 0)("-","*");                	            		        
	        MySpace.Cookies.save(MySpace.Cookies.MSCulture,".myspace.com",new (Date)().addDays(7));		       
	        if( _proxy_jslib_handle(null, 'domain', domain, 0, 0).length==0) 
	             _proxy_jslib_handle(window, 'location', '', 0, 0).reload(false);	        
            return;
        }		
        MySpace.Cookies.MSCulture.get_values().PreferredCulturePending=culture;                	
        MySpace.Cookies.MSCulture.get_values().PreferredCulture=culture;                	        
	    MySpace.Cookies.save(MySpace.Cookies.MSCulture,".myspace.com",new (Date)().addDays(7));	
	    //if they are logged in,there **SHOULD** be two radio buttons
	    var c= _proxy_jslib_handle(sender._box.childNodes[2], 'getElementsByTagName', '', 1, 0)("input");
		if(c[1]!=null && c[1].checked) {//Persist user's language
			Sys.Net.WebServiceProxy.invoke("/Services/GeoLocation.asmx", "SavePreferredCulture", false, {culture:state.culture}, _goToDomain, _goToDomain, null, 0);
			return;
		}
		_goToDomain();
	}
	function _goToDomain() {//needed for callback
		if( _proxy_jslib_handle(null, 'domain', domain, 0, 0).length > 0)  _proxy_jslib_assign('', window, 'location', '=', ( "http://" +  _proxy_jslib_handle(null, 'domain', domain, 0, 0)));		
		else  _proxy_jslib_handle(window, 'location', '', 0, 0).reload(true);
	}
}
MySpace.UI.Header.gamesLinkClick=function(gamesLink) {
    var prompt=MySpace.UI.Popup.create('','');
         _proxy_jslib_assign('', prompt._element, 'innerHTML', '=', ( "<div class='popup_box2'><a class='popup_ex'></a><div class='popup_title'></div><div class='popup_content2' style='padding:20px'></div><div class='popup_buttons'></div></div>"));
    prompt._box = prompt._element.firstChild; 
    prompt.set_content(MySpaceRes.CultureSpecific.GamesPromptEnglish + "<div style='color:#039'>" + MySpaceRes.International.GamesPromptLocal + "</div>");
    prompt.set_title(MySpaceRes.International.GamesPromptTitle);                                          
    prompt.add_button(MySpaceRes.Header.Continue);
    prompt.add_button(MySpaceRes.Header.Cancel, true).isCancel=true;
    prompt.addCssClass("popupChangeLanguage");
    prompt.show(_popupCallback);		

    function _popupCallback(sender, args) {		
        if(args.target.isCancel) {//clicked cancel
            return;
        }
        //redirect to games page
         _proxy_jslib_assign('', window, 'location', '=', ( gamesLink));
    }
}
MySpace.UI.Header.registerClass('MySpace.UI.Header');

MySpace.IM = function() {throw "Cannot instantiate static class.";}
MySpace.IM.get_info = function() {
	switch(Sys.Browser.agent) {
	case Sys.Browser.InternetExplorer:
		var objMySpaceIMX = new (ActiveXObject)("MySpaceIMX.MySpaceIMPlugin.1");
		if(typeof objMySpaceIMX === "undefined")
			return {ver:null,hasSkype:null};
		else {
			var IMVer = 100;
			if(objMySpaceIMX.GetMSIMVersion()) {
				IMVer = objMySpaceIMX.GetMSIMVersion();
				//Extract build num
				var verArr = IMVer.split(".");
				IMVer = parseInt(verArr[2],10);
			}
			return {ver:IMVer,hasSkype:(parseFloat(IMVer)>0)};
		}
	case Sys.Browser.Firefox:
		if(navigator.mimeTypes || navigator.mimeTypes.length) {
			var mType =  _proxy_jslib_handle(navigator.mimeTypes, ("application/myspaceim.1"), 0, 0);
			if(mType) return {ver:719,hasSkype:true};
			mType =  _proxy_jslib_handle(navigator.mimeTypes, ("application/myspaceim"), 0, 0);
			if(myType) return {ver:100,hasSkype:false};
		}
	case Sys.Browser.Safari:
	case Sys.Browser.Opera:
		//Currently cannot accurately tell if these browsers have IM or not
		//Cookie usually only set for IE but check just in case
		if( _proxy_jslib_handle(document, 'cookie', '', 0, 0) &&  _proxy_jslib_handle(document, 'cookie', '', 0, 0).indexOf("imyspaceim") != -1)
			return {ver:100,hasSkype:null};
		else
			return {ver:-1,hasSkype:null};
	default:
		return {ver:null,hasSkype:null};
	}
}
MySpace.IM.openGetIM = function(winHeight,winWidth) {
	/// <param name="winHeight" type="Number" integer="true"></param>
	/// <param name="winWidth" type="Number" integer="true"></param>
	var getIMurl = "http://www.myspace.com/Modules/IM/Pages/GetIM.aspx";
	var winLeft = (screen.availwidth-winWidth)/2;
	var winTop = (screen.availheight-winHeight)/2;
	 _proxy_jslib_handle(window, 'open', '', 1, 0)(getIMurl,null,'height='+winHeight+',width='+winWidth+',left='+winLeft+',top='+winTop+',status=no,toolbar=no,menubar=no,location=no');
}
MySpace.IM.openIMById = function(friendId) {
	/// <param name="friendId" type="Number" integer="true"></param>
	var ver = MySpace.IM.get_info().ver;
	if (typeof ver !== "undefined" && ver != null) {
		 _proxy_jslib_assign('',  _proxy_jslib_handle(window, 'location', '', 0, 0), 'href', '=', ('myim:sendIM?uID=0&cID='+friendId));
	} else {
		MySpace.IM.openGetIM(475,600);
	}
}
MySpace.IM.openIM = function() {
	MySpace.IM.openIMById(MySpace.Util.get_profileId());
}

MySpace.UI.Tooltip = function (element) {
	// Create the div element
	this._tipDiv = document.createElement("div");
	 _proxy_jslib_assign('', this._tipDiv, 'innerHTML', '=', ( '<div class="innerwrapper origin_tl arrow_lt"><div class="closeButton"></div><div class="arrow"></div><div class="corner"></div><div class="top"></div><div class="content"></div></div>'));
	this._tipDiv.className = 'tooltip';	
	MySpace.UI.Tooltip.initializeBase(this,[element]);
}
	
MySpace.UI.Tooltip.prototype = {
	_tipDiv: null,
	get_classes : function() {return this._tipDiv.firstChild.className;},
	set_classes : function(value) {this._tipDiv.firstChild.className =  _proxy_jslib_handle(null, 'value', value, 0, 0);},
	get_content : function() {return  _proxy_jslib_handle(this._tipDiv.firstChild.lastChild, 'innerHTML', '', 0, 0);},
	set_content : function(value) {if (typeof( _proxy_jslib_handle(null, 'value', value, 0, 0)) === 'object') {this._tipDiv.firstChild.lastChild.appendChild( _proxy_jslib_handle(null, 'value', value, 0, 0));} else { _proxy_jslib_assign('', this._tipDiv.firstChild.lastChild, 'innerHTML', '=', (  _proxy_jslib_handle(null, 'value', value, 0, 0)));}},	
	get_tipDiv : function() {return this._tipDiv;},
	set_tipDiv : function(value) {this._tipDiv =  _proxy_jslib_handle(null, 'value', value, 0, 0);},	
	initialize : function() {		
        // Add the div element to the current object
		this._element.appendChild(this._tipDiv); 
		
		// attach a close event to the close button image
		$addHandler(this._tipDiv.firstChild.firstChild,"click", Function.createDelegate(this,this.hide));
	},
	dispose : function() {
	  $clearHandlers(this._element);	  
	  MySpace.UI.Tooltip.callBaseMethod(this, 'dispose');
	},
    show : function() {
      this._tipDiv.style.display='block';
      
      var handler = this.get_events().getHandler('visibilityChanged');
        if(handler) {
            var eventArgs = new (Sys.EventArgs)();
            handler(this, eventArgs);
        }
    },
    hide : function() {
      this._tipDiv.style.display='none';
      
      var handler = this.get_events().getHandler('tooltipClosed');
        if(handler) {
            var eventArgs = new (Sys.EventArgs)();
            handler(this, eventArgs);
        }
    },
    add_tooltipClosed : function(handler) {
        this.get_events().addHandler("tooltipClosed", handler);
    },
    remove_tooltipClosed : function(handler) {
        this.get_events().removeHandler("tooltipClosed", handler);
    },
    add_visibilityChanged : function(handler) {
        this.get_events().addHandler("visibilityChanged", handler);
    },
    remove_visibilityChanged : function(handler) {
        this.get_events().removeHandler("visibilityChanged", handler);
    }
}
MySpace.UI.Tooltip.registerClass('MySpace.UI.Tooltip', Sys.UI.Control);

Type.registerNamespace('MySpace.UI.TooltipBehavior');

MySpace.UI.TooltipBehavior.Hover = function(element) {
   MySpace.UI.TooltipBehavior.Hover.initializeBase(this, [element]);
}

MySpace.UI.TooltipBehavior.Hover.prototype = {
	_hideDelay: 500,
	_showDelay: 0,
	_timerID: 0,
    
    get_hideDelay : function() {return this._hideDelay;},
	set_hideDelay : function(value) {this._hideDelay =  _proxy_jslib_handle(null, 'value', value, 0, 0);},
    get_showDelay : function() {return this._showDelay;},
	set_showDelay : function(value) {this._showDelay =  _proxy_jslib_handle(null, 'value', value, 0, 0);},

    initialize : function() {
        MySpace.UI.TooltipBehavior.Hover.callBaseMethod(this, 'initialize');
   
        // get a ref to the base element
        var el = this.get_element();
      
        // add a mouse out handler to the tool tip div
        $addHandler(el.lastChild,"mouseout", Function.createDelegate(this,this._delayedHide));
        $addHandler(el,"mouseover", Function.createDelegate(this,this._delayedShow));
        $addHandler(el,"mouseout", Function.createDelegate(this,this._delayedHide));        
   },
   dispose : function() {
        $clearHandlers(this.get_element().lastChild);
        $clearHandlers(this.get_element());
      
        MySpace.UI.TooltipBehavior.Hover.callBaseMethod(this, 'dispose');
   },
	_clearTimerID: function() {
		if (this._timerID){
			clearTimeout(this._timerID);
			this._timerID = 0;
		}
	},
	_hide: function(args) {
		this.get_element().control.hide();
	},
	_delayedShow: function(e) {
		this._clearTimerID();		
		this._timerID =  _proxy_jslib_handle(window, 'setTimeout', '', 1, 0)(Function.createDelegate(this,this._show),this._showDelay);
	},	
	_show: function(e) {
		this.get_element().control.show();
	},
	_delayedHide: function(e) {
		this._clearTimerID();		
		this._timerID =  _proxy_jslib_handle(window, 'setTimeout', '', 1, 0)(Function.createDelegate(this,this._hide),this._hideDelay);
	}
}

MySpace.UI.TooltipBehavior.Hover.registerClass('MySpace.UI.TooltipBehavior.Hover', Sys.UI.Behavior);

MySpace.UI.TooltipBehavior.AutoPos = function(element) {
   MySpace.UI.TooltipBehavior.AutoPos.initializeBase(this, [element]);
}

MySpace.UI.TooltipBehavior.AutoPos.prototype = {
    _tipDiv: Function.emptyFunction,
    _quadrants: ["origin_br arrow_rb","origin_bl arrow_lb","origin_tr arrow_rt","origin_tl arrow_lt"],
    
    get_quadrants : function() {return this._quadrants;},
	set_quadrants : function(value) {this._quadrants =  _proxy_jslib_handle(null, 'value', value, 0, 0);},
    
    initialize : function() {
        MySpace.UI.TooltipBehavior.AutoPos.callBaseMethod(this, 'initialize');
   
        // get a ref to the base element
        var el = this.get_element();
                      
        // get the width and height of the tipDiv for positioning
        this._setTipDivWH(el.lastChild);                
        
        el.control.add_visibilityChanged(Function.createDelegate(this,this._setPos));                
   },
   dispose : function() {
      MySpace.UI.TooltipBehavior.AutoPos.callBaseMethod(this, 'dispose');
   },
   _setTipDivWH : function(tipDiv) {
        var style = tipDiv.style;
        
        style.visibility = 'hidden';
        style.display = 'block';        
        
        this._tipDiv.height = tipDiv.firstChild.clientHeight;
        this._tipDiv.width = tipDiv.firstChild.clientWidth;        
        
        style.display = 'none';
        style.visibility = 'visible';
   },
   _setPos : function(e) {
    
        var el = this.get_element();
        var tipDiv = el.lastChild;
        
        if(el.Hover){ el.Hover._clearTimerID(); }
        
        var minX = (typeof(window.pageXOffset) !== 'undefined') ? window.pageXOffset : document.documentElement.scrollLeft;
        var minY = (typeof(window.pageYOffset) !== 'undefined') ? window.pageYOffset : document.documentElement.scrollTop;
        var maxX = (window.innerWidth ? window.innerWidth : document.documentElement.clientWidth);
        var maxY = (window.innerHeight ? window.innerHeight : document.documentElement.clientHeight);
        
        var quadrant = 3;
                
        // determine the quadrant that the tooltip should appear in
        quadrant = (el.offsetLeft - this._tipDiv.width > minX ? 
                    (el.offsetTop - minY + this._tipDiv.height > maxY && el.offsetTop - (this._tipDiv.height) > minY ? 1 : 3) :
                      (el.offsetTop - minY + this._tipDiv.height > maxY ? 2 : 4));
                
        var posCss =  _proxy_jslib_handle(this._quadrants, (quadrant-1), 0, 0);
                
        tipDiv.firstChild.className = 'innerwrapper ' + posCss;
        tipDiv.style.display = 'block';   
   }   
}

MySpace.UI.TooltipBehavior.AutoPos.registerClass('MySpace.UI.TooltipBehavior.AutoPos', Sys.UI.Behavior);

MySpace.UI.getElementsByClassName = function(className, element) {
    element = element || document;
    className = ' ' + className + ' ';
    var potentials = element.all ||  _proxy_jslib_handle(element, 'getElementsByTagName', '', 1, 0)("*");
    var l = potentials.length, results = [], i;
    for (i = 0; i < l; i++) {
        if ((' ' +  _proxy_jslib_handle(potentials, (i), 0, 0).className + ' ').indexOf(className) !== -1) {
             _proxy_jslib_assign('', results, (results.length), '=', (  _proxy_jslib_handle(potentials, (i), 0, 0)));
        }
    }
    return results;
};

MySpace.UI.getComputedStyle = function(node) {
            switch(Sys.Browser.agent) {
            case Sys.Browser.Safari:
                {
                        var s;
                        if(node instanceof HTMLElement){
                                var dv = node.ownerDocument.defaultView;
                                s = dv.getComputedStyle(node, null);
                                if(!s && node.style){
                                        node.style.display = "";
                                        s = dv.getComputedStyle(node, null);
                                }
                        }
                        return s || {};
                }

            case Sys.Browser.InternetExplorer:
                {
                        // IE (as of 7) doesn't expose Element like sane browsers
                        return node.nodeType == 1   ? node.currentStyle : {};
                }
            
            default:
                {
                        return node instanceof HTMLElement ?
                                node.ownerDocument.defaultView.getComputedStyle(node, null) : {};
                }
            }
        }
        
MySpace.UI.getContentBox = function(node) {
    //  Returns an object that encodes the height
    //  of the node's content box, irrespective of the
    //  current box model.
    //var px=MySpace.UI._toPixelValue;
    var s = MySpace.UI.getComputedStyle(node);
    var pe = {
                //t: s.paddingTop, //px(node, s.paddingTop),
                h: parseFloat(s.paddingTop)+parseFloat(s.paddingBottom)  

 };
    var bt = (s.borderTopStyle != "none" ? parseFloat(s.borderTopWidth) : 0);
    var be = {
                h: bt + (s.borderBottomStyle!="none" ? parseFloat(s.borderBottomWidth) : 0) 

 };
    var h = node.clientHeight;
    // check for Opera...On Opera, offsetLeft includes the parent's border
    //if(d.isOpera){ pe.l += be.l; pe.t += be.t; };
    return {
                h: h - pe.h - be.h

 };
}


MySpace.Timer=function() {
	MySpace.Timer.initializeBase(this);
	this._interval=1000;
	this._enabled=false;
	this._timer=null

};
MySpace.Timer.prototype={
	get_interval:function() {
		return this._interval

 },
	set_interval:function(a) {
		if(this._interval!==a){
			this._interval=a;
			this.raisePropertyChanged("interval");
			if(!this.get_isUpdating()&&this._timer!==null)this.restartTimer()

 }
	},
	get_enabled:function() {
		return this._enabled

 },
	set_enabled:function(a) {
		if(a!==this.get_enabled()){
			this._enabled=a;
			this.raisePropertyChanged("enabled");
			if(!this.get_isUpdating())if(a)this._startTimer();
			else this._stopTimer()

 }
	},
	add_tick:function(a) {
		this.get_events().addHandler("tick",a)

 },
	remove_tick:function(a) {
		this.get_events().removeHandler("tick",a)

 },
	dispose:function() {
		this.set_enabled(false);
		this._stopTimer();
		MySpace.Timer.callBaseMethod(this,"dispose")

 },
	updated:function() {
		MySpace.Timer.callBaseMethod(this,"updated");
		if(this._enabled)this.restartTimer()

 },
	_timerCallback:function() {
		var a=this.get_events().getHandler("tick");
		if(a)a(this,Sys.EventArgs.Empty)

 },
	restartTimer:function() {
		this._stopTimer();
		this._startTimer()

 },
	_startTimer:function() {
		this._timer= _proxy_jslib_handle(window, 'setInterval', '', 1, 0)(Function.createDelegate(this,this._timerCallback),this._interval)

 },
	_stopTimer:function() {
		window.clearInterval(this._timer);
		this._timer=null

 }
};
MySpace.Timer.registerClass("MySpace.Timer",Sys.Component);

//PreviewDragDrop.js
//----------------------------------------------------------
MySpace.UI._DragDropManager=function() { };
MySpace.UI._DragDropManager.prototype={
	_instance:null,
	_events:null,
	add_dragStart:function(a) {
		this.get_events().addHandler("dragStart",a)

 },
	remove_dragStart:function(a) {
		this.get_events().removeHandler("dragStart",a)

 },
	get_events:function() {
		if(!this._events)this._events=new (Sys.EventHandlerList);
		return this._events

 },
	add_dragStop:function(a) {
		this.get_events().addHandler("dragStop",a)

 },
	remove_dragStop:function(a) {
		this.get_events().removeHandler("dragStop",a)

 },
	_getInstance:function() {
		if(!this._instance){
			this._instance=new (MySpace.UI.GenericDragDropManager);
			this._instance.initialize();
			this._instance.add_dragStart(Function.createDelegate(this,this._raiseDragStart));
			this._instance.add_dragStop(Function.createDelegate(this,this._raiseDragStop))

 }
		return this._instance

 },
	startDragDrop:function(dragSource,dragVisual,context) {
		this._getInstance().startDragDrop(dragSource,dragVisual,context)

 },
	registerDropTarget:function(target) {
		this._getInstance().registerDropTarget(target)

 },
	unregisterDropTarget:function(target) {
		this._getInstance().unregisterDropTarget(target)

 },
	dispose:function() {
		 _proxy_jslib_assign('delete', (this), ('_events'), '');
		Sys.Application.unregisterDisposableObject(this);
		Sys.Application.removeComponent(this)

 },
	_raiseDragStart:function(sender,eventArgs) {
		var handler=this.get_events().getHandler("dragStart");
		if(handler)handler(this,eventArgs)

 },
	_raiseDragStop:function(sender,eventArgs) {
		var handler=this.get_events().getHandler("dragStop");
		if(handler)handler(this,eventArgs)

 }
};
MySpace.UI._DragDropManager.registerClass("MySpace.UI._DragDropManager");
MySpace.UI.DragDropManager=new (MySpace.UI._DragDropManager);
MySpace.UI.DragDropEventArgs=function(dragMode,dragDataType,dragData) {
	this._dragMode=dragMode;
	this._dataType=dragDataType;
	this._data=dragData;
};
MySpace.UI.DragDropEventArgs.prototype={
	get_dragMode:function() {
		return this._dragMode||null

 },
	get_dragDataType:function() {
		return this._dataType||null

 },
	get_dragData:function() {
		return this._data||null

 }
};
MySpace.UI.DragDropEventArgs.registerClass("MySpace.UI.DragDropEventArgs");
MySpace.UI.IDragSource=function() {
};
MySpace.UI.IDragSource.prototype={
	get_dragDataType:function() {
		throw Error.notImplemented()

 },
	getDragData:function() {
		throw Error.notImplemented()

 },
	get_dragMode:function() {
		throw Error.notImplemented()

 },
	onDragStart:function() {
		throw Error.notImplemented()

 },
	onDrag:function() {
		throw Error.notImplemented()

 },
	onDragEnd:function() {
		throw Error.notImplemented()

 }
};
MySpace.UI.IDragSource.registerInterface("MySpace.UI.IDragSource");
MySpace.UI.IDropTarget=function() {
};
MySpace.UI.IDropTarget.prototype={
	get_dropTargetElement:function() {
		throw Error.notImplemented()

 },
	canDrop:function() {
		throw Error.notImplemented()

 },
	drop:function() {
		throw Error.notImplemented()

 },
	onDragEnterTarget:function() {
		throw Error.notImplemented()

 },
	onDragLeaveTarget:function() {
		throw Error.notImplemented()

 },
	onDragInTarget:function() {
		throw Error.notImplemented()

 }
};
MySpace.UI.IDropTarget.registerInterface("MySpace.UI.IDropTarget");
MySpace.UI.DragMode=function() {
	throw Error.invalidOperation()

};
MySpace.UI.DragMode.prototype={
	Copy:0,Move:1

};
MySpace.UI.DragMode.registerEnum("MySpace.UI.DragMode");
MySpace.UI.GenericDragDropManager=function() {
	MySpace.UI.GenericDragDropManager.initializeBase(this)

};
MySpace.UI.GenericDragDropManager.prototype={
	_dropTargets:null,
	_radius:10,
	_activeDragVisual:null,
	_activeContext:null,
	_activeDragSource:null,
	_underlyingTarget:null,
	_oldOffset:null,
	_potentialTarget:null,
	_isDragging:false,
	_mouseUpHandler:null,
	_mouseMoveHandler:null,

	_scrollEdgeConst:40,
	_scrollByConst:10,
	_scroller:null,
	_scrollDeltaX:null,
	_scrollDeltaY:null,
	_keyPressHandler:null,
	
	add_dragStart:function(a) {
		this.get_events().addHandler("dragStart",a)

 },
	remove_dragStart:function(a) {
		this.get_events().removeHandler("dragStart",a)

 },
	add_dragStop:function(a) {
		this.get_events().addHandler("dragStop",a)

 },
	remove_dragStop:function(a) {
		this.get_events().removeHandler("dragStop",a)

 },
	initialize:function() {
		MySpace.UI.GenericDragDropManager.callBaseMethod(this,"initialize");
		this._mouseUpHandler=Function.createDelegate(this,this.mouseUpHandler);
		this._mouseMoveHandler=Function.createDelegate(this,this.mouseMoveHandler);
		this._keyPressHandler=Function.createDelegate(this,this.keyPressHandler);
		if(Sys.Browser.agent===Sys.Browser.Safari){
			MySpace.UI.GenericDragDropManager.__loadSafariCompatLayer(this);
		}
		this._scroller=new (MySpace.Timer);
		this._scroller.set_interval(10);
		this._scroller.add_tick(Function.createDelegate(this,this.scrollerTickHandler))

 

 },
	dispose:function() {
		if(this._dropTargets){
			for(var a=0;a<this._dropTargets;a++)this.unregisterDropTarget( _proxy_jslib_handle(this._dropTargets, (a), 0, 0));
			this._dropTargets=null

 }
		MySpace.UI.GenericDragDropManager.callBaseMethod(this,"dispose")

 },
	startDragDrop:function(dragSource,dragVisual,context) {
		this._activeDragSource=dragSource;
		this._activeDragVisual=dragVisual;
		this._activeContext=context;
			      
		var h=window._event;
		if(this._isDragging)return;
		this._underlyingTarget=null;
		var e={
			x:h.clientX,y:h.clientY

 };
		dragVisual.originalPosition=dragVisual.style.position;
		dragVisual.style.position="absolute";
		document._lastPosition=e;
		dragVisual.startingPoint=e;
		var i=this.getScrollOffset(dragVisual,true);
		dragVisual.startingPoint=this.addPoints(dragVisual.startingPoint,i);
		if(dragVisual.style.position=="absolute"){
			dragVisual.startingPoint=this.subtractPoints(dragVisual.startingPoint,Sys.UI.DomElement.getLocation(dragVisual));
		}
		else{
			var c=parseInt(dragVisual.style.left),d=parseInt( _proxy_jslib_handle(dragVisual.style, 'top', '', 0, 0));
			if(isNaN(c))c="0";
			if(isNaN(d))d="0";
			dragVisual.startingPoint=this.subtractPoints(dragVisual.startingPoint,{
				x:c,y:d

 });
		}
		this._prepareForDomChanges();
		dragSource.onDragStart();
		var j=new (MySpace.UI.DragDropEventArgs)(dragSource.get_dragMode(),dragSource.get_dragDataType(),dragSource.getDragData(context)),g=this.get_events().getHandler("dragStart");
		if(g)g(this,j);
		this._recoverFromDomChanges();
		this._wireEvents();
		this._drag(true)

 },
	_stopDragDrop:function(canceled) {
		this._scroller.set_enabled(false);
			      
		var c=window._event;
		if(this._activeDragSource){
			this._unwireEvents();
			if(!canceled){
				canceled=this._underlyingTarget==null;
			}
			if(!canceled&&this._underlyingTarget){
				this._underlyingTarget.drop(this._activeDragSource.get_dragMode(),this._activeDragSource.get_dragDataType(),this._activeDragSource.getDragData(this._activeContext));
			}
			this._activeDragSource.onDragEnd(canceled);
			var b=this.get_events().getHandler("dragStop");
			if(b){
				b(this,Sys.EventArgs.Empty);
			}
			this._activeDragVisual.style.position=this._activeDragVisual.originalPosition;
			this._activeDragSource=null;
			this._activeContext=null;
			this._activeDragVisual=null;
			this._isDragging=false;
			this._potentialTarget=null;
			c.preventDefault()

 }
	},
	_drag:function(isInitialDrag) {
		var d=window._event,c={
			x:d.clientX,y:d.clientY

 };
		document._lastPosition=c;
		var f=this.getScrollOffset(this._activeDragVisual,true),a=this.addPoints(this.subtractPoints(c,this._activeDragVisual.startingPoint),f);

		//Constrain to the page
		var dragVisualRect=Sys.UI.DomElement.getBounds(this._activeDragVisual);
		if(a.x<0){
			a.x=0;
		}else if(a.x+dragVisualRect.width> _proxy_jslib_handle(document, 'body', '', 0, 0).offsetWidth){
			a.x= _proxy_jslib_handle(document, 'body', '', 0, 0).offsetWidth-dragVisualRect.width;
		}
		if(a.y<0){
			a.y=0;
		}

		if(!isInitialDrag&&parseInt(this._activeDragVisual.style.left)==a.x&&parseInt( _proxy_jslib_handle(this._activeDragVisual.style, 'top', '', 0, 0))==a.y)return;
		Sys.UI.DomElement.setLocation(this._activeDragVisual,a.x,a.y);
		this._prepareForDomChanges();
		this._activeDragSource.onDrag();
		this._recoverFromDomChanges();
		this._potentialTarget=this._findPotentialTarget(this._activeDragSource,this._activeDragVisual);
		var b=this._potentialTarget!=this._underlyingTarget||this._potentialTarget==null;
		if(b&&this._underlyingTarget!=null)this._leaveTarget(this._activeDragSource,this._underlyingTarget);
		if(this._potentialTarget!=null){
			if(b){
				this._underlyingTarget=this._potentialTarget;
				this._enterTarget(this._activeDragSource,this._underlyingTarget)

 }
			else{
				this._moveInTarget(this._activeDragSource,this._underlyingTarget);
			}
		}
		else{
		       this._underlyingTarget=null

 }

		this._autoScroll()

 },
	_wireEvents:function() {
		Sys.UI.DomEvent.addHandler(document,"mouseup",this._mouseUpHandler);
		Sys.UI.DomEvent.addHandler(document,"mousemove",this._mouseMoveHandler);
		Sys.UI.DomEvent.addHandler(document,"keypress",this._keyPressHandler)

 },
	_unwireEvents:function() {
		Sys.UI.DomEvent.removeHandler(document,"keypress",this._keyPressHandler);
		Sys.UI.DomEvent.removeHandler(document,"mousemove",this._mouseMoveHandler);
		Sys.UI.DomEvent.removeHandler(document,"mouseup",this._mouseUpHandler)

 },
	registerDropTarget:function(target) {
		if(!this._dropTargets)this._dropTargets=[];
		Array.add(this._dropTargets,target);
	},
	unregisterDropTarget:function(target) {
		if(this._dropTargets)Array.remove(this._dropTargets,target)

 },
	mouseUpHandler:function(evt) {
		window._event=evt;
		this._stopDragDrop(false)

 },
	mouseMoveHandler:function(evt) {
		window._event=evt;
		this._drag()

 },
	keyPressHandler:function(evt) {
		window._event=evt;
		var b=evt.keyCode?evt.keyCode:evt.rawEvent.keyCode;
		if(b==27)this._stopDragDrop(true)

 },
	_autoScroll:function() {
		var b=window._event,a=this.getBrowserRectangle();
		if(a.width>0){
			this._scrollDeltaX=this._scrollDeltaY=0;
			if(b.clientX<a.x+this._scrollEdgeConst)this._scrollDeltaX=-this._scrollByConst;
			else if(b.clientX>a.width-this._scrollEdgeConst)this._scrollDeltaX=this._scrollByConst;
			if(b.clientY<a.y+this._scrollEdgeConst)this._scrollDeltaY=-this._scrollByConst;
			else if(b.clientY>a.height-this._scrollEdgeConst)this._scrollDeltaY=this._scrollByConst;
			if(this._scrollDeltaX!=0||this._scrollDeltaY!=0)this._scroller.set_enabled(true);
			else this._scroller.set_enabled(false)

 }
	},
	scrollerTickHandler:function() {
		var d= _proxy_jslib_handle(document, 'body', '', 0, 0).scrollLeft,f= _proxy_jslib_handle(document, 'body', '', 0, 0).scrollTop;
		
		// Don't scroll if already at bottom of page
		var browserRect=this.getBrowserRectangle();
		var scrollY=(document.documentElement.scrollTop + browserRect.height + this._scrollEdgeConst) <  _proxy_jslib_handle(document, 'body', '', 0, 0).offsetHeight;
		var scrollX=(document.documentElement.scrollLeft + browserRect.width + this._scrollEdgeConst) <  _proxy_jslib_handle(document, 'body', '', 0, 0).offsetWidth;
		
		window.scrollBy(scrollX ? this._scrollDeltaX : 0, scrollY ? this._scrollDeltaY : 0);
		var c= _proxy_jslib_handle(document, 'body', '', 0, 0).scrollLeft,e= _proxy_jslib_handle(document, 'body', '', 0, 0).scrollTop,a=this._activeDragVisual,b={
			x:parseInt(a.style.left)+(c-d),y:parseInt( _proxy_jslib_handle(a.style, 'top', '', 0, 0))+(e-f)

 };
		Sys.UI.DomElement.setLocation(a,b.x,b.y)

 },
	_getDropTarget:function(element) {
		while(element){
			if(element._dropTarget!=null)return element._dropTarget;
			element=element.parentNode

 }
		return null

 },
	_dragDrop:function() {
		if(this._isDragging)return;
		this._isDragging=true;
		this._activeDragVisual.dragDrop();
		document.selection.empty()

 },
	_moveInTarget:function(dragSource,dropTarget) {
		this._prepareForDomChanges();
		dropTarget.onDragInTarget(dragSource.get_dragMode(),dragSource.get_dragDataType(),dragSource.getDragData(this._activeContext));
		this._recoverFromDomChanges()

 },
	_enterTarget:function(dragSource,dropTarget) {
		this._prepareForDomChanges();
		dropTarget.onDragEnterTarget(dragSource.get_dragMode(),dragSource.get_dragDataType(),dragSource.getDragData(this._activeContext));
		this._recoverFromDomChanges()

 },
	_leaveTarget:function(dragSource,dropTarget) {
		this._prepareForDomChanges();
		dropTarget.onDragLeaveTarget(dragSource.get_dragMode(),dragSource.get_dragDataType(),dragSource.getDragData(this._activeContext));
		this._recoverFromDomChanges()

 },
	_findPotentialTarget:function(dragSource) {
		var f=window._event;
		if(!this._dropTargets)return null;
		var m=dragSource.get_dragDataType(),l=dragSource.get_dragMode(),k=dragSource.getDragData(this._activeContext),d=this.getScrollOffset( _proxy_jslib_handle(document, 'body', '', 0, 0),true),n=f.clientX+d.x,o=f.clientY+d.y,g={
			x:n-this._radius,y:o-this._radius,width:this._radius*2,height:this._radius*2

 };
		for(var c=0;c<this._dropTargets.length;c++){
			var b= _proxy_jslib_handle(this._dropTargets, (c), 0, 0),j=b.canDrop(l,m,k);
			if(!j)continue;
			var e=b.get_dropTargetElement(),h=Sys.UI.DomElement.getBounds(e),i=Sys.UI.Control.overlaps(g,h);
			if(i||e=== _proxy_jslib_handle(document, 'body', '', 0, 0))return b

 }
		return null

 },
	_prepareForDomChanges:function() {
		this._oldOffset=Sys.UI.DomElement.getLocation(this._activeDragVisual)

 },
	_recoverFromDomChanges:function() {
		var a=Sys.UI.DomElement.getLocation(this._activeDragVisual);
		if(this._oldOffset.x!=a.x||this._oldOffset.y!=a.y){
			this._activeDragVisual.startingPoint=this.subtractPoints(this._activeDragVisual.startingPoint,this.subtractPoints(this._oldOffset,a));
			scrollOffset=this.getScrollOffset(this._activeDragVisual,true);
			var b=this.addPoints(this.subtractPoints(document._lastPosition,this._activeDragVisual.startingPoint),scrollOffset);
			Sys.UI.DomElement.setLocation(this._activeDragVisual,b.x,b.y)

 }
	},
	addPoints:function(p1,p2) {
		return{
			x:p1.x+p2.x,y:p1.y+p2.y

 }
	},
	subtractPoints:function(p1,p2) {
		return{
			x:p1.x-p2.x,y:p1.y-p2.y

 }
	},
	getScrollOffset:function(element,recursive) {
		var c=element.scrollLeft,d=element.scrollTop;
		if(recursive){
			var a=element.parentNode;
			while(a!=null&&a.scrollLeft!=null){
				c+=a.scrollLeft;
				d+=a.scrollTop;
				if(a== _proxy_jslib_handle(document, 'body', '', 0, 0)&&(c!=0&&d!=0))break;
				a=a.parentNode

 }
		}
		return{
			x:c,y:d

 }
	},
	getBrowserRectangle:function() {
		return {
			x:0,
			y:0,
			width:window.innerWidth || document.documentElement.clientWidth,
			height:window.innerHeight || document.documentElement.clientHeight

 };
	},
	getNextSibling:function(item) {
		for(item=item.nextSibling;item!=null;item=item.nextSibling)if( _proxy_jslib_handle(item, 'innerHTML', '', 0, 0)!=null)return item;
		return null

 },
	hasParent:function(element) {
		return element.parentNode!=null&&element.parentNode.tagName!=null

 }
};
MySpace.UI.GenericDragDropManager.registerClass("MySpace.UI.GenericDragDropManager",Sys.Component);

if(Sys.Browser.agent===Sys.Browser.Safari){
	MySpace.UI.GenericDragDropManager.__loadSafariCompatLayer=function(ddm) {
		ddm._getScrollOffset=ddm.getScrollOffset;
		ddm.getScrollOffset=function() {
			return{ x:0,y:0 }
		};
		ddm._getBrowserRectangle=ddm.getBrowserRectangle;
		ddm.getBrowserRectangle=function() {
			var b=ddm._getBrowserRectangle(),c=ddm._getScrollOffset( _proxy_jslib_handle(document, 'body', '', 0, 0),true);
			return{ x:b.x+c.x,y:b.y+c.y,width:b.width+c.x,height:b.height+c.y }
		}
	};
}

MySpace.UI.RepeatDirection=function() {
	throw Error.invalidOperation()

};
MySpace.UI.RepeatDirection.prototype={
	Horizontal:0,Vertical:1

};
MySpace.UI.RepeatDirection.registerEnum("MySpace.UI.RepeatDirection");
MySpace.UI.DragDropList=function(associatedElement) {
	MySpace.UI.DragDropList.initializeBase(this,[associatedElement]);
	this._acceptedDataTypes=[];
	this._allowedItemIds=[];
};
MySpace.UI.DragDropList.prototype={
	_isDragging:null,
	_dataType:null,
	_dragMode:null,
	_dragVisual:null,
	_direction:MySpace.UI.RepeatDirection.Vertical,
	_emptyTemplate:null,
	_emptyTemplateInstance:null,
	_dropCueTemplate:null,
	_dropCueTemplateInstance:null,
	_floatContainerInstance:null,
	_originalParent:null,
	_originalNextSibling:null,
	_originalZIndex:null,
	_currentContext:null,
	_data:null,
	get_currentContext:function() {
	    return this._currentContext;
	},
	get_data:function() {
		return this._data

 },
	set_data:function(a) {
		this._data=a

 },
	initialize:function() {
		MySpace.UI.DragDropList.callBaseMethod(this,"initialize");
		this.get_element().__dragDropList=this;
		MySpace.UI.DragDropManager.registerDropTarget(this)

 },
	startDragDrop:function(dragObject,context,dragVisual) {
		if(!this._isDragging){
			this._isDragging=true;
			this._currentContext=context;
			if(!dragVisual)dragVisual=this.createDragVisual(dragObject);
			else this._dragVisual=dragVisual;
			MySpace.UI.DragDropManager.startDragDrop(this,dragVisual,context)

 }
	},
	createDragVisual:function(dragObject) {
		if(this._dragMode===MySpace.UI.DragMode.Copy)this._dragVisual=dragObject.cloneNode(true);
		else this._dragVisual=dragObject;
		var e=MySpace.UI.DragDropManager._getInstance().getScrollOffset(dragObject,true);
		this._originalSize={w: this._dragVisual.style.width, h: this._dragVisual.style.height};
		this._originalLocation=Sys.UI.DomElement.getLocation(dragObject);
		this._dragVisual.style.width=dragObject.offsetWidth+"px";
		this._dragVisual.style.height=dragObject.offsetHeight+"px";
		this._dragVisual.style.opacity="0.4";
		this._dragVisual.style.filter="progid:DXImageTransform.Microsoft.BasicImage(opacity=0.4);";
		this._originalZIndex=this._dragVisual.style.zIndex;
		this._dragVisual.style.zIndex=99999;
		this._originalParent=this._dragVisual.parentNode;
		this._originalNextSibling=MySpace.UI.DragDropManager._getInstance().getNextSibling(this._dragVisual);
		var f=MySpace.UI.DragDropManager._getInstance(),c=Sys.UI.DomElement.getLocation(dragObject),b=this._getFloatContainer();
		Sys.UI.DomElement.setLocation(b,c.x,c.y);
		if(MySpace.UI.DragDropManager._getInstance().hasParent(this._dragVisual)){
			var dropCue=this._getDropCueTemplateInstance(this._dragVisual);
			this._dragVisual.parentNode.replaceChild(dropCue, this._dragVisual);
		}
		b.appendChild(this._dragVisual);
		var d=f.getScrollOffset(dragObject,true);
		if(e.x!==d.x||e.y!==d.y){
			var h=f.subtractPoints(e,d),g=f.subtractPoints(c,h);
			Sys.UI.DomElement.setLocation(b,g.x,g.y)

 }
		return b

 },
	get_emptyTemplate:function() {
		return this._emptyTemplate

 },
	set_emptyTemplate:function(a) {
		this._emptyTemplate=a

 },
	get_dragDataType:function() {
		return this._dataType

 },
	set_dragDataType:function(a) {
		this._dataType=a

 },
	getDragData:function(a) {
		return a

 },
	get_dragMode:function() {
		return this._dragMode

 },
	set_dragMode:function(a) {
		this._dragMode=a

 },
	dispose:function() {
		this.get_element().__dragDropList=null;
		MySpace.UI.DragDropList.callBaseMethod(this,"dispose")

 },
	onDragStart:function() {
		this._validate()

 },
	onDrag:function() {
	},
	onDragEnd:function(canceled) {
		if(canceled && this._floatContainerInstance){
			var placeholder = document.createElement("div");
			if(this._originalNextSibling) this._originalParent.insertBefore(placeholder,this._originalNextSibling);
			else this._originalParent.appendChild(placeholder);
			
			var currentLocation=Sys.UI.DomElement.getLocation(this._floatContainerInstance);
			
			var heightAnimation=$create(MySpace.UI.Effects.LengthAnimation, {
				target: placeholder,
				property:"style",
				propertyKey:"height",
				startValue:0,
				endValue:this._floatContainerInstance.offsetHeight

 });
			var leftAnimation=$create(MySpace.UI.Effects.LengthAnimation, {
				target:this._floatContainerInstance,
				property:"style",
				propertyKey:"left",
				startValue:currentLocation.x,
				endValue:this._originalLocation.x

 });
			var topAnimation=$create(MySpace.UI.Effects.LengthAnimation, {
				target:this._floatContainerInstance,
				property:"style",
				propertyKey:"top",
				startValue:currentLocation.y,
				endValue:this._originalLocation.y

 });

			var animation=$create(MySpace.UI.Effects.CompositeAnimation, {
				animations:[heightAnimation, leftAnimation, topAnimation],
				duration:0.3,
				fps:12

 }, {
				ended:Function.createDelegate(this, function() {
					placeholder.parentNode.removeChild(placeholder);
					this._onDragEnd(canceled);
				})

 });
			
			animation.play();
		} else {
			this._onDragEnd(canceled);
		}
	},
	_onDragEnd:function(canceled) {
		if(this._floatContainerInstance){
			if(this._dragMode===MySpace.UI.DragMode.Copy){
				this._floatContainerInstance.removeChild(this._dragVisual);
			}
			else{
				this._dragVisual.style.opacity="0.999";
				this._dragVisual.style.filter="";
				this._dragVisual.style.zIndex=this._originalZIndex?this._originalZIndex:0;
				if(this._originalSize){
					this._dragVisual.style.width=this._originalSize.w;
					this._dragVisual.style.height=this._originalSize.h;
				}
				if(canceled){
					this._dragVisual.parentNode.removeChild(this._dragVisual);
					if(this._originalNextSibling!=null){
						this._originalParent.insertBefore(this._dragVisual,this._originalNextSibling);
					}
					else{
						this._originalParent.appendChild(this._dragVisual)

 }
				}
				else if(this._dragVisual.parentNode===this._floatContainerInstance){
					this._dragVisual.parentNode.removeChild(this._dragVisual)

 }
			}
			 _proxy_jslib_handle(document, 'body', '', 0, 0).removeChild(this._floatContainerInstance)

 }
		else{
			this._dragVisual.parentNode.removeChild(this._dragVisual);
		}
		if(!canceled&&this._data&&this._dragMode===MySpace.UI.DragMode.Move){
			var a=this.getDragData(this._currentContext);
			if(this._data&&a){
				if(this._data instanceof Array){
					if(typeof this._data.remove==="function"){
						this._data.remove(a);
					}
					else{
						Array.remove(this._data,a)

 }
				}
			}
		}
		if(!canceled){
			var handler=this.get_events().getHandler("dragSuccessful");
			if(handler){
			    handler(this, null);
			}
		}
		this._isDragging=false;
		this._validate()

 },
	get_direction:function() {
		return this._direction

 },
	set_direction:function(a) {
		this._direction=a

 },
	get_acceptedDataTypes:function() {
		return this._acceptedDataTypes

 },
	set_acceptedDataTypes:function(a) {
		this._acceptedDataTypes=a

 },
	get_allowedItemIds:function() {
		return this._allowedItemIds;
	},
	set_allowedItemIds:function(a) {
		this._allowedItemIds=a;
	},
	get_dropCueTemplate:function() {
		return this._dropCueTemplate

 },
	set_dropCueTemplate:function(a) {
		this._dropCueTemplate=a

 },
	get_dropTargetElement:function() {
		return this.get_element()

 },
	canDrop:function(dragMode, dataType, data) {
		if(!Array.contains(this._acceptedDataTypes, dataType)){
			return false;
		}
		if(this._allowedItemIds.length>0 && !Array.contains(this._allowedItemIds, data.id)){
			return false;
		}
		if(data.DraggableListItem.get_allowedListIds().length>0 && !Array.contains(data.DraggableListItem.get_allowedListIds(), this._element.id)){
			return false;
		}
		return true;
	},
	drop:function(dragMode,dataType,data) {
		if(dataType==="HTML"&&dragMode===MySpace.UI.DragMode.Move){
			var dragVisual=data;
			var c=this._findPotentialNextSibling(dragVisual);
			this._setDropCueVisible(false,dragVisual);
			dragVisual.parentNode.removeChild(dragVisual);
			if(c)this.get_element().insertBefore(dragVisual,c);
			else this.get_element().appendChild(dragVisual)

 }
		else{
			this._setDropCueVisible(false);
		}

		if(this._data&&data){
			var b=data;
			if(this._data instanceof Array){
				if(typeof this._data.add==="function"){
					this._data.add(b);
				}
				else{
					Array.add(this._data,b)

 }
			}
		}
	},
	onDragEnterTarget:function(dragMode,dataType,data) {
		if(dataType==="HTML"){
			this._setDropCueVisible(true,data);
			this._validate()

 }
	},
	onDragLeaveTarget:function(dragMode,dataType) {
		if(dataType==="HTML"){
			this._setDropCueVisible(false);
			this._validate()

 }
	},
	onDragInTarget:function(dragMode,dataType,data) {
		if(dataType==="HTML")this._setDropCueVisible(true,data)

 },
	add_dragSuccessful: function(handler) {
		this.get_events().addHandler("dragSuccessful", handler);
	},
	remove_dragSuccessful: function(handler) {
		this.get_events().removeHandler("dragSuccessful", handler);
	},			   
	_setDropCueVisible:function(visible,dragVisual) {
		if(this._dropCueTemplate){
			var instance=this._getDropCueTemplateInstance(dragVisual);
			if(visible){
				var a=this._findPotentialNextSibling(dragVisual);
				this._dropCueTemplateInstance.style.width=dragVisual.offsetWidth+"px";
				this._dropCueTemplateInstance.style.height=dragVisual.offsetHeight+"px";
				if(!MySpace.UI.DragDropManager._getInstance().hasParent(instance)){
					if(a)this.get_element().insertBefore(instance,a);
					else this.get_element().appendChild(instance);
				}
				else if(MySpace.UI.DragDropManager._getInstance().getNextSibling(instance)!==a){
					this.get_element().removeChild(instance);
					if(a)this.get_element().insertBefore(instance,a);
					else this.get_element().appendChild(instance)

 }
			}
			else if(instance && MySpace.UI.DragDropManager._getInstance().hasParent(instance)){
				this.get_element().removeChild(instance)

 }
		}
	},
	_getDropCueTemplateInstance:function(dragVisual) {
		if(!this._dropCueTemplateInstance){
			this._dropCueTemplateInstance=this._dropCueTemplate.cloneNode(true);
		}
		return this._dropCueTemplateInstance;
	},
	_findPotentialNextSibling:function(dragVisual) {
		var dragVisualRect=Sys.UI.DomElement.getBounds(dragVisual)
		var isVertical=this._direction===MySpace.UI.RepeatDirection.Vertical
		var nodeRect;
		for(var node=this.get_element().firstChild;node!==null;node=node.nextSibling){
			if( _proxy_jslib_handle(node, 'innerHTML', '', 0, 0) && node!==this._dropCueTemplateInstance && node!==this._emptyTemplateInstance){
				nodeRect=Sys.UI.DomElement.getBounds(node);
				if(!isVertical&&dragVisualRect.x<=nodeRect.x||isVertical&&(dragVisualRect.y<=nodeRect.y)){
					return node

 }
			}
		}
		return null

 },
	_validate:function() {
		var b=this._dropCueTemplateInstance==null||!MySpace.UI.DragDropManager._getInstance().hasParent(this._dropCueTemplateInstance),c=0;
		for(var a=this.get_element().firstChild;a!==null;a=a.nextSibling)if( _proxy_jslib_handle(a, 'innerHTML', '', 0, 0)&&a!==this._emptyTemplateInstance&&a!==this._dropCueTemplateInstance)c++;
		if(c>0)b=false;
		this._setEmptyTemplateVisible(b)

 },
	_setEmptyTemplateVisible:function(visible) {
		if(this._emptyTemplate)if(visible){
			if(!this._emptyTemplateInstance)this._emptyTemplateInstance=this._emptyTemplate.cloneNode(true);
			else if(!MySpace.UI.DragDropManager._getInstance().hasParent(this._emptyTemplateInstance))this.get_element().appendChild(this._emptyTemplateInstance)

 }
		else if(this._emptyTemplateInstance&&MySpace.UI.DragDropManager._getInstance().hasParent(this._emptyTemplateInstance))this.get_element().removeChild(this._emptyTemplateInstance)

 },
	_getFloatContainer:function() {
		if(!this._floatContainerInstance){
			this._floatContainerInstance=document.createElement(this.get_element().tagName);
			var a="0px 0px 0px 0px";
			this._floatContainerInstance.style.position="absolute";
			this._floatContainerInstance.style.padding=a;
			this._floatContainerInstance.style.margin=a;
			 _proxy_jslib_handle(document, 'body', '', 0, 0).appendChild(this._floatContainerInstance)

 }
		else if(!MySpace.UI.DragDropManager._getInstance().hasParent(this._floatContainerInstance)) _proxy_jslib_handle(document, 'body', '', 0, 0).appendChild(this._floatContainerInstance);
		return this._floatContainerInstance

 }
};
MySpace.UI.DragDropList.registerClass("MySpace.UI.DragDropList",Sys.UI.Behavior,MySpace.UI.IDragSource,MySpace.UI.IDropTarget,Sys.IDisposable);

MySpace.UI.DraggableListItem=function(element) {
	MySpace.UI.DraggableListItem.initializeBase(this,[element]);
	var d,a,c,b,allowedListIds=[];
	this.get_data=function() {
		if(d==null){
			var a=this._findDragSource();
			if(a!=null&&a.get_dragDataType()=="HTML")return this.get_element()

 }
		return d

 };
	this.set_data=function(a) {
		d=a

 };
	this.get_handle=function() {
		return a

 };
	this.set_handle=function(b) {
		if(a!=null){
			Sys.UI.DomEvent.removeHandler(a,"mousedown",this._handleMouseDown);
			a.__draggableBehavior=null

 }
		if(b.element)b=b.element;
		a=b;
		a.__draggableBehavior=this;
		Sys.UI.DomEvent.addHandler(a,"mousedown",this._handleMouseDown);
		a.__draggableBehavior=this

 a.style.zoom=1;		// Need to force hasLayout to work right in IE6
	};
	this.get_dragVisualTemplate=function() {
		return c

 };
	this.set_dragVisualTemplate=function(a) {
		c=a

 };
	this.get_allowedListIds=function() {
		return allowedListIds;
	};
	this.set_allowedListIds=function(a) {
		allowedListIds=a;
	};
	this._handleMouseDown=function(b) {
		window._event=b;
		a.__draggableBehavior._handleMouseDownInternal()

 };
	this._handleMouseDownInternal=function() {
		var b=window._event;
		if(b.button<=1){
			var a=this._findDragSource();
			if(a!=null){
				var c=this._createDragVisual();
				a.startDragDrop(this.get_element(),this.get_data(),c);
				b.preventDefault()

 }
		}
	};
	this._createDragVisual=function() {
		var d=window._event;
		if(c!=null){
			if(b==null)b=c.createInstance(this.get_element()).instanceElement;
			else if(!MySpace.UI.DragDropManager._getInstance().hasParent(b))this.get_element().appendChild(b);
			var a={
				x:d.clientX,y:d.clientY

 };
			a=MySpace.UI.DragDropManager._getInstance().addPoints(a,MySpace.UI.DragDropManager._getInstance().getScrollOffset( _proxy_jslib_handle(document, 'body', '', 0, 0),true));
			Sys.UI.DomElement.setLocation(b,a.x,a.y)

 }
		return b

 };
	this._findDragSource=function() {
		var a=this.get_element();
		while(a!=null){
			if(a.__dragDropList!=null)return a.__dragDropList;
			a=a.parentNode

 }
		return null

 }
};
MySpace.UI.DraggableListItem.registerClass("MySpace.UI.DraggableListItem",Sys.UI.Behavior);

Sys.UI.Control.overlaps = function(r1, r2) {
    var xLeft = (r1.x >= r2.x && r1.x <= (r2.x + r2.width));
    var xRight = ((r1.x + r1.width) >= r2.x && (r1.x + r1.width) <= r2.x + r2.width);
    var xComplete = ((r1.x < r2.x) && ((r1.x + r1.height) > (r2.x + r2.height)));
    
    var yLeft = (r1.y >= r2.y && r1.y <= (r2.y + r2.height));
    var yRight = ((r1.y + r1.height) >= r2.y && (r1.y + r1.height) <= r2.y + r2.height);
    var yComplete = ((r1.y < r2.y) && ((r1.y + r1.height) > (r2.y + r2.height)));
    if ((xLeft || xRight || xComplete) && (yLeft || yRight || yComplete)) {
        return true;
    }
   
    return false;
}

//PreviewGlitz.js
//----------------------------------------------------------
Type.registerNamespace("MySpace.UI.Effects");

MySpace.UI.Effects.Glitz=function() {
	throw Error.invalidOperation()

};

MySpace.UI.Effects.Glitz.interpolate=function(value1,value2,percentage,easingFn) {
	if(easingFn){percentage=100*easingFn(percentage/100);}
	return value1+(value2-value1)*(percentage/100)

};
MySpace.UI.Effects.Glitz.setElementOpacity=function(a,b) {
	if(a.filters){
		if(b==1){	// opacity=100 makes text fuzzy on IE7, so remove it
			 _proxy_jslib_assign('', a.style, 'cssText', '=', ( _proxy_jslib_handle( _proxy_jslib_handle(a.style, 'cssText', '', 0, 0), 'replace', '', 1, 0)(/FILTER:[^;]*;?/i, "")));
		}
		else{
			a.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+b*100+")"

 }
	}
	else a.style.opacity=b

};

MySpace.UI.Effects.Easing={
	linear:function(n) {
		return n;
	},
	quadIn:function(n) {
		return n*n;
	},
	quadOut:function(n) {
		return n*(n-2)*-1;
	},
	quadInOut: function(n) {
		n=n*2;
		if(n<1){ return Math.pow(n, 2) / 2; }
		return -1 * (((n= _proxy_jslib_assign_rval('--', 'n', '', '', n)))*(n-2) - 1) / 2;
	},
	quartIn: function(n) {
		return Math.pow(n, 4);
	},
	quartOut: function(n) {
		return -1 * (Math.pow(n-1, 4) - 1);
	},
	quartInOut: function(n) {
		n=n*2;
		if(n<1){ return Math.pow(n, 4) / 2; }
		n-=2;
		return -1/2 * (Math.pow(n, 4) - 2);
	},
	circIn: function(n) {
		return -1 * (Math.sqrt(1 - Math.pow(n, 2)) - 1);
	},
	circOut: function(n) {
		n = n-1;
		return Math.sqrt(1 - Math.pow(n, 2));
	},
	circInOut: function(n) {
		n = n*2;
		if(n<1){ return -1/2 * (Math.sqrt(1 - Math.pow(n, 2)) - 1); }
		n-=2;
		return 1/2 * (Math.sqrt(1 - Math.pow(n, 2)) + 1);
	},
	backIn: function(n) {
		var s = 1.70158;
		return Math.pow(n, 2) * ((s+1)*n - s);
	},
	backOut: function(n) {
		// summary: an easing function that pops past the range briefly, and 
		// 	slowly comes back. 
		n = n - 1;
		var s = 1.70158;
		return Math.pow(n, 2) * ((s + 1) * n + s) + 1;
	},
	backInOut: function(n) {
		var s = 1.70158 * 1.525;
		n = n*2;
		if(n < 1){ return (Math.pow(n, 2)*((s+1)*n - s))/2; }
		n-=2;
		return (Math.pow(n, 2)*((s+1)*n + s) + 2)/2;
	},
	elasticIn: function(n) {
		if(n==0){ return 0; }
		if(n==1){ return 1; }
		var p = .3;
		var s = p/4;
		n = n - 1;
		return -1 * Math.pow(2,10*n) * Math.sin((n-s)*(2*Math.PI)/p);
	},
	elasticOut: function(n) {
		// summary: An easing function that elasticly snaps around the target value, near the end of the Animation
		if(n==0) return 0;
		if(n==1) return 1;
		var p = .3;
		var s = p/4;
		return Math.pow(2,-10*n) * Math.sin((n-s)*(2*Math.PI)/p) + 1;
	},
	elasticInOut: function(n) {
		// summary: An easing function that elasticly snaps around the value, near the beginning and end of the Animation		
		if(n==0) return 0;
		n = n*2;
		if(n==2) return 1;
		var p = .3*1.5;
		var s = p/4;
		if(n<1){
			n-=1;
			return -.5*(Math.pow(2,10*n) * Math.sin((n-s)*(2*Math.PI)/p));
		}
		n-=1;
		return .5*(Math.pow(2,-10*n) * Math.sin((n-s)*(2*Math.PI)/p)) + 1;
	},
	bounceIn: function(n) {
		// summary: An easing function that "bounces" near the beginning of an Animation
		return (1 - MySpace.UI.Effects.Easing.bounceOut(1-n)); // Decimal
	},
	bounceOut: function(n) {
		// summary: An easing function that "bounces" near the end of an Animation
		var s=7.5625;
		var p=2.75;
		var l; 
		if(n < (1 / p)){
			l = s*Math.pow(n, 2);
		}else if(n < (2 / p)){
			n -= (1.5 / p);
			l = s * Math.pow(n, 2) + .75;
		}else if(n < (2.5 / p)){
			n -= (2.25 / p);
			l = s * Math.pow(n, 2) + .9375;
		}else{
			n -= (2.625 / p);
			l = s * Math.pow(n, 2) + .984375;
		}
		return l;
	},
	bounceInOut: function(n) {
		// summary: An easing function that "bounces" at the beginning and end of the Animation
		if(n<0.5){ return MySpace.UI.Effects.Easing.bounceIn(n*2) / 2; }
		return (MySpace.UI.Effects.Easing.bounceOut(n*2-1) / 2) + 0.5;
	}	
};

MySpace.UI.Effects.Animation=function() {
	MySpace.UI.Effects.Animation.initializeBase(this)

};
MySpace.UI.Effects.Animation.prototype={
	_duration:1,
	_fps:25,
	_target:null,
	_tickHandler:null,
	_timer:null,
	_percentComplete:0,
	_percentDelta:null,
	_parentAnimation:null,
	get_duration:function() {
		return this._duration

 },
	set_duration:function(a) {
		this._duration=a

 },
	get_fps:function() {
		return this._fps

 },
	set_fps:function(a) {
		this._fps=a

 },
	get_isActive:function() {
		return this._timer!==null

 },
	get_isPlaying:function() {
		return this._timer!==null&&this._timer.get_enabled()

 },
	get_percentComplete:function() {
		return this._percentComplete

 },
	get_target:function() {
		return this._target

 },
	set_target:function(a) {
		this._target=a

 },
	add_ended:function(a) {
		this.get_events().addHandler("ended",a)

 },
	remove_ended:function(a) {
		this.get_events().removeHandler("ended",a)

 },
	add_started:function(a) {
		this.get_events().addHandler("started",a)

 },
	remove_started:function(a) {
		this.get_events().removeHandler("started",a)

 },
	dispose:function() {
		if(this._timer){
			this._timer.dispose();
			this._timer=null

 }
		this._tickHandler=null;
		this._target=null;
		MySpace.UI.Effects.Animation.callBaseMethod(this,"dispose")

 },
	getAnimatedValue:function() {
		throw Error.notImplemented()

 },
	onEnd:function() {
	},
	onStart:function() {
	},
	onStep:function(percentage) {
		this.setValue(this.getAnimatedValue(percentage))

 },
	pause:function() {
		if(!this._parentAnimation)if(this._timer){
			this._timer.set_enabled(false);
			this.raisePropertyChanged("isPlaying")

 }
	},
	play:function() {
		if(!this._parentAnimation){
			var a=true;
			if(!this._timer){
				a=false;
				if(!this._tickHandler)this._tickHandler=Function.createDelegate(this,this._onTimerTick);
				this._timer=new (MySpace.Timer);
				this._timer.set_interval(1000/this._fps);
				this._timer.add_tick(this._tickHandler);
				this._percentDelta=100/(this._duration*this._fps);
				this.onStart();
				this._updatePercentComplete(0,true)

 }
			this._timer.set_enabled(true);
			this.raisePropertyChanged("isPlaying");
			if(!a)this.raisePropertyChanged("isActive")

 }
	},
	setOwner:function(a) {
		this._parentAnimation=a

 },
	setValue:function() {
		throw Error.notImplemented()

 },
	stop:function() {
		if(!this._parentAnimation){
			var a=this._timer;
			this._timer=null;
			if(a){
				a.dispose();
				this._updatePercentComplete(100);
				this.onEnd();
				var handler = this.get_events().getHandler("ended");
				if (handler) {
				    handler(this, null);
				}					
				this.raisePropertyChanged("isPlaying");
				this.raisePropertyChanged("isActive")

 }
		}
	},
	_onTimerTick:function() {
		this._updatePercentComplete(this._percentComplete+this._percentDelta,true)

 },
	_updatePercentComplete:function(percentComplete,animate) {
		if(percentComplete>100)percentComplete=100;
		this._percentComplete=percentComplete;
		this.raisePropertyChanged("percentComplete");
		if(animate)this.onStep(percentComplete);
		if(percentComplete===100)this.stop()

 }
};
MySpace.UI.Effects.Animation.registerClass("MySpace.UI.Effects.Animation",Sys.Component);
MySpace.UI.Effects.PropertyAnimation=function() {
	MySpace.UI.Effects.PropertyAnimation.initializeBase(this)

};
MySpace.UI.Effects.PropertyAnimation.prototype={
	_property:null,
	_propertyKey:null,
	get_property:function() {
		return this._property

 },
	set_property:function(a) {
		this._property=a

 },
	get_propertyKey:function() {
		return this._propertyKey

 },
	set_propertyKey:function(a) {
		this._propertyKey=a

 },
	add_ended:function(a) {
		this.get_events().addHandler("ended",a)

 },
	remove_ended:function(a) {
		this.get_events().removeHandler("ended",a)

 },
	add_started:function(a) {
		this.get_events().addHandler("started",a)

 },
	remove_started:function(a) {
		this.get_events().removeHandler("started",a)

 },
	setValue:function(value) {
		if(this._propertyKey){
			 _proxy_jslib_assign('',  _proxy_jslib_handle(this.get_target(), (this._property), 0, 0), (this._propertyKey), '=', (  _proxy_jslib_handle(null, 'value', value, 0, 0)));
		}
		else{
			 _proxy_jslib_assign('', this.get_target(), (this._property), '=', (  _proxy_jslib_handle(null, 'value', value, 0, 0)));
		}
	}
};
MySpace.UI.Effects.PropertyAnimation.registerClass("MySpace.UI.Effects.PropertyAnimation",MySpace.UI.Effects.Animation);
MySpace.UI.Effects.InterpolatedAnimation=function() {
	MySpace.UI.Effects.InterpolatedAnimation.initializeBase(this)

};
MySpace.UI.Effects.InterpolatedAnimation.prototype={
	_startValue:null,
	_endValue:null,
	_easingFunction:null,
	get_endValue:function() {
		return this._endValue

 },
	set_endValue:function(a) {
		this._endValue=a

 },
	get_startValue:function() {
		return this._startValue

 },
	set_startValue:function(a) {
		this._startValue=a

 },
	get_easingFunction:function() {
		return this._easingFunction;
	},
	set_easingFunction:function(a) {
		this._easingFunction=a;
	}
};
MySpace.UI.Effects.InterpolatedAnimation.registerClass("MySpace.UI.Effects.InterpolatedAnimation",MySpace.UI.Effects.PropertyAnimation);
MySpace.UI.Effects.DiscreteAnimation=function() {
	MySpace.UI.Effects.DiscreteAnimation.initializeBase(this);
	this._values=[]

};
MySpace.UI.Effects.DiscreteAnimation.prototype={
	get_values:function() {
		return this._values

 },
	set_values:function(a) {
		this._values=a

 },
	getAnimatedValue:function(percentage) {
		var b=Math.round(percentage/100*(this._values.length-1));
		return  _proxy_jslib_handle(this._values, (b), 0, 0)

 }
};
MySpace.UI.Effects.DiscreteAnimation.registerClass("MySpace.UI.Effects.DiscreteAnimation",MySpace.UI.Effects.PropertyAnimation);
MySpace.UI.Effects.NumberAnimation=function() {
	MySpace.UI.Effects.NumberAnimation.initializeBase(this)

};
MySpace.UI.Effects.NumberAnimation.prototype={
	_integralValues:false,
	get_integralValues:function() {
		return this._integralValues

 },
	set_integralValues:function(a) {
		this._integralValues=a

 },
	getAnimatedValue:function(percentage) {
		var a=MySpace.UI.Effects.Glitz.interpolate(this.get_startValue(),this.get_endValue(),percentage,this.get_easingFunction());
		if(this._integralValues)a=Math.round(a);
		return a

 }
};
MySpace.UI.Effects.NumberAnimation.registerClass("MySpace.UI.Effects.NumberAnimation",MySpace.UI.Effects.InterpolatedAnimation);
MySpace.UI.Effects.LengthAnimation=function() {
	MySpace.UI.Effects.LengthAnimation.initializeBase(this)

};
MySpace.UI.Effects.LengthAnimation.prototype={
	_unit:"px",
	get_unit:function() {
		return this._unit

 },
	set_unit:function(a) {
		this._unit=a

 },
	getAnimatedValue:function(percentage) {
		var b=MySpace.UI.Effects.Glitz.interpolate(this.get_startValue(),this.get_endValue(),percentage,this.get_easingFunction());
		return Math.round(b)+this._unit

 }
};
MySpace.UI.Effects.LengthAnimation.registerClass("MySpace.UI.Effects.LengthAnimation",MySpace.UI.Effects.InterpolatedAnimation);
MySpace.UI.Effects.CompositeAnimation=function() {
	MySpace.UI.Effects.CompositeAnimation.initializeBase(this);
	this._animations=[];
};
MySpace.UI.Effects.CompositeAnimation.prototype={
	get_animations:function() {
		return this._animations

 },
	add_animation:function(a) {
		this._animations.push(a);
	},
	getAnimatedValue:function() {
		throw Error.invalidOperation()

 },
	dispose:function() {
		for(var a=0;a<this._animations.length;a++) _proxy_jslib_handle(this._animations, (a), 0, 0).dispose();
		this._animations=null;
		MySpace.UI.Effects.CompositeAnimation.callBaseMethod(this,"dispose")

 },
	onEnd:function() {
		for(var a=0;a<this._animations.length;a++) _proxy_jslib_handle(this._animations, (a), 0, 0).onEnd()

 },
	onStart:function() {
		for(var a=0;a<this._animations.length;a++) _proxy_jslib_handle(this._animations, (a), 0, 0).onStart()

 },
	onStep:function(b) {
		for(var a=0;a<this._animations.length;a++) _proxy_jslib_handle(this._animations, (a), 0, 0).onStep(b)

 }
};
MySpace.UI.Effects.CompositeAnimation.registerClass("MySpace.UI.Effects.CompositeAnimation",MySpace.UI.Effects.Animation);

MySpace.UI.Effects.ColorAnimation = function(target, duration, fps, property, propertyKey, startValue, endValue) {
    MySpace.UI.Effects.ColorAnimation.initializeBase(this, [target, duration, fps, property, propertyKey, startValue, endValue]);
    
    this._start = null;
    this._end = null;
    
    this._interpolateRed = false;
    this._interpolateGreen = false;
    this._interpolateBlue = false;
}
MySpace.UI.Effects.ColorAnimation.prototype = {
    onStart : function() {
        MySpace.UI.Effects.ColorAnimation.callBaseMethod(this, 'onStart');
       
        this._start = MySpace.UI.Effects.ColorAnimation.getRGB(this.get_startValue());
        this._end = MySpace.UI.Effects.ColorAnimation.getRGB(this.get_endValue());
        
        this._interpolateRed = (this._start.Red != this._end.Red);
        this._interpolateGreen = (this._start.Green != this._end.Green);
        this._interpolateBlue = (this._start.Blue != this._end.Blue);
    },
    
    getAnimatedValue : function(percentage) {
        var r = this._start.Red;
        var g = this._start.Green;
        var b = this._start.Blue;
        
        if (this._interpolateRed)
            r = Math.round(MySpace.UI.Effects.Glitz.interpolate(r, this._end.Red, percentage, this.get_easingFunction()));
        
        if (this._interpolateGreen)
            g = Math.round(MySpace.UI.Effects.Glitz.interpolate(g, this._end.Green, percentage, this.get_easingFunction()));
        
        if (this._interpolateBlue)
            b = Math.round(MySpace.UI.Effects.Glitz.interpolate(b, this._end.Blue, percentage, this.get_easingFunction()));
        
        return MySpace.UI.Effects.ColorAnimation.toColor(r, g, b);
    },
    
    set_startValue : function(value) {
        if (this._startValue !=  _proxy_jslib_handle(null, 'value', value, 0, 0)) {
            this._startValue =  _proxy_jslib_handle(null, 'value', value, 0, 0);
            this.raisePropertyChanged('startValue');
        }
    },
    
    set_endValue : function(value) {
        if (this._endValue !=  _proxy_jslib_handle(null, 'value', value, 0, 0)) {
            this._endValue =  _proxy_jslib_handle(null, 'value', value, 0, 0);
            this.raisePropertyChanged('endValue');
        }
    }   
}
MySpace.UI.Effects.ColorAnimation.getRGB = function(color) {
    if (!color || color.length != 7) {
        throw String.format(AjaxControlToolkit.Resources.Animation_InvalidColor, color);
    }
    return { 'Red': parseInt(color.substr(1,2), 16),
             'Green': parseInt(color.substr(3,2), 16),
             'Blue': parseInt(color.substr(5,2), 16) };
}
MySpace.UI.Effects.ColorAnimation.toColor = function(red, green, blue) {
    var r =  _proxy_jslib_handle(red, 'toString', '', 1, 0)(16);
    var g =  _proxy_jslib_handle(green, 'toString', '', 1, 0)(16);
    var b =  _proxy_jslib_handle(blue, 'toString', '', 1, 0)(16);
    if (r.length == 1) r = '0' + r;
    if (g.length == 1) g = '0' + g;
    if (b.length == 1) b = '0' + b;
    return '#' + r + g + b;
}
MySpace.UI.Effects.ColorAnimation.registerClass('MySpace.UI.Effects.ColorAnimation', MySpace.UI.Effects.InterpolatedAnimation);

MySpace.UI.Effects.FadeEffect=function() {
	throw Error.invalidOperation()

};
MySpace.UI.Effects.FadeEffect.prototype={
	FadeIn:0,FadeOut:1

};
MySpace.UI.Effects.FadeEffect.registerEnum("MySpace.UI.Effects.FadeEffect");
MySpace.UI.Effects.FadeAnimation=function() {
	MySpace.UI.Effects.FadeAnimation.initializeBase(this)

};
MySpace.UI.Effects.FadeAnimation.prototype={
	_effect:MySpace.UI.Effects.FadeEffect.FadeIn,
	get_effect:function() {
		return this._effect

 },
	set_effect:function(a) {
		this._effect=a

 },
	getAnimatedValue:function(c) {
		var a=0,b=1;
		if(this._effect===MySpace.UI.Effects.FadeEffect.FadeOut){
			a=1;
			b=0

 }
		return MySpace.UI.Effects.Glitz.interpolate(a,b,c)

 },
	onStart:function() {
		var a=0;
		if(this._effect===MySpace.UI.Effects.FadeEffect.FadeOut){a=1;}
		this.setValue(a)

 if(a==0){this.get_target().style.visibility="visible";}
	},
	onEnd:function() {
		var a=1;
		if(this._effect===MySpace.UI.Effects.FadeEffect.FadeOut)a=0;
		this.setValue(a)

 if(a==0){this.get_target().style.visibility="hidden";}
	},
	setValue:function(a) {
		MySpace.UI.Effects.Glitz.setElementOpacity(this.get_target(),a)

 }
};
MySpace.UI.Effects.FadeAnimation.registerClass("MySpace.UI.Effects.FadeAnimation",MySpace.UI.Effects.Animation);

//Sliding Automation Start
//Defining the slideEffect enum
MySpace.UI.Effects.SlideEffect=function() {
	throw Error.invalidOperation()

};
MySpace.UI.Effects.SlideEffect.prototype={
	SlideIn:0,SlideOut:1

};
MySpace.UI.Effects.SlideEffect.registerEnum("MySpace.UI.Effects.SlideEffect");

MySpace.UI.Effects.SlidingAnimation=function() {
    
	MySpace.UI.Effects.SlidingAnimation.initializeBase(this)

};

MySpace.UI.Effects.SlidingAnimation.prototype = {
	_effect:MySpace.UI.Effects.SlideEffect.SlideIn,
    
	get_effect:function() {
		return this._effect

 },
	set_effect:function(a) {
		this._effect=a

 },

	initialize : function() {
        this.get_target().style.overflow="hidden";
        
        var display = this.get_target().style.display;
        this.get_target().style.display="block";
        
        this.set_property("style");
        this.set_propertyKey("height");
        if(this._effect===MySpace.UI.Effects.SlideEffect.SlideIn)
        {
            this.set_startValue(MySpace.UI.getContentBox(this.get_target()).h);
            this.set_endValue(0);
        }
        else{
            this.set_startValue(0);
            this.set_endValue(MySpace.UI.getContentBox(this.get_target()).h);
        }
        this.get_target().style.display=display;
    },
	
	onStart:function() {
        //Set the display to block before expanding the div
        if(this._effect===MySpace.UI.Effects.SlideEffect.SlideOut){
			this.get_target().style.display="block";
		}
	},
	onEnd:function() {
        //Set the display to none only after collapsing the div
        if(this._effect===MySpace.UI.Effects.SlideEffect.SlideIn){
			this.get_target().style.display="none";
        }
    }
}
MySpace.UI.Effects.SlidingAnimation.registerClass('MySpace.UI.Effects.SlidingAnimation', MySpace.UI.Effects.LengthAnimation);
//Sliding Automation End

MySpace.UI.DragDropModuleManager = function() {
	MySpace.UI.DragDropModuleManager.initializeBase(this);
};
MySpace.UI.DragDropModuleManager.prototype = {
	zoneClass: "dropZone",
	moduleClass: "module",
	handleClass: "handle",
	dropCueClass: "dropCue",

	initialize: function() {
		MySpace.UI.DragDropModuleManager.callBaseMethod(this, "initialize");

		// Create template for the drop cue
		var dropCueTemplate=document.createElement("div");
		dropCueTemplate.className=this.dropCueClass;

		// Create a DragDropList for each zone
		var zones=MySpace.UI.getElementsByClassName(this.zoneClass);
		for(var i=0;i<zones.length;i++){
			var modsStr= _proxy_jslib_handle(zones, (i), 0, 0).getAttribute("allowedModules") || "";
			var allowedModules=modsStr ? modsStr.split(",") : [];
			$create(MySpace.UI.DragDropList, {acceptedDataTypes: ['HTML'], dragDataType: 'HTML', dragMode: MySpace.UI.DragMode.Move, dropCueTemplate: dropCueTemplate, allowedItemIds: allowedModules}, {dragSuccessful: Function.createDelegate(this, this.onDragSuccessful)}, null,  _proxy_jslib_handle(zones, (i), 0, 0));

			// Create a DraggableListItem for each module
			var mods=MySpace.UI.getElementsByClassName(this.moduleClass,  _proxy_jslib_handle(zones, (i), 0, 0));
			for(var j=0;j<mods.length;j++){
				var zonesStr= _proxy_jslib_handle(mods, (j), 0, 0).getAttribute("allowedZones") || "";
				var allowedZones=zonesStr ? zonesStr.split(",") : [];
				var handle=MySpace.UI.getElementsByClassName(this.handleClass,  _proxy_jslib_handle(mods, (j), 0, 0))[0];
				$create(MySpace.UI.DraggableListItem, {handle: handle, allowedListIds: allowedZones}, null, null,  _proxy_jslib_handle(mods, (j), 0, 0));
			}
		}
	},

	add_moduleMoved: function(handler) {
		this.get_events().addHandler("moduleMoved", handler);
	},
	remove_moduleMoved: function(handler) {
		this.get_events().removeHandler("moduleMoved", handler);
	},

	onDragSuccessful: function() {
		var handler = this.get_events().getHandler("moduleMoved");
		if (handler) {
		    handler(this, null);
		}		
	}
};
MySpace.UI.DragDropModuleManager.registerClass("MySpace.UI.DragDropModuleManager", Sys.Component);


MySpace.UI.CascadingDropDownSelectionChangedEventArgs = function(oldValue, newValue) {
	MySpace.UI.CascadingDropDownSelectionChangedEventArgs.initializeBase(this);
	
	this._oldValue=oldValue;
	this._newValue=newValue;
};
MySpace.UI.CascadingDropDownSelectionChangedEventArgs.prototype={
	get_oldValue:function() {
		return this._oldValue;
	},
	get_newValue:function() {
		return this._newValue;
	}
};
MySpace.UI.CascadingDropDownSelectionChangedEventArgs.registerClass('MySpace.UI.CascadingDropDownSelectionChangedEventArgs', Sys.EventArgs);

MySpace.UI.CascadingDropDown=function(e) {
	MySpace.UI.CascadingDropDown.initializeBase(this, [e]);

	this._parentControlIDs=null;
	this._parentCategory=null;
	this._category=null;
	this._optional=false;
	this._defaultValue="";
	this._promptText=null;
	this._loadingText=null;
	this._promptValue=null;
	this._emptyValue=null;
	this._emptyText=null;
	this._disableNode=null;
	this._disableClass="disabled";
	this._labelNode=null;

	this._servicePath=null;
	this._serviceMethod=null;
	this._serviceExtraParams=null;
	
	this._changeHandler=null;
	this._parentChangeHandler=null;
	this._lastParentValues=null;
	this._selectedValue=null;
};
MySpace.UI.CascadingDropDown.prototype={
	initialize:function() {
		MySpace.UI.CascadingDropDown.callBaseMethod(this, 'initialize');

		var e=this.get_element();

		// Clear any items that may have been put there for server side convenience
		this._clearItems();

		// Set properties on element so that children controls (if any) can have easy access
		e.CascadingDropDownCategory=this._category;
		e.CascadingDropDownOptional=this._optional;
		e.CascadingDropDownDefaultValue=this._defaultValue;

		// Attach change handler to self
		this._changeHandler=Function.createDelegate(this, this._onChange);
		$addHandler(e, "change",this._changeHandler);

		if(this._labelNode){
			this._defaultLabel= _proxy_jslib_handle(this._labelNode, 'innerHTML', '', 0, 0);
		}
				
		// Attach change handler to parent
		this._parentChangeHandlers=[];
		if(this._parentControlIDs){
			e.CascadingDropDownParentControlIDs=this._parentControlIDs.join(",");
			for(var i=0;i<this._parentControlIDs.length;i++){
				var parentControlID= _proxy_jslib_handle(this._parentControlIDs, (i), 0, 0);
				var parentElement=$get(parentControlID);
				Sys.Debug.assert(parentElement != null, String.format("Failed to find parent element '{0}'", parentControlID));
				if(parentElement){
					if(this._parentCategory && !parentElement.CascadingDropDownCategory)
						parentElement.CascadingDropDownCategory=this._parentCategory;
						
					var handler=Function.createDelegate(this, this._onParentChange);
					this._parentChangeHandlers.push(handler);
					$addHandler(parentElement, "change", handler);
					
					if (!parentElement.childDropDown) {
						parentElement.childDropDown = [];
					}
					parentElement.childDropDown.push(this);
				}
			}
		}

		// Simulate parent change to populate self, even if no parent exists.
		this._onParentChange(null, true);
	},

	dispose: function() {
		var e = this.get_element();

		if (this._changeHandler) {
			$removeHandler(e, "change", this._changeHandler);
			this._changeHandler = null;
		}

		for(var i=0;i<this._parentChangeHandlers.length;i++){
			var el=$get( _proxy_jslib_handle(this._parentControlIDs, (i), 0, 0));
			if (el) {
				$removeHandler(el, "change",  _proxy_jslib_handle(this._parentChangeHandlers, (i), 0, 0));
			}
			this._parentChangeHandlers = [];
		}

		MySpace.UI.CascadingDropDown.callBaseMethod(this, 'dispose');
	},

	_clearItems: function() {
		var e = this.get_element();
		while (0 < e.options.length) {
			e.remove(0);
		}
	},

	_isPopulated: function() {
		var items = this.get_element().options.length;
		return this._promptText ? (items > 1) : (items > 0);
	},

	_setOptions: function(options, inInit, gettingList) {
		/// <summary>
		/// Set the contents of the DropDownList to the specified list
		/// </summary>
		/// <param name="options" mayBeNull="true" elementType="Object">
		/// Hash of options (value -> description)
		/// </param>
		/// <param name="inInit" type="Boolean" optional="true">
		/// Whether this is being called from the initialize method
		/// </param>
		/// <param name="gettingList" type="Boolean" optional="true">
		/// Whether we are fetching the list of options from the web service
		/// </param>
		/// <returns />

		if (!this.get_isInitialized()) {
			return;
		}

		// Update the label
		if(this._labelNode){
			if(options && options._CascadingDropdownLabel){
				 _proxy_jslib_assign('', this._labelNode, 'innerHTML', '=', (options._CascadingDropdownLabel));
			}else{
				 _proxy_jslib_assign('', this._labelNode, 'innerHTML', '=', (this._defaultLabel));
			}
		}
		if(options){  _proxy_jslib_assign('delete', (options), ('_CascadingDropdownLabel'), ''); }
		
		var e = this.get_element();
		this._clearItems();

		var count = 0;
		if(options){
			for(var v in options){
				count++;
			}
		}
		
		// Populate prompt text (if available) 
		var headerText;
		var headerValue = "";
		if (gettingList && this._loadingText) {
			headerText = this._loadingText;
		}
		else if (!gettingList && options && (count == 0) && this._emptyText) {
			headerText = this._emptyText;
			if (this._emptyValue) {
				headerValue = this._emptyValue;
			}
		}
		else if (this._promptText) {
			headerText = this._promptText;
			if (this._promptValue) {
				headerValue = this._promptValue;
			}
		}
		if (headerText) {
			var optionElement = new (Option)(headerText, headerValue);
			 _proxy_jslib_assign('', e.options, (e.options.length), '=', ( optionElement));
		}

		// Add each item to the DropDownList, selecting the previously selected item
		var selectedValueOption = null;

		if (options) {
			for (var listItemValue in options) {
				var listItemName =  _proxy_jslib_handle(options, (listItemValue), 0, 0);
				
				var optionElement = new (Option)(listItemName, listItemValue);
				if (listItemValue == this._selectedValue) {
					selectedValueOption = optionElement;
				}

				 _proxy_jslib_assign('', e.options, (e.options.length), '=', ( optionElement));
			}
			if (selectedValueOption) {
				selectedValueOption.selected = true;
			}
		}
		
		// if we didn't match the selected value, and we found a default
		// item, select that one.
		if (selectedValueOption) {
			// Call set_selectedValue to store the text as well
			this.set_selectedValue( _proxy_jslib_handle( _proxy_jslib_handle(e.options, (e.selectedIndex), 0, 0), 'value', '', 0, 0),  _proxy_jslib_handle(e.options, (e.selectedIndex), 0, 0).text);
		}
		else if (count == 1) {
			// If there's only one item, default to it
			var defaultIndex = this._promptText ? 1 : 0;
			 _proxy_jslib_handle(e.options, (defaultIndex), 0, 0).selected = true;
			this.set_selectedValue( _proxy_jslib_handle( _proxy_jslib_handle(e.options, (defaultIndex), 0, 0), 'value', '', 0, 0),  _proxy_jslib_handle(e.options, (defaultIndex), 0, 0).text);
		}
		else if (!inInit && !gettingList && !this._promptText && (e.options.length > 0)) {
			// If no prompt text or default item, select the first item
			this.set_selectedValue( _proxy_jslib_handle(e.options[0], 'value', '', 0, 0), e.options[0].text);
		}
		else if (!inInit && !gettingList) {
			this.set_selectedValue('', '');
		}

		if (e.childDropDown && !gettingList) {
			for(i = 0; i < e.childDropDown.length; i++) {
				 _proxy_jslib_handle(e.childDropDown, (i), 0, 0)._onParentChange();
			}
		}
		else {
			if (options && (Sys.Browser.agent !== Sys.Browser.Safari) && (Sys.Browser.agent !== Sys.Browser.Opera)) {
				// Fire the onchange event for the control to notify any listeners of the change
				if (document.createEvent) {
					var onchangeEvent = document.createEvent('HTMLEvents');
					onchangeEvent.initEvent('change', true, false);
					e.dispatchEvent(onchangeEvent);
				}
				else if( document.createEventObject ) {
					e.fireEvent('onchange');
				}
			}
		}

		// Disable the control if loading/prompt text is present and an empty list was populated
		if (this._loadingText || this._promptText || this._emptyText) {
			e.disabled = (count == 0);
			grayOut = !options;
			if (this._disableNode && (grayOut != Sys.UI.DomElement.containsCssClass(this._disableNode, this._disableClass))) {
				Sys.UI.DomElement.toggleCssClass(this._disableNode, this._disableClass);
			}
		}

		this.raisePopulated(Sys.EventArgs.Empty);
	},

	_onChange: function() {
		if (!this._isPopulated()) {
			return;
		}

		var e = this.get_element();
		
		// Record the selected value in the client state
		if ((-1 != e.selectedIndex) && !(this._promptText && (0 == e.selectedIndex))) {
			this.set_selectedValue( _proxy_jslib_handle( _proxy_jslib_handle(e.options, (e.selectedIndex), 0, 0), 'value', '', 0, 0),  _proxy_jslib_handle(e.options, (e.selectedIndex), 0, 0).text);
		}
		else {
			this.set_selectedValue('', '');
		}
	},

	_onParentChange: function(evt, inInit) {
		var e = this.get_element();

		var knownCategoryValues = {};
		
		var parentIDs=[];
		if(this._parentControlIDs){
			for(var i=0;i<this._parentControlIDs.length;i++)
				parentIDs.push( _proxy_jslib_handle(this._parentControlIDs, (i), 0, 0));
		}
			
		while (parentIDs.length) {
			var parentElement = $get(parentIDs[0]);
			parentIDs=parentIDs.splice(1,parentIDs.length-1); //Remove first element
			if (parentElement && (-1 != parentElement.selectedIndex)){
				var selectedValue =  _proxy_jslib_handle( _proxy_jslib_handle(parentElement.options, (parentElement.selectedIndex), 0, 0), 'value', '', 0, 0);
				
				if (selectedValue && selectedValue != "") {
					 _proxy_jslib_assign('', knownCategoryValues, (parentElement.CascadingDropDownCategory), '=', ( selectedValue));
					var ids=parentElement.CascadingDropDownParentControlIDs ? parentElement.CascadingDropDownParentControlIDs.split(",") : [];
					for(var i=0;i<ids.length;i++)
						parentIDs.push( _proxy_jslib_handle(ids, (i), 0, 0));
					continue;
				}
				else if (parentElement.CascadingDropDownOptional){
				     _proxy_jslib_assign('', knownCategoryValues, (parentElement.CascadingDropDownCategory), '=', ( parentElement.CascadingDropDownDefaultValue));
				}
				else{	// Found a required parent with no value, abort
					knownCategoryValues={};
					break;
				}
			}
		}
		
		var serializedValues = Sys.Serialization.JavaScriptSerializer.serialize(knownCategoryValues);
		if (serializedValues != '{}' && this._lastParentValues == serializedValues) {
			return;
		}
		
		this._lastParentValues = serializedValues;
		
		// we have a parent but it doesn't have a valid value
		if (serializedValues == '{}' && this._parentControlIDs) {
			this._setOptions(null, inInit);
			return;
		}
		

		// Show the loading text (if any)
		this._setOptions(null, inInit, true);

		if (this._servicePath && this._serviceMethod) {
			// Raise the populating event and optionally cancel the web service invocation
			var eventArgs = new (Sys.CancelEventArgs)();
			this.raisePopulating(eventArgs);
			if (eventArgs.get_cancel()) {
				return;
			}
			
			if(this._serviceExtraParams){
				for(var param in this._serviceExtraParams){
					 _proxy_jslib_assign('', knownCategoryValues, (param), '=', ( _proxy_jslib_handle(this._serviceExtraParams, (param), 0, 0)));
				}
			}
			
			// Call the helper web service
			Sys.Net.WebServiceProxy.invoke(this._servicePath, this._serviceMethod, false, knownCategoryValues,
				Function.createDelegate(this, this._onMethodComplete), Function.createDelegate(this, this._onMethodError));
		}
	},

	_onMethodComplete: function(result, userContext, methodName) {
		// Update the DropDownList
		this._setOptions(result);
	},

	_onMethodError: function(webServiceError, userContext, methodName) {
		// Indicate failure
		var msg;
		if (webServiceError.get_timedOut()) {
			msg = "[Method timeout]"; // I18N
		}
		else {
			msg = String.format("[Method error {0}]", webServiceError.get_statusCode()); // I18N
		}
		var options = {};
		 _proxy_jslib_assign('', options, (msg), '=', ( msg));
		this._setOptions(options);
	},

	get_parentControlID: function() { return null; },
	set_parentControlID: function(value) { this._parentControlIDs = [ _proxy_jslib_handle(null, 'value', value, 0, 0)] },
	
	get_parentControlIDs: function(value) { return this._parentControlIDs; },
	set_parentControlIDs: function(value) { this._parentControlIDs =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_category: function() { return this._category; },
	set_category: function(value) { this._category =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_optional: function() { return this._optional; },
	set_optional: function(value) { this._optional =  _proxy_jslib_handle(null, 'value', value, 0, 0); },
	
	get_defaultValue: function() { return this._defaultValue; },
	set_defaultValue: function(value) { this._defaultValue =  _proxy_jslib_handle(null, 'value', value, 0, 0); },
	
	get_parentCategory: function() { return this._parentCategory; },
	set_parentCategory: function(value) { this._parentCategory =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_promptText: function() { return this._promptText; },
	set_promptText: function(value) { this._promptText =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_promptValue: function() { return this._promptValue; },
	set_promptValue: function(value) { this._promptValue =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_emptyText: function() { return this._emptyText; },
	set_emptyText: function(value) { this._emptyText =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_emptyValue: function() { return this._emptyValue; },
	set_emptyValue: function(value) { this._emptyValue =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_loadingText: function() { return this._loadingText; },
	set_loadingText: function(value) { this._loadingText =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

 	get_disableNode: function() { return this._disableNode; },
	set_disableNode: function(value) { this._disableNode =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_labelNode: function() { return this._labelNode; },
	set_labelNode: function(value) { this._labelNode =  _proxy_jslib_handle(null, 'value', value, 0, 0); },
	
 	get_disableClass: function() { return this._disableClass; },
	set_disableClass: function(value) { this._disableClass =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_servicePath: function() { return this._servicePath; },
	set_servicePath: function(value) { this._servicePath =  _proxy_jslib_handle(null, 'value', value, 0, 0); },

	get_serviceMethod: function() { return this._serviceMethod; },
	set_serviceMethod: function(value) { this._serviceMethod =  _proxy_jslib_handle(null, 'value', value, 0, 0); },
	
	get_serviceExtraParams: function() { return this._serviceExtraParams; },
	set_serviceExtraParams: function(value) { this._serviceExtraParams =  _proxy_jslib_handle(null, 'value', value, 0, 0); },
	
	get_selectedValue: function() {
		return this._selectedValue;
	},
	set_selectedValue: function(value, text) {
		if (this._selectedValue !=  _proxy_jslib_handle(null, 'value', value, 0, 0)) {
			var oldValue = this._selectedValue;
			this._selectedValue =  _proxy_jslib_handle(null, 'value', value, 0, 0);
			this.raiseSelectionChanged(new (MySpace.UI.CascadingDropDownSelectionChangedEventArgs)(oldValue,  _proxy_jslib_handle(null, 'value', value, 0, 0)));
		}
	},

	add_selectionChanged: function(handler) { this.get_events().addHandler('selectionChanged', handler); },
	remove_selectionChanged: function(handler) { this.get_events().removeHandler('selectionChanged', handler); },
	raiseSelectionChanged: function(eventArgs) {
		var handler = this.get_events().getHandler('selectionChanged');
		if (handler) {
			handler(this, eventArgs);
		}
	},
	
	add_populating: function(handler) { this.get_events().addHandler('populating', handler); },
	remove_populating: function(handler) { this.get_events().removeHandler('populating', handler); },
	raisePopulating: function(eventArgs) {
		/// The populating event can be used to provide custom data to
		/// CascadingDropDown instead of using a web service.  Just cancel the
		/// event (using the CancelEventArgs) and pass your own data to the
		/// _setOptions method.
		
		var handler = this.get_events().getHandler('populating');
		if (handler) {
			handler(this, eventArgs);
		}
	},
	
	add_populated: function(handler) { this.get_events().addHandler('populated', handler); },
	remove_populated: function(handler) { this.get_events().removeHandler('populated', handler); },
	raisePopulated: function(eventArgs) {
		var handler = this.get_events().getHandler('populated');
		if (handler) {
			handler(this, eventArgs);
		}
	}
}
MySpace.UI.CascadingDropDown.registerClass('MySpace.UI.CascadingDropDown', Sys.UI.Behavior);

(function() {
var Selector = function() {};

var reNth = /^(?:([-]?\d*)(n){1}|(odd|even)$)*([-+]?\d*)$/;

Selector.prototype = {
    document: window.document,
    attrAliases: {
        'for': 'htmlFor'

 },

    shorthand: {
        '\\#(-?[_a-z]+[-\\w]*)': '[id=$1]',
        '\\.(-?[_a-z]+[-\\w]*)': '[class~=$1]'

 },

    operators: {
        '=': function(attr, val) { return attr === val; }, 
        '!=': function(attr, val) { return attr !== val; }, 
        '~=': function(attr, val) { 
            var s = ' ';
            return (s + attr + s).indexOf((s + val + s)) > -1;
        },
        '|=': function(attr, val) { return getRegExp('^' + val + '[-]?').test(attr); }, 
        '^=': function(attr, val) { return attr.indexOf(val) === 0; }, 
        '$=': function(attr, val) { return attr.lastIndexOf(val) === attr.length - val.length; }, 
        '*=': function(attr, val) { return attr.indexOf(val) > -1; }, 
        '': function(attr, val) { return attr; }
    },

    pseudos: {
        'root': function(node) {
            return node === node.ownerDocument.documentElement;
        },

        'nth-child': function(node, val) {
            return getNth(node, val);
        },

        'nth-last-child': function(node, val) {
            return getNth(node, val, null, true);
        },

        'nth-of-type': function(node, val) {
            return getNth(node, val, node.tagName);
        },
         
        'nth-last-of-type': function(node, val) {
            return getNth(node, val, node.tagName, true);
        },
         
        'first-child': function(node) {
            return getChildren(node.parentNode)[0] === node;
        },

        'last-child': function(node) {
            var children = getChildren(node.parentNode);
            return  _proxy_jslib_handle(children, (children.length - 1), 0, 0) === node;
        },

        'first-of-type': function(node, val) {
            return getChildren(node.parentNode, node.tagName.toLowerCase())[0];
        },
         
        'last-of-type': function(node, val) {
            var children = getChildren(node.parentNode, node.tagName.toLowerCase());
            return  _proxy_jslib_handle(children, (children.length - 1), 0, 0);
        },
         
        'only-child': function(node) {
            var children = getChildren(node.parentNode);
            return children.length === 1 && children[0] === node;
        },

        'only-of-type': function(node) {
            return getChildren(node.parentNode, node.tagName.toLowerCase()).length === 1;
        },

        'empty': function(node) {
            return node.childNodes.length === 0;
        },

        'not': function(node, simple) {
            return !Selector.test(node, simple);
        },

        'contains': function(node, str) {
            var text = node.innerText || node.textContent || '';
            return text.indexOf(str) > -1;
        },
        'checked': function(node) {
            return node.checked === true;
        }
    },

    test: function(node, selector) {
        node =  _proxy_jslib_handle(Selector.document, 'getElementById', '', 1, 0)(node) || node;

        if (!node) {
            return false;
        }

        var groups = selector ? selector.split(',') : [];
        if (groups.length) {
            for (var i = 0, len = groups.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
                if ( rTestNode(node,  _proxy_jslib_handle(groups, (i), 0, 0)) ) { 
                    return true;
                }
            }
            return false;
        }
        return rTestNode(node, selector);
    },
    
    filter: function(nodes, selector) {
        nodes = nodes || [];

        var node,
            result = [],
            tokens = tokenize(selector);

        if (!nodes.item) { 
            for (var i = 0, len = nodes.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
                if (! _proxy_jslib_handle(nodes, (i), 0, 0).tagName) { 
                    node =  _proxy_jslib_handle(Selector.document, 'getElementById', '', 1, 0)( _proxy_jslib_handle(nodes, (i), 0, 0));
                    if (node) { 
                         _proxy_jslib_assign('', nodes, (i), '=', ( node));
                    } else {
                        // skip invalid node
                    }
                }
            }
        }
        result = rFilter(nodes, tokenize(selector)[0]);
        clearParentCache();
        
        return result;
    },

    query: function(selector, root, firstOnly) {
        var result = query(selector, root, firstOnly);
        
        return result;
    }
};

var query = function(selector, root, firstOnly, deDupe) {
    var result =  (firstOnly) ? null : [];
    if (!selector) {
        return result;
    }

    var groups = selector.split(','); 
    if (groups.length > 1) {
        var found;
        for (var i = 0, len = groups.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
            found = arguments.callee( _proxy_jslib_handle(groups, (i), 0, 0), root, firstOnly, true);
            result = firstOnly ? found : result.concat(found); 
        }
        clearFoundCache();
        return result;
    }

    if (root && !root.nodeName) {
        root =  _proxy_jslib_handle(Selector.document, 'getElementById', '', 1, 0)(root);
        if (!root) {
            
            return result;
        }
    }

    root = root || Selector.document;
    var tokens = tokenize(selector);
    var idToken =  _proxy_jslib_handle(tokens, (getIdTokenIndex(tokens)), 0, 0),
        nodes = [],
        node,
        id,
        token = tokens.pop() || {};
        
    if (idToken) {
        id = getId(idToken.attributes);
    }

    if (id) {
        if (id === token.id) { 
            nodes = [ _proxy_jslib_handle(Selector.document, 'getElementById', '', 1, 0)(id)] || root;
        } else { 
            node =  _proxy_jslib_handle(Selector.document, 'getElementById', '', 1, 0)(id);
            if (root === Selector.document || contains(node, root)) {
                if ( node && rTestNode(node, null, idToken) ) {
                    root = node; 
                }
            } else {
                return result;
            }
        }
    }

    if (root && !nodes.length) {
        nodes =  _proxy_jslib_handle(root, 'getElementsByTagName', '', 1, 0)(token.tag);
    }

    if (nodes.length) {
        result = rFilter(nodes, token, firstOnly, deDupe); 
    }
    clearParentCache();
    return result;
};

var contains = function() {
    if (document.documentElement.contains && !(Sys.Browser.agent === Sys.Browser.Safari && Sys.Browser.version < 3))  {
        return function(needle, haystack) {
            return haystack.contains(needle);
        };
    } else if ( document.documentElement.compareDocumentPosition ) {
        return function(needle, haystack) {
            return !!(haystack.compareDocumentPosition(needle) & 16);
        };
    } else  { 
        return function(needle, haystack) {
            var parent = needle.parentNode;
            while ( _proxy_jslib_handle(null, 'parent', parent, 0, 0)) {
                if (needle ===  _proxy_jslib_handle(null, 'parent', parent, 0, 0)) {
                    return true;
                }
                 parent= _proxy_jslib_assign_rval('', 'parent', '=', (  _proxy_jslib_handle(null, 'parent', parent, 0, 0).parentNode), parent);
            } 
            return false;
        }; 
    }
}();

var rFilter = function(nodes, token, firstOnly, deDupe) {
    var result = firstOnly ? null : [];

    for (var i = 0, len = nodes.length; i < len; i++) {
        if (! rTestNode( _proxy_jslib_handle(nodes, (i), 0, 0), '', token, deDupe)) {
            continue;
        }

        if (firstOnly) {
            return  _proxy_jslib_handle(nodes, (i), 0, 0);
        }
        if (deDupe) {
            if ( _proxy_jslib_handle(nodes, (i), 0, 0)._found) {
                continue;
            }
             _proxy_jslib_handle(nodes, (i), 0, 0)._found = true;
             _proxy_jslib_assign('', foundCache, (foundCache.length), '=', (  _proxy_jslib_handle(nodes, (i), 0, 0)));
        }

         _proxy_jslib_assign('', result, (result.length), '=', (  _proxy_jslib_handle(nodes, (i), 0, 0)));
    }

    return result;
};

var rTestNode = function(node, selector, token, deDupe) {
    token = token || tokenize(selector).pop() || {};

    if (!node.tagName ||
        (token.tag !== '*' && node.tagName.toUpperCase() !== token.tag) ||
        (deDupe && node._found) ) {
        return false;
    }

    if (token.attributes.length) {
        var attribute;
        for (var i = 0, len = token.attributes.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
            attribute = node.getAttribute( _proxy_jslib_handle(token.attributes, (i), 0, 0)[0], 2);
            if (attribute === undefined) {
                return false;
            }
            if (  _proxy_jslib_handle(Selector.operators, ( _proxy_jslib_handle(token.attributes, (i), 0, 0)[1]), 0, 0) &&
                    ! _proxy_jslib_handle(Selector.operators, ( _proxy_jslib_handle(token.attributes, (i), 0, 0)[1]), 1, 0)(attribute,  _proxy_jslib_handle(token.attributes, (i), 0, 0)[2])) {
                return false;
            }
        }
    }

    if (token.pseudos.length) {
        for (var i = 0, len = token.pseudos.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
            if ( _proxy_jslib_handle(Selector.pseudos, ( _proxy_jslib_handle(token.pseudos, (i), 0, 0)[0]), 0, 0) &&
                    ! _proxy_jslib_handle(Selector.pseudos, ( _proxy_jslib_handle(token.pseudos, (i), 0, 0)[0]), 1, 0)(node,  _proxy_jslib_handle(token.pseudos, (i), 0, 0)[1])) {
                return false;
            }
        }
    }

    return (token.previous && token.previous.combinator !== ',') ?
             _proxy_jslib_handle(combinators, (token.previous.combinator), 1, 0)(node, token) :
            true;
};


var foundCache = [];
var parentCache = [];
var regexCache = {};

var clearFoundCache = function() {
    
    for (var i = 0, len = foundCache.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
        try { 
             _proxy_jslib_assign('delete', ( _proxy_jslib_handle(foundCache, (i), 0, 0)), ('_found'), '');
        } catch(e) {
             _proxy_jslib_handle(foundCache, (i), 0, 0).removeAttribute('_found');
        }
    }
    foundCache = [];
    
};

var clearParentCache = function() {
    if (!document.documentElement.children) { 
        return function() {
            for (var i = 0, len = parentCache.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
                 _proxy_jslib_assign('delete', ( _proxy_jslib_handle(parentCache, (i), 0, 0)), ('_children'), '');
            }
            parentCache = [];
        };
    } else return function() {}; 
}();

var getRegExp = function(str, flags) {
    flags = flags || '';
    if (! _proxy_jslib_handle(regexCache, (str + flags), 0, 0)) {
         _proxy_jslib_assign('', regexCache, (str + flags), '=', ( new (RegExp)(str, flags)));
    }
    return  _proxy_jslib_handle(regexCache, (str + flags), 0, 0);
};

var combinators = {
    ' ': function(node, token) {
        while (node = node.parentNode) {
            if (rTestNode(node, '', token.previous)) {
                return true;
            }
        }  
        return false;
    },

    '>': function(node, token) {
        return rTestNode(node.parentNode, null, token.previous);
    },
    '+': function(node, token) {
        var sib = node.previousSibling;
        while (sib && sib.nodeType !== 1) {
            sib = sib.previousSibling;
        }

        if (sib && rTestNode(sib, null, token.previous)) {
            return true; 
        }
        return false;
    },

    '~': function(node, token) {
        var sib = node.previousSibling;
        while (sib) {
            if (sib.nodeType === 1 && rTestNode(sib, null, token.previous)) {
                return true;
            }
            sib = sib.previousSibling;
        }

        return false;
    }
};

var getChildren = function() {
    if (document.documentElement.children) { 
        return function(node, tag) {
            return (tag) ? node.children.tags(tag) : node.children || [];
        };
    } else {
        return function(node, tag) {
            if (node._children) {
                return node._children;
            }
            var children = [],
                childNodes = node.childNodes;

            for (var i = 0, len = childNodes.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
                if ( _proxy_jslib_handle(childNodes, (i), 0, 0).tagName) {
                    if (!tag ||  _proxy_jslib_handle(childNodes, (i), 0, 0).tagName.toLowerCase() === tag) {
                         _proxy_jslib_assign('', children, (children.length), '=', (  _proxy_jslib_handle(childNodes, (i), 0, 0)));
                    }
                }
            }
            node._children = children;
             _proxy_jslib_assign('', parentCache, (parentCache.length), '=', ( node));
            return children;
        };
    }
}();

var getNth = function(node, expr, tag, reverse) {
    if (tag) tag = tag.toLowerCase();
    reNth.test(expr);
    var a = parseInt(RegExp.$1, 10), 
        n = RegExp.$2, 
        oddeven = RegExp.$3, 
        b = parseInt(RegExp.$4, 10) || 0, 
        result = [];

    var siblings = getChildren(node.parentNode, tag);

    if (oddeven) {
        a = 2; 
        op = '+';
        n = 'n';
        b = (oddeven === 'odd') ? 1 : 0;
    } else if ( isNaN(a) ) {
        a = (n) ? 1 : 0; 
    }

    if (a === 0) { 
        if (reverse) {
            b = siblings.length - b + 1; 
        }

        if ( _proxy_jslib_handle(siblings, (b - 1), 0, 0) === node) {
            return true;
        } else {
            return false;
        }

    } else if (a < 0) {
        reverse = !!reverse;
        a = Math.abs(a);
    }

    if (!reverse) {
        for (var i = b - 1, len = siblings.length; i < len; i += a) {
            if ( i >= 0 &&  _proxy_jslib_handle(siblings, (i), 0, 0) === node ) {
                return true;
            }
        }
    } else {
        for (var i = siblings.length - b, len = siblings.length; i >= 0; i -= a) {
            if ( i < len &&  _proxy_jslib_handle(siblings, (i), 0, 0) === node ) {
                return true;
            }
        }
    }
    return false;
};

var getId = function(attr) {
    for (var i = 0, len = attr.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
        if ( _proxy_jslib_handle(attr, (i), 0, 0)[0] == 'id' &&  _proxy_jslib_handle(attr, (i), 0, 0)[1] === '=') {
            return  _proxy_jslib_handle(attr, (i), 0, 0)[2];
        }
    }
};

var getIdTokenIndex = function(tokens) {
    for (var i = 0, len = tokens.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
        if (getId( _proxy_jslib_handle(tokens, (i), 0, 0).attributes)) {
            return i;
        }
    }
    return -1;
};

var patterns = {
    tag: /^((?:-?[_a-z]+[\w-]*)|\*)/i,
    attributes: /^\[([a-z]+\w*)+([~\|\^\$\*!=]=?)?['"]?([^'"\]]*)['"]?\]*/i,
    pseudos: /^:([-\w]+)(?:\(['"]?(.+)['"]?\))*/i,
    combinator: /^\s*([>+~]|\s)\s*/

};

var tokenize = function(selector) {
    var token = {},     
        tokens = [],    
        id,             
        found = false,  
        match;          

    selector = replaceShorthand(selector); 

    do {
        found = false; 
        for (var re in patterns) {
                if (!MySpace.Utils.hasOwnProperty(patterns, re)) {
                    continue;
                }
                if (re != 'tag' && re != 'combinator') { 
                     _proxy_jslib_assign('', token, (re), '=', (  _proxy_jslib_handle(token, (re), 0, 0) || []));
                }
            if (match =  _proxy_jslib_handle(patterns, (re), 0, 0).exec(selector)) {
                found = true;
                if (re != 'tag' && re != 'combinator') {
                    if (re === 'attributes' && match[1] === 'id') {
                        token.id = match[3];
                    }

                     _proxy_jslib_handle(token, (re), 0, 0).push(match.slice(1));
                } else { 
                     _proxy_jslib_assign('', token, (re), '=', ( match[1]));
                }
                selector =  _proxy_jslib_handle(selector, 'replace', '', 1, 0)(match[0], ''); 
                if (re === 'combinator' || !selector.length) { 
                    token.attributes = fixAttributes(token.attributes);
                    token.pseudos = token.pseudos || [];
                    token.tag = token.tag ? token.tag.toUpperCase() : '*';
                    tokens.push(token);

                    token = {
                        previous: token

 };
                }
            }
        }
    } while (found);

    return tokens;
};

var fixAttributes = function(attr) {
    var aliases = Selector.attrAliases;
    attr = attr || [];
    for (var i = 0, len = attr.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
        if ( _proxy_jslib_handle(aliases, ( _proxy_jslib_handle(attr, (i), 0, 0)[0]), 0, 0)) { 
             _proxy_jslib_handle(attr, (i), 0, 0)[0] =  _proxy_jslib_handle(aliases, ( _proxy_jslib_handle(attr, (i), 0, 0)[0]), 0, 0);
        }
        if (! _proxy_jslib_handle(attr, (i), 0, 0)[1]) { 
             _proxy_jslib_handle(attr, (i), 0, 0)[1] = '';
        }
    }
    return attr;
};

var replaceShorthand = function(selector) {
    var shorthand = Selector.shorthand;
    var attrs = selector.match(patterns.attributes); 
    if (attrs) {
        selector =  _proxy_jslib_handle(selector, 'replace', '', 1, 0)(patterns.attributes, 'REPLACED_ATTRIBUTE');
    }
    for (var re in shorthand) {
        if (!MySpace.Utils.hasOwnProperty(shorthand, re)) {
            continue;
        }
        selector =  _proxy_jslib_handle(selector, 'replace', '', 1, 0)(getRegExp(re, 'gi'),  _proxy_jslib_handle(shorthand, (re), 0, 0));
    }

    if (attrs) {
        for (var i = 0, len = attrs.length; i < len; (i= _proxy_jslib_assign_rval('++', 'i', '', '', i))) {
            selector =  _proxy_jslib_handle(selector, 'replace', '', 1, 0)('REPLACED_ATTRIBUTE',  _proxy_jslib_handle(attrs, (i), 0, 0));
        }
    }
    return selector;
};

if (Sys.Browser.agent === Sys.Browser.InternetExplorer) { 
     _proxy_jslib_assign('', Selector.prototype.attrAliases, ('class'), '=', ( 'className'));
}

Selector = new (Selector)();
Selector.patterns = patterns;
MySpace.Utils.Selector = Selector;
})();

MySpace.Utils.hasOwnProperty = (Object.prototype.hasOwnProperty) ?
    function(o, prop) {
        return o && o.hasOwnProperty(prop);
    } : function(o, prop) {
        return !(typeof( _proxy_jslib_handle(o, (prop), 0, 0)) === 'undefined' &&  _proxy_jslib_handle(o.construc