window.addEvent('domready', function()
{
	if($('mainmenu')) initMainMenu();
	//initTooltips();
});

function initMainMenu()
{
	var numitems = $$('#mainmenu li').length;
	var width = numitems * 85;
/*
	new BySlideMenu('mainmenu', {
		defaultIndex: numitems,
		autoSize: false,
		compressSize: 68,
		elementWidth: 200,
		containerHeight: 60
//		,containerWidth: width
//		,transition: Fx.Transitions.Bounce.easeOut
	});
*/


	new BySlideMenu({
		'container': 'mainmenu',
		'compressSize': 68,
		'selector': 'li'
	});
}

function initBrowsePage()
{
	window.addEvent('domready', function()
	{
		$$('.pager a').addEvent('click', function(event)
		{
			if($chk(event)) event.preventDefault();
			var content = $('browse-content');
			content.set('load', {evalScripts: true});
			content.load(this.get('href') + '&mode=ajax');
		});
	});
}

function sortBrowse()
{
	var strColumn = $('sortBy').selectedIndex;
	var bChecked = $('photo_first').checked;
//	location.href='?ps='+page+'&order='+strColumn+'&pf='+bChecked;
	
	var content = $('browse-content');
	content.set('load', {evalScripts: true});
	content.load('?order='+strColumn+'&pf='+bChecked+'&mode=ajax');
}

function initProfilePage()
{
	window.addEvent('domready', function()
	{
		$$('.prop a').addEvent('click', function(event)
		{
			if($chk(event)) event.preventDefault();
			var content = $('propertypage-content');
			content.set('load', {evalScripts: true});
			content.load(this.get('href') + '&mode=ajax');
			
			$$('.prop').removeClass('propselected');
			this.getParent().addClass('propselected');
		});
	});
}

function showVideo(url)
{
	new Swiff('includes/nonverblaster/NonverBlaster.swf', {
		id: 'video',
		width: 320,
		height: 256,
		container: $('propertypage-content'),
		params: {
			wmode: 'opaque',
			bgcolor: '#ff9933',
			menu: false,
			allowFullScreen: true,
			allowScriptAccess: 'always'
		},
		vars: {
			mediaURL: url,
			//teaserURL: "../nice-flowers.jpg",
			//indentImageURL: "indentImage.png",
			allowSmoothing: "true",
			autoPlay: "false",
			buffer: "6",
			showTimecode: "true",
			loop: "false",
			controlColor: "0xCC0000",
			controlBackColor: "0x000000",
			scaleIfFullScreen: "true",
			showScalingButton: "true",
			defaultVolume: "100"
		}
	});
	
	registerForJavaScriptCommunication('video');
}

function showEditor(id)
{
	$(id).mooEditable();
}

function showGallery()
{
	new SlideItMoo({
		itemsVisible:5,
		currentElement: 0,
		thumbsContainer: 'thumbs',
		elementScrolled: 'thumb_container',
		overallContainer: 'gallery_container'
	});
}

function initUploadProgress()
{
	$('upload').addEvent('submit', function(event)
	{
		new Element('div',
		{
			'id': strMsg,
			'class': 'chatuser',
			'html': strMsg,
			'events': {
				'click': function()
				{
					if(this.hasClass('chatuser-selected'))
					{
						this.removeClass('chatuser-selected');
						_chatPvt.set('value', '');
					}
					else {
						$$('.chatuser').removeClass('chatuser-selected');
						this.addClass('chatuser-selected');
						_chatPvt.set('value', this.id);
					}
				}
			}
		});

		pollUploadProgress();
	});
}

function pollUploadProgress()
{
	// make ajax call
}

function showUploadProgress()
{
	// update progress bar
	pollUploadProgress();
}

