Type.registerNamespace("MySpace");
MySpace.MaintenanceKeys={};
MySpace.MaintenanceKeys.MSPLinksConvertAll = true;

// 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(!window.disableMSPLinks && MySpace.MaintenanceKeys.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( _proxy_jslib_handle(l, 'protocol', '', 0, 0)) && !changeLinksHrefRegex.test( _proxy_jslib_handle(l, 'hostname', '', 0, 0))){
      l.onclick = function() {
         _proxy_jslib_assign('', document, 'location', '=', ( "http://www.msplinks.com/" +  _proxy_jslib_handle(this, 'href', '', 0, 0)));
      }
    }
  }
}

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"],true);this._fade(true);},
	hide: function() {MySpace.UI.hideElements(["iframe","object","embed"],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.set_visible(true);
		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,

	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) { _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();
		this.set_visible(true);
		if(this._defaultButton)this._defaultButton.focus();
		MySpace.UI._Popup._activePopup = this;
	},
	_hide: function() {
		window.get_overlay().hide();
		this.set_visible(false);
		MySpace.UI._Popup._activePopup=null;
	},
	_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 becuase 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');
	},
	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,callback,MySpaceRes.Common.Ok);
}
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,callback,MySpaceRes.Common.Yes);
	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');



MySpace.Util=function() {throw "Cannot instantiate static class.";}
MySpace.Util.parseNameValuePair=function(nameValuePair, delimiter, modifier) {
	/// <param name="nameValuePair" type="String"></param>
	/// <param name="delimiter" type="Regex"></param>
	/// <param name="modifier" type="Function" mayBeNull="true" optional="true"></param>
	/// <returns type="Object"></returns>
	if(!delimiter) delimiter="=";
	if(!nameValuePair || nameValuePair[0]===delimiter) return null;
	var nameValueObject;
	var pos= _proxy_jslib_handle(nameValuePair, 'search', '', 1, 0)(delimiter);
	if(pos>0){
		nameValueObject={
			name:nameValuePair.substring(0,pos),
			value:nameValuePair.substring(pos+1)

 }
	}
	else nameValueObject={name:nameValuePair,value:""};

	if(modifier) nameValueObject=modifier(nameValueObject);
	return nameValueObject;
}
MySpace.Util.parseNameValuePairs=function(nameValuePairs, pairDelimiter, nameValueDelimiter, nameValueModifier) {
	/// <param name="nameValuePairs" type="String"></param>
	/// <param name="pairDelimiter" type="Regex"></param>
	/// <param name="nameValueDelimiter" type="Regex"></param>
	/// <param name="modifier" type="Function" mayBeNull="true" optional="true"></param>
	/// <returns type="Object"></returns>
	var _collection=null,nameValuePair=null;
	var _pairs = nameValuePairs.split(pairDelimiter);
	for(var i=0;i<_pairs.length;i++){
		nameValuePair=MySpace.Util.parseNameValuePair( _proxy_jslib_handle(_pairs, (i), 0, 0),nameValueDelimiter,nameValueModifier);
		if(!nameValuePair) continue;
		if(!_collection) _collection={};
		 _proxy_jslib_assign('', _collection, (nameValuePair.name), '=', ( _proxy_jslib_handle(nameValuePair, 'value', '', 0, 0)));
	}
	return _collection;
}
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');




MySpace.Cookie=function(name, rawValue) {
	/// <param name="name" type="String"></param>
	/// <param name="rawValue" type="String"></param>
	this._name = name;
	this._rawValue = rawValue;
	this._value = unescape(rawValue);
	this._values = MySpace.Util.parseNameValuePairs(rawValue,"&",null,this._modifier);
}
MySpace.Cookie.prototype={
	get_name:function() {return this._name;},
	get_value:function() {return this._value;},
	get_values:function() {return this._values;},

	_modifier:function(nameValueObject) {
		if(! _proxy_jslib_handle(nameValueObject, 'value', '', 0, 0)) return null;
		 _proxy_jslib_assign('', nameValueObject, 'value', '=', (unescape( _proxy_jslib_handle(nameValueObject, 'value', '', 0, 0))));
		return nameValueObject;
	},
	toString:function() {
		/// <returns type="String"></returns>
		var valuesArray=[];
		var values=this.get_values();
		if(!values) return this.get_value();
		for(var i in values)
			 _proxy_jslib_assign('', valuesArray, (valuesArray.length), '=', ( i+"="+escape( _proxy_jslib_handle(values, (i), 0, 0))));
		return valuesArray.join("&");
	}
}
MySpace.Cookie.registerClass('MySpace.Cookie');



MySpace._Cookies=function() {
	var nvc = MySpace.Util.parseNameValuePairs( _proxy_jslib_handle(document, 'cookie', '', 0, 0),/\s?;\s?/,null);
	for(var name in nvc)
		 _proxy_jslib_assign('', this, (name), '=', ( new (MySpace.Cookie)(name,  _proxy_jslib_handle(nvc, (name), 0, 0))));
}
MySpace._Cookies.prototype={
	save:function(cookie,domain,expires) {
		/// <param name="cookie" type="MySpace.Cookie"></param>
		/// <param name="domain" type="String"></param>
		/// <param name="expires" type="Date"></param>
		var value= _proxy_jslib_handle( _proxy_jslib_handle(null, 'cookie', cookie, 0, 0), 'toString', '', 1, 0)();
		var parts=[ _proxy_jslib_handle(null, 'cookie', cookie, 0, 0).get_name()+"="+ _proxy_jslib_handle(null, 'value', value, 0, 0)];
		if( _proxy_jslib_handle(null, 'domain', domain, 0, 0)){
			if( _proxy_jslib_handle(null, 'domain', domain, 0, 0)!=="localhost" &&  _proxy_jslib_handle(null, 'domain', domain, 0, 0).charAt(0)!==".")
				throw Error.invalidOperation("domain must start with '.'");
			parts[1]="domain="+ _proxy_jslib_handle(null, 'domain', domain, 0, 0);
		}
		if(expires) _proxy_jslib_assign('', parts, (parts.length), '=', ("expires="+expires.toGMTString()));
		 _proxy_jslib_assign('', parts, (parts.length), '=', ("path=/"));
		 _proxy_jslib_assign('', document, 'cookie', '=', ( parts.join("; "))); 
		MySpace.Cookies=new (MySpace._Cookies)();
	},
	remove:function(cookieName, domain) {
		/// <param name="cookieName" type="String"></param>
		this.save(new (MySpace.Cookie)(cookieName,""), _proxy_jslib_handle(null, 'domain', domain, 0, 0),new (Date)().addDays(-1));
	}
}
MySpace._Cookies.registerClass('MySpace._Cookies');
MySpace.Cookies=new (MySpace._Cookies)();

//Sitewide implimentations of global controls
if(typeof MySpace.Cookies.MSCulture!=='undefined'){
	var d = new (Date)();
	d.setMonth(0);	
	
	if(typeof updateClientTimeZone !== 'undefined')
	{
	    if(updateClientTimeZone == 1)
            MySpace.Cookies.MSCulture.get_values().clientTimeZone=(d.getTimezoneOffset()/-60)+8; 
	    else
	        MySpace.Cookies.MSCulture.get_values().timeZone=(d.getTimezoneOffset()/-60)+8;
    }
    else
        MySpace.Cookies.MSCulture.get_values().clientTimeZone=(d.getTimezoneOffset()/-60)+8; 
	
	MySpace.Cookies.save(MySpace.Cookies.MSCulture,".myspace.com",new (Date)().addDays(7));
}

MySpace.CSP=function() {throw "Cannot instantiate static class.";}
MySpace.CSP.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+"&loggedin="+MySpace.ClientContext.IsLoggedIn, _onComplete, null, context, 0);
	
	function _onComplete(response, eventArgs) {
		if(callback) callback(response, eventArgs);
	}
	return null;
}
MySpace.CSP.registerClass('MySpace.CSP');

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.CSP.getContent(culture, _contentRetrieved);
	function _contentRetrieved(content) {
	    var p = MySpace.UI.Popup.create( _proxy_jslib_handle(null, 'content', content, 0, 0),MySpaceRes.Common.Attention);
		p.add_button(MySpaceRes.Header.Continue);
		p.add_button(MySpaceRes.Header.Cancel, 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
		    if( _proxy_jslib_handle(null, 'domain', domain, 0, 0).length>0) MySpace.Cookies.MSCulture.get_values().PreferredCulturePending="";                	
            else 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 a checkbox
	    var c= _proxy_jslib_handle(sender._box.childNodes[2], 'getElementsByTagName', '', 1, 0)("input");
		if(c.length>0 && c[0].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.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) { _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,"click", Function.createDelegate(this,function() {this._tipDiv.style.display='none';}));
	},
	dispose : function() {
	  $clearHandlers(this._element);	  
	  MySpace.UI.Tooltip.callBaseMethod(this, 'dispose');
	},
    show : function() {
      this._tipDiv.style.display='block';
    },
    hide : function() {
      this._tipDiv.style.display='none';
    }
}
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().lastChild.style.display = 'none';
	},
	_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().lastChild.style.display = 'block';
	},
	_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);

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();
 ;
_proxy_jslib_flush_write_buffers() ;