function hideBox(boxName) {
	var Slide = new Fx.Slide(boxName);
	Slide.hide();
}

function toggleBox(boxName) {
	var Slide = new Fx.Slide(boxName);
	Slide.toggle();
}

function ajaxCallInDiv(ajax_url, ajax_method, ajax_div, ajax_data, scrollWindow) {
	if(scrollWindow == undefined) {
		scrollWindow = true;	
	}
	var ajax = new Request.HTML({ url: ajax_url, method: ajax_method, evalScripts:true, data: ajax_data, update: ajax_div,
								onSuccess: function(html) {
									$('loader').style.display = 'none';	
									if(scrollWindow) {
										var scroller = new Fx.Scroll(window).toTop(); }
									return true;
								},
								
								onFailure: function(){
									$('loader').style.display = 'none';	
									return false;
								}				
				});
	$('loader').style.display = 'inline';
	ajax.send();
}

function ajaxCallInWindow(ajax_url, ajax_method, ajax_data, win) {
	win.setAjax(''+ajax_url+'');
	win.show();
}

function ajaxCallForBool(ajax_url, ajax_method, ajax_data, successFunction, failureFunction) {
	var ajax = new Request({
					url: ajax_url, method: ajax_method, evalScripts:true, data: ajax_data,
				
				onSuccess: function(txt){
					$('loader').style.display = 'none';	
					if(txt === 'true') {
						eval(successFunction);	
					} else {
						eval(failureFunction);	
					}
				},
				
				onFailure: function(){
					$('loader').style.display = 'none';	
					eval(failureFunction);
				}
	});
	$('loader').style.display = 'inline';
	ajax.send();
}

function pageCallInWindow(url, win) {
	win.setUrl(''+url+'');
	win.show();
}

/*
Script: PictureNotices.js
	Class for creating notices over pictures.
*/

var PictureNoticer = new Class({
	
	Implements: [Options],
	
	options: {
		pictureNotices: 0
	},
					
	// constructor
	initialize: function(options) {
		this.picture = $(options.picture);
		this.noticeBox = $(options.noticeBox);
		this.name = options.name;
	},
	
	// add function
	add: function(noticeId, x, y, width, height, pictureBoxContent, noticeBoxContent, noticeBoxLink, deleteable, deleteLink) {
		pictureBox = new Element('div', {id: 'pictureBox_'+noticeId, 'class': 'div_pictureLinkMarkBox'});
		pictureBoxInner = new Element('div', {'class': 'div_pictureLinkMarkContent'});
		pictureBoxInner.set('text', pictureBoxContent);
		pictureBoxInner.injectInside(pictureBox);
		pictureBox.set('styles', {
					   'top': y+'px',
					   'left': x+'px',
					   'width': width+'px',
					   'height': height+'px'});
		pictureBox.injectInside(this.picture);
		
		noticeBox = new Element('div', {id: 'noticeBox_'+noticeId, 'class': 'div_noticeBox'});
		noticeBoxLink = new Element('a', {'href': noticeBoxLink});
		noticeBoxLink.set('text', noticeBoxContent);
		noticeBoxLink.set('styles', {'float': 'left'});
		if(deleteable) {
			deleteLinkBox = new Element('a', {'class': 'subLink'});
			deleteLinkBox.set('onclick', 'ajaxCallForBool(\''+deleteLink+'\', \'get\', null, \''+this.name+'.remove('+noticeId+')\')');
			deleteLinkBox.set('text', '[x]');
			deleteLinkBox.set('styles', {'float': 'right'});
			deleteLinkBox.injectInside(noticeBox);
		}
		noticeBoxLink.injectInside(noticeBox);
		noticeBox.set('events', {
					   'mouseover': function() { $('pictureBox_'+noticeId).set('class', 'div_pictureLinkMarkBox_active') },
					   'mouseout': function() { $('pictureBox_'+noticeId).set('class', 'div_pictureLinkMarkBox') }});
		noticeBox.injectInside(this.noticeBox);
		this.options.pictureNotices++;
		if(this.options.pictureNotices > 0) {
			this.noticeBox.set('styles', {'display': 'table'});
		}
	},
	
	// remove function
	remove: function(noticeId) {
		this.picture.removeChild($('pictureBox_'+noticeId));
		this.noticeBox.removeChild($('noticeBox_'+noticeId));
		this.options.pictureNotices--;
		if(this.options.pictureNotices == 0) {
			this.noticeBox.set('styles', {'display': 'none'});
		}
	}
});
