function fullimage(imageurl) {
  var generated=window.open('','name','width=600px, height=500px, menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=yes');
  var gd = generated.document;
  gd.write('<html><head><title>View Full Image</title>');
  gd.write('</head><body style="background-color: #fff;">');
  gd.write('<div style="text-align: center; padding: 5px 0;"><input type="button" onclick="javascript:window.close()" value="Close this window"/></div>');
  gd.write('<img src="' + imageurl + '" style="margin: 0 auto; border: 1px solid #c8c8c8; padding: 2px;" />');
  gd.write('<div style="text-align: center; padding: 5px 0;"><input type="button" onclick="javascript:window.close()" value="Close this window"/></div>');
  gd.write('</body></html>');
  gd.title = 'View Full Image';
  gd.close();
  return false;
}

function fullmovie(movieurl,width,height) {
  var mimetypes = {	'mov'	:{'mime':'video/quicktime','classid':'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B','codebase':'http://www.apple.com/qtactivex/qtplugin.cab'},
  					'qt'	:{'mime':'video/quicktime','classid':'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B','codebase':'http://www.apple.com/qtactivex/qtplugin.cab'},
/*use quicktime*/	'mpg'	:{'mime':'video/mpeg','classid':'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'},
/*to play mpegs*/	'mpeg'	:{'mime':'video/mpeg','classid':'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'},
  					'wmv'	:{'mime':'video/x-ms-wmv','classid':'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'},
  					'asx'	:{'mime':'video/x-ms-asf','classid':'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'}
  				};
  var ext = movieurl.split(".");
  ext = ext[ext.length-1];
  var generated=window.open('','name','width=600px, height=500px, menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=yes');
  var gd = generated.document;
  var undefined;
  
  gd.write('<html><head><title>Watch Movie</title>\n');
  gd.write('</head><body style="background-color: #fff;text-align:center;">\n');
  gd.write('<div style="padding: 5px 0;"><input type="button" onclick="javascript:window.close()" value="Close this window"/></div>\n');
  gd.write('<object classid="'+ mimetypes[ext]['classid']+'"');
  if (mimetypes[ext]['codebase'] != undefined)
  	gd.write(' codebase="'+mimetypes[ext]['codebase']+'" ');
  gd.write(' width="'+width+'" height="'+(height+15)+'">\n');
  gd.write('<param name="src" value="'+movieurl+'"/>\n');
  gd.write('<param name="url" value="'+movieurl+'"/>\n');
  gd.write('<param name="controller" value="true"/>\n');
  if (navigator.userAgent.indexOf("MSIE")==-1) {
	gd.write('\t<object style="margin: 5px auto;" type="'+mimetypes[ext]['mime']+'" ');
  	gd.write(' data="'+movieurl+'" width="'+width+'" height="'+(height+15)+'">\n');
  		gd.write('\t\t<param name="controller" value="true"/>\n');
  	gd.write('\t</object>\n');
  }
  gd.write('</object>\n');
  gd.write('<div style="text-align: center; padding: 5px 0;"><input type="button" onclick="javascript:window.close()" value="Close this window"/></div>\n');
  gd.write('</body></html>');
  gd.title = 'Watch Movie';
  gd.close();
  return false;
}

/* start workshop schedule */

// determines what the next workshop is and prints and link to the workshop 
function goToNext() {
    var anchor;
    var now = new Date();
    var currDate = now.getDate();
    var currMon = now.getMonth() + 1;
    if(currMon < 10) {
        currMon = "0" + currMon;
    }
    if(currDate < 10) {
        currDate = "0" + currDate;
    }

    var today = "" + currMon + currDate;
    var i = 0;
    if (today <= workshops[workshops.length-1]) {   
        while (today > workshops[i]) { i++; }
    }
    anchor = "#" + workshops[i];

    var upcoming = document.getElementById("upcomingWorkshop");
    upcoming.innerHTML = "<a href=\"" + anchor + "\">View upcoming workshop</a>";
}
/* end workshop schedule */

/* video embedding */
var catalystVideo = {
	/**
	 * Embeds a video in the sidebar
	 * Takes a path to the video file (.flv)
	 * Takes the id of the HTML to place the video
	*/
	'sidebar' : function(video, id) {
		// smaller video size
		var params = {
			'allowfullscreen' : 'true'
		};
		var flvars = {
			width : '220',
			height : '192',
			file : video,
			smoothing : 'true'
		};
		var attr = {
			'class' : 'catalyst-video-sidebar'
		};
		this._embed(id, '220', '192', flvars, params, attr);
	},

	/**
	 * Embeds a video in the main content area
	 * Takes a path to the video file (.flv)
	 * Takes the id of the HTML to place the video
	 */	
	'content' : function(video, id) {
		// larger video size
		var params = {
			allowfullscreen : 'true'
		};
		var flvars = {
			width : '220',
			height : '192',
			file : video,
			smoothing : 'true'
		};
		var attr = {
			'class' : 'catalyst-video-content'
		};
		this._embed(id, '220', '192', flvars, params, attr);
	},

	/**
	 * Private method that embeds the video
	 */
	'_embed' : function(id, width, height, flvars, params, attr) {
		swfobject.embedSWF('mediaplayer.swf', id, width, height, '7.0.0', '', flvars, params, attr);
	}
}
/* end video embedding */

/* inject skin styles into kupu */
function insertStyles(kupu) {
  if (kupu != undefined && kupu != null) {
    var doc = kupu.contentWindow.document;
    if (doc == undefined || doc == null) doc = kupu.contentDocument;

    if (doc != undefined && doc != null && doc.getElementsByTagName('head').length) {
      var style = doc.createElement('link');
      style.setAttribute('type', 'text/css');
      style.setAttribute('href', '/lst/static/css/skin.css');
      style.setAttribute('rel', 'stylesheet');
      doc.getElementsByTagName('head')[0].appendChild(style);
    }
  }
}

registerPloneFunction(function() {
  var kupu = document.getElementById('kupu-editor-iframe-text');
  if (kupu != undefined && kupu != null) {
    addEventHandler(window, 'load', function() { insertStyles(kupu); }, document);
  }
});
