function showactivelb(){
	document.getElementById('activelbbox').style.display = "inline";	
}

function hideactivelb(){
	document.getElementById('activelbbox').style.display = "none";	
}

evalResponse = function(request) {
    try {
        return eval('('+request.responseText+')');
    } catch (e) {}
}

function deleteLightBox(lightBoxId, lightBoxName){
	lightBoxName = decodeURIComponent(lightBoxName);
	if (confirm('Delete '+ lightBoxName +'?')) {
		var postData = "method=delete&lightBoxId="+lightBoxId; 
		var deleteLightBoxAjaxEvent = new SPF.AjaxEvent();
		deleteLightBoxAjaxEvent.subscribe(deleteLightBoxReturn);
		deleteLightBoxAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
	}
}

function deleteLightBoxReturn(o){
	if(o.success == 1){
		if (o.message) {
			alert(o.message);
		}
		javascript:finishAction('', 40);
	}
}

function changeactive(lightBoxId){
	var postData = "method=changelightbox&lightBoxId="+lightBoxId; 
	var changeLightBoxAjaxEvent = new SPF.AjaxEvent();
	changeLightBoxAjaxEvent.subscribe(changeactiveReturn);
	changeLightBoxAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
}

function changeactiveReturn(o){
	var loc = window.location.href
	window.location = loc;
	//document.getElementById('activelbname').innerHTML = o.name;
}

function emptyLightBox(lightBoxId, lightBoxName){
	lightBoxName = decodeURIComponent(lightBoxName);
	if (confirm('Empty '+ lightBoxName +'?')) {
		var postData = "method=empty&lightBoxId="+lightBoxId; 
		var emptyLightBoxAjaxEvent = new SPF.AjaxEvent();
		emptyLightBoxAjaxEvent.subscribe(emptyLightBoxReturn);
		emptyLightBoxAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
		
	}
}

function emptyLightBoxReturn(o){
	if(o.success == 1){
		javascript:finishAction(o.lightBoxId, 0);
	}
}

function addAlbumLightBox(albumId, lightBoxId){
	postData = 'method=addalbum&albumId=' + albumId + '&lightBoxId=' + lightBoxId;
	var deleteLightBoxAjaxEvent = new SPF.AjaxEvent();
	deleteLightBoxAjaxEvent.subscribe(addAlbumLightBoxReturn);
	deleteLightBoxAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
}

function addAlbumLightBoxReturn(o){
	if(o.success == 1){
		var loc = window.location.href
		window.location = loc;
	}

}

function changeLightBoxItem(imageId, lightBoxId){

	if(document.getElementById('lightboxtextadd') || document.getElementById('lightboxtextremove')){
		xoffset = 0;
		yoffset = 20;
	}else{
		xoffset= 25;
		yoffset = 5;
	}
	showloadingsmall('lblink'+ imageId, xoffset, yoffset);
	postData = 'method=changeitem&imageId=' + imageId + '&lightBoxId=' + lightBoxId;
	var changeLightBoxItemAjaxEvent = new SPF.AjaxEvent();
	changeLightBoxItemAjaxEvent.subscribe(changeLightBoxItemReturn);
	changeLightBoxItemAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
}

function changeLightBoxItemReturn(o){
	hideloadingsmall();
	if(document.getElementById('lightboxtextadd') || document.getElementById('lightboxtextremove')){
		if(o.method == 'add'){
			document.getElementById('lblink'+ o.imageId).innerHTML = document.getElementById('lightboxtextremove').innerHTML;
		}
		else{
			document.getElementById('lblink' + o.imageId).innerHTML = document.getElementById('lightboxtextadd').innerHTML;
		}
	}
	if(document.getElementById('lightboxicon'+o.imageId)){
		if(o.method == 'add'){
			document.getElementById('lightboxicon'+o.imageId).className = 'lightboxiconin';
		}
		else{
			document.getElementById('lightboxicon'+o.imageId).className = 'lightboxicon';
		}
	}
	// update lb toolbar with new number of images
	if(document.lbtoolbarform.lbtoolbarddown){
		var oldoption = document.lbtoolbarform.lbtoolbarddown.options[document.lbtoolbarform.lbtoolbarddown.selectedIndex].text;
		var parts = oldoption.split("(");
		var lbname = '';
		for(i = 0; i < parts.length-1; i++){
				lbname = lbname + parts[i];
		}
		numimages = parts[parts.length-1];
		numimages = parseInt(numimages.split(" ")[0]);
		if (o.method == 'add') {
			numimages = numimages + 1;
		} else {
			numimages = numimages - 1;
		}
		newoption = new Option(lbname.replace(/^\s+|\s+$/g, '') + ' (' + numimages + ' images)');
		document.lbtoolbarform.lbtoolbarddown.options[document.lbtoolbarform.lbtoolbarddown.selectedIndex] = newoption;
		newoption.selected = true;
	}
}

// same as changeLightBoxItem(imageId, lightBoxId) but deltes the thumbnail from the page
function deleteLightBoxItem(imageId, lightBoxId){

	if(document.getElementById('lightboxtextadd') || document.getElementById('lightboxtextremove')){
		xoffset = 0;
		yoffset = 20;
	}else{
		xoffset= 25;
		yoffset = 5;
	}
	showloadingsmall('lblink'+ imageId, xoffset, yoffset);
	postData = 'method=changeitem&imageId=' + imageId + '&lightBoxId=' + lightBoxId;
	var deleteLightBoxItemAjaxEvent = new SPF.AjaxEvent();
	deleteLightBoxItemAjaxEvent.subscribe(deleteLightBoxItemReturn);
	deleteLightBoxItemAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
}

function deleteLightBoxItemReturn(o){
	hideloadingsmall();
	if(o.success == 1){
		if(document.getElementById('lightboxnumberitems')){
			var lightboxnumberitems = parseInt(document.getElementById('lightboxnumberitems').innerHTML);
			lightboxnumberitems = lightboxnumberitems - 1;
			document.getElementById('lightboxnumberitems').innerHTML = lightboxnumberitems;
		}
		var thumbid = 'thumb'+o.imageId;
		document.getElementById(thumbid).style.display = "none";
	}
	if(document.lbselectorform.lightboxselector){
		var oldoption = document.lbselectorform.lightboxselector.options[document.lbselectorform.lightboxselector.selectedIndex].text;
		var parts = oldoption.split("(");
		var lbname = '';
		for(i = 0; i < parts.length-1; i++){
				lbname = lbname + parts[i];
		}
		numimages = parts[parts.length-1];
		numimages = parseInt(numimages.split(" ")[0]);
		if (o.method == 'add') {
			numimages = numimages + 1;
		} else {
			numimages = numimages - 1;
		}
		newoption = new Option(lbname.replace(/^\s+|\s+$/g, '') + ' (' + numimages + ')');
		document.lbselectorform.lightboxselector.options[document.lbselectorform.lightboxselector.selectedIndex] = newoption;
		newoption.selected = true;
	}
}


function reorderImages(imageIds, lightBoxId){
	postData = 'method=reorder&imageId=' + imageIds + '&lightBoxId=' + lightBoxId;
	var reorderImagesAjaxEvent = new SPF.AjaxEvent();
	reorderImagesAjaxEvent.subscribe(reorderImagesReturn);
	reorderImagesAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
}

function reorderImagesReturn(o){
	javascript:finishAction(o.lightBoxId, 110);
}


/////////////////////////////////////////////////////////////////////////////////////
// batchactionoverlay

function batchcopy(lightBoxId){
	if(getSelectedImages()){
		document.getElementById('batchLightBoxTitle').innerHTML = 'Copy selected images';
		document.getElementById('batchLightBoxText').innerHTML = 'Copy to:';
		document.getElementById('batchOriginLightboxId').value = lightBoxId;
		document.getElementById('batchLightboxaction').value = 'copyitem';
		YAHOO.batchlightbox.overlay.batchlightboxpanel.show();
	} else {
		alert('Please select first the images you want to copy.');
	}
}

function batchmove(lightBoxId){
	if(getSelectedImages()){
		document.getElementById('batchLightBoxTitle').innerHTML = 'Move selected images';
		document.getElementById('batchLightBoxText').innerHTML = 'Move to:';
		document.getElementById('batchOriginLightboxId').value = lightBoxId;
		document.getElementById('batchLightboxaction').value = 'moveitem';
		YAHOO.batchlightbox.overlay.batchlightboxpanel.show();
	} else {
		alert('Please select first the images you want to move.');
	}
}

function batchdelete(lightBoxId){
	var imageIds = getSelectedImages();
	if(imageIds){
		if(confirm('Remove selected images?')) {
			postData = 'method=changeitem&imageId=' + imageIds + '&lightBoxId=' + lightBoxId;
			var batchDeleteLightBoxItemAjaxEvent = new SPF.AjaxEvent();
			batchDeleteLightBoxItemAjaxEvent.subscribe(batchDeleteReturn);
			batchDeleteLightBoxItemAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
		}
	} else {
		alert('Please select first the images you want to remove.');
	}
}

function batchDeleteReturn(o){
	window.location = window.location.href;
}

function getSelectedImages(){
	var checklist = document.lbthumbsform.lbthumbcheck;
	var imageIds = '';
	if(checklist.length > 0){
		for(i=0; i<checklist.length; i++){
			if(checklist[i].checked == true){
				imageIds = imageIds + checklist[i].value + '-';
			}
		}
		return imageIds;
	} else {
		if(checklist.checked == true){
			return checklist.value;
		}
	}
}

function batchLightBox(){
	
	var action = document.getElementById('batchLightboxaction').value;
	var lightBoxId = document.getElementById('batchOriginLightboxId').value;
	var targetLightBoxId = document.batchlightboxform.batchlightboxdropdown.options[document.batchlightboxform.batchlightboxdropdown.selectedIndex].value;
	var imageIds = getSelectedImages();
	postData = 'method=' + action + '&imageId=' + imageIds + '&lightBoxId=' + lightBoxId + '&targetLightBoxId=' + targetLightBoxId;
	var batchLightBoxAjaxEvent = new SPF.AjaxEvent();
	batchLightBoxAjaxEvent.subscribe(batchLightBoxReturn);
	batchLightBoxAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
}

function batchselect(option){
	checkboxToggle('lbthumbsform', 'lbthumbcheck', option)
}

function batchLightBoxReturn(o){
	YAHOO.batchlightbox.overlay.batchlightboxpanel.hide();
	
	if (o.method == 'copyitem') {
		javascript: finishAction(o.lightBoxId, 60);
	}
	if (o.method == 'moveitem') {
		javascript: finishAction(o.lightBoxId, 70);
	}
}

/////////////////////////////////////////////////////////////////////////////////////
// checkusersoverlay

function checkEmails(){
	if(document.getElementById('shareEmails').value == ''){
		alert('You must enter at least one email address');
	} else {
		form = document.sharelightboxform;
		var postData = 'method=checkemails&emails=' + encodeURIComponent(document.getElementById('shareEmails').value);
		var checkEmailsAjaxEvent = new SPF.AjaxEvent();
		checkEmailsAjaxEvent.subscribe(checkEmailsReturn);
		checkEmailsAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
	}
} 

function checkEmailsReturn(o){
	matches = o.checkedEmails;
	nomatches = o.unCheckedEmails;
	result = '';
	for(i=0; i < matches.length; i++){
		if(matches[i] != 0){
			result = result + 'OK - ' + matches[i] + '.<br />';
		}
	}
	for(i=0; i < nomatches.length; i++){
		if(nomatches[i] != 0){
			result = result + nomatches[i] + ' doesn\'t match any users. An email will be sent offering to register with the site.<br />';
		}
	}
	document.getElementById('checkuserscontent').innerHTML = result;
	YAHOO.checkusers.overlay.checkuserspanel.show();
}


/////////////////////////////////////////////////////////////////////////////////////
// copylightbox overlay

function copylightboxoverlay(lightBoxId, lightBoxName){
	document.getElementById('copyLightBoxName').value = 'Copy of ' + unescape(lightBoxName);
	document.getElementById('copyLightBoxId').value = lightBoxId;
	YAHOO.copylightbox.overlay.copylightboxpanel.show();
	document.getElementById('copyLightBoxName').focus();
}



function copyLightBox(){
	javascript:processCopyLightBox();
	return false;
}

function processCopyLightBox() {
	if(document.getElementById('copyLightBoxName').value == ''){
		alert('You must enter a name for the new ' + selectionsterm);
		return false;
	}
	var parameters = 'method=copy&lightBoxId=' + document.getElementById('copyLightBoxId').value + '&name=' + encodeURIComponent(document.getElementById('copyLightBoxName').value);
	
	 // submit the form using Ajax
 	new Ajax.Request(lightBoxAjaxRemoteUrl, {
 	parameters : parameters,
   	onComplete :  processCopyLightBoxtRequest
 });
} 

function processCopyLightBoxtRequest(resp, json){
	var j = evalResponse(resp);
	if(j.success == 1){
		YAHOO.copylightbox.overlay.copylightboxpanel.hide();
		javascript:finishAction(j.lightBoxId, 50);
	}
}

/////////////////////////////////////////////////////////////////////////////////////
// createlightbox overlay

function createlightboxoverlay(lightBoxId, action){
	document.getElementById('createLightBoxName').value = '';
	document.getElementById('createLightBoxProject').value = '';
	document.getElementById('createLightBoxDescription').value = '';
	if(action == 'edit'){
		document.getElementById('createLightBoxAction').innerHTML = 'Edit ' + selectionsterm;
		postData = 'method=getlightbox&lightBoxId=' + lightBoxId;
		var editLightBoxAjaxEvent = new SPF.AjaxEvent();
		editLightBoxAjaxEvent.subscribe(editLightBoxReturn);
		editLightBoxAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
		
	} else {
		document.getElementById('createLightBoxAction').innerHTML = 'Create ' + selectionsterm;
	}
	document.getElementById('createlightboxaction').value = action;
	document.getElementById('createlightboxId').value = lightBoxId;
	YAHOO.createlightbox.overlay.createlightboxpanel.show();
	document.getElementById('createLightBoxName').focus();
}


function editLightBoxReturn(o){
	if(o.success == 1){
		lightBox = o.lightBox;
		document.getElementById('createLightBoxName').value = lightBox.name;
		document.getElementById('createLightBoxProject').value = lightBox['projectName'];
		document.getElementById('createLightBoxDescription').value = lightBox.description;
	}
	return;
}



function createLightBox(){
	javascript:processCreateLightBox();
	return false;
}

function processCreateLightBox() {
	if(document.getElementById('createLightBoxName').value == ''){
		alert('You must enter a name for the new ' + selectionsterm);
		return false;
	}
	var action = document.getElementById('createlightboxaction').value;
	var lightBoxId = document.getElementById('createlightboxId').value;
	var parameters = 'method=' + action + '&lightBoxId=' + lightBoxId + '&name=' + encodeURIComponent(document.getElementById('createLightBoxName').value) + '&projectname=' + encodeURIComponent(document.getElementById('createLightBoxProject').value)  + '&description=' + encodeURIComponent(document.getElementById('createLightBoxDescription').value);
	 // submit the form using Ajax
 	new Ajax.Request(lightBoxAjaxRemoteUrl, {
 	parameters : parameters,
   	onComplete :  processCreateLightBoxRequest
 });
} 

function processCreateLightBoxRequest(resp, json){
	var j = evalResponse(resp);
	if(j.success == 1){
		YAHOO.createlightbox.overlay.createlightboxpanel.hide();
		if (j.action == 'createactive') {
			changeactive(j.lightBoxId);
		}else if (j.action == 'create'){
			javascript: finishAction(j.lightBoxId, 31);
		}else{
			javascript: finishAction(j.lightBoxId, 30);
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////
// lightboxnote overlay

function addnoteoverlay(lightBoxId, imageId){
	getNotes(lightBoxId, imageId);
	document.getElementById('noteLightBoxId').value = lightBoxId;
	document.getElementById('noteImageId').value = imageId;
	document.getElementById('lightboxNote').value = '';
}


function getNotes(lightBoxId, imageId){
	postData = 'method=getnotes&lightBoxId=' + lightBoxId + '&imageId=' + imageId;
	var getLBNotesBoxAjaxEvent = new SPF.AjaxEvent();
	getLBNotesBoxAjaxEvent.subscribe(getNotesReturn);
	getLBNotesBoxAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);	
}

function getNotesReturn(o){
	if(o.notes != undefined && o.notes[0].note != ''){
		document.getElementById('lightboxnoteauthorfields').style.display = '';
		document.getElementById('noteAuthor').innerHTML = o.notes[0].userName;
		document.getElementById('lightboxNote').value = o.notes[0].note;
	} else {
		
		document.getElementById('lightboxNote').value = '';
	}
	YAHOO.lightboxnote.overlay.lightboxnotepanel.show();
	document.getElementById('lightboxNote').focus();
}

function addNote(){
	javascript:processAddNote();
	return false;
}

function processAddNote() {
	var parameters = 'method=addnote&lightBoxId=' + document.getElementById('noteLightBoxId').value + '&imageId=' + document.getElementById('noteImageId').value + '&note=' + encodeURIComponent(document.getElementById('lightboxNote').value);
	
	 // submit the form using Ajax
 	new Ajax.Request(lightBoxAjaxRemoteUrl, {
 	parameters : parameters,
   	onComplete :  processAddNoteRequest
 });
} 

function processAddNoteRequest(resp, json){
	var j = evalResponse(resp);
	if(j.success == 1){
		document.getElementById('noteLightBoxId').value = '';
		document.getElementById('noteImageId').value = '';
		document.getElementById('lightboxNote').value = '';
	}
	YAHOO.lightboxnote.overlay.lightboxnotepanel.hide();
	javascript:finishAction(j.lightBoxId, 80);
}

/////////////////////////////////////////////////////////////////////////////////////
// sharelightbox overlay

function clearTextBox(){
	document.getElementById('shareEmails').value = '';
}

function sharelightboxoverlay(lightBoxId, lightBoxName){
	document.getElementById('shareLightBoxId').value = lightBoxId;
	document.getElementById('sharelightboxname').innerHTML = unescape(lightBoxName);
	document.getElementById('shareEmails').value = '';
	document.getElementById('shareMessage').value = '';
	document.getElementById('sharelightboxwrite').checked = false;
	YAHOO.sharelightbox.overlay.sharelightboxpanel.show();
}



function shareLightBox(){
	javascript:processShareLightBox();
	return false;
}

function processShareLightBox() {
	if(document.getElementById('shareEmails').value == ''){
		alert('You must enter at least one email address');
		return false;
	}
	var write = 0;
	if(document.getElementById('sharelightboxwrite').checked){
		write = 1;
	}
	form = document.sharelightboxform;
	var parameters = 'method=share&lightBoxId=' + document.getElementById('shareLightBoxId').value + '&shareemails=' + encodeURIComponent(document.getElementById('shareEmails').value) + '&write=' + write + '&sharemessage=' +document.getElementById('shareMessage').value;
	
	document.getElementById("sharealightboxform").innerHTML = "<br />Please Wait...<br />";
	document.getElementById("sharebuttons").innerHTML = "";
	
	 // submit the form using Ajax
 	new Ajax.Request(lightBoxAjaxRemoteUrl, {
 	parameters : parameters,
   	onComplete :  processShareLightBoxtRequest
 });
} 

function processShareLightBoxtRequest(resp, json){
	var j = evalResponse(resp);
	if(j.success == 1){
		YAHOO.sharelightbox.overlay.sharelightboxpanel.hide();
		finishAction(0, 90);
	}
}

/////////////////////////////////////////////////////////////////////////////////////
// viewshare overlay


function viewshareoverlay(lightBoxId, lightBoxName){
	document.getElementById('viewsharelightboxid').value = lightBoxId;
	document.getElementById('viewsharename').innerHTML = lightBoxName;
	elementid = 'contents'+lightBoxId;
	contents = document.getElementById(elementid).innerHTML
	document.getElementById('viewsharecontents').innerHTML = contents;
	document.getElementById('viewsharepanel').style.display = '';
	YAHOO.viewshare.overlay.viewsharepanel.show();
	//getShare(lightBoxId);
}

function getShare(lightBoxId) {
	var parameters = 'method=getshares&lightBoxId=' + document.getElementById('viewsharelightboxid').value;
	
	 // submit the form using Ajax
 	new Ajax.Request(lightBoxAjaxRemoteUrl, {
 	parameters : parameters,
   	onComplete : processGetShare
 });
} 

function processGetShare(resp, json){
	var j = evalResponse(resp);
	if (j.success == 1) {
		if (j.shares[0].canWrite == '1') {
			readwrite = ' checked';
		}
		else {
			readwrite = '';
		}
		var sharecontents = '<form name="viewshareform"><div class="row"><div class="cell label">Shared with:</div><div class="cell field">' + j.shares[0].userEmail + ' | <input type="checkbox" name="lbsharecheck" value="' + j.shares[0].lightBoxId + '"' + readwrite + '>User can modify ' + selectionsterm + '</input> | <a title="Remove share" href="javascript:removeshare(' + j.shares[0].lightBoxId + ')">Remove share</A></div><div class="clear"></div></div><div class="clear"></div><form name="viewshareform">';
		for(i=1; i < j.shares.length; i++){
			if(j.shares[i].canWrite == '1'){
				readwrite = ' checked';
			} else {
				readwrite = '';
			}
			sharecontents = sharecontents + '<div class="row" id="viewshareinfo"><div class="cell label">&nbsp</div><div class="cell field">' + j.shares[i].userEmail + ' | <input type="checkbox" name="lbsharecheck" value="' + j.shares[i].lightBoxId + '"' + readwrite + '>User can modify ' + selectionsterm + '</input> | <a title="Remove share" href="javascript:removeshare(' + j.shares[i].lightBoxId + ')">Remove share</A></div><div class="clear"></div></div><div class="clear"></div></form>';
		}
		document.getElementById('viewsharecontents').innerHTML = sharecontents + '</form>';
		YAHOO.viewshare.overlay.viewsharepanel.show();
		
	}
}

function removeshare(lightBoxId){
	deleteLightBox(lightBoxId, 'share');
}

function processviewshare(){
	var checklist = document.viewshareform.lbsharecheck;
	var shareIds = '';
	var shareChecks = '';
	if(checklist.length > 0){
		for(i=0; i<checklist.length; i++){
				shareIds = shareIds + checklist[i].value + '-';
				if(checklist[i].checked){
					check = '1';
				} else {
					check = '0';
				}
				shareChecks = shareChecks + check + '-';
		}
		postData = 'method=changesharepermission&shareId=' + shareIds + '&sharePermission=' + shareChecks;
		var editShareItemAjaxEvent = new SPF.AjaxEvent();
		editShareItemAjaxEvent.subscribe(editShareItemReturn);
		editShareItemAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
	} else {
		if(checklist.checked){
					check = '1';
				} else {
					check = '0';
				}
		postData = 'method=changesharepermission&shareId=' + checklist.value + '&sharePermission=' + check;
		var editShareItemAjaxEvent = new SPF.AjaxEvent();
		editShareItemAjaxEvent.subscribe(editShareItemReturn);
		editShareItemAjaxEvent.connect(lightBoxAjaxRemoteUrl, postData);
	}
}

function editShareItemReturn(o){
	//getShare(o.lightBoxId);
	YAHOO.viewshare.overlay.viewsharepanel.hide();
	document.getElementById('viewsharepanel').style.display = 'none';
	javascript:finishAction('', 100);
}
 //////////////////////// COOKIE ////////////////////
 
	function getLBCookie(name) {
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
			begin = dc.indexOf(prefix);
			if (begin != 0)return null;
		} else {
			begin += 2;
		}
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		end = dc.length;
		return unescape(dc.substring(begin + prefix.length, end));
	}
	
	function setLBCookie(name, value, expires, path, domain, secure) {
		var curCookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
		document.cookie = curCookie;
	}
	
	YAHOO.namespace("lightbox.container");
	function positionlightboxchooser(e) {
		var height = YAHOO.util.Dom.getViewportHeight();
		var scrollx = YAHOO.util.Dom.getDocumentScrollTop();
		if (scrollx + height <= docHeight) {
			document.getElementById('lightboxchooser').style.display = '';
			YAHOO.lightbox.container.lightboxchooser.cfg.setProperty("y", height + scrollx - 23);
		}
	}
	function positionlightboxchooseronresize(e){
		document.getElementById('lightboxchooser').style.display = 'none';
		docHeight = YAHOO.util.Dom.getDocumentHeight();
		positionlightboxchooser(e);
	}	
	
	function closelightboxchooser(){
		setLBtoolbarCookie();
		document.getElementById('lightboxchooser').style.display = 'none';
		document.getElementById('lbtoolbarpanel').style.display = '';
		YAHOO.lbtoolbar.overlay.closelbtoolbarpanel.show();
	}
