﻿/*
 * Date Format 1.2.2
 * (c) 2007-2008 Steven Levithan <stevenlevithan.com>
 * MIT license
 * Includes enhancements by Scott Trenda <scott.trenda.net> and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */
   
var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && (typeof date == "string" || date instanceof String) && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date();
		if (isNaN(date)) throw new SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};
Date.prototype.toTimezone = function() {
	var xdtDate = new Date(this);
	var xdtNow = new Date();
	var dtDate = new Date(xdtDate.toUTCString());
	var dtNow = new Date(xdtNow.toUTCString());
	
		
	var tzD = xdtDate.getTimezoneOffset();
	var tzN = xdtNow.getTimezoneOffset();
	if (tzD!=tzN)
	{
		return new Date(dtDate+tzN);
	}
	return this;
};
Date.prototype.difference = function (compare,maximum) {
  date1 = this;
  date2 = new Date(compare);
  diff  = new Date();

   // sets difference date to difference of first date and second date

  diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

  timediff = diff.getTime();
  var result = {"years":0, "weeks":0, "days":0, "hours":0, "minutes":0, "seconds":0};

if (maximum == 'y')
{
  result.years = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7 * 52));
  timediff -= result.years * (1000 * 60 * 60 * 24 * 7 * 52);
}
if (maximum == 'y' || maximum == 'w')
{
  result.weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
  timediff -= result.weeks * (1000 * 60 * 60 * 24 * 7);
}
if (maximum == 'y' || maximum == 'w' || maximum == 'd')
{
  result.days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
  timediff -= result.days * (1000 * 60 * 60 * 24);
}

  result.hours = Math.floor(timediff / (1000 * 60 * 60)); 
  timediff -= result.hours * (1000 * 60 * 60);

  result.minutes = Math.floor(timediff / (1000 * 60)); 
  timediff -= result.minutes * (1000 * 60);

  result.seconds = Math.floor(timediff / 1000); 
  timediff -= result.seconds * 1000;

   
  return result;
};

function SkinClass() 
{
	this.domain = 'http://'+document.domain;
	this.urandom=Math.floor(Math.random() * 100000);   
	this.embedDart=function(i,j) {
		document.write('<iframe src="'+i+';ord='+this.urandom+'" width="728" height="90" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling=no borderCOLOR="#000000"></iframe>');
		document.write('<script src="'+j+';ord='+this.urandom+'" type="text/javascript"><\/script>');
	}
	
	//this.serviceurl = '/DesktopModules/R2iSmash/Service.aspx';
	this.serviceurl = '/services/service.ashx';
	this.skinpath = '/Portals/_default/Skins/SmashCapComSkin';
	this.map = null;
	this.factoid = function(day)
	{
		window.location = '/Home.aspx?Day='+day;
	}
	this.FactoidsLoaded = false;
	this.FactoidMenuLoaded = false;
	this.FactoidMenuVisible = false;
	this.showFactoidMenu=function(mid)
	{
		if (!this.FactoidMenuLoaded)
		{
			skin.toggleFactoids(mid);this.FactoidMenuLoaded=true;
		}
		if (!this.FactoidMenuVisible)
		{		
			this.FactoidMenuVisible = true;
			jQuery('.FactoidRoot').slideDown('slow');
		}
		else
		{
			this.FactoidMenuVisible = false;
			jQuery('.FactoidRoot').slideUp('slow');
		}
		
	}
	this.toggleFactoids = function(modid,weekid)
	{
		if (typeof weekid=='undefined'||weekid==null)
		{

			if (document.getElementById('FactoidRightImage').className=='up')
			{
					//document.getElementById('FactoidRightImage').className='down';
					$jq('#FactoidItems').slideUp();
			}
			else
			{
				if (this.FactoidsLoaded==false)
				{
					this.FactoidsLoaded = true;
					//document.getElementById('FactoidRightImage').className='ajax';
					ows.Fetch(modid,-1,'ShowFacts=1','FactoidItems');
				}
				else
				{
					//document.getElementById('FactoidRightImage').className='up';
					$jq('#FactoidItems').slideDown();
				}
			}
		}
		else
		{
			if (document.getElementById('FactoidRightImage'+weekid).className=='up')
			{
					document.getElementById('FactoidRightImage'+weekid).className='down';$jq('#'+weekid).slideUp();
			}
			else
			{
				document.getElementById('FactoidRightImage'+weekid).className='up';$jq('#'+weekid).slideDown();
			}
		}

	}
	this.urlFormat = function(source) {
		var uriregex = /(^|[^'">])((ftp|http|https):\/\/(\S+))(\b|$)/gi;
		source = source.replace(uriregex ,"$1<a class='msgUrl' target='_blank' href='$2'>$2</a>");
		return source;
	}
	
	this.runCalendar = function(targetId,interval)
	{
		//LOOP THROUGH PARAMETERS;
		var now = new Date();
		var src = document.getElementById(targetId);
		if (typeof src != 'undefined' && src!=null)
		{
			try
			{
				var attributes = src.getAttribute('calendar');
				if (attributes!=null && attributes.length>0)
				{
					var parameters = false;
					eval('var parameters = ' + attributes);
					if (parameters && parameters.Targets.length > 0 && parameters.Targets.length == parameters.Formats.length)
					{
            if (typeof(parameters.countdown)=='undefined'||parameters.countdown==null||parameters.countdown.length==0)
            {
              var i = 0;
              for(i=0;i<parameters.Targets.length;i++)
              {
                var target = document.getElementById(parameters.Targets[i]);
                if (typeof target != 'undefined' && target!=null)
                {
                  var format = parameters.Formats[i];
                  target.innerHTML = now.format(format);
                }
              }
						}
						else
						{
              var targetdate = new Date(parameters.countdown);
              var now = new Date();
              var difference = now.difference(targetdate,'d');
		var showblanks = false;
		//ADDED TO END COUNTDOWN AT SPECIFIC TIME!
		if (targetdate<now)
		{
			var enddate = new Date(parameters.enddate);
			if (enddate<now)
			{
				showblanks = true;
				difference.years = 0; difference.weeks=0; difference.days=0; difference.hours=0;difference.minutes=0;difference.seconds=0;
			}
			
		}
		//----------------------------------------
              var i = 0;
              for(i=0;i<parameters.Targets.length;i++)
              {
                var target = document.getElementById(parameters.Targets[i]);
                if (typeof target != 'undefined' && target!=null)
                {
                  var format = parameters.Formats[i];
                  var value = '';
		  if (showblanks==false)
		  {
                  switch(format)
                  {
                    case 'yy':
                      value = strpad(difference.years+'', 2, '0', STR_PAD_LEFT);
                    break;
                    case 'y':
                      value = difference.years;
                    break;
                    case 'ww':
                      value = strpad(difference.weeks+'', 2, '0', STR_PAD_LEFT);
                    break;
                    case 'w':
                      value = difference.weeks;
                    break;
                    case 'dd':
                      value = strpad(difference.days+'', 2, '0', STR_PAD_LEFT);
                    break;
                    case 'd':
                      value = difference.days;
                    break;
                    case 'hh':
                      value = strpad(difference.hours+'', 2, '0', STR_PAD_LEFT);
                    break;
                    case 'h':
                      value = difference.hours;
                    break;
                    case 'MM':
                      value = strpad(difference.minutes+'', 2, '0', STR_PAD_LEFT);
                    break;
                    case 'M':
                      value = difference.minutes;
                    break;
                    case 'ss':
                      value = strpad(difference.seconds+'', 2, '0', STR_PAD_LEFT);
                    break;
                    case 's':
                      value = difference.seconds;
                    break;
                  }
		}
                  target.innerHTML = value;
                }
              }              
						}
					}
				}
			}
			catch(ex)
			{
			}
		}
		
		window.setTimeout('skin.runCalendar(\'' + targetId + '\','+interval+');',interval)
	}

var STR_PAD_LEFT = 1;
var STR_PAD_RIGHT = 2;
var STR_PAD_BOTH = 3;
 
function strpad(str, len, pad, dir) {
 
	if (typeof(len) == "undefined") { var len = 0; }
	if (typeof(pad) == "undefined") { var pad = ' '; }
	if (typeof(dir) == "undefined") { var dir = STR_PAD_RIGHT; }
 
	if (len + 1 >= str.length) {
 
		switch (dir){
 
			case STR_PAD_LEFT:
				str = Array(len + 1 - str.length).join(pad) + str;
			break;
 
			case STR_PAD_BOTH:
				var right = Math.ceil((padlen = len - str.length) / 2);
				var left = padlen - right;
				str = Array(left+1).join(pad) + str + Array(right+1).join(pad);
			break;
 
			default:
				str = str + Array(len + 1 - str.length).join(pad);
			break;
 
		} // switch
 
	}
 
	return str;
 
}

	this.messages = {"Media":[]};
	this.messagesTotal = -1;
	this.messagesPage = -1;
	this.messagesPlay = true;
	this.messageItems = new Array();
	this.messageLastIndex = -1;
	this.messageIndex = 0;	
	this.messageIcons = new Array();
	this.messageIconKeys = new Array();
	this.imageAds = new Array();
	this.adLast = 0;
	this.adI = 0;
	this.adInt = 4;
	this.messageAlt = true;
	this.messageRegisters = new Array();
	this.messageRegisterKeys = new Array();
	this.messageWait = false;
	this.messageScroll = false;
	this.messageMax = true;
	this.messageError = false;
	this.showAvatars = true;
	this.defaultAvatarSize = 'normal';
	
	this.avatarSize = function(type)
       {
               var sizetype = "";
               switch(type)
               {
                       case 'mini':
                       case 'undefined':
                       case null:
                               sizetype = '_m';//24x24
                               break;
                       case 'normal':
                               sizetype = '_n';//default 48x48
                               break;
                       case 'bigger':
                               sizetype = '_b';//73x73
                               break;
                       case 'original':
                               sizetype = '_o';//original user uploaded profile picture
                               break;
               }
               return sizetype;
       };
	
	this.registerIcon = function(name,icon)
	{
		this.messageIconKeys.push(name.toLowerCase());
		this.messageIcons[name.toLowerCase()]=icon;
	}
	this.checkIcon = function(name,servicetypeid)
	{
		if (this.messageIconKeys.indexOf(name.toLowerCase())>-1)
		{
			return this.messageIcons[name.toLowerCase()];
		}
		else
		{
			if (this.showAvatars==true)
			{
					switch(servicetypeid+'')
					{
						case '5':
								return 'http://img.tweetimag.es/i/'+name+this.avatarSize(this.defaultAvatarSize);
							break;
					}
			}
			return this.domain+this.skinpath+'/_i/servicetype'+servicetypeid+'.gif';
		}
	}
	this.registerAd = function(url)
	{
		this.imageAds.push(url);
	}
	this.attention = function(selector)
	{
		jQuery(selector).animate({opacity:"0.1"},400)
		.animate({opacity:"1"},400)
		.animate({opacity:"0.1"},400)
		.animate({opacity:"1"},400)
		.animate({opacity:"0.1"},400)
		.animate({opacity:"1"},400)
		.animate({opacity:"0.1"},400)
		.animate({opacity:"1"},400);
	}

	this.commentId = 0;
	this.skinRandomId = Math.floor(Math.random()*1000000);
	this.CommentAuthor = 'Comment';
	this.latitude = '';
	this.longitude = '';
	this.sendComment = function(targetId,maxcount,txtBox,StatusID,statusText,moduleId,statusHidden,showNow,txtLatitude,txtLongitude)
	{
		try{
					var txtObj = document.getElementById(txtBox);		
					if (typeof(showNow)=='undefined'||showNow==null)
						showNow=false;
					this.commentId++;
					$jq('#'+StatusID).html(statusText);
					var now = new Date();
										
					var coords = '';
					var jcoords = '';
					var messageBody = {"src":txtObj.value,"title":"","date":now.toString(),"author":this.CommentAuthor,"link":"","internal":"False","type":"7","id":this.commentId,"latitude":null,"longitude":null}

					if (typeof(txtLatitude)!='undefined'&&txtLatitude!=null&&typeof(txtLongitude)!='undefined'&&txtLongitude!=null)
					{
						try {
							if (typeof(google)!='undefined'&&google!=null&&typeof(google.loader)!='undefined'&&google.loader!=null&&typeof(google.loader.ClientLocation)!='undefined'&&google.loader.ClientLocation!=null) {
									skin.latitude=google.loader.ClientLocation.latitude;
									skin.longitude=google.loader.ClientLocation.longitude;
							}
							} catch(ex2) { }
							
						if (skin.latitude!='') {
							messageBody.latitude=skin.latitude;
							document.getElementById(txtLatitude).value=skin.latitude;
							}
						if (skin.longitude!='') {
							messageBody.longitude=skin.longitude;
							document.getElementById(txtLongitude).value=skin.longitude;
							}
						coords = '&lat='+txtLatitude+'&lon='+txtLongitude;
					}
					if (showNow)
					{
						
						this.showMessage(targetId,messageBody,maxcount-1,true);
					}
					window.setTimeout('$jq(\'#'+StatusID+'\').html(\'\');',2000);
					//SEND COMMENT WITH this.CommentAuthor-this.skinRandomId:
					if (typeof(moduleId) != 'undefined' && moduleId != null)
					{
						var author = this.CommentAuthor;
						if (showNow)
							author = this.CommentAuthor + '-' + this.skinRandomId;
						var querystring = 'action=comment&author='+author+'&text='+txtBox+coords;
						ows.Fetch(moduleId,-1,querystring,statusHidden);
					}
					txtObj.value = '';
			} catch(ex) {
				alert(ex);
			}
	}

	this.checkAd = function()
	{
		if (this.imageAds.length > 0)
		{
			this.adI++;
			if (this.adI>=this.adInt)
			{
				this.adI=0;
				if (this.adLast==0)
				{
					this.adLast++;
					return this.imageAds[0];
				}
				else
				{
					if (this.adLast>=this.imageAds.length)
					{
						this.adLast=1;
						return this.imageAds[0];
					}
					else
					{
						this.adLast++;
						return this.imageAds[this.adLast];
					}
				}
			}
		}
		return null;
	}
	this.howto = function(targetid,hide)
	{
		if (!hide)
		{
			$jq('#'+targetid).slideDown();
		}
		else
		{
			$jq('#'+targetid).slideUp();
		}
	}
	this.registerMessages = function(targetid,maxcount,interval,pid,eid,lid,sid,flt,xid,pg)
	{
	if (typeof xid=='undefined'||xid==null)
	{
		if (typeof document.getElementById('cpr') != 'undefined' && document.getElementById('cpr')!=null && document.getElementById('cpr').value.length > 0)
			xid = document.getElementById('cpr').value;
		else
			xid = -1;
	}
	if (typeof pg=='undefined'||pg==null)
		pg = -1;
    if (this.messageRegisters['msg'+targetid]==null)
    {
      this.messageRegisterKeys.push('msg'+targetid);
      this.messageRegisters["msg"+targetid] = {"targetid":targetid,"maxcount":maxcount,"interval":interval,"pid":pid,"eid":eid,"lid":lid,"sid":sid,"flt":flt,"xid":xid,"pg":pg};
    }
	}
	this.refreshMessages = function()
	{
    var keyi = 0;
    for (keyi=0;keyi<this.messageRegisterKeys.length;keyi++)
    {
      var r = this.messageRegisters[this.messageRegisterKeys[keyi]];
      this.runMessages(r.targetid,r.maxcount,r.interval,r.pid,r.eid,r.lid,r.sid,r.flt,r.xid,r.pg);
    }
	}
	
	this.runMessages = function(targetid,maxcount,interval,pid,eid,lid,sid,flt,xid,pg)
	{
        if (this.messagesPlay)
		{
			if (typeof(eid)=='undefined'||eid==null)
				eid = -1;
			if (typeof(pid)=='undefined'||pid==null)
				pid = -1;
			if (typeof(lid)=='undefined'||lid==null)
				lid = -1;
			if (typeof(sid)=='undefined'||sid==null)
				sid = -1;
			if (typeof(xid)=='undefined'||xid==null||xid.length==0)
			{
				var elemCpr = document.getElementById('cpr');
				if (typeof elemCpr != 'undefined' && elemCpr!=null && elemCpr.value.length > 0)
					xid = elemCpr.value;
				else
					xid = -1;
			}
			if (typeof(pg)=='undefined'||pg==null)
				pg = -1;				
			if (typeof(flt)=='undefined'||flt==null)
				flt = '';
				
			this.registerMessages(targetid,maxcount,interval,pid,eid,lid,sid,flt,xid,pg);
			
			if (this.messageIndex < this.messages.Media.length)
			{
				//SHOW THE MESSAGE
				this.showMessage(targetid,this.messages.Media[this.messageIndex],maxcount-1);
			}
			this.messageIndex=this.messageIndex+1;
			if (this.messageIndex >= this.messages.Media.length && !this.messageWait)
			{
				this.getMessages(pid,eid,lid,sid,flt,xid,pg);
			}
			window.setTimeout('skin.runMessages(\'' + targetid + '\','+maxcount+','+interval+','+pid+','+eid+','+lid+','+sid+',\'' + flt + '\','+xid+','+pg+');',interval)
		}
	}
	this.messageCounter = 0;
	this.showMessage = function(targetid,message,max,isLocal)
	{
		if (message.author!= this.CommentAuthor+'-'+this.skinRandomId)
		{
			this.messageCounter++;
			if (this.messageCounter>10000)
				this.messageCounter = 0;
			
			var target = document.getElementById(targetid);
			var parentid = $jq('#'+targetid).parent().attr("id");
			
			this.messageAlt = !this.messageAlt;
			if (typeof(isLocal)=='undefined'||isLocal==null)
				isLocal=false;
			if (!isLocal)
				this.messageLastIndex=this.messages.Media[this.messageIndex].id;
			while (this.messageItems.length > max*2)
			{
				$jq(this.messageItems[0]).slideUp('slow');
				$jq(this.messageItems[1]).slideUp('slow');
				target.removeChild(this.messageItems[0]);
				target.removeChild(this.messageItems[1]);
				this.messageItems.splice(0,2);
			}
			var newMessage = document.createElement('div');
			var internalContainer = '';
			var newStamp = document.createElement('div');
			var background = '';
			if (!this.messageAlt)
			{
				background='#bbb';
				internalContainer = 'text';
				newMessage.className = 'text_icon_container';
			}
			else
			{
				background='#eee'; //'#dddddd';
				internalContainer = 'text_alter';
				newMessage.className = 'text_icon_container_alter';
			}
			newStamp.className = 'timestamp';
			newMessage.style.display='none';
			newStamp.style.display='none';
			var datevalue = message.date;
			if (typeof datevalue!='undefined' && datevalue!=null)
			{
			datevalue = new Date(datevalue + ' EDT');
			datevalue = datevalue.toTimezone();
			try {
				//datevalue = (new Date(datevalue)).format('mmmm d yyyy h:MM tt');
				if (this.messagesPlay)
					datevalue = datevalue.format('h:MM tt');
				else
					datevalue = datevalue.format('mm/dd/yyyy h:MM tt');
			}
			catch (ex)
			{
				datevalue = '';
			}
			}
			var sourcetxt = '';
			if (message.internal=='True')
			{
				sourcetxt = '<img align="right" class="serviceIcon" src="'+this.checkIcon(message.author,message.type)+'" />';
			}
			else
			{
				sourcetxt = '<img align="right" class="serviceIcon" src="'+this.checkIcon(message.author,message.type)+'" />';
			}
			
			
			//newMessage.innerHTML = '<div class="'+internalContainer+'" id="'+parentid+'m'+this.messageCounter+'"><div class="frame1"><div class="frame2"><div class="frame3"></div></div></div><p>' + sourcetxt + '<b>'+message.author+'</b> ' + message.src + '</p><div class="frame4"><div class="frame5"><div class="frame6"></div></div></div></div></div>';	
			newMessage.innerHTML = '<div class="'+internalContainer+'" id="'+parentid+'m'+this.messageCounter+'"><div class="sourceframe">' + sourcetxt + '</div><div class="contentframe"><div class="textframe">' + this.urlFormat(message.src) + '</div><div class="dateframe">'+datevalue+(message.author.length>0?' from ':'')+message.author+'</div></div></div><div class="clear"></div>';	
			newStamp.innerHTML = '';
			
			
			this.messageItems.push(newMessage);
			this.messageItems.push(newStamp);
			target.appendChild(newMessage);
			target.appendChild(newStamp);
			
			if (typeof this.map != 'undefined' && this.map != null)
			{
				if (typeof message.latitude != 'undefine' && message.latitude!=null && message.latitude!='')
				{
					var mapMessage = '';
					mapMessage =  '' + sourcetxt + '<p class="mapBox">'+this.urlFormat(message.src) + '<br/>'+(message.author.length>0?'<b>'+message.author+'</b> ':'')+'<i>'+datevalue+'</i>'+'</p>';	
					this.map.plot(message.latitude,message.longitude,message.src,message.author,this.checkIcon(message.author,message.type),datevalue);
				}				
			}
			
			$jq(newMessage).fadeIn('slow');$jq(newStamp).fadeIn('slow');
			if (this.messageScroll==false)
				this.messageScroll = document.getElementById(parentid);
			this.messageScroll.scrollTop = this.messageScroll.scrollHeight;
		}
	}

	this.getMessages = function(pid,eid,lid,sid,flt,xid,pg)
	{
		if (this.messageError)
		{
			window.clearTimeout(this.messageError);
			this.messageError =false;
		}

		this.messageWait = true;
		//REQUEST DATA
				var extras = '';
		if (pid>-1)
			extras=extras+'&pid='+pid;
		if (eid>-1)
			extras=extras+'&eid='+eid;
		if (lid>-1)
			extras=extras+'&lid='+lid;
		if (sid>-1)
			extras=extras+'&sid='+sid;
		if (flt.length>0)
			extras=extras+'&flt='+flt;
		if (typeof pg == 'undefined')
			pg = -1;
		if (typeof xid == 'undefined')
			xid = -1;
		if (pg > -1)
			extras=extras+'&pg='+pg;
		if (xid > -1)
			extras=extras+'&xid='+xid;

		if (!this.messageMax)
		{
			this.ajax('messages',this.domain+this.serviceurl+'?stmp='+(new Date()).format('mmddyyyyhhMMss')+'&type=json'+extras+'&src=note&id='+this.messageLastIndex+'&pre=skin.loadMessages(&post=);');
		}
		else
		{
			this.messageMax=false;
			this.ajax('messages',this.domain+this.serviceurl+'?stmp='+(new Date()).format('mmddyyyyhhMMss')+'&type=json'+extras+'&src=note&max=1&pre=skin.loadMessages(&post=);');
		}
		this.messageError = window.setTimeout ( "skin.messageWait=false;", 60000 );
	}
	this.isVideoGallery = false;
	this.showVideoGallery = function(w,h)
	{
		var qs = new Array();
		if (typeof w!='undefined' && w!=null)
			qs.push('width='+w);
		if (typeof h!='undefined' && h!=null)
			qs.push('height='+h);
			
		if (!this.isVideoGallery)
		{
			this.isVideoGallery=true;
			ows.Create('vdoList',-1,20,'s:1x,m:vdoList,pm:2226,p:1383,id:632ddc86-ded8-4571-b78f-6ccd9851ad7c,lxSrc:dnn$ctrvdoList$dnn,pp:42','/DesktopModules/OWS/','/DesktopModules/OWS/',false,-1,'',null,null,qs.join('&'),null);
		}
	}
	this.isPhotoGallery = false;
	this.showPhotoGallery = function(w,h)
	{
		var qs = new Array();
		if (typeof w!='undefined' && w!=null)
			qs.push('width='+w);
		if (typeof h!='undefined' && h!=null)
			qs.push('height='+h);
		
		if (!this.isPhotoGallery)
		{
			this.isPhotoGallery=true;
			ows.Create('photoList',-1,20,'s:1x,m:photoList,pm:2226,p:1383,id:555ddc86-ded8-4571-b78f-6ccd9851ad7c,lxSrc:dnn$ctrphotoList$dnn,pp:42','/DesktopModules/OWS/','/DesktopModules/OWS/',false,-1,'',null,null,qs.join('&'),null);
		}
	}	

	this.lastMessage = function()
	{
		//depricated
		//this.messageMax = true;
		//this.imageMax = true;
		//this.videoMax = true;
	}
	this.loadMessages = function(content)
	{

		if (content.Media.length > 0)
		{
			this.messages = content;
			this.messageIndex = 0;
		}
		if (typeof content.Total != 'undefined' && content.Total != null)
			this.messagesTotal = content.Total;
		else
			this.messagesTotal = -1;
		if (typeof content.Page != 'undefined' && content.Page != null)
			this.messagesPage = content.Page;
		else
			this.messagesPage = -1;

		if (this.messagesTotal > -1)
		{
			this.renderMessagePage();
		}
		this.messageWait = false;
	}
	this.renderMessagePage=function()
	{
		for (var i=0;i<this.messages.Media.length;i++)
		{
			this.showMessage(this.messagePageTargetId,this.messages.Media[i],10);
		}
		$jq('#messageTarget').parent().height($jq('#messageTarget').height());
		this.renderMessagePager();
	}
	this.renderMessagePager=function()
	{

		var CURRENTPAGE = this.messagesPage*1;
		var DATALENGTH = this.messagesTotal*1;
		var RPP = 10;
		var PGStext = '';
		var minPage = 0;
		var maxPage = 0;
		var lastPage = 0;
		
		var PGSHeader = '';
		var PGSFooter = '';
		var PGSPages = 10;
		var PGSPageHalf = 0;
		var PGSPage = 'PAGENUMBER';
		var PGSQueryString = '';
		var PGSTargetId = '';
		var PGSTargetIdValue = '';
		var PGSBack = 'Back';
		var PGSNext = 'Next';
		var PGSFirst = 'First';
		var PGSLast = 'Last';
		var PGSSeparator = '|';
		var PGSPageSeparator = '&nbsp;';
		var PGSBackSeparator = '...';
		var PGSNextSeparator = '...';
		var HistoryPageAnchor;

		PGSHeader = '<div style="width: 100%; text-align: center;">';
		PGSFooter = '</div>';

		if (DATALENGTH > 1)
		{
			PGSPageHalf = PGSPages/2;
			minPage = (CURRENTPAGE + 1) - (PGSPageHalf-1); //4
			
			if (RPP > 0)
			{
				lastPage = Math.ceil((DATALENGTH/RPP));
			}
			else
			{
				lastPage = minPage;
			}
			
			if (minPage < 1)
			{
				minPage = 1;
			}
			maxPage = minPage + (PGSPageHalf+1); //6
			if (maxPage > lastPage)
			{
				maxPage = lastPage;
			}

			if (DATALENGTH==RPP)
			{
				maxPage = minPage;
				lastPage = minPage;
			}
			if (PGSTargetId!=null&&PGSTargetId.length>0)
			    PGSTargetIdValue = ',\''+PGSTargetId+'\''
			if ((lastPage-1) > 0)
			{
				if (CURRENTPAGE > 1)
				{
					if (PGSBack.length > 0)
					{
						PGStext += '<a href="#" onclick="' + this.pagerMethod.replace(/PAGENUMBER/g,(CURRENTPAGE - 1)) + ';return false;' + '">' + PGSBack + '</a>' + PGSPageSeparator + '' + PGSBackSeparator + '&nbsp;';
					}
					if (PGSFirst.length > 0)
					{
						PGStext += '<a href="#" onclick="' + this.pagerMethod.replace(/PAGENUMBER/g,1) + ';return false;">' + PGSFirst + '</a>' + PGSPageSeparator + '' + PGSSeparator + '' + PGSPageSeparator + '';
					}
				}
				else
				{
					if (PGSBack.length > 0)
					{
						PGStext += '' + PGSBack + '' + PGSPageSeparator + '' + PGSBackSeparator + '' + PGSPageSeparator + '';
					}
					if (PGSFirst.length > 0)
					{
						PGStext += '' + PGSFirst + '' + PGSPageSeparator + '' + PGSSeparator + '' + PGSPageSeparator + '';
					}
				}
				//PGStext += PGSHeader;
				for (x=minPage;x<=maxPage;x++)
				{	
					if (x==CURRENTPAGE)
						PGStext +=  PGSPage.replace(/PAGENUMBER/,(x));
					else
						PGStext += '<a href="#" onclick="' + this.pagerMethod.replace(/PAGENUMBER/g,x) + ';return false;">' + PGSPage.replace(/PAGENUMBER/,(x)) + '</a>';
					
					PGStext += '' + PGSPageSeparator + '';
				}
				//PGStext += PGSFooter;
				if (CURRENTPAGE < (lastPage))
				{
					if (PGSLast.length > 0)
					{
						PGStext += '' + PGSSeparator + '' + PGSPageSeparator + '<a href="#" onclick="' + this.pagerMethod.replace(/PAGENUMBER/g,(lastPage - 1)) + ';return false;' + '">' + PGSLast + '</a>' + PGSPageSeparator + '' + PGSNextSeparator + '' + PGSPageSeparator + '';
					}
					
					if (PGSNext.length > 0)
					{
						PGStext += '<a href="#" onclick="' + this.pagerMethod.replace(/PAGENUMBER/g,(CURRENTPAGE + 1)) + ';return false;">' + PGSNext + '</a>';
					}
				}
				else
				{
					if (PGSLast.length > 0)
					{
						PGStext += '' + PGSSeparator + ' ' + PGSLast + ' ' + PGSNextSeparator + ' ';
					}
					if (PGSNext.length > 0)
					{
						PGStext += '' + PGSNext  + '';
					}
				}
				PGStext = PGSHeader + PGStext + PGSFooter;
			}
		}
		//PGStext = PGSHeader + PGStext + PGSFooter;
		
		if (PGStext.length > 0)
		{
			$jq('#'+this.pagerId).html(PGStext);
		}
	}
	this.subscribe=function() { }
	this.pagerId = '';
	this.pagerMethod = '';
	this.CurrentParent = -1;
	this.messagesPager = function()
	{
		if (this.messageError)
		{
			window.clearTimeout(this.messageError);
			this.messageError =false;
		}
	}
	this.messagePageTargetId='';
	this.getMessagesPage = function(targetid,pid,eid,lid,sid,flt,xid,pg)
	{
		if (typeof document.getElementById('cpr') != 'undefined' && document.getElementById('cpr')!=null && document.getElementById('cpr').value.length > 0)
			xid = document.getElementById('cpr').value;
			
		this.messagePageTargetId=targetid;
		this.messagesPlay = false;
		if (this.messageError)
		{
			window.clearTimeout(this.messageError);
			this.messageError =false;
		}
		this.getMessages(pid,eid,lid,sid,flt,xid,pg);
	}	
		
	this.images = {"Media":[]};
	this.imageLastIndex = -1;
	this.imageIndex = 0;
	this.display_images = new Array();
	this.display_text = new Array();
	this.display_image = new Array();
	this.imageWait = false;
	this.imageMax = false;
	this.imageError = false;
	
	this.loadImages = function(content)
	{
		if (content.Media.length > 0)
		{
			this.images = content;
			this.imageIndex = 0;
		}
		this.imageWait = false;
	}
  this.runImages = function(pid,eid,lid,sid)
	{
		if (typeof(eid)=='undefined'||eid==null)
			eid = -1;
		if (typeof(pid)=='undefined'||pid==null)
			pid = -1;
		if (typeof(lid)=='undefined'||lid==null)
			lid = -1;
		if (typeof(sid)=='undefined'||sid==null)
			sid = -1;
		
		this.getImages(pid,eid,lid,sid);
	}
	this.getLastImage = function(selector)
	{
		var obj = $jq(selector);
		var img = obj.children('img');
		if (img!=null&&img.length>0)
			return img.attr('src');
		return null;
	}
  
  this.nextImage = function(pid,eid,lid,sid) {
		var url = '/Portals/'+pid+'/live.jpg';
		var adUrl = this.checkAd();
		if (adUrl!=null)
		{
			return adUrl;
		}
		else
		{
			if (this.imageIndex < this.images.Media.length)
			{
				//SHOW THE IMAGE
				this.imageLastIndex=this.images.Media[this.imageIndex].id;			
				url = '/assets/'+this.images.Media[this.imageIndex].srv+'/'+this.images.Media[this.imageIndex].src;
			}
			this.imageIndex=this.imageIndex+1;
			if (this.imageIndex >= this.images.Media.length && !this.imageWait)
			{
				this.getImages(pid,eid,lid,sid);
			}	
			url = this.domain+url;
			try {
					this.fullImages.push(this.images.Media[this.imageIndex].src);
					var img = new Image();
					img.src = this.images.Media[this.imageIndex].src + '.large.jpg';
			} catch(ex) { }
		}
	return url;
	}
	
  this.getImages = function(pid,eid,lid,sid) {
		if (this.imageError)
		{
			window.clearTimeout(this.imageError);
			this.imageError =false;
		}
		this.imageWait = true;
		//alert(this.imageLastIndex);
		//REQUEST DATA
		//alert(this.imageLastIndex);

		var extras = '';
		if (pid>-1)
			extras=extras+'&pid='+pid;
		if (eid>-1)
			extras=extras+'&eid='+eid;
		if (lid>-1)
			extras=extras+'&lid='+lid;
		if (sid>-1)
			extras=extras+'&sid='+sid;
		if (!this.imageMax)
		{
			this.ajax('images',this.domain+this.serviceurl+'?stmp='+(new Date()).format('mmddyyyyhhMMss')+'&type=json'+extras+'&src=photo&id='+this.imageLastIndex+'&pre=skin.loadImages(&post=);');
		}
		else
		{
			this.imageMax=false;
			this.ajax('images',this.domain+this.serviceurl+'?stmp='+(new Date()).format('mmddyyyyhhMMss')+'&type=json'+extras+'&src=photo&max=1&pre=skin.loadImages(&post=);');
		}
		this.imageError = window.setTimeout ( "skin.imageWait=false;", 60000 );
		
	}

					
	this.videos = {"Media":[]};
	this.videoLastIndex = 1;
	this.videoIndex = 0;
	this.videoWait = false;
	this.display_video = new Array();
	
	this.register = function(name,id)
	{
		switch(name)
		{
			case 'image':
				this.display_image.push($jq('#'+id));
				break;
			case 'images':
				this.display_images.push($jq('#'+id));
				break;
			case 'video':
				this.display_video.push($jq('#'+id));
				break;
			case 'text':
				this.display_text.push($jq('#'+id));
				break;
		}
	}
	this.transfer = function(id) {this.transferid=id};
	this.transferid = null;
	this.sliderCycle = 0;

	this.showTransfer=true;
	this.showFullImage = function(fullImage,frequency) {
try {
		for(var i=0;i<this.display_image.length;i++)
		{
		
			var slider = $jq('#'+'skinslider'+i);
			if (slider!=null&&slider.length>0&&this.transferid!=null)
			{
				if (this.showTransfer)
				{
					var bgobj = $jq('#stylizer123');
					if (bgobj==null||bgobj.length==0)
					{
						var objdiv = document.createElement('div');
						objdiv.id = 'stylizer123';
						$jq('#Footer').append(objdiv);
						bgobj = $jq('#stylizer123');
					}
					var lastImagesrc = this.getLastImage(slider);
					if (lastImagesrc!=null)
						bgobj.html('<style>.ui-effects-transfer{background: url('+lastImagesrc+');}</style>');
									
						eval('slider.hide(\'transfer\',{to: "#'+this.transferid+'",className: "ui-effects-transfer"},'+(frequency/4)+',function() { skin.slideFullImage(\''+fullImage+'\','+i+','+frequency+') });');
					slider.fadeOut(frequency/6);
				}
				else
				{
					eval('slider.hide(\'clip\',{},'+(frequency/10)+',function() { skin.slideFullImage(\''+fullImage+'\','+i+','+frequency+') });');
				}
			}
			else
			{
				skin.slideFullImage(fullImage,i,frequency);
			}
		}
} catch(ex) { 
debugger;
}
	}
	this.slideFullImage = function(fullImage,index,frequency)
	{
		$jq('#skinslider'+index).remove();
			this.display_image[index].html('<div id="skinslider'+index+'" style="display:none;"><img class="fullImage" src="' + fullImage + '"></div>');
		$jq('#skinslider'+index).show('scale',{percent: 100},(frequency*1)/10);
	}

	this.setStatus = function(src,status)
	{
		switch(src.toLowerCase())
		{
			case 'photo':
			{
				if (status.toLowerCase()=='live')
					this.imageLastIndex = -1;
				else
					this.imageLastIndex = 1;
				this.imageMax = true;
				this.photos = {"Media":[]};
				break;
			}
			case 'text':
			{
				if (status.toLowerCase()=='live')
					this.messageLastIndex = -1;
				else
					this.messageLastIndex = 1;
				this.messageMax = true;					
				this.messages = {"Media":[]};
				break;
			}
			case 'video':
			{
				if (status.toLowerCase()=='live')
					this.videoLastIndex = -1;
				else
					this.videoLastIndex = 1;
				this.videoMax = true;					
				this.videos = {"Media":[]};
				break;
			}
		}
	}

	
	this.nextVideo = function() {
		var url = null;
		if (this.videoIndex < this.videos.Media.length)
		{
			//SHOW THE IMAGE
			this.videoLastIndex=this.videos.Media[this.videoIndex].id;		
			var urlPath  = '/assets/'+this.videos.Media[this.videoIndex].srv+'/';
			var urlSource = this.videos.Media[this.videoIndex].src;
			if (urlSource.substr(0,5)=='http:')
			{
					urlPath='';
			}
			else
			{
				if (this.videos.Media[this.videoIndex].src.substr(0,1)=='/' || this.videos.Media[this.videoIndex].src.substr(0,1)=='\\')
					urlPath = '';
			}
			url = urlPath+this.videos.Media[this.videoIndex].src;
		}
		this.videoIndex=this.videoIndex+1;
		if (this.videoIndex >= this.videos.Media.length && !this.videoWait)
		{
			this.getVideos();
		}	
		if (url!=null)
			url = url;
		return url;
	}
	
	this.videoPlayer = false;
	this.videoMax = false;
	this.videoWait = false;
	this.getVideos = function()
	{
		this.videoWait = true;
		//REQUEST DATA
		if (!this.videoMax)
		{
			if (this.videoLastIndex==0)
				this.videoLastIndex = 1;
	//alert(this.videoLastIndex);
			this.ajax('videos',this.domain+this.serviceurl+'?stmp='+(new Date()).format('mmddyyyyhhMMss')+'&type=json&src=video&id='+this.videoLastIndex+'&'+this.videoParameters+'&pre=skin.loadVideos(&post=);');
		}
		else
		{
			this.videoMax=false;
			this.ajax('videos',this.domain+this.serviceurl+'?stmp='+(new Date()).format('mmddyyyyhhMMss')+'&type=json&src=video&max=1'+'&'+this.videoParameters+'&pre=skin.loadVideos(&post=);');
		}
	}	
	
	this.loadVideos = function(content)
	{
		if (content.Media.length > 0)
		{
			this.videos = content;
			this.videoIndex = 0;
		}
		this.videoWait = false;
	}	
	this.videoParent = false;
	this.videoParentWidth = 0;
	this.videoParentHeight = 0;
	this.videoParameters = '';
	this.runSlides = function(targetid,width,height,url,autoplay)
	{
		if (typeof autoplay == 'undefined' || autoplay==null) { autoplay=0;	}
		var dest = document.getElementById(targetid);
		//var str = '<embed id="myplayer" flashvars="controlbar=none&screencolor=ffffff&stretching=fill" name="myplayer" src="/player/player.swf" width="'+width+'" height="'+height+'" />';
		dest.innerHTML = '';
		
		//var so = new SWFObject('http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=' + url + '&amp;rel=0&amp;stripped_title=sxsw-open-leadership','myplayer',width,height,"9","#ffffff");
		//var so = new SWFObject('http://static.slidesharecdn.com/swf/ssplayer2.swf','myplayer',width,height,"9","#ffffff");
		//msinternettrends060710final-100607133705-phpapp02-video
		var swfname = 'ssplayer2.swf';
		if (url.replace('-video')!=url) {
			swfname = 'playerv.swf';
		}
		var so = new SWFObject('http://static.slidesharecdn.com/swf/'+swfname+'?doc=' + url + '&stripped_title='+url,'myplayer',width,height,"9","#ffffff");
		so.addParam('wmode','transparent');
		so.addParam('quality','high');
		so.addParam('flashvars','controlbar=none&screencolor=ffffff&stretching=fill&wmode=transparent&autoplay='+autoplay);
		so.write(targetid);
		
		//this.videos = {"Media":[{"id":"-1","author":"","url":"","link":"","title":"","src":"","date":""}]};
		//this.videos.Media[0].src = url;
		
	}
	
	this.runVideos = function(targetid,width,height,url,pid,eid,lid,sid,flt,paused)
	{
        
		if (typeof(eid)=='undefined'||eid==null)
			eid = -1;
		if (typeof(pid)=='undefined'||pid==null)
			pid = -1;
		if (typeof(lid)=='undefined'||lid==null)
			lid = -1;
		if (typeof(sid)=='undefined'||sid==null)
			sid = -1;
		if (typeof(flt)=='undefined'||flt==null)
			flt = '';
		if (typeof(paused)=='undefined'||paused==null)
			paused = false;
			
		this.videoParameters = 'pid='+pid+'&eid='+eid+'&lid='+lid+'&sid='+sid+'&flt='+flt
		
		this.videoParent = targetid;
		this.videoParentWidth = width;
		this.videoParentHeight = height;
		var dest = document.getElementById(targetid);
		//var str = '<embed id="myplayer" flashvars="controlbar=none&screencolor=ffffff&stretching=fill" name="myplayer" src="/player/player.swf" width="'+width+'" height="'+height+'" />';
		//dest.innerHTML = str;
		/*
		var so = new SWFObject('/player/player.swf','myplayer',width,height,"9","#ffffff");
		so.addParam('wmode','transparent');
		if (pid==21)
			so.addParam('flashvars','controlbar=none&screencolor=ffffff&stretching=fill&wmode=transparent');
		else
			so.addParam('flashvars','controlbar=none&screencolor=ffffff&stretching=fill&wmode=transparent&file=http://youtube.com/watch%3Fv%3DDdR41fe9Zeg');
		so.write(targetid);
		*/
		
		// allowScriptAccess must be set to allow the Javascript from one 
		// domain to access the swf on the youtube domain
		var params = { allowScriptAccess: "always", bgcolor: "#ffffff", wmode:"transparent" };
		// this sets the id of the object or embed tag to 'myytplayer'.
		// You then use this id to access the swf and make calls to the player's API
		var atts = { id: "myytplayer" };
		this.videoDefaultPaused = paused;
		
		swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer", 
                         targetid, width, height, "8", null, null, params, atts);
		
		this.videos = {"Media":[]};
		//this.videos.Media[0].src = url;
	}
	this.videoDefaultPaused = false;
	this.videoFeedSource = 0;
	this.videoFeedWait = false;
	this.videoFeedChange = function(rslt)
	{
		this.videoFeedWait = false;
		this.videoFeedSource = 0;

		this.videos = {"Media":[{"id":"0","author":"","url":"","link":"","title":"","src":"","date":""}]};

		this.playState = new Function('');
		try {
			this.videoPlayer.stopVideo();
		} catch(ex) { }
				
//var str = '<object type="application/x-shockwave-flash" width="'+this.videoParentWidth+'" height="'+this.videoParentHeight+'" data="/Portals/0/webcamxp.swf">';
//str += '<param name="movie" value="webcamxp.swf?webcam=http://127.0.0.1:8080/cam_1.jpg&amp;refresh=50&amp;connect=&amp;offline=&amp;transtype=Fade&amp;bgcolor=#FFFFFF&amp;txtcolor=#808080" />';
//str += '<param name="FlashVars" value="webcam=http://127.0.0.1:8080/cam_1.jpg&amp;refresh=50&amp;connect=&amp;offline=&amp;transtype=Fade&amp;bgcolor=#FFFFFF&amp;txtcolor=#808080" />';
//str += '<param name="loop" value="false" />';
//str += '<param name="menu" value="false" />';
//str += '<param name="quality" value="best" />';
//str += '<param name="scale" value="noscale" />';
//str += '<param name="salign" value="lt" />';
//str += '<param name="wmode" value="opaque" />';
//str += '</object>';
		
		var FFL = (navigator.userAgent.indexOf("Firefox")!=-1)?true:false;
		if (!FFL)
			FFL = (navigator.userAgent.indexOf("Chrome")==-1 && navigator.userAgent.indexOf("Safari")!=-1)?true:false;
			
		if (!FFL)
		{
			var so = new SWFObject('/Portals/0/webcamxp.swf','myplayer',this.videoParentWidth,this.videoParentHeight,"9","#ffffff");
			so.addParam('flashvars','webcam=http://r2imedia.r2integrated.com:8080/cam_' + rslt + '.jpg&amp;refresh=50&amp;connect=&amp;offline=&amp;transtype=Fade&amp;bgcolor=#FFFFFF&amp;txtcolor=#808080');
			so.addParam('movie','webcamxp.swf?webcam=http://r2imedia.r2integrated.com:8080/cam_' + rslt + '.jpg&amp;refresh=50&amp;connect=&amp;offline=&amp;transtype=Fade&amp;bgcolor=#FFFFFF&amp;txtcolor=#808080');
			so.addParam('loop','false');
			so.addParam('menu','false');
			so.addParam('quality','best');
			so.addParam('scale','noscale');
			so.addParam('salign','lt');
			so.addParam('wmode','opaque');
			so.write(this.videoParent);
		}
		else
		{
			document.getElementById(this.videoParent).innerHTML = '<img src="http://r2imedia.r2integrated.com:8080/cam_' + rslt + '.cgi" class="webcam" id="webcam1" width="'+this.videoParentWidth+'" height="'+this.videoParentHeight+'" alt="Live Stream" />';
		}

//		document.getElementById(this.videoParent).innerHTML = str;

	
	
	}
	this.videoFeedTime = function()
	{
		var dateH = (new Date()).format('hh') * 1;
		var dateM = (new Date()).format('MM') * 1;
		if (dateH >= 5 && dateM >= 10)
		{	
			this.videoFeedSource = 0;
			this.videoFeed();
		}	
		else
		{
			window.setTimeout('skin.videoFeedTime();',10000);
		}
	}
	this.videoFeed = function()
	{
		this.videoFeedSource++;
		if (!this.videoFeedWait)
		{
			this.videoFeedWait = true;
			window.setTimeout('skin.videoFeedChange();',2000);
		}		
	}
	
	this.playVideos = function(player)
	{
		this.videoPlayer = player;
		//this.videoPlayer.addModelListener('STATE','skin.playState');		
		this.playVideo();
	}
	this.playState = function(obj)
	{
		if (obj.newstate == 'COMPLETED')
		{
			this.playVideo();
		}
	}
	this.skipVideo = function()
	{
		this.playVideo();
	}
	this.playVideo = function()
	{
	  var url=this.nextVideo();
		//this.videoPlayer.sendEvent("LOAD",url);
		//this.videoPlayer.sendEvent("PLAY");	
		startNewVideo(url);
	}
	
	this.ajaxItems = new Array();
	this.ajaxCreate = function (name)
	{
		if (typeof this.ajaxItems[name] == 'undefined' || this.ajaxItems[name] == null)
		{
			this.ajaxItems[name] = {"request":false,"response":false};
			eval('this.ajaxItems[name].response = new Function("skin.ajaxResponse(\''+name+'\');");');
			try
			{
				this.ajaxItems[name].request = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try
				{
					this.ajaxItems[name].request = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch(oc)
				{
					this.ajaxItems[name].request = null;
				}
			}
			//Mozilla and Safari 
			if((typeof this.ajaxItems[name].request == 'undefined' || this.ajaxItems[name].request == null) && typeof XMLHttpRequest != "undefined") 
			{
				this.ajaxItems[name].request = new XMLHttpRequest();
			}
		}
	}

	this.ajax = function(name,url)
	{
		this.ajaxCreate(name);
		
		// If browser supports XMLHTTPRequest object
		if(this.ajaxItems[name].request!=null && this.ajaxItems[name].request)
		{
			try {
			//Setting the event handler for the response
			this.ajaxItems[name].request.onreadystatechange = this.ajaxItems[name].response;
			
			//Initializes the request object with GET (METHOD of posting), 
			//Request URL and sets the request as asynchronous.
			this.ajaxItems[name].request.open("GET", url,  true);

			//Sends the request to server
			this.ajaxItems[name].request.send(null);	

			//return XmlHttp.responseText;		
			}
			catch(ex)
			{
			}
		}
	}
		this.assetUrl=function(asset,key){
			var url = '';
			if (typeof asset.thumb != 'undefined' && asset.thumb != null && asset.thumb.length > 0)
				url = '/assets/'+asset.srv+'/'+asset.thumb;
			else
			{
				url = '/assets/'+asset.srv+'/'+asset.src;
			}
			if (typeof key!='undefined' && key!=null)
			{
				var turl = url;
				url = {"url":turl,"key":asset.link};
			}
			return url;
		}
		this.youtubeUrl=function(asset,key)
		{
			var url = '';
			if (typeof asset.thumb != 'undefined' && asset.thumb != null && asset.thumb.length > 0)
				url = asset.thumb;
			else
			{
				url = asset.src;
			}
			if (url!=null && (url.length>url.replace(/youtube/,'').length))
			{
				var ytid = '';
				//http://www.youtube.com/watch?v=aUUvTggn3M0&feature=youtube_gdata
				url = url.replace('http://www.youtube.com/watch?v=','').replace('&feature=youtube_gdata','');
				ytid = url;
				url = 'http://i3.ytimg.com/vi/'+ytid+'/default';
			}
			else
			{
				if (url!=null && url.length>url.replace(/default.flv/,'').length)
				{
					//Nothing to do.
				}
				else
					url = '/assets/'+asset.srv+'/' + url;
			}

			if (typeof key!='undefined' && key!=null)
			{
				var turl = url;
				url = {"url":turl,"key":asset.link};
			}
			return url;


		}
	this.ajaxResponse = function(name)
	{
		 // To make sure receiving response data from server is completed
		 if(this.ajaxItems[name].request.readyState == 4)
		 {
		  // To make sure valid response is received from the server, 200 means response received is OK
		  if(this.ajaxItems[name].request.status == 200)
		  {   
			try
			{
			
				var JSONResult = eval(this.ajaxItems[name].request.responseText);
				this.ajaxItems[name] = null;
			
			//loadExecResult(JSONResult);
			} 
			catch(ex)
			{

			}
		  }
		  else
		  {

		  }
		 }
	}
	/*FB FAN*/
	this.facebook_fanboxes = new Array();
	this.facebook_fanbox=function(id,target,container,item,row,rows,max)
	{
		if (typeof max=='undefined') { max = null; }
		this.facebook_fanboxes['fb'+id] = {"target":target,"container":container,"item":item,"row":row,"rows":rows,"max":max};
		this.ajax('fb'+id,'/Fan.aspx?id='+id);
	}
	this.facebook_fans=function(data)
	{
		var target = this.facebook_fanboxes['fb'+data.id];
		var items = new Array();
		if (data.fans.length>1)
		{
			var lenmax = data.fans.length-1;
			if (target.max!=null && target.max<lenmax) { lenmax=target.max; };
			
			var itemcount = (lenmax)/target.rows;
		
			for (var f=1;f<=lenmax;f++)
			{
				if (data.fans[f].url.length==0) data.fans[f].url='#';
				if (data.fans[f].name[0]=='?') data.fans[f].name='';
				items.push(target.item.replace(/##TOTAL##/g,data.total).replace(/##URL##/g,data.fans[f].url).replace(/##SRC##/g,data.fans[f].src).replace(/##NAME##/g,data.fans[f].name));
				if (f%itemcount==0)
					items.push(target.row);
			}
		}
		$jq(target.target).html(target.container.replace(/##TOTAL##/g,data.total).replace(/##ITEMS##/,items.join('')));		
	}
	this.hide=function(elems)
	{
		if (typeof elems.length!='undefined' && elems.length > 0)
		{
			for (var i = 0;i<elems.length;i++)
				document.getElementById(elems[i]).style.display='none';
		}
	}
	this.show=function(elems)
	{
		if (typeof elems.length!='undefined' && elems.length > 0)
		{
			for (var i = 0;i<elems.length;i++)
				document.getElementById(elems[i]).style.display='block';
		}
	}	
	this.className=function(id,name)
	{
		document.getElementById(id).className=name;
	}
/*	
	this.twitter_retweet=function(sid)
	{
		twttr.anywhere(function(T) {
		  if (T.isConnected()) {
			T.Status.retweet(sid);
		  } else {
			T('#twtLogin').connectButton();
		  }
		});
	}
*/
	this.twitter_follow=function(username,id)
	{
		try {
		eval("twttr.anywhere(function (T) {	T('#'+id).followButton(username);});");
		} catch (ex) { }
	}
	this.twitter_box=function(id,label,width,height,content,targetId,maxcount,txtBox,StatusID,statusText,moduleId,statusHidden,showNow,txtLatitude,txtLongitude)
	{
		try {
		  eval('twttr.anywhere(function (T) {'+
			'T("#'+id+'").tweetBox({'+
			  'height: '+height+','+
			  'width: '+width+','+
			  'label: "'+label+'",'+
			  'defaultContent: "'+content+'",'+
			  'onTweet: function(p,h){skin.twitter(p,h,"'+targetId+'",'+maxcount+',"'+txtBox+'","'+StatusID+'","'+statusText+'",'+moduleId+',"'+statusHidden+'",'+showNow+',"'+txtLatitude+'","'+txtLongitude+'")}'+
			'}); });	');
		} catch(ex) { }
	}
	this.twitter=function(plain,html,targetId,maxcount,txtBox,StatusID,statusText,moduleId,statusHidden,showNow,txtLatitude,txtLongitude)
	{
		document.getElementById(txtBox).value = plain;
		skin.sendComment(targetId,maxcount,txtBox,StatusID,statusText,moduleId,statusHidden,showNow,txtLatitude,txtLongitude);
	}
}
//twttr.anywhere.config({assetHost:'twitter-any.s3.amazonaws.com'});
var skin = new SkinClass();
//skin.runImages();
/*
function playerReady(obj) {
	var objX = document.getElementById(obj['id']);
	if (typeof obj['id'] == 'undefined')
	{
		objX = document.getElementById('myplayer');
	}
	skin.playVideos(objX);
};
*/
function mapClass(id,obj,type,icon,skinobj)
{
	this.id = id;
	this.obj = obj;
	this.type = type;
	this.icon = icon;
	this.points = new Array();
	this.init = function() {
		switch(this.type)
		{
			case 'google':
					this.obj = new GIcon(); 
					var img = this.icon;
					//this.icon.image = 'http://charleneli.r2ismash.com/images/chat.png';
					this.icon.image = img;
					//this.icon.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
					this.icon.iconSize = new GSize(19, 19);
					this.icon.shadowSize = new GSize(20, 20);
					this.icon.iconAnchor = new GPoint(6, 20);
					this.icon.infoWindowAnchor = new GPoint(19, 19);
						GEvent.addListener(this.obj, "click", function(overlay, point) {
						 if( overlay )
						 {
							skin.map.obj.openInfoWindowHtml(overlay.infopoint,overlay.info);
						 }
						 else
						 {
						
						 }
					});	
				break;
			case 'bing':
				if (typeof this.obj == 'undefined' || this.obj==null)
				{
					if (document.getElementById(this.id)!=null)
						this.obj = document.getElementById(this.id);
				}
				break;
		}	
	}
	this.plot = function(lat,lon,text,author,avatar,posted)
	{
		switch(this.type)
		{
			case 'google':
				this.google(lat,lon,text);
				break;
			case 'bing':
				this.bing(lat,lon,text,author,avatar,posted);
				break;
		}
	}
	this.google = function(lat,lon,text)
	{
		if (typeof this.obj != 'undefined' && this.obj!=null)
		{

			var options = { 
				draggable: false,
				bouncy: true,
				icon: this.mapIcon
			};

			var point = new GLatLng(lat,lon);
			var marker = new GMarker(point,options);
			marker.info = text;
			marker.infopoint = point;
			this.points.push(marker);
			this.obj.addOverlay(marker);
			this.obj.openInfoWindowHtml(point,text);
			this.obj.panTo(point);
			while (this.points.length>50)
			{
				//remove the points...
				marker = this.points.pop();
				this.obj.removeOverlay(marker);
			}
		}
	}
	this.bing = function(lat,lon,text,author,avatar,posted)
	{	
		if (typeof this.obj == 'undefined' || this.obj==null)
		{
			if (document.getElementById(this.id)!=null)
				this.obj = document.getElementById(this.id);
		}
		if (typeof this.obj != 'undefined' && this.obj!=null)
		{
			this.obj.Content.objMap.Navigate(lon,lat,text.replace(/&amp;/g,'&').replace(/&quot;/g,'"'),author,avatar,posted);
		}
	}	
	//initialize the map
	this.init();
	skinobj.map = this;
}

function imageCycle(name,id,cclass,iwidth,iheight,iclass,count,frequency,position,direction,callback,pid,eid,lid,sid,onclick) {
		if (typeof(eid)=='undefined'||eid==null)
			this.eid = -1;
		else
			this.eid = eid;
		if (typeof(pid)=='undefined'||pid==null)
			this.pid = -1;
		else
			this.pid = pid;
		if (typeof(lid)=='undefined'||lid==null)
			this.lid = -1;
		else
			this.lid = lid;
		if (typeof(sid)=='undefined'||sid==null)
			this.sid = -1;	
		else
			this.sid = sid;
		if (typeof(onclick)=='undefined'||onclick==null)
      this.onclick=false;
     else
      this.onclick=onclick;
	this.name = name;
	this.id = id;
	this.target = $jq('#'+id);
	this.cclass=cclass;
	this.iwidth=iwidth;
	this.iheight=iheight;
	this.iclass=iclass;
	this.count=count;
		this.loaded=false;
	this.frequency=frequency;
	if(this.frequency <= 0)
		this.frequency=1000;
	this.position=position;
	this.direction=direction;
	this.callback=callback;
	
	this.timer = null;
	this.items = new Array();


	this.cycler = 0;
	this.imagePreloader = new Array();
	this.getLastImage = function(selector)
	{
		var obj = $jq(selector);
		var img = obj.children('img');
		if (img!=null&&img.length>0)
			return img.attr('src');
		return null;
	}
	this.drop = function(selector)
	{
 		var obj = $jq(selector);
		obj.remove();
		img =null;
		obj = null;
	}
	this.slide = function(selector)
	{
		$jq(selector).animate({width: this.iwidth},(this.frequency*.25));
	}
	this.cycle = function()
	{
		this.cycler++;
		if (this.cycler>10000) this.cycler=0;
		var nurl = null;
		var url = null;
		var nkey = null;
		var key = null;
		try {
			eval('nurl='+this.callback);
			key = '';
			if (typeof nurl.key != 'undefined' && nurl.key!=null)
			{	
				nkey = nurl.key;
				nurl = nurl.url;
			}
		}
		catch(ex)
		{
			nurl = null;
			nkey = null;
		}
		if (nurl!=null)
		{	
		
		var bufferCount = 2;
		if (skin.display_image.length>0)
			bufferCount = 4;
			if (this.imagePreloader.length==bufferCount)
			{
				url = this.imagePreloader[0].src;
				key = this.imagePreloader[0].alt;
				if (skin.display_image.length>0)
          this.imagePreloader.splice(0,2);
        else
          this.imagePreloader.splice(0,1);  
			}
			
			var smallImage = new Image();
			var largeImage = new Image();
			
			smallImage.src = nurl;
			smallImage.alt = nkey;
			this.imagePreloader.push(smallImage);
							
							
			if (skin.display_image.length>0)
			{
				largeImage.alt = nurl+'.large.jpg';
				largeImage.key = nkey;
				this.imagePreloader.push(largeImage);
			}
			
			if (skin.display_image.length>0&&this.imagePreloader.length==4)
			{
				skin.showFullImage(this.imagePreloader[1].src,this.frequency);				
			}
			
		}
		if (url!=null)
		{	
				var remove = null;
				if (this.items.length == this.count)
				{
					remove = '#'+this.items[0];
					this.items.splice(0,1);
				}
				var itemid = this.id+'s'+this.cycler;
				skin.transferid = itemid;

				var item = '';
				if (this.direction!='random')
				{
					item = '<div id="'+itemid+'" style="display:none;width:0;position:relative;float:'+this.direction+'" class="'+this.cclass+'">';
					item = item +'<img style="position:absolute;left:0;top:0;" id="'+itemid+'img" src="'+url+'" width="'+this.iwidth+'" height="'+this.iheight+'" class="'+this.iclass+'"/>';
					
					if (this.onclick)
						item = item +'<img style="position:absolute;left:0;top:0;" src="'+skin.skinpath+'/_i/frame.gif" onclick="'+this.onclick.replace(/##URL##/g,url).replace(/##KEY##/g,key)+'" width="'+this.iwidth+'" height="'+this.iheight+'" class="'+this.iclass+'"/>';
					else
						item = item +'<img style="position:absolute;left:0;top:0;" src="'+skin.skinpath+'/_i/frame.gif" width="'+this.iwidth+'" height="'+this.iheight+'" class="'+this.iclass+'"/>';								
						
					item = item + '</div>'
				}
				else
				{
					var maxWidth = 327;
					var maxHeight = 218;
					var px = Math.floor(Math.random()*(this.iwidth-maxWidth));
					var py = Math.floor(Math.random()*(this.iheight-maxHeight));
					
					item = '<div id="'+itemid+'" style="display:none;width:0;position:absolute;top:'+py+'px;left:'+py+'px;" class="'+this.cclass+'">';
					if (this.onclick)
						item = item +'<img style="position:absolute;left:0;top:0;" id="'+itemid+'img" src="'+url+'.large.jpg" onclick="'+this.onclick.replace(/##URL##/g,url).replace(/##KEY##/g,key)+'" class="'+this.iclass+'"/>';
					else
						item = item +'<img style="position:absolute;left:0;top:0;" id="'+itemid+'img" src="'+url+'.large.jpg" class="'+this.iclass+'"/>';				
					item = item + '</div>'				
				}

		
				
				this.items.push(itemid);

				var rItem = null;
				if (remove!=null) rItem = $jq(remove);
				
				switch(this.direction)
				{
					case 'left':
							this.target.prepend(item);
						if (remove!=null)
						{
							eval('rItem.hide(\'slide\',{},'+(this.frequency/10)+', function() {'+this.name+'.drop(\''+remove+'\');'+this.name+'.slide(\'#'+itemid+'\');});');	
						}
						else
						{
							this.slide('#'+itemid);
						}
						break;
					case 'right':
							this.target.prepend(item);
						//aItem.animate({width: this.iwidth},750);
						
						if (remove!=null)
						{
							eval('rItem.hide(\'slide\',{},'+(this.frequency/10)+', function() {'+this.name+'.drop(\''+remove+'\');'+this.name+'.slide(\'#'+itemid+'\');});');	
						}
						else
						{
							this.slide('#'+itemid);
						}
						//eval('if (remove!=null) rItem.animate({ width:"0",display:"none" }, { queue:false, duration:500, complete: function() {'+this.name+'.drop(\''+remove+'\');}});');
						//aItem.animate({ width:this.iwidth, display:"block" }, { queue:false, duration:1000},'swing');				
						break;
					case 'down':
							this.target.prepend(item);
						if (remove!=null)
						{
							$jq(remove).hide('slow',function() {$jq(this).remove()});
						}
						$jq('#'+itemid).slideDown();
						break;
					case 'up':
						this.target.append(item);
						if (remove!=null)
						{
							$jq(remove).hide('slow',function() {$jq(this).remove()});
						}
						$jq('#'+itemid).slideUp();
					case 'random':
						this.target.append(item);
						if (remove!=null)
						{
							$jq(remove).hide('slow',function() {$jq(this).remove()});
						}
						$jq('#'+itemid).fadeIn();						
						break;
				}
				
				rItem = null;
				itemid = null;
				item = null;
				//aItem = null;
		}
		
		if (this.cycler>this.count+bufferCount&&!this.loaded)
			this.loaded=true;
		window.setTimeout(this.name+'.cycle();',(this.loaded?this.frequency:400));
	}
	this.cycle();
}

function imageCycleProperties(callback,pid,eid,lid,sid)
{
		if (typeof(eid)=='undefined'||eid==null)
			this.eid = -1;
		else
			this.eid = eid;
		if (typeof(pid)=='undefined'||pid==null)
			this.pid = -1;
		else
			this.pid = pid;
		if (typeof(lid)=='undefined'||lid==null)
			this.lid = -1;
		else
			this.lid = lid;
		if (typeof(sid)=='undefined'||sid==null)
			this.sid = -1;	
		else
			this.sid = sid;
		
		this.getURL = function()
		{
			var nurl = null;
			var url = null;
			try {
				eval('nurl='+this.callback);
			}
			catch(ex)
			{
				nurl = null;
			}	
			return nurl;
		}
}

function smashStream(name,entryType,count,iDefault,autoRestart)
{
  this.autoRestart=false;
  if (typeof autoRestart=='undefined' || autoRestart == null)
    this.autoRestart=autoRestart;
  this.domain = 'http://'+document.domain;
  this.serviceurl = '/services/service.ashx';
  this.iDefault = iDefault;
  this.name = name;
  this.entryType = entryType;
  this.count=count;
  this.stream = {"Media":[]};
	this.LastIndex = -1;
	this.Index = 0;
	this.display_images = new Array();
	this.display_text = new Array();
	this.display_image = new Array();
	this.Wait = false;
	this.Max = false;
	this.Error = false;
	
	this.load = function(content)
	{
		if (content.Media.length > 0)
		{
			this.stream = content;
			this.Index = 0;
		}
    else
    {
    if (this.autoRestart)
      this.Max=true;
    }
		this.Wait = false;
	}
  this.run = function(pid,eid,lid,sid)
	{
		if (typeof(eid)=='undefined'||eid==null)
			eid = -1;
		if (typeof(pid)=='undefined'||pid==null)
			pid = -1;
		if (typeof(lid)=='undefined'||lid==null)
			lid = -1;
		if (typeof(sid)=='undefined'||sid==null)
			sid = -1;
		
		this.get(pid,eid,lid,sid);
	}
	
	/*
	this.getLastImage = function(selector)
	{
		var obj = $jq(selector);
		var img = obj.children('img');
		if (img!=null&&img.length>0)
			return img.attr('src');
		return null;
	}
	*/
  
  this.next = function(pid,eid,lid,sid) {
      var result = this.iDefault;
		
			if (this.Index < this.stream.Media.length)
			{
				//SHOW THE ITEM
				this.LastIndex=this.stream.Media[this.Index].id;			
				result = this.stream.Media[this.Index];
			}
			this.Index=this.Index+1;
			if (this.Index >= this.stream.Media.length && !this.Wait)
			{
				this.get(pid,eid,lid,sid);
			}	
      return result;
	}
	
  this.get = function(pid,eid,lid,sid) {
		if (this.Error)
		{
			window.clearTimeout(this.Error);
			this.Error =false;
		}
		this.Wait = true;

		var extras = '';
		if (pid>-1)
			extras=extras+'&pid='+pid;
		if (eid>-1)
			extras=extras+'&eid='+eid;
		if (lid>-1)
			extras=extras+'&lid='+lid;
		if (sid>-1)
			extras=extras+'&sid='+sid;
		if (this.count>-1)
      extras=extras+'&count='+this.count;
      
		if (!this.Max)
		{
			skin.ajax(this.name,this.domain+this.serviceurl+'?stmp='+(new Date()).format('mmddyyyyhhMMss')+'&type=json'+extras+'&src='+this.entryType+'&id='+this.LastIndex+'&pre='+this.name+'.load(&post=);');
		}
		else
		{
			this.Max=false;
			skin.ajax(this.name,this.domain+this.serviceurl+'?stmp='+(new Date()).format('mmddyyyyhhMMss')+'&type=json'+extras+'&src='+this.entryType+'&max=1&pre='+this.name+'.load(&post=);');
		}
		this.Error = window.setTimeout ( this.name+'.Wait=false;', 20000 );
		
	}
}

        function updateHTML(elmId, value) {
          document.getElementById(elmId).innerHTML = value;
        }

        function setytplayerState(newState) {
          //updateHTML("playerstate", newState);
			if (translateYTPState(newState) == 'ended') { //&& parseInt(getCurrentTime()) > 0)
				skin.playVideo();
          }
        }

	
        function onYouTubePlayerReady(playerId) {
          ytplayer = document.getElementById("myytplayer");
          //setInterval(updateytplayerInfo, 250);
          //updateytplayerInfo();
          
		  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
		  skin.playVideos(ytplayer);

          //ytpEventTracker._trackEvent("Player Loaded", eventLabel);
	}

        function onytplayerStateChange(newState) {
          setytplayerState(newState);
        }

        function translateYTPState(state) {
          switch (state) {
            case -1: return "unstarted";
            case 0 : return "ended";
            case 1 : return "playing";
            case 2 : return "paused";
            case 3 : return "buffering";
            case 5 : return "video cued";
          }
          return;
        }

        function onPlayerError(errorCode) {
          alert("An error occurred: "+ errorCode);
          //ytpEventTracker._trackEvent("Error: " + errorCode, eventLabel);
        }

        function updateytplayerInfo() {
          updateHTML("bytesloaded", getBytesLoaded());
          updateHTML("bytestotal", getBytesTotal());
          updateHTML("videoduration", getDuration());
          updateHTML("videotime", getCurrentTime());
          updateHTML("startbytes", getStartBytes());
          updateHTML("volume", getVolume());
        }

        // functions for the api calls
        function loadNewVideo(id, startSeconds) {
          if (ytplayer) {
            ytplayer.loadVideoById(id, startSeconds);
	  }
        }

        function cueNewVideo(url, startSeconds) {
          if (ytplayer) {
			var vid=url.replace('http://i3.ytimg.com/vi/','').replace('/default','');
            ytplayer.cueVideoById(vid, startSeconds);
			play();
          }
        }
    
	var eventLabel;
	var nowPlaying;
	function startNewVideo(url) {
	  // if there is a current video playing, record the end
	  var oldTime = parseInt(getCurrentTime());
          var oldEventLabel = eventLabel;

          if (oldTime > 0) { 
	    recordEnd(oldEventLabel, oldTime);
	  }	
			var vid = '';
			if (url.length > url.replace('www.youtube.com','').length)
			{
				vid=url.replace('http://www.youtube.com/watch?v=','').replace('&feature=youtube_gdata','');
			}
			if (url.length > url.replace('.ytimg.com').length)
			{
				vid=url.replace('http://i3.ytimg.com/vi/','').replace('/default','');
			}

			if (vid.length > 0)
				loadNewVideo(vid, 0);
			
          //ytpEventTracker._trackEvent("Video Started", eventLabel);
	}

        function recordEnd(l,t) {
           // ytpEventTracker._trackEvent("Ended", l, parseInt(t));
        }

        function play() {
          if (ytplayer) {
            ytplayer.playVideo();
            //ytpEventTracker._trackEvent("Play",eventLabel);
          }
        }

        function pause() {
          if (ytplayer) {
            ytplayer.pauseVideo();
            //ytpEventTracker._trackEvent("Pause",eventLabel);
	  }
        }

        function stop() {
          if (ytplayer) {
            ytplayer.stopVideo();
            //ytpEventTracker._trackEvent("Stop",eventLabel);
          }
        }

        function getPlayerState() {
          if (ytplayer) {
            return ytplayer.getPlayerState();
          }
        }

        function seekTo(seconds) {
          if (ytplayer) {
            ytplayer.seekTo(seconds, true);
            //ytpEventTracker._trackEvent("Seek To: " + seconds, eventLabel); 
          }
        }

        function getBytesLoaded() {
          if (ytplayer) {
            return ytplayer.getVideoBytesLoaded();
          }
        }

        function getBytesTotal() {
          if (ytplayer) {
            return ytplayer.getVideoBytesTotal();
          }
        }

        function getCurrentTime() {
          if (ytplayer) {
            return ytplayer.getCurrentTime();
          }
        }

        function getDuration() {
          if (ytplayer) {
            return ytplayer.getDuration();
          }
        }

        function getStartBytes() {
          if (ytplayer) {
            return ytplayer.getVideoStartBytes();
          }
        }

        function mute() {
          if (ytplayer) {
            ytplayer.mute();
            //ytpEventTracker._trackEvent("Mute",eventLabel);
          }
        }

        function unMute() {
          if (ytplayer) {
            ytplayer.unMute();
            //tpEventTracker._trackEvent("Unmute",eventLabel);
          }
        }
        
        function getEmbedCode() {
          alert(ytplayer.getVideoEmbedCode());
	  //ytpEventTracker._trackEvent("Get Embed Code", eventLabel); 
        }

        function getVideoUrl() {
          alert(ytplayer.getVideoUrl());
          //ytpEventTracker._trackEvent("Get Video URL", eventLabel); 
	}
        
        function setVolume(newVolume) {
          if (ytplayer) {
            ytplayer.setVolume(newVolume);
          }
        }

        function getVolume() {
          if (ytplayer) {
            return ytplayer.getVolume();
          }
        }

        function clearVideo() {
          if (ytplayer) {
            ytplayer.clearVideo();
          }
        }

	function ImageStream(moduleId,portalId,width,height,count,restart,frequency,align,direction,rewriteShowVideo) {
		var sA = new Array();
		sA.push('var vgs'+moduleId+' = {"m":'+moduleId+',"p":'+portalId+',"width":'+width+',"height":'+height+',"count":'+count+',"restart":'+restart+',"frequency":'+frequency+',"align":"'+align+'","direction":"'+direction+'"};');
		sA.push('var vgsStream'+moduleId+' = new smashStream(\'vgsStream\'+vgs'+moduleId+'.m,\'video\',8,{');
		sA.push('"src":"/Portals/"+vgs'+moduleId+'.p+"/default.flv",');
		sA.push('"title":"11/4/2009 2:27:55 PM",');
		sA.push('"date":"11/4/2009 2:27:55 PM",');
		sA.push('"author":"",');
		sA.push('"link":"",');
		sA.push('"type":"",');
		sA.push('"id":"-1"},vgs'+moduleId+'.restart); ');
		sA.push('vgsStream'+moduleId+'.run(vgs'+moduleId+'.p,-1,-1,-1); ');
		//sA.push('var vgsICycle'+moduleId+' = null; ');
	
		sA.push("var vgsICycle"+moduleId+"=new imageCycle(");
		sA.push("'vgsICycle'+vgs"+moduleId+".m,");
		sA.push("'pstream'+vgs"+moduleId+".m,");
		sA.push("'SmallPhotoContainer',");
		sA.push("vgs"+moduleId+".width,");
		sA.push("vgs"+moduleId+".height,");
		sA.push("'SmallPhotoItem',");
		sA.push("vgs"+moduleId+".count, ");
		sA.push("vgs"+moduleId+".frequency,");
		sA.push("vgs"+moduleId+".direction,");
		sA.push("vgs"+moduleId+".align,");
		sA.push("'skin.youtubeUrl(vgsStream'+vgs"+moduleId+".m+'.next(vgsICycle'+vgs"+moduleId+".m+'.pid,vgsICycle'+vgs"+moduleId+".m+'.eid,vgsICycle'+vgs"+moduleId+".m+'.lid,vgsICycle'+vgs"+moduleId+".m+'.sid))+\'.jpg\';',");
		sA.push("vgs"+moduleId+".p,");
		sA.push("-1,-1,-1,");
		sA.push("'showVideo(\'##URL##\');',");
		sA.push("vgs"+moduleId+".restart); ");
	
		if (rewriteShowVideo) {
		sA.push('function showVideo(url) ');
		sA.push('{ ');
		sA.push('	url=url.replace(/.jpg/g,\'\'); ');
		sA.push('	skin.currentVideo=url; ');
		sA.push('	skin.videos = {');
		sA.push('	"Media":[');
		sA.push('		{"id":"-1","author":"","url":url,"link":url,"title":"","src":url,"date":""}]}; ');
		sA.push('	startNewVideo(url); ');
		sA.push('	} ');
		}

		return sA.join('');
	}	
		
		
		//window.setTimeout("showVideo('http://i3.ytimg.com/vi/XG69vrLDxOc/default.jpg');",5000);
		function loadDefaultVideo(burl)
		{
			/*
			if (typeof burl=='undefined')
				burl = null;
			if (typeof ytplayer == 'undefined' || ytplayer == null)
				window.setTimeout("loadDefaultVideo('"+burl+"');",1000);
			else
			{
				if (burl!=null)
					cueNewVideo(burl,0);
				else {
					var url = skin.nextVideo();
					if (url==null)
						window.setTimeout("loadDefaultVideo();",1000);
					else
					{
						if (url.length > url.replace('default.flv').length)
						{
							url = skin.nextVideo();
						}
						if (url==null)
							window.setTimeout("loadDefaultVideo();",1000);
						else
						{
							startNewVideo(url);
						}
					}
				}
			}
			*/
		}
		function startDefaultVideo() {
			if (typeof defaultVideoUrl!='undefined' && defaultVideoUrl!=null)
				loadDefaultVideo(defaultVideoUrl);
			else
				loadDefaultVideo();
		}
			window.setTimeout("startDefaultVideo();",1000);	
