stc.swfu = ({
	startHandler: function (o) {
		YAHOO.util.Dom.setStyle("swfuVideoButton", "overflow","hidden");		
		YAHOO.util.Dom.setStyle("swfuVideoButton", "border","1px solid #ff0000");
		YAHOO.util.Dom.setStyle("swfuVideoButton", "height","1px");
		return true;
	},
	
	photoQueued: function (o) {
		this.blog_id = document.getElementById("swfuBlogID").value;
		stc.swfu.stcUpload.setPostParams({
			"blog_id" 		: ""+this.blog_id+"",
			"gallery_id"	: "1"
		});
		this.coreu = document.getElementById('stcU').value;
		this.corex = document.getElementById('stcX').value;
		this.userAgent = document.getElementById('agent').value;
		this.upURL = "http://services.onesite.com/rest/ugcPhoto?action=uploadPhoto&coreU="+this.coreu+"&coreX="+this.corex+"&method=file&client_agent=" + this.userAgent + "&agent=theAgent&nodeID=153559";
		stc.swfu.stcUpload.setUploadURL(this.upURL);
		stc.swfu.stcUpload.startUpload();
		//stc.swfu.stcUpload.setButtonDisabled(true);
	},
	
	videoQueued: function (o) {
		this.blog_id = document.getElementById("swfuBlogID").value;
		stc.swfu.stcUpload.setPostParams({
			"site_id" 		: ""+this.blog_id+"",
			"gallery_id"	: "1"
		});
		stc.swfu.stcUpload.setFilePostName('video_file');
		
		this.coreu = document.getElementById('stcU').value;
		this.corex = document.getElementById('stcX').value;
		this.userAgent = document.getElementById('agent').value;
		this.upURL = "http://services.onesite.com/rest/svcVideoUpload?action=upload&coreU="+this.coreu+"&coreX="+this.corex+"&method=file&client_agent=" + this.userAgent + "&node_id=153559";
		stc.swfu.stcUpload.setUploadURL(this.upURL);
		stc.swfu.stcUpload.startUpload();
	},
	
	stcError: function(o,er,m){
		console.log("object: "+o);
		console.log("error: "+er);
		console.log("message: "+m);
	},
	
	stcQError: function(o,er,m){
		if(er=="-100") {
			m = "Only one file may be attached to a broadcast.";	
		}
		this.msgBox = document.getElementById("bcMessageBox");
		this.msgBox.innerHTML = "<span>"+m+"</span>";
	},
	
	stcProgress: function(o,c,t) {
		YAHOO.util.Dom.setStyle('swfuProgressCont', "display", "block");
		var contR = YAHOO.util.Dom.getRegion("swfuProgressCont");
		var contW = contR.right-contR.left;
		this.percent = (c/t);
		var progW = contW*this.percent;
		YAHOO.util.Dom.setStyle('swfuProgressBar', "width", progW+"px");
	},
	
	stcUploadSuccess: function(o,s) {
		// Internet Asploder
		try {
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.loadXML(s);
		}
		catch(e) {
			//Firefox, Mozilla, Opera, etc.
			try {
				parser=new DOMParser();
				xmlDoc=parser.parseFromString(s,"text/xml");
			}
			catch(e) {
				alert(e.message);
				return;
			}
		}
		this.pid = xmlDoc.getElementsByTagName("item")[0].childNodes[0].nodeValue;
		this.message = xmlDoc.getElementsByTagName("message")[0].childNodes[0].nodeValue;
		YAHOO.util.Dom.setStyle('swfuProgressCont', "display", "none");
		stc.bc.getPhotoURL(this.pid, this.message);
	},
	
	videoUploadSuccess: function(o,s)
	{
		// Internet Asploder
		try {
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.loadXML(s);
		}
		catch(e) {
			//Firefox, Mozilla, Opera, etc.
			try {
				parser=new DOMParser();
				xmlDoc=parser.parseFromString(s,"text/xml");
			}
			catch(e) {
				alert(e.message);
				return;
			}
		}
		this.pid = xmlDoc.getElementsByTagName("video_id")[0].childNodes[0].nodeValue;
		this.message = xmlDoc.getElementsByTagName("message")[0].childNodes[0].nodeValue;
		YAHOO.util.Dom.setStyle('swfuProgressCont', "display", "none");
		stc.bc.getVidURL(this.pid, this.message);
	},
	
	photo: {
		flash_url 				: "/resources/scripts/swfupload/Flash10/SWFUploader.swf",
		
		file_size_limit			: '12288', //12MB
		file_types				: '*.jpg;*.jpeg;*.gif;*.png',
		file_upload_limit		: '1',
			
		debug					: false,
		flash_width				: '108px',
		flash_height			: '23px',
		flash_container			: "swfuPhotoButton",
		upload_start_handler	: function(o){return true;},
		file_dialog_complete_handler	: function(o){stc.swfu.photoQueued(o);},
		file_queue_error_handler: function(o,er,m){stc.swfu.stcQError(o,er,m);},
		upload_error_handler	: function(o,er,m){stc.swfu.stcError(o,er,m);},
		upload_progress_handler	: function(o,c,t){stc.swfu.stcProgress(o,c,t);},
		upload_success_handler	: function(o,s){stc.swfu.stcUploadSuccess(o,s);}
	},
	
	video: {
		flash_url : "/resources/scripts/swfupload/Flash10/SWFUploader.swf",
		button_placeholder_id : "swfuVideoButton",
		
		file_size_limit			: '122880', //12MB
		file_types				: '*.wmv;*.mov;*.avi;*.m4v;*.3gp',
		file_upload_limit		: '1',
		
		debug					: false,
		flash_width				: '108px',
		flash_height			: '23px',
		flash_container			: "swfuVideoButton",
		
		upload_start_handler	: function(o){return true;},
		file_dialog_complete_handler	: function(o){stc.swfu.videoQueued(o);},
		file_queue_error_handler: function(o,er,m){stc.swfu.stcQError(o,er,m);},
		upload_error_handler	: function(o,er,m){stc.swfu.stcError(o,er,m);},
		upload_progress_handler	: function(o,c,t){stc.swfu.stcProgress(o,c,t);},
		upload_success_handler	: function(o,s){stc.swfu.videoUploadSuccess(o,s);}
	}
});
