//  This file requires staticModal.js to be loaded first.

if(!console) {
	var console = {
		log: function() {
			for(var x; x<arguments.length; x++) {
				alert(arguments[x]);
			}
		}	
	}
};

// If the stc object doesn't exist, create it.
if(!stc) var stc = new Object();

stc.bc = {
	
	broadcastLink: "staticNavBroadcast",
	
	useModal: true,
	
	charCount: 140,
	
	init: function(e) {
		YAHOO.util.Event.addListener(stc.bc.broadcastLink, "click", stc.bc.loadForm);
		if(typeof(stcPreventBC) !== "undefined") {
			stc.bc.countInit();
		}
		if(typeof(stcshwbc) !== "undefined") {
			stc.bc.loadForm(this);
		}
	},
	
	loadForm: function(e, bcType) {	
		YAHOO.util.Event.preventDefault(e);
		if(typeof(stcPreventBC) !== "undefined") {
			return false;
		}
		if(bcType) {
			stc.bc.bcType = bcType;
		}
		stc.bc.foundLink = "";
		stc.bc.charCount = 140;
		var params = new Array();
		
		params['responseFunction'] = stc.bc.useModal?stc.bc.displayModal:stc.bc.displayResults;
		params['templateName'] = 'component/createBroadcast';
		params['action'] = 'loadTemplate';
		params['responseType'] = 'JSON';
		params['handlerName'] = 'one_ajax_templateLoader';
		params['requestType'] = 'class';
		params['sdb'] = 1;
		
		OneAjax.request(params);
	},
	
	cancel: function(e) {
		if(document.getElementById("toolbarRefresh").value=true) {
			window.location.reload();
		}
	},
	
	displayResults: function(o) {
		if(o.output == "refresh"){
			window.location.reload(true);
			return;
		}
		stc.bc.roller = new stc.roll();
		stc.bc.roller.rContent = o.output;
		stc.bc.roller.rKillCallback = stc.bc.addTopBox;
		stc.bc.roller.rCreate();
		stc.bc.roller.rRollit();
		stc.bc.countInit();
	},
	
	displayModal: function(o) {
		if(o.output == "refresh"){
			window.location.reload(true);
			return;
		}
		stc.mbc = new stc.modal();
		stc.mbc.boxTitle = "Create New Broadcast";
		stc.mbc.content = o.output;
		this.create = stc.mbc.create();
		YAHOO.util.Event.removeListener("broadcastCancel", "click");
		YAHOO.util.Event.addListener("broadcastCancel", "click", function(e){stc.mbc.destroy(e,stc.mbc.cssName+"_modal_bounder");});
		stc.bc.countInit();
		if(stc.bc.bcType) {
			switch(stc.bc.bcType) {
				case "live":
					stc.bc.addLive();
				break;	
			}
		}
	},
	
	makeAnnounce: function() {
		var ckBox = document.getElementById('makeAnnouncement');
		if(ckBox.checked == true) {
			YAHOO.util.Dom.setStyle("broadcastAttachButtons", "display", "none");
			YAHOO.util.Dom.setStyle("broadcastCategoryCont", "display", "none");
			YAHOO.util.Dom.setStyle("bcAnnouncementTitle", "display", "block");
			document.getElementById("broadcastType").value = "announcement";
		}
		else {
			YAHOO.util.Dom.setStyle("broadcastAttachButtons", "display", "block");
			YAHOO.util.Dom.setStyle("broadcastCategoryCont", "display", "block");
			YAHOO.util.Dom.setStyle("bcAnnouncementTitle", "display", "none");
			document.getElementById("broadcastType").value = "status";
		}

	},
	
	addPhoto: function(_link) {
		YAHOO.util.Dom.setStyle("broadcastAttachButtons", "display", "none");
		YAHOO.util.Dom.setStyle("broadcastPhotoCont", "display", "block");
	},
	
	addVideo: function(_link) {
		YAHOO.util.Dom.setStyle("broadcastAttachButtons", "display", "none");
		YAHOO.util.Dom.setStyle("broadcastVideoCont", "display", "block");
	},
	
	addPhotoSwfu: function() {
		YAHOO.util.Dom.setStyle("uploadObject", "display", "none");
		YAHOO.util.Dom.setStyle("broadcastAttachButtons", "display", "none");
		YAHOO.util.Dom.setStyle("broadcastPhotoCont", "display", "block");
		YAHOO.util.Dom.setStyle("swfuPhotoButton", "display","block");
		YAHOO.util.Dom.setStyle("bcMakeAnnouncement", "display", "none");
		stc.swfu.stcUpload = new SWFUpload(stc.swfu.photo); 
		stc.bc.charCount = 110;
		stc.bc.countChars("");
	},
	
	addVideoSwfu: function () {
		YAHOO.util.Dom.setStyle("vidUploadObject", "display", "none");
		YAHOO.util.Dom.setStyle("broadcastAttachButtons", "display", "none");
		YAHOO.util.Dom.setStyle("broadcastVideoCont", "display", "block");
		YAHOO.util.Dom.setStyle("swfuVideoButton", "display","block");
		YAHOO.util.Dom.setStyle("bcMakeAnnouncement", "display", "none");
		stc.swfu.stcUpload = new SWFUpload(stc.swfu.video); 
		stc.bc.charCount = 110;
		stc.bc.countChars("");
	},
	
	addLink: function(_link) {
		YAHOO.util.Dom.setStyle("broadcastAttachButtons", "display", "none");
		YAHOO.util.Dom.setStyle("broadcastLinkCont", "display", "block");
		YAHOO.util.Dom.setStyle("broadcastDescCont", "display", "block");
		YAHOO.util.Dom.setStyle("bcMakeAnnouncement", "display", "none");
		stc.bc.growCont();
		document.getElementById("broadcastType").value = "web";
		if(_link) {
			document.getElementById("broadcastLink").value = _link;	
		}
		stc.bc.charCount = 110;
		stc.bc.countChars("");
	},
	
	addLive: function() {
		YAHOO.util.Dom.setStyle("broadcastAttachButtons", "display", "none");
		YAHOO.util.Dom.setStyle("broadcastLiveCont", "display", "block");
		YAHOO.util.Dom.setStyle("broadcastDescCont", "display", "block");
		document.getElementById("broadcastType").value = "live";
		stc.bc.charCount = 110;
		stc.bc.countChars("");
	},
	
	tryPhotoUpload: function(type) {
		if(type == "photo") {
			this._path = '/admin/quickupload.one?a=upload_photo';
			this._formName = "broadcastPhotoForm";
		}
		else if(type == "video") {
			this._path = '/admin/quickupload.one?a=upload_video';
			this._formName = "broadcastVideoForm";
		}
		else return;
		if(stc.bc.useNewPath) {
			this.coreu = document.getElementById('stcU').value;
			this.corex = document.getElementById('stcX').value;
			this._path = "http://services.onesite.com/rest/ugcPhoto?action=uploadPhoto&coreU="+this.coreu+"&coreX="+this.corex+"&method=file&includeFullObjects=1";
		}
		this.msgBox = document.getElementById("bcMessageBox");
		this.msgBox.innerHTML = "<span>Uploading "+type+" for attachment...</span>";
		
		document.getElementById("broadcastSubmit").disabled = true;
		YAHOO.util.Dom.setStyle("uploadObject", "visibility", "hidden");
	
		this.createSuccess = function(o) {		
			if(stc.bc.useNewPath) console.log(o);	
			if(o.responseText !== undefined){ 
				try {
					//Try to parse the response into an array
					var resultArray = eval('(' + o.responseText + ')');
				}
				catch(e) {
					this.msgBox = document.getElementById("bcMessageBox");
					this.msgBox.innerHTML = "<span>Photo upload failed.</span>";
					//Caught an exception - alert the message
					return;
				}	
				if(type=="photo") {
					stc.bc.getPhotoURL(resultArray.content.uploadObject.photo_id, resultArray.message);
				}
				else {
					stc.bc.getVidURL(resultArray.content.uploadObject.video_id, resultArray.message);
				}
			} 
		}
	
		this.displayError = function (o) {
	
			this.msgBox = document.getElementById("bcMessageBox");
			this.msgBox.innerHTML = "<span>Photo upload failed.</span>";
		}
	
		YAHOO.util.Connect.setForm(this._formName, true, true); 
	
		//Make the ajax request to upload the file
		var upConnect = YAHOO.util.Connect.asyncRequest('POST', this._path, { upload:this.createSuccess,failure: this.displayError}); 

	},
	
	getPhotoURL: function(pid, message) {
		var params = new Array();
		
		this.msgBox = document.getElementById("bcMessageBox");
		this.msgBox.innerHTML = "<span>Upload: "+message+". Getting Photo URL</span>";
		
		params['responseFunction'] = stc.bc.insertThumb;
		params['templateName'] = 'component/_photoFactory';
		params['action'] = 'loadTemplate';
		params['responseType'] = 'JSON';
		params['handlerName'] = 'one_ajax_templateLoader';
		params['requestType'] = 'class';
		params['pid'] = pid;
		params['sdb'] = 1;
		params['type'] = "photo";
		
		OneAjax.request(params);
	},
	
	getVidURL: function(pid, message) {
		var params = new Array();
		
		this.msgBox = document.getElementById("bcMessageBox");
		this.msgBox.innerHTML = "<span>Upload: "+message+". Getting Photo URL</span>";
		
		params['responseFunction'] = stc.bc.insertVid;
		params['templateName'] = 'component/_photoFactory';
		params['action'] = 'loadTemplate';
		params['responseType'] = 'JSON';
		params['handlerName'] = 'one_ajax_templateLoader';
		params['requestType'] = 'class';
		params['pid'] = pid;
		params['sdb'] = 1;
		params['type'] = "video";
		
		OneAjax.request(params);
	},
	
	insertThumb: function(o) {
		
		this.msgBox = document.getElementById("bcMessageBox");
		this.msgBox.innerHTML = "";
		
		this.photo = eval ('('+o.output+')');
		this.container = document.getElementById('broadcastPhotoCont');
		this.photoField = document.getElementById('uploadObject');
		YAHOO.util.Dom.setStyle(this.photoField, "display", "none");
		YAHOO.util.Dom.setStyle("swfuPhotoButton", "display","none");
		
		this.newImg = document.createElement('img');
		this.newImg.id = "broadcastPhotoPreview";
		this.newImg.setAttribute('src',this.photo.thumb);
		this.newImg.setAttribute('height', '80');
		
		this.imgLabel = document.createElement('label');
		this.imgLabel.setAttribute('for', "broadcastPhotoPreview");
		this.imgLabel.innerHTML = "Image:";
		
		document.getElementById("broadcastPhotoURL").value = this.photo.large;
		document.getElementById("broadcastPhotoPage").value = this.photo.page;
		
		this.container.appendChild(this.newImg);
		
		YAHOO.util.Dom.setStyle("broadcastDescCont", "display", "block");
		
		document.getElementById("broadcastType").value = "image";
		
		document.getElementById("broadcastSubmit").disabled = false;
		
		stc.bc.growCont();
		
	},
	
	insertVid: function(o) {
		this.msgBox = document.getElementById("bcMessageBox");
		this.msgBox.innerHTML = "";
		
		this.photo = eval ('('+o.output+')');
		this.container = document.getElementById('broadcastVideoCont');
		this.photoField = document.getElementById('vidUploadObject');
		YAHOO.util.Dom.setStyle(this.photoField, "display", "none");
		YAHOO.util.Dom.setStyle("swfuVideoButton", "display","none");
		
		this.newImg = document.createElement('img');
		this.newImg.id = "broadcastVideoPreview";
		this.newImg.setAttribute('src',this.photo.preview);
		this.newImg.setAttribute('height', '80');
		
		document.getElementById("broadcastPhotoURL").value = "";
		document.getElementById("broadcastPhotoPage").value = this.photo.url;
		
		this.container.appendChild(this.newImg);
		
		YAHOO.util.Dom.setStyle("broadcastDescCont", "display", "block");
		
		document.getElementById("broadcastType").value = "video";
		
		document.getElementById("broadcastSubmit").disabled = false;
		
		stc.bc.growCont();

	},
	
	growCont: function() {
		
		YAHOO.util.Dom.setStyle("broadcastHolder", "height", "auto");
	},
	
	submitBroadcast: function () {
		var params = new Array();
		
		this.msgBox = document.getElementById("bcMessageBox");
		
		this.groupBox = document.getElementById("broadcastGroup");
		this.catBox = document.getElementById("broadcastCategory");
		
		params['contType'] = document.getElementById("broadcastType").value;
		params['contXREF'] = document.getElementById("broadcastPhotoPage").value;
		params['contURL'] = params['contXREF'];
		params['contTitle'] = encodeURIComponent(document.getElementById("broadcastTitle").value);
		params['contGroup'] = this.groupBox?this.groupBox.options[this.groupBox.selectedIndex].value:1;
		params['contCat'] = this.catBox.options[this.catBox.selectedIndex].value;
		if(params['contType'] == "announcement") {
			params['annTitle'] = encodeURIComponent(document.getElementById("announcementTitleInput").value);
		}
		
		if((params['contTitle']=="" || params['contCat']=="") && params['contType'] != 'announcement') {
			this.msgBox.innerHTML = "<span>Your broadcast must have a message and a category.</span>";
			return false;
		}
		
		if(params['contType'] == "live") {
			var sts = new Date();
			params['contType'] = "video";
			params['contURL'] = document.getElementById("broadcastPhotoPage").value;
			params['contXREF'] = params['contURL']+sts.getTime();
			var bcTitle = document.getElementById("broadcastLive").value;
			if(bcTitle == "") {
				this.msgBox.innerHTML = "<span>Your live broadcast must have a title.</span>";
				return false;
			}
			var flashBroadcaster = window.document.stcFlashBroadcaster;
			var liveSuccess = flashBroadcaster.setTitle(bcTitle);
			if(liveSuccess) {
				this.msgBox.innerHTML = "<span>Your live broadcast has begun!</span>";
				flashBroadcaster.liveStream();
			}
			else {
				this.msgBox.innerHTML = "<span>Live broadcast failed to initialize. Please try again.</span>";
			}
		}
		
		params['contDesc'] = encodeURIComponent(document.getElementById("broadcastTags").value);
		params['contLink'] = encodeURIComponent(document.getElementById("broadcastLink").value);
		params['contImageLink'] = document.getElementById("broadcastPhotoURL").value;
		
		params['responseFunction'] = stc.bc.confirmBroadcast;
		params['templateName'] = 'component/_submitBroadcast';
		params['action'] = 'loadTemplate';
		params['responseType'] = 'JSON';
		params['handlerName'] = 'one_ajax_templateLoader';
		params['requestType'] = 'class';
		params['sdb'] = 1;
		
		document.getElementById("broadcastSubmit").disabled = "disabled";	
		YAHOO.util.Dom.addClass("broadcastSubmit", "disabled");	
		
		OneAjax.request(params);
	},
	
	confirmBroadcast: function(o) {
		if(o.status==1){
			this.message = "Your broadcast was a success!";
			if(typeof(stcPreventBC) !== "undefined" && document.getElementById("broadcastType").value!="live") {
				this.closeTimer = setTimeout("stc.bc.pgRld();", 1000);
			}
			else if (document.getElementById("broadcastType").value!="live"){
				this.closeTimer = stc.bc.useModal?setTimeout("stc.mbc.destroy();", 1000):setTimeout("stc.bc.cancel();", 1000);
			}
			//console.log(o.output);
			var bcInfo = eval('('+o.output+')');
		}
		else {
			this.message = "Broadcast failure.  Please try again.";
		}
		this.msgBox = document.getElementById("bcMessageBox");
		this.msgBox.innerHTML = "<span>"+this.message+"</span>";
		if(document.getElementById("toolbarRefresh")) {
			if(document.getElementById("toolbarRefresh").value=true) {
				window.location.reload();
			}
		}
		if(document.getElementById("broadcastType").value=="live") {
			var bcHolder = document.getElementById("createBroadcastCont");
			var shardHolder = document.createElement("input");
			shardHolder.setAttribute("type", "hidden");
			shardHolder.id="broadcastShard";
			shardHolder.value=bcInfo.shardID;
			bcHolder.appendChild(shardHolder);
			
			var extHolder = document.createElement("input");
			extHolder.setAttribute("type", "hidden");
			extHolder.id="broadcastExtID";
			extHolder.value=bcInfo.extContID;
			bcHolder.appendChild(extHolder);
			YAHOO.util.Dom.setStyle(bcHolder, "display","none");
		}
	},
	
	pgRld: function() {
		var resetButton = document.getElementById("broadcastReset");
		window.location = resetButton.href;
	},
	
	countInit: function() {
		this.countBox = document.getElementById("broadcastTitleCounter");
		YAHOO.util.Event.addListener("broadcastTitle", "keyup", stc.bc.countChars);
		YAHOO.util.Event.addListener("broadcastTitle", "blur", stc.bc.countChars);
		YAHOO.util.Event.addListener("broadcastTitle", "blur", stc.bc.findURL);
		this.countBox.innerHTML = stc.bc.charCount;
	},
	
	countChars: function(e) {
		clearTimeout(urlTimer);
		var urlTimer = setTimeout("stc.bc.findURL();", 500);
		this.msgBox = document.getElementById("broadcastTitle");
		this.countBox = document.getElementById("broadcastTitleCounter");
		this.currCount = stc.bc.charCount - this.msgBox.value.length;
		this.countBox.innerHTML = this.currCount;
		if(this.currCount>10) {
			YAHOO.util.Dom.removeClass(this.countBox, "toolong");
			YAHOO.util.Dom.removeClass(this.countBox,"caution");
		}if(this.currCount<=10) {
			YAHOO.util.Dom.addClass(this.countBox, "caution");
			YAHOO.util.Dom.removeClass(this.countBox,"toolong");
		}if(this.currCount<0){
			YAHOO.util.Dom.addClass(this.countBox, "toolong");
			YAHOO.util.Dom.removeClass(this.countBox,"caution");
		}
	},
	
	findURL: function() {
		if(document.getElementById("broadcastType").value != "status") return;
		//var linkReg = new RegExp("(?:[\\s\\(\\)\\<\\>\\:-])((https?|ftp|news)://)?([\\w\\-]+\\.([\\w\\-]+\\.)*[\\w]+(:[0-9]+)?)([^\\s\\(\\)\\<\\>]*)(?=[\\s\\(\\)\\<\\>\\n])", "gim");
		var linkReg = new RegExp("\\b((https?|ftp|news)://)?([\\w\\-]+\\.([\\w\\-]+\\.)*[\\w]+(:[0-9]+)?)([^\\s\\(\\)\\<\\>]*)\\b", "gim");
		this.msgBox = document.getElementById("broadcastTitle");
		if(this.msgBox.value.match(linkReg)) {
			var linkURL = this.msgBox.value.match(linkReg)[0];
			if(stc.bc.foundLink == true) return;
			stc.bc.foundLink = true;
			stc.bc.attURLPrompt(linkURL.substring(1));
		}
		else{
			var lnkBox = document.getElementById("linkFoundPrompt");
			if(lnkBox) {
				lnkBox.parentNode.removeChild(lnkBox);
				stc.bc.foundLink = "";
			}
		}
	},
	
	attURLPrompt: function(_url) {
		var txtCont = document.getElementById("broadcastTitleCont");
		var linkButCont = document.createElement("div");
		var linkButton = document.createElement("a");
		linkButton.setAttribute("href", _url);
		YAHOO.util.Event.addListener(linkButton, "click", stc.bc.attURL, _url);
		linkButton.innerHTML = "<span>Attach to broadcast.</span>";
		linkButCont.id = "linkFoundPrompt";
		linkButCont.innerHTML = "Link detected. ";
		linkButCont.appendChild(linkButton);
		txtCont.appendChild(linkButCont);
	},
	
	attURL: function(e) {
		var linkButton = e.target || e.srcElement;
		YAHOO.util.Event.preventDefault(e);
		this.msgBox = document.getElementById("broadcastTitle");
		var linkReg = new RegExp("\\b((https?|ftp|news)://)?([\\w\\-]+\\.([\\w\\-]+\\.)*[\\w]+(:[0-9]+)?)([^\\s\\(\\)\\<\\>]*)\\b", "gim");
		var _url = this.msgBox.value.match(linkReg)[0];
		stc.bc.addLink(_url);
		var lnkBox = document.getElementById("linkFoundPrompt");
		lnkBox.parentNode.removeChild(lnkBox);
		//this.msgBox.value = this.msgBox.value.replace(linkURL, '');
	},
	
	bcflag: function(_url,e) {
		YAHOO.util.Event.preventDefault(e);
		var flagModal = new stc.modal;
		flagModal.title = "Flag this content";
		flagModal.content = '<div id="createBroadcastCont" class="flagBox">';
		flagModal.content += "Reason for flagging this content:<br />";
		flagModal.content += '<textarea id="flagReason"></textarea><br />';
		flagModal.content += '<input type="hidden" id="contentURL" value="'+_url+'" />';
		flagModal.content += '<button onclick="stc.bc.doFlag();" id="doFlagButton"><span>Flag Content</span></button>';
		flagModal.content += '</div>';
		flagModal.create();
		flagModal.appear();
	},
	
	doFlag: function () {
		var params = new Array();
		
		params['responseFunction'] = stc.bc.flagged;
		params['templateName'] = 'component/_emailer';
		params['action'] = 'loadTemplate';
		params['responseType'] = 'JSON';
		params['handlerName'] = 'one_ajax_templateLoader';
		params['requestType'] = 'class';
		params['sdb'] = 1;
		params['contURL'] = document.getElementById("contentURL").value;
		params['contReason'] = document.getElementById("flagReason").value;
		
		OneAjax.request(params);
	},
	
	flagged: function(o) {
		var modalCont = document.getElementById("createBroadcastCont");
		modalCont.innerHTML = "Content has successfully been flagged.<br />"+o.output;
	},
	
	addTopBox: function() {
		stc.bc.useModal = false;
		if(document.getElementById("staticNavBroadcast")){
			var bl = document.getElementById("staticNavBroadcast");
			bl.parentNode.removeChild(bl);
		}
		var bcCont = document.createElement('div');
		bcCont.id = "stcBCtrigger";
		YAHOO.util.Event.addListener(bcCont, "click", stc.bc.startDrop);
		bcCont.innerHTML = '<input type="text" value="add your update" />';
		var cont = document.getElementById("oneSiteContainer");
		cont.insertBefore(bcCont, cont.firstChild);
	},
	
	startDrop: function(e) {
		var bcCont = document.getElementById("stcBCtrigger");
		bcCont.parentNode.removeChild(bcCont);
		stc.bc.loadForm(e);
	}

}

stc.ann = {
	init: function() {
		var disBut = document.getElementById("staticAnnouncementClose");
		YAHOO.util.Event.addListener(disBut, "click", stc.ann.dismiss);
	},
	
	dismiss: function(e) {
		var annID = document.getElementById("staticAnnouncementID").value;
		var userID = document.getElementById("staticAnnouncementUserID").value;
		
		var params = new Array();
		
		params['responseFunction'] = stc.ann.hideAnn;
		params['templateName'] = 'component/hideAnnouncement';
		params['action'] = 'loadTemplate';
		params['responseType'] = 'JSON';
		params['handlerName'] = 'one_ajax_templateLoader';
		params['requestType'] = 'class';
		params['sdb'] = 1;
		params['announcementID'] = annID;
		params['userID'] = userID;
		
		OneAjax.request(params);
	},
	
	hideAnn: function(o) {
		var box = document.getElementById("staticAnnouncementHeader");
		if(o.status !="1") {
			console.log(o.status);
			box.innerHTML = box.innerHTML+'<div id="staticError">Something went wrong. Please try again.</div>';
			return;
		}
		var newAttributes = {
		   height:  { to: 0 },
		   padding: { to: 0 }
		};
		var newAnim = new YAHOO.util.Anim(box, newAttributes);
		newAnim.duration = .5;
		newAnim.method = YAHOO.util.Easing.easeBoth;
		newAnim.onComplete.subscribe(function(){
				var box=document.getElementById("staticAnnouncementHeader");
				box.parentNode.removeChild(box);
			}); 
		newAnim.animate();
	}
}

stc.roll = function () {
	
}

stc.roll.prototype = {
	rTitle: 		"Static Alert",
	rCSSID: 		"stcRoller",
	rParent: 		"oneBackgroundLayer",
	rHeight: 		"200",
	rContent: 		"",
	rCloseLink: 	"broadcastCancel",
	rOnloadFocus: 	"broadcastTitle",
	rKillCallback: 	{},
	
	rCreate: function () {
		if(document.getElementById(this.rCSSID)) {
			return false;
		}
		this.roller = document.createElement("div");
		this.roller.id = this.rCSSID;
		this.roller.innerHTML = this.rContent;
		YAHOO.util.Dom.setStyle(this.roller, "overflow", "hidden");
		YAHOO.util.Dom.setStyle(this.roller, "position", "absolute");
		YAHOO.util.Dom.setStyle(this.roller, "left", "-10000px");
		if(this.rContent == "") {
			return false;
		}
		var container = this.rParent == ""?document.body:document.getElementById(this.rParent);
		container.insertBefore(this.roller, container.firstChild);
		if(YAHOO.util.Dom.getRegion(this.roller)) {
			var h = YAHOO.util.Dom.getRegion(this.roller);
			this.rHeight = h.bottom-h.top;
		}
		YAHOO.util.Dom.setStyle(this.roller, "height", "0px");
		YAHOO.util.Dom.setStyle(this.roller, "position", "");
		YAHOO.util.Dom.setStyle(this.roller, "left", "");
		var closer = document.getElementById(this.rCloseLink);
		YAHOO.util.Event.addListener(closer, "click", this.rKillit, this, true);
	},
	
	rRollit: function () {
		var rollAtt = {
			height: {from: 0, to:this.rHeight}
		}
		var rollAnim = new YAHOO.util.Anim(this.roller, rollAtt);
		rollAnim.duration = .5;
		rollAnim.method = YAHOO.util.Easing.easeBoth;
		var roller = this.roller;
		var focused = this.rOnloadFocus
		rollAnim.onComplete.subscribe(function(){
			YAHOO.util.Dom.setStyle(roller, "height", "auto");
			document.getElementById(focused).focus();
		});
		rollAnim.animate();
	},
	
	rKillit: function (e) {
		YAHOO.util.Event.preventDefault(e);
		var reg = YAHOO.util.Dom.getRegion(this.roller);
		var rH = reg.bottom-reg.top;
		var rollAtt = {
			height: {from: rH, to:0}
		}
		var rollAnim = new YAHOO.util.Anim(this.roller, rollAtt);
		rollAnim.duration = .5;
		rollAnim.method = YAHOO.util.Easing.easeBoth;
		var roller = this.roller;
		var callback = this.rKillCallback;
		rollAnim.onComplete.subscribe(function(){
			roller.parentNode.removeChild(roller);
			if(YAHOO.lang.isFunction(callback)) {
				callback();
			}
			else {
				console.log(callback);
			}
		});
		rollAnim.animate();

	}
	
}

function showStaticBroadcast() {
	stc.bc.loadForm("","live");
}

function stopStaticBroadcast(vidID) {
	var shardID = document.getElementById("broadcastShard").value;
	var extContID = document.getElementById("broadcastExtID").value;
	var _url = "http://static.com/go/ajax/updateVideoID?videoID="+vidID+"&shardID="+shardID+"&extContentID="+extContID;
	//console.log(_url);
	var iframe = document.createElement("div");
	iframe.innerHTML = '<iframe src="'+_url+'" frameborder="0" width="0" height="0"></iframe>';
	document.body.appendChild(iframe);
	
	//YAHOO.util.Connect.asyncRequest('GET', _url,this.callback , null); 
}

YAHOO.util.Event.onDOMReady(stc.bc.init);
YAHOO.util.Event.onDOMReady(stc.ann.init);