<!--
function getObjById(id)
{
	if (document.getElementById)
		var returnVar = document.getElementById(id);
	else if (document.all)
		var returnVar = document.all[id];
	else if (document.layers)
		var returnVar = document.layers[id];
	return returnVar;
}

function isdefined(object, variable)
{
	return (typeof(eval(object)[variable]) != 'undefined');
}

function getEventTarget(e) {
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
		
	return targ;
}

var box_tabs = new Array();
var box_corners = new Array();
var box_onesmalltab = new Array();
var box_names = new Array();
var ajax_tabs = new Array();
var selected_tabs = new Array();

function cancelEvent(e) {
	new Event(e).stop();
}

var ajax_requests = [];

closed_tabs = [];

function hideRanks(b_id) {
	try {
	
		ranksFx[b_id].stop();
		var o = {};
		for (i = 0; i < ranksNum[b_id]; i++) {
			o[i] = { opacity: 0 };
		}
		ranksFx[b_id].set(o);
		
	} catch (e) { }
}

function showRanks(b_id) {
	try {

		ranksFx[b_id].stop();
		var o = {};
		for (i = 0; i < ranksNum[b_id]; i++) {
			o[i] = { opacity: [0, 1] };
		}
		ranksFx[b_id].start(o);
		
	} catch (e) { }
}

function showCpSelects() {
/*	$$(".cp_select").each(function (el) {
		el.setStyle('visibility', 'visible');
	});*/
}

function getTab(t_id, b_id) {
	var box_c = getObjById("box_c"+ b_id);
	var box_loading_icon = getObjById("box_loading_icon"+ b_id);
	var curtab_content = getObjById("curtab_content"+ b_id);

	
	selected_tabs[b_id] = t_id;	
	
	//if (curtab_content) curtab_content.style.visibility = "hidden";
	//if (curtab_content) fade(curtab_content, 'out', 0, 100, 1);
	
	for (i = 0; i < ajax_tabs[b_id].length; i++) {
		if (!ajax_tabs[b_id][i]) {
			var tab_obj = getObjById("tab_content"+ b_id +"_"+ i);
			if (tab_obj) {
				tab_obj.style.display = "none";
				//fade(tab_obj, 'out', 0, 100, 1);
				//$("tab_content"+ b_id +"_"+ i).effect("opacity", {}).set(0);
				tab_content_fx["tab_content"+ b_id +"_"+ i].set(0);
			}
		}
	}
	
	//if (curtab_content) $("curtab_content"+ b_id).effect("opacity", {}).set(0.001);
	if (curtab_content) {
		//curtab_content_fx[b_id].set(0.001);
		$(curtab_content).empty();
		$(curtab_content).setStyle('visibility', 'hidden');
		curtab_content.scrollTop = 0;
		curtab_content.scrollLeft = 0;
	}
	
	if (showscroll_timeout[b_id]) clearTimeout(showscroll_timeout[b_id]);	
	
	if (ajax_requests[b_id]) {
		ajax_requests[b_id].cancel();
	}
	
	hideRanks(b_id);
	
	if (ajax_tabs[b_id][t_id]) {
		//if (curtab_content) box_c.removeChild(curtab_content);

		curtab_content_fx[b_id].stop();
		
		//if (box_loading_icon) $(box_loading_icon).setStyle('display', 'block');
		
		if (!closed_tabs[b_id]) {
			if (box_loading_icon) box_loading_icon.style.visibility = "visible";
		}

		//var ajaxRequest = new AjaxRequest("../../get_content.php?b_id="+ b_id +"&t_id="+ t_id +"&b_name="+ box_names[b_id]); // create AjaxRequest object
		//ajaxRequest.sendRequest();  // send the request
		if (document.location.href.substr(7, 7) == 'ragazze') {
			var url = "/get_content.php";
		} else {
			var url = "/ragazze/get_content.php";
		}
		var rand = (Math.round((Math.random()*99999)+1));
		var query_string = "b_id="+ b_id +"&t_id="+ t_id +"&b_name="+ box_names[b_id] +"&r="+ rand;

		ajax_requests[b_id] = new XHR({
			method: 'get',
			onSuccess: function () { 
				var content = ajax_requests[b_id].response.text;
				onAjaxResponse(b_id, t_id, content); 
			}
		});
		ajax_requests[b_id].send(url, query_string);
	} else {
		var tab_obj = getObjById("tab_content"+ b_id +"_"+ t_id);		
		if (tab_obj) {
			tab_obj.style.display = "block";
			//fade(tab_obj, 'in');
			//$("tab_content"+ b_id +"_"+ t_id).effect("opacity", {duration:500}).start(0, 1);
			
			tab_content_fx["tab_content"+ b_id +"_"+ t_id].stop();
			
			if (box_loading_icon) box_loading_icon.style.visibility = "hidden";
			//if (box_loading_icon) $(box_loading_icon).setStyle('display', 'none');
			
			if (!closed_tabs[b_id]) {
		
				if (tabs_fx[b_id +'_'+ t_id] == 0) {	// no effect
					tab_content_fx["tab_content"+ b_id +"_"+ t_id].set(1).chain(function () { showCpSelects(); showDelayedScrolls(b_id, t_id, 500); });
				} else if (tabs_fx[b_id +'_'+ t_id] == 1) {	// fade-in effect
					tab_content_fx["tab_content"+ b_id +"_"+ t_id].start(0, 1).chain(function () { showCpSelects(); showDelayedScrolls(b_id, t_id, 250); });
				} else if (tabs_fx[b_id +'_'+ t_id] == 2 || tabs_fx[b_id +'_'+ t_id] == 3) {	// expand + fade-in effect - bounce + fade-in effect
					setTimeout(function () { expandFx(b_id, t_id, tabs_fx[b_id +'_'+ t_id]); }, 500);
				}
			}
			
		}
	}
}

function showDelayedScrolls(b_id, t_id, delay) {
	showRanks(b_id);
	showscroll_timeout[b_id] = setTimeout(function () { showScroll(b_id, t_id); }, delay);
}

function openClose(b_id, obj) {
	if (!closed_tabs[b_id]) {
		closeFx(b_id, selected_tabs[b_id], 2);
		hideRanks(b_id);
	} else {
		expandFx(b_id, selected_tabs[b_id], 2);
	}
	obj.blur();
}

var expand_fx = [];
box_tabsheight = [];
var close_fx = [];

function hideScrolls(b_id) {
	var scroll_bottom_obj = getObjById('box_vscroll_bottom'+ b_id);
	var scroll_top_obj = getObjById('box_vscroll_top'+ b_id);
	var scroll_right_obj = getObjById('box_hscroll_right'+ b_id);
	var scroll_left_obj = getObjById('box_hscroll_left'+ b_id);
	
	if (showscroll_timeout[b_id]) {
		clearTimeout(showscroll_timeout[b_id]);
	}
	
	if (scroll_bottom_obj) {
		scroll_bottom_obj.style.visibility = "hidden";
		bottomscroll_fx[b_id].stop();
		bottomscroll_fx[b_id].set(0);
	}
	if (scroll_top_obj) {
		scroll_top_obj.style.visibility = "hidden";
		topscroll_fx[b_id].stop();
		topscroll_fx[b_id].set(0);
	}
	if (scroll_right_obj) {
		scroll_right_obj.style.visibility = "hidden";
		rightscroll_fx[b_id].stop();
		rightscroll_fx[b_id].set(0);
	}
	if (scroll_left_obj) {
		scroll_left_obj.style.visibility = "hidden";
		leftscroll_fx[b_id].stop();
		leftscroll_fx[b_id].set(0);
	}
}

function closeFx(b_id, t_id, fx_type) {
	var content_divs = [];
	for (j = 0; j < ajax_tabs[b_id].length; j++) {
		content_divs[j] = getObjById(!ajax_tabs[b_id][j] ? "tab_content"+ b_id +"_"+ j : "curtab_content"+ b_id);
	}
	
	var box_lcr = $$("#box_l"+ b_id, "#box_c"+ b_id, "#box_r"+ b_id, content_divs);
	if (!$defined(close_fx[b_id])) {
		if (fx_type == 2) {
			close_fx[b_id] = new Fx.Elements(box_lcr, {duration:600,transition:Fx.Transitions.Cubic.easeOut, onComplete: function () {closed_tabs[b_id] = true;} });
		} else if (fx_type == 3) {
			close_fx[b_id] = new Fx.Elements(box_lcr, {duration:1300,transition:Fx.Transitions.Bounce.easeOut, onComplete: function () {closed_tabs[b_id] = true;} });
		}
	} else {
		close_fx[b_id].stop();
	}
	if ($defined(expand_fx[b_id])) {
		expand_fx[b_id].stop();
	}
	
	var o = {};
	box_lcr.each(function (el, i) {
		if (i < 3) {
			o[i] = {height: [el.getStyle('height').toInt(), 15]};
		} else {
			o[i] = {height: [el.getStyle('height').toInt(), 0]};
		}
	});
	
	var div_fx = (!ajax_tabs[b_id][t_id] ? tab_content_fx["tab_content"+ b_id +"_"+ t_id] : curtab_content_fx[b_id]);
	
	if (ajax_requests[b_id]) {
		ajax_requests[b_id].cancel();
	}
	
	var box_loading_icon = getObjById("box_loading_icon"+ b_id);
	if (box_loading_icon) box_loading_icon.style.visibility = "hidden";
	
	if (div_fx) {
		div_fx.stop();
		div_fx.start(1, 0);
	}
	
	hideScrolls(b_id);
	
	/*div_fx.start(1, 0).chain(function () {*/

		close_fx[b_id].start(o);
		
	/*});*/
}

function expandFx(b_id, t_id, fx_type) {
	var content_divs = [];
	for (j = 0; j < ajax_tabs[b_id].length; j++) {
		content_divs[j] = getObjById(!ajax_tabs[b_id][j] ? "tab_content"+ b_id +"_"+ j : "curtab_content"+ b_id);
	}
	
	var box_lcr = $$("#box_l"+ b_id, "#box_c"+ b_id, "#box_r"+ b_id, content_divs);
	if (!$defined(expand_fx[b_id])) {
		if (fx_type == 2) { 
			expand_fx[b_id] = new Fx.Elements(box_lcr, {duration:600,transition:Fx.Transitions.Cubic.easeOut, onComplete: function () {closed_tabs[b_id] = false;} });
		} else if (fx_type == 3) {
			expand_fx[b_id] = new Fx.Elements(box_lcr, {duration:1300,transition:Fx.Transitions.Bounce.easeOut, onComplete: function () {closed_tabs[b_id] = false;} });
		}
	} else {
		expand_fx[b_id].stop();
	}
	if ($defined(close_fx[b_id])) {
		close_fx[b_id].stop();
	}
	if (showscroll_timeout[b_id]) {
		clearTimeout(showscroll_timeout[b_id]);
	}
	
	var o = {};
	box_lcr.each(function (el, i) {
		if (i < 3) {
			o[i] = {height: [15, box_tabsheight[b_id]]};
		} else {
			o[i] = {height: [0, (box_tabsheight[b_id]-15)]};
		}
	});
	
	var div_fx = (!ajax_tabs[b_id][t_id] ? tab_content_fx["tab_content"+ b_id +"_"+ t_id] : curtab_content_fx[b_id]);
	
	if (div_fx) {
		div_fx.stop();
		div_fx.set(0);
	}

	/*(function () { */
		expand_fx[b_id].start(o).chain(function () { if (div_fx) { div_fx.start(0, 1).chain(function () { showCpSelects(); showDelayedScrolls(b_id, t_id, 250); }); }});
	/*}).delay(500);*/
}

tabs_fx = [];

function onAjaxResponse(b_id, t_id, content) {
	//$("box_loading_icon"+ b_id).setStyle('display', 'none');
	if ($defined($("box_loading_icon"+ b_id))) $("box_loading_icon"+ b_id).setStyle('visibility', 'hidden');

	//fade('curtab_content'+ b_id, 'in');
	//$('curtab_content'+ b_id).effect("opacity", {duration:500}).set(0);

	curtab_content_fx[b_id].set(0);
	
	$('curtab_content'+ b_id).innerHTML = content;
	
	//$('curtab_content'+ b_id).setStyle('visibility', 'visible');
	//$('curtab_content'+ b_id).setStyle("display", "block");
	//$('curtab_content'+ b_id).effect("opacity", {duration:500}).start(0.001, 1);

	if (!closed_tabs[b_id]) {
		if (tabs_fx[b_id +'_'+ t_id] == 0) {	// no effect
			curtab_content_fx[b_id].set(1).chain(function () { showDelayedScrolls(b_id, t_id, 500); });
		} else if (tabs_fx[b_id +'_'+ t_id] == 1) {	// fade-in effect
			curtab_content_fx[b_id].start(0, 1).chain(function () { showDelayedScrolls(b_id, t_id, 250); });
		} else if (tabs_fx[b_id +'_'+ t_id] == 2 || tabs_fx[b_id +'_'+ t_id] == 3) {	// expand + fade-in effect
			setTimeout(function () { expandFx(b_id, t_id, tabs_fx[b_id +'_'+ t_id]); }, 500);
		}
		//showscroll_timeout[b_id] = setTimeout(function () { showScroll(b_id, t_id); }, 500);
		//onmousewheel(getObjById('curtab_content'+ b_id), function (delta) { mouseScroll(b_id, delta, true, false); });
	}
}

curtab_content_fx = [];
tab_content_fx = [];

bottomscroll_fx = [];
rightscroll_fx = [];
topscroll_fx = [];
leftscroll_fx = [];

function selectTab(event) {
	var anchor = getEventTarget(event);
	var box = anchor.parentNode.parentNode;
	var box_id = box.id;
	var currentTab = -1;
	
	var box_idnum = box_id.substr(3);

	var tabs = box_tabs[box_id];
	for (var i = 0; i < tabs.length; i++) {
		getObjById(tabs[i]).style.background = "none";
		if (anchor.parentNode.id == tabs[i]) {
			currentTab = i;
		}
	}
	
	var left_corner_id = box_corners[box_id][0];
	var right_corner_id = box_corners[box_id][1];
	var left_corner = getObjById(left_corner_id);
	var right_corner = getObjById(right_corner_id);
	
	left_corner.className = "box_tlg";
	right_corner.className = "box_trg";
	
	if (currentTab == 0) {
		left_corner.className = "box_tlw";
	}
	var one_small_tab = box_onesmalltab[box_id];
	if ((currentTab == tabs.length - 1) && !one_small_tab) {
		right_corner.className = "box_trw";
	}
		
	anchor.parentNode.style.backgroundColor = "#ffffff";
	
	cancelEvent(event);
	
	getTab(currentTab, box_idnum);
	
	hideScrolls(box_idnum);
}

scroll_interval = [];
scroll_increment = 3;
mousescroll_increment = 10;
delay = 50;
showscroll_timeout = [];

function scroll(b_id, dir, increment) {
	if (ajax_tabs[b_id][selected_tabs[b_id]]) {
		var obj = getObjById("curtab_content"+ b_id);
	} else {
		var obj = getObjById("tab_content"+ b_id +"_"+ selected_tabs[b_id]);
	}
	var op = 0.65;
	switch (dir) {
		case 'down':
			if (obj.scrollTop < obj.scrollHeight - obj.clientHeight) {
				obj.scrollTop += increment;
				topscroll_fx[b_id].set(op);
			}
			if (obj.scrollTop == obj.scrollHeight - obj.clientHeight) {
				bottomscroll_fx[b_id].set(0);
			}
		break;
		case 'up':
			if (obj.scrollTop > 0) {
				obj.scrollTop -= increment;
				bottomscroll_fx[b_id].set(op);
			}
			if (obj.scrollTop == 0) {
				topscroll_fx[b_id].set(0);
			}
		break;
		case 'right':
			if (obj.scrollLeft < obj.scrollWidth - obj.clientWidth) {
				obj.scrollLeft += increment;
				leftscroll_fx[b_id].set(op);
			}
			if (obj.scrollLeft == obj.scrollWidth - obj.clientWidth) {
				rightscroll_fx[b_id].set(0);
			}
		break;
		case 'left':
			if (obj.scrollLeft > 0) {
				obj.scrollLeft -= increment;
				rightscroll_fx[b_id].set(op);
			}
			if (obj.scrollLeft == 0) {
				leftscroll_fx[b_id].set(0);
			}
		break;
	}
}

var vscroll_timeout = [];
var hscroll_timeout = [];

function mouseScroll(b_id, delta, vscroll, hscroll) {
	var scroll_bottom_obj = getObjById('box_vscroll_bottom'+ b_id);
	var scroll_top_obj = getObjById('box_vscroll_top'+ b_id);
	var scroll_right_obj = getObjById('box_hscroll_right'+ b_id);
	var scroll_left_obj = getObjById('box_hscroll_left'+ b_id);
	
	if (ajax_tabs[b_id][selected_tabs[b_id]]) {
		var obj = getObjById("curtab_content"+ b_id);
	} else {
		var obj = getObjById("tab_content"+ b_id +"_"+ selected_tabs[b_id]);
	}
	
	var off_op = 0.65;
	var op = 0.8;

	if (vscroll) {
		var dir = (delta < 0) ? "down" : "up";
		
		if (dir == "down") {
			//fade(scroll_bottom_obj, 'in', '80', 80, 1);
			if (obj.scrollTop < obj.scrollHeight - obj.clientHeight) {
				bottomscroll_fx[b_id].set(op);
				clearTimeout(vscroll_timeout[b_id]);
				vscroll_timeout[b_id] = setTimeout(function () { if (obj.scrollTop < obj.scrollHeight - obj.clientHeight) { bottomscroll_fx[b_id].set(off_op); } topscroll_fx[b_id].set(off_op); }, 300);
			}
		} else if (dir == "up") {
			//fade(scroll_top_obj, 'in', 80, 80, 1);
			if (obj.scrollTop > 0) {
				topscroll_fx[b_id].set(op);
				clearTimeout(vscroll_timeout[b_id]);
				vscroll_timeout[b_id] = setTimeout(function () { if (obj.scrollTop > 0) { topscroll_fx[b_id].set(off_op); } bottomscroll_fx[b_id].set(off_op); }, 300);
			}
		}
		
		scroll(b_id, dir, mousescroll_increment);
	} else if (hscroll) {
		var dir = (delta == -1) ? "right" : "left";
		
		if (dir == "right") {
			//fade(scroll_right_obj, 'in', '80', 80, 1);
			if (obj.scrollLeft < obj.scrollWidth - obj.clientWidth) {
				rightscroll_fx[b_id].set(op);
				clearTimeout(hscroll_timeout[b_id]);
				hscroll_timeout[b_id] = setTimeout(function () { if (obj.scrollLeft < obj.scrollWidth - obj.clientWidth) { rightscroll_fx[b_id].set(off_op); } leftscroll_fx[b_id].set(off_op); }, 300);
			}
		} else if (dir == "left") {
			//fade(scroll_left_obj, 'in', 80, 80, 1);
			if (obj.scrollLeft > 0) {
				leftscroll_fx[b_id].set(op);
				clearTimeout(hscroll_timeout[b_id]);
				hscroll_timeout[b_id] = setTimeout(function () { if (obj.scrollLeft > 0) { leftscroll_fx[b_id].set(off_op); } rightscroll_fx[b_id].set(off_op); }, 300);
			}
		}
		
		scroll(b_id, dir, mousescroll_increment);
	}
}

function startScrolling(b_id, dir) {
	if (ajax_tabs[b_id][selected_tabs[b_id]]) {
		var obj = getObjById("curtab_content"+ b_id);
	} else {
		var obj = getObjById("tab_content"+ b_id +"_"+ selected_tabs[b_id]);
	}
	var op = 0.8;
	switch (dir) {
		case 'down':
			if (obj.scrollTop < obj.scrollHeight - obj.clientHeight) {
				bottomscroll_fx[b_id].set(op);
			}
		break;
		case 'right':
			if (obj.scrollLeft < obj.scrollWidth - obj.clientWidth) {
				rightscroll_fx[b_id].set(op);
			}
		break;
		case 'up':
			if (obj.scrollTop > 0) {
				topscroll_fx[b_id].set(op);
			}
		break;
		case 'left':
			if (obj.scrollLeft > 0) {
				leftscroll_fx[b_id].set(op);
			}
		break;
	}
	scroll_interval[b_id] = setInterval("scroll('"+ b_id +"', '"+ dir +"', "+ scroll_increment +")", delay);
}

function stopScrolling(b_id, dir) {
	if (ajax_tabs[b_id][selected_tabs[b_id]]) {
		var obj = getObjById("curtab_content"+ b_id);
	} else {
		var obj = getObjById("tab_content"+ b_id +"_"+ selected_tabs[b_id]);
	}
	var op = 0.65;
	clearInterval(scroll_interval[b_id]);
	switch (dir) {
		case 'down':
			if (obj.scrollTop == obj.scrollHeight - obj.clientHeight) {
				bottomscroll_fx[b_id].set(0);
			}
			else
			{
				bottomscroll_fx[b_id].set(op);
			}
		break;
		case 'right':
			if (obj.scrollLeft == obj.scrollWidth - obj.clientWidth) {
				rightscroll_fx[b_id].set(0);
			}
			else
			{
				rightscroll_fx[b_id].set(op);
			}
		break;
		case 'up':
			if (obj.scrollTop == 0) {
				topscroll_fx[b_id].set(0);
			}
			else
			{
				topscroll_fx[b_id].set(op);
			}
		break;
		case 'left':
			if (obj.scrollLeft == 0) {
				leftscroll_fx[b_id].set(0);
			}
			else
			{
				leftscroll_fx[b_id].set(op);
			}
		break;
	}
}

function showScroll(box_id, tab_id) {
	if (closed_tabs[box_id]) return;

	var scroll_bottom_obj = getObjById('box_vscroll_bottom'+ box_id);
	var scroll_top_obj = getObjById('box_vscroll_top'+ box_id);
	var scroll_right_obj = getObjById('box_hscroll_right'+ box_id);
	var scroll_left_obj = getObjById('box_hscroll_left'+ box_id);
	
	if (ajax_tabs[box_id][tab_id]) {
		var curtab_obj = getObjById('curtab_content'+ box_id);
	} else {
		var curtab_obj = getObjById('tab_content'+ box_id +'_'+ tab_id);
	}
	
	var op = 0.65;
	
	if (curtab_obj) {
		if (scroll_bottom_obj) {
			scroll_bottom_obj.style.visibility = "visible";
			//fade(scroll_bottom_obj, 'in', 80);
			if (curtab_obj.scrollTop < curtab_obj.scrollHeight - curtab_obj.clientHeight) {
				bottomscroll_fx[box_id].start(0, op);
			} else {
				bottomscroll_fx[box_id].set(0);
			}
		}
		if (scroll_right_obj) {
			scroll_right_obj.style.visibility = "visible";
			//fade(scroll_right_obj, 'in', 80);
			if (curtab_obj.scrollLeft < curtab_obj.scrollWidth - curtab_obj.clientWidth) {
				rightscroll_fx[box_id].start(0, op);
			} else {
				rightscroll_fx[box_id].set(0);
			}
		}
		if (scroll_top_obj) {
			scroll_top_obj.style.visibility = "visible";
			if (curtab_obj.scrollTop > 0) {
				topscroll_fx[box_id].start(0, op);
			} else {
				topscroll_fx[box_id].set(0);
			}
		}
		if (scroll_left_obj) {
			scroll_left_obj.style.visibility = "visible";
			if (curtab_obj.scrollLeft > 0) {
				leftscroll_fx[box_id].start(0, op);
			} else {
				leftscroll_fx[box_id].set(0);
			}
		}
	}

}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function scrollBoxTab(b_id, t_id, st) {
	var scroll_obj = getObjById('tab_content'+ b_id +'_'+ t_id);
	if (scroll_obj) scroll_obj.scrollTop = st;
}

function loadMp3(m_id, w, h, mp3) {	
	var s1 = new SWFObject("http://monotonia.it/swf/mediaplayer.swf", "mediaplayer"+ m_id, w, h, "8");
	s1.addParam("allowfullscreen", "false");
	s1.addVariable("autostart", "true");
	s1.addVariable("width", w);
	s1.addVariable("height", h);
	//s1.addVariable("file", "http://monotonia.it/stream.php?file="+ mp3);
	s1.addVariable("file", mp3);
	/*s1.addVariable("image", "../../img/speaker.png");*/
	
	//s1.useExpressInstall('http://monotonia.it/swf/expressinstall.swf');

	//s1.addVariable('javascriptid', "mediaplayer"+ m_id);
	//s1.addVariable('enablejs','true');

	s1.write("audio"+ m_id);
}

function loadVideo(v_id, w, h, flv) {
	var s1 = new SWFObject("http://monotonia.it/swf/mediaplayer.swf", "mediaplayer"+ v_id, w, h, "8");
	s1.addParam("allowfullscreen", "true");
	s1.addParam("allowscriptaccess", "always");
	s1.addVariable("autostart", "true");
	s1.addVariable("width", w);
	s1.addVariable("height", h);
	//s1.addVariable("file", "http://monotonia.it/stream.php?file="+ flv);
	s1.addVariable("file", flv);
	s1.addVariable("logo", "http://monotonia.it/img/watermark_small.png");
	
	//s1.useExpressInstall('http://monotonia.it/swf/expressinstall.swf');
	
	//s1.addVariable('javascriptid', "mediaplayer"+ v_id);
	//s1.addVariable('enablejs', 'true');
	
	s1.write("video"+ v_id);
}

function toolTips_init() {
	var tips = new Tips($$('.tips'), {
		initialize: function() {
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});	
}

function toolTips() {
	window.addEvent('domready', function () {
		toolTips_init();
	});
}

loginBox_open_fx = null;
loginBox_close_fx = null;
loginBox_content_fx = null;
loginBox_h = 125;

window.addEvent('domready', function () {

	loginBox_open_fx = new Fx.Style('loginbox_c', 'height', {duration:1000,wait:false,transition:Fx.Transitions.Elastic.easeOut});
	loginBox_close_fx = new Fx.Style('loginbox_c', 'height', {duration:1000,wait:false,transition:Fx.Transitions.Cubic.easeOut});
	loginBox_content_fx = new Fx.Style('loginbox_content', 'opacity', {duration:500,wait:false});

});

function disableTooltips() {
	$$(".tool-tip").each(function (el, i) {
		el.style.display = "none";
	});
}

function enableTooltips() {
	$$(".tool-tip").each(function (el, i) {
		el.style.display = "block";
	});	
}

loginBox_opened = false;

function loginBox_open(obj) {
	if (loginBox_opened) {
		return;
	}
	
	loginBox_opened = true;

	$(obj).style.textDecoration = 'underline';
	
	loginBox_close_fx.stop();
	
	$('u').value = '';
	$('p').value = '';
	
	$('login_text').style.visibility = 'hidden';
	$('loginbox').style.visibility = 'visible';
	$('loginbox').style.display = 'block';
	
	disableTooltips();
	
	$('login_form').style.display = 'block';
	$('pwdlost_form').style.display = 'none';
	enableLoginBtn();
	
	loginBox_open_fx.start(1, loginBox_h).chain(function () {
		//loginBox_content_fx.set(0.0001);
		enableTooltips();
		loginBox_content_fx.start(0, 1).chain(function () {
			if (loginBox_opened) {
				backToLogin();
			}
		});

	});
}

function loginBox_close(obj) {
	loginBox_opened = false;
	
	$(obj).style.textDecoration = 'underline';
	
	$('p').blur();
	$('u').blur();
	$('e').blur();
	window.focus();

	loginBox_open_fx.stop();
	
	disableTooltips();
	
	//$('login_content').style.visibility = 'hidden';
	
	loginBox_content_fx.start(1, 0);

	loginBox_close_fx.start(loginBox_h, 0).chain(function () {
		enableTooltips();
		/*backToLogin();*/
		$('login_text').style.visibility = 'visible';
		$('loginbox').style.visibility = 'hidden';
		/*$('loginbox').style.display = 'none';*/
		$('login_err_msg').empty();
		$('pwdlost_msg').empty();
	});
}

function onLogin(ret_msg) {
	if (ret_msg == 'ko') {
		$('login_err_msg').innerHTML = "Login errato.";
		$('login_btn').disabled = false;
	} else if (ret_msg == 'ok') {
		if (document.location.href.substr(0, 22) == 'http://monotonia.it/cp') {
			document.location.reload();
		} else {
			document.location.href = 'http://monotonia.it/cp/';
		}
	}
}

function login(evt, form_obj) {
	var username = $('u').value;
	var password = $('p').value;
	
	form_obj = $(form_obj);
	
	$('login_btn').focus();
	$('login_btn').disabled = true;
	$('login_btn').blur();
	$('login_err_msg').innerHTML = "Attendi...";
	
	var rand = (Math.round((Math.random()*99999)+1));
	
	var query_string = "u="+ username +"&p="+ password +"&r="+ rand;
	//var url = "http://monotonia.it/cp/";
	url = form_obj.getAttribute("action");

	login_request = new XHR({
		method: 'post',
		onSuccess: function () { 
			var ret_msg = login_request.response.text;
			onLogin(ret_msg); 
		}
	});
	
	try {
		login_request.send(url, query_string);
	} catch (e) {
		$('login_btn').focus();
		$('login_btn').disabled = false;
		$('login_btn').blur();
		$('login_err_msg').innerHTML = "Errore.";
		cancelEvent(evt);
	}
	
	/*$('login_err_msg').empty();*/
	
	cancelEvent(evt);
}

function logout() {
	document.forms['logout_form'].submit();
}

var topmenubtns_state = [];

function rollover(obj) {
	var o = $(obj);
	topmenubtns_state[o.id] = o.getProperty("class");
	o.setProperty("class", "on");
}

function rollout(obj) {
	var o = $(obj);
	o.setProperty("class", topmenubtns_state[o.id]);
}

function switchToPwdLost() {
	$('pwdlost_msg').empty();
	$('login_form').style.display = 'none';
	$('pwdlost_form').style.display = 'block';
	try {
	
		var p = $('p');
		var e = $('e');
		var u = $('u');
		
		p.blur();
		u.blur();
			
		e.focus();
		e.value = '';
		
		$('pwdlost_btn').disabled = true;
	} catch (e) { }
}

function backToLogin() {
	$('login_err_msg').empty();
	$('login_form').style.display = 'block';
	$('pwdlost_form').style.display = 'none';
	try {
		
		var p = $('p');
		var e = $('e');
		var u = $('u');
		
		p.blur();
		e.blur();
		
		p.value = '';
		u.focus();
		u.value = '';
		
		$('login_btn').disabled = true;
		
	} catch (e) { }
}

function onLoginDataSent(ret_msg) {
	if (ret_msg == 'ko') {
		$('pwdlost_msg').innerHTML = "Errore: e-mail sconosciuta.";
	} else if (ret_msg == 'ok') {
		$('pwdlost_msg').innerHTML = "Dati di accesso inviati.";
	}
	$('pwdlost_btn').disabled = false;
}

function send_login_info(evt, form_obj) {
	form_obj = $(form_obj);

	var email = $('e').value;
	
	$('pwdlost_btn').focus();
	$('pwdlost_btn').disabled = true;
	$('pwdlost_btn').blur();
	$('pwdlost_msg').innerHTML = "Attendi...";
	
	var rand = (Math.round((Math.random()*99999)+1));
	
	var query_string = "e="+ email +"&r="+ rand;
	//var url = "http://monotonia.it/cp/";
	url = form_obj.getAttribute("action");

	sli_request = new XHR({
		method: 'post',
		onSuccess: function () { 
			var ret_msg = sli_request.response.text;
			onLoginDataSent(ret_msg); 
		}
	});
	sli_request.send(url, query_string);
	/*$('pwdlost_msg').empty();*/
	
	cancelEvent(evt);
}

var ranksFx = [];
var ranksNum = [];

function boxInit(b_id) {
	window.addEvent('domready', function () {
	
		var str = "#box"+ b_id +" .top, #box"+ b_id +" .pro, #box"+ b_id +" .vip";
		var elements = $$(str);
		ranksNum[b_id] = elements.length;
		ranksFx[b_id] = new Fx.Elements(elements, {wait:false});
	
	});
}

function enableLoginBtn() {
	if ($('u').value != "" && $('p').value != "") {
		$('login_btn').disabled = false;
	} else {
		$('login_btn').disabled = true;
	}
}

function enablePwdLostBtn() {
	if ($('e').value != "") {
		$('pwdlost_btn').disabled = false;
	} else {
		$('pwdlost_btn').disabled = true;
	}
}

function updateUsr() {
	var str_usr = $('reg_user').value;
	if (str_usr.length > 20) {
		str_usr = str_usr.substr(0, 20);
		$('reg_user').value = str_usr;
	} else if (str_usr.length == 0) {
		str_usr = "<b>username</b>";
	}
	$('usr').innerHTML = str_usr;
}

function addUsrObserver() {
	window.addEvent("domready", function () {

		$('reg_user').addEvent("keyup", function () {
			updateUsr();
		});
		
		$('reg_user').addEvent("keydown", function () {
			updateUsr();
		});
		
		$('reg_user').addEvent("change", function () {
			updateUsr();
		});
	
	});
}

function onRegSubmit() {
	try {
		$('reg_btn').disabled = true;
		$('reg_err').innerHTML = "<span class=\"err\">Attendi...</span>";
	} catch (e) { }
}

function getCurDate() {
	var time=new Date();
	var month=time.getMonth() + 1;
	var day=time.getDate();
	var year=time.getYear();
	if (year < 2000)
	year = year + 1900;
	ret = [];
	ret[0] = day;
	ret[1] = month;
	ret[2] = year;
	return ret;
}

function getAge(dob) {
	dob_d = parseInt(dob.substr(0, 2), 10);	// day
	dob_m = parseInt(dob.substr(3, 2), 10);	// month
	dob_y = parseInt(dob.substr(6, 4), 10);	// year
	
	curDate = getCurDate();

	if (dob_d == 0 && dob_m == 0 && dob_y == 0)
	{
		return 0;
	}

	// get current date
	cd_d = curDate[0];		// day
	cd_m = curDate[1];		// month
	cd_y = curDate[2];		// year
	
	/*alert(cd_d +", "+ dob_d);
	alert(cd_m +", "+ dob_m);
	alert(cd_y +", "+ dob_y);*/

	age = cd_y - dob_y;

	subtractOne = false;
	if (cd_m != dob_m)
	{
		subtractOne = (dob_m > cd_m);
	}
	else
	{
		subtractOne = (dob_d > cd_d);
	}
	if (subtractOne)
		age--;

	return age;
}

function datePicker_onpick(value) {
	age = getAge(value);
	if (age < 10) {
		$('cp_eta').innerHTML = "<span class=\"err\"><span class=\"small_text\">devi avere almeno 10 anni</span></span>";		
	} else 	if (age > 35) {
		$('cp_eta').innerHTML = "<span class=\"err\"><span class=\"small_text\">devi avere massimo 35 anni</span></span>";		
	} else {
		$('cp_eta').innerHTML = age +" anni";
	}
}

function datePicker_init() {
	window.addEvent('domready', function(){

		$$('input.DatePicker').each( function(el){
			new DatePicker(el);
			datePicker_onpick(el.value);
		});

	});
}

editableBars_lastBtn = "up";
editableBars_text = Array(
	"<span onMouseOver=\"this.style.cursor = 'help';\" onMouseOut=\"this.style.cursor = 'default';\" class=\"tips\" title=\"Non dichiarato :: Livello di preparazione non specificato\">n.d.</span>",
	"basso",
	"intermedio",
	"buono",
	"molto buono",
	"ottimo"
);

function editableBars_init() {
	window.addEvent('domready', function(){

		$$(".capacita_minus").each( function(el){
			el.addEvent("mousedown", function () {
				decreaseBar(el.id.substr(14, 1));
				editableBars_lastBtn = "down";
			});
			el.addEvent("mouseup", function () {
				if (editableBars_lastBtn != "down") {
					decreaseBar(el.id.substr(14, 1));
				}
				editableBars_lastBtn = "up";
			});
		});

		$$(".capacita_plus").each( function(el){
			el.addEvent("mousedown", function () {
				increaseBar(el.id.substr(13, 1));
				editableBars_lastBtn = "down";
			});
			el.addEvent("mouseup", function () {
				if (editableBars_lastBtn != "down") {
					increaseBar(el.id.substr(13, 1));
				}
				editableBars_lastBtn = "up";
			});
		});

	});
}

function increaseBar(id) {
	el = $('bar'+ id +'_value');
	value = el.className.substr(9, 1);
	if (value < 5) {
		value++;
		el.innerHTML = editableBars_text[value];
		el.className = "bar_value"+ value;
		toolTips_init();
	}
	$('cp_capacita'+ id).value = value;
}

function decreaseBar(id) {
	el = $('bar'+ id +'_value');
	value = el.className.substr(9, 1);
	if (value > 0) {
		value--;
		el.innerHTML = editableBars_text[value];
		el.className = "bar_value"+ value;
		toolTips_init();
	}
	$('cp_capacita'+ id).value = value;
}

function editableList_preview(id) {
	text = $('cp_cv_text'+ id);
	list = $('cp_cv_preview');	
	
	items = text.value.split('\n');
	list.innerHTML = "";
	list_html = "";
	for (var i = 0; i < items.length; i++) {
		if (items[i].clean() != "") {
			list_html += "<li>"+ htmlentities(items[i]) +"</li>\n";
		}
	}
	list.innerHTML = list_html;
	anteprima_labels = new Array('curriculum', 'interessi', 'altro');
	$('cp_anteprima_label').innerHTML = anteprima_labels[id - 1];
}

function editableList_update(textBox_id) {
	id = selected_tabs[textBox_id] + 1;
	
	$('cp_cv_tab').value = id;
	
	editableList_preview(id);
}

function editableList_afterUpdate(b_id) {
	hideScrolls(b_id);
	getTab(0, b_id);
	showDelayedScrolls(b_id, 0, 250);
}

var swfu;
var avatarimg_fade;

function uploadAvatar_init(sid) {
	window.addEvent("domready", function () {
		swfu = new SWFUpload({
			// Backend Settings
			upload_url: "../ragazze/upload_avatar.php",	// Relative to the SWF file
			post_params: {"PHPSESSID": sid},

			// File Upload Settings
			file_size_limit : "10 MB",	// 10MB
			file_types : "*.jpg",
			file_types_description : "Immagini JPEG",
			file_upload_limit : "0",
			
			flash_container_id : "flash10_fix",

			// Event Handler Settings - these functions as defined in Handlers.js
			//  The handlers are not part of SWFUpload but are part of my website and control how
			//  my website reacts to the SWFUpload events.
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_progress_handler : uploadProgress_avatar,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess_avatar,
			upload_complete_handler : uploadComplete_avatar,
			upload_start_handler : uploadStart_avatar,

			// Flash Settings
			flash_url : "http://monotonia.it/swf/swfupload.swf",	// Relative to this file

			custom_settings : {
				upload_target : "avatarUpload_div"
			},

			// Debug Settings
			debug: false
		});
		avatarimg_fade = new Fx.Style('cp_avatar_img', 'opacity', {duration:500,wait:false});
	});
}

function onCpDatiAccountSubmit() {
	try {
		$('cp_account_submit_btn').disabled = true;
		$('cp_account_err').innerHTML = "<span class=\"err\">Attendi...</span>";
	} catch (e) { }
}

function cambiaPaesenas(estero, obj) {
	if (estero) {
		$('cp_paesenas').setStyle('display', 'block');
		$('cp_provincianas').setStyle('display', 'none');
	} else {
		$('cp_paesenas').setStyle('display', 'none');
		$('cp_provincianas').setStyle('display', 'block');
	}
	$(obj).blur();
}

function onCpDatiSubmit(event) {
	try {
		var altezza = $('cp_dati_altezza').value;
		if (altezza.indexOf('.') == -1 && altezza.indexOf(',') == -1 && altezza.indexOf('e') == -1) {
			$('cp_dati_submit_btn').disabled = true;
			$('cp_dati_err').innerHTML = "<span class=\"err\">Attendi...</span>";
		} else {
			alert("Errore: l'altezza va espressa in centimetri (es. 173)");
			new Event(event).stop();
		}
	} catch (e) { }
}

function onCpCapacitaSubmit() {
	try {
		$('cp_capacita_submit_btn').disabled = true;
		$('cp_capacita_err').innerHTML = "<span class=\"err\">Attendi...</span>";
	} catch (e) { }
}

function onCpCvSubmit() {
	try {
		$('cp_cv_submit_btn').disabled = true;
		$('cp_cv_err').innerHTML = "<span class=\"err\">Attendi...</span>";
	} catch (e) { }
}

function onCpMatSubmit() {
	try {
		$('cp_mat_salva_btn').disabled = true;
		$('cp_mat_err').innerHTML = "<span class=\"err\">Attendi...</span>";
	} catch (e) { }
}

function htmlentities(str) {
    var i,output='',len,char='';
    len = str.length;
    for(i=0;i<len;i++){
        char = str.charAt(i).charCodeAt(0);
        if( (char>47 && char<58)||(char>62 && char<127) ){
            output += str.charAt(i);
        }else{
            output += "&#" + str.charAt(i).charCodeAt(0) + ";";
        }
    }
    return output;
}

function uploadFile_init(sid, filetype, user) {
	switch (filetype) {
		case '0': // foto
			filetypes_label = "*.jpg";
			filetypes_desc = "Immagini JPEG";
			//upload_url_str = "../ragazze/upload_file.php";
			upload_url_str = "http://monotonia.it/ragazze/upload_file.php";
			flash_url_str = "http://monotonia.it/swf/swfupload.swf";
			break;

		case '1': // video
			filetypes_label = "*.*";
			filetypes_desc = "File video";
			upload_url_str = "http://monotonia.tv/encoder/upload.php";
			flash_url_str = "http://monotonia.tv/swf/swfupload.swf";
			break;

		case '2': // mp3
			filetypes_label = "*.mp3";
			filetypes_desc = "File mp3";
			//upload_url_str = "../ragazze/upload_file.php";
			upload_url_str = "http://monotonia.it/ragazze/upload_file.php";
			flash_url_str = "http://monotonia.it/swf/swfupload.swf";
			break;

		default:
			filetypes_label = "*.jpg";
			filetypes_desc = "Immagini JPEG";
			upload_url_str = "../ragazze/upload_file.php";
			flash_url_str = "http://monotonia.it/swf/swfupload.swf";
			break;
	}
	window.addEvent("domready", function () {
		swfu = new SWFUpload({
			// Backend Settings
			upload_url: upload_url_str,	// Relative to the SWF file
			post_params: {"PHPSESSID": sid, "tipo": filetype, "user": user},

			// File Upload Settings
			file_size_limit : "100 MB",	// 100MB
			file_types : filetypes_label,
			file_types_description : filetypes_desc,
			file_upload_limit : "0",
			
			flash_container_id : "flash10_fix",

			// Event Handler Settings - these functions as defined in Handlers.js
			//  The handlers are not part of SWFUpload but are part of my website and control how
			//  my website reacts to the SWFUpload events.
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			upload_progress_handler : uploadProgress_file,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess_file,
			upload_complete_handler : uploadComplete_file,
			upload_start_handler : uploadStart_file,

			// Flash Settings
			flash_url : flash_url_str,	// Relative to this file

			custom_settings : {
				upload_target : "fileUpload_div"
			},

			// Debug Settings
			debug: false
		});
	});
}

function selectText(el, start, len) {
	el = $(el);
	if (el.createTextRange) {
		var oRange = el.createTextRange();
		oRange.moveStart("character", start);
		oRange.moveEnd("character", len - el.value.length);
		oRange.select();
	} else if (el.setSelectionRange) {
		el.setSelectionRange(start, len);
	}
}

function limitChars(e, obj, maxchars) {
	var o = $(obj);
	if (o.value.length > maxchars) {
		o.value = o.value.substr(0, maxchars);
		selectText(o, maxchars, maxchars);
		o.scrollTop = o.scrollHeight;
	}
}

function eliminaFile(id, sid, t_id, user) {
	if (confirm("Sicura di voler eliminare il file?")) {
		$('cp_mat_elimina_btn').disabled = true;
		$('cp_mat_err').innerHTML = "Eliminazione in corso...";
		document.location.href = 'http://ragazze.monotonia.it/delete_file.php?id='+ id +'&PHPSESSID='+ sid +'&t_id='+ t_id;
	}
}

function sendEvent(swf, typ, prm) { 
	thisMovie(swf).sendEvent(typ,prm); 
}

function getUpdate(typ, pr1, pr2, swf) {
}

function thisMovie(swf) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[swf];
	} else {
		return document[swf];
	}
}

function loadFile(swf,obj) { 
	thisMovie(swf).loadFile(obj); 
}

function stopPlayer() {
	try {
		//sendEvent("mediaplayer0", 'stop');
		loadFile("mediaplayer0", {});
	} catch (e) { }
}

function hidePlayer() {
	stopPlayer();
	$('player_container').innerHTML = "<div align=\"center\" style=\"padding-top: 100px;\">nessun contenuto selezionato</div>\n";
}

function checkFileInfo(e) {
	var titolo_obj = $('contenuto_titletext');
	var desc_obj = $('contenuto_textarea');
	titolo = titolo_obj.value;
	descrizione = desc_obj.value;
	if (titolo == "" || descrizione == "") {
		alert("Errore: inserisci titolo e descrizione appropriati.");
		new Event(e).stop();
	}
}

function setSelectionRange(input, selectionStart, selectionEnd) {
	if (input.setSelectionRange) {
		input.focus();
		input.setSelectionRange(selectionStart, selectionEnd);
	} else if (input.createTextRange) {
		var range = input.createTextRange();
		range.collapse(true);
		range.moveEnd('character', selectionEnd);
		range.moveStart('character', selectionStart);
		range.select();
	}
}

function replaceSelection(input, replaceString) {
	if (input.setSelectionRange) {
		var selectionStart = input.selectionStart;
		var selectionEnd = input.selectionEnd;
		input.value = input.value.substring(0, selectionStart)+ replaceString + input.value.substring(selectionEnd);

		if (selectionStart != selectionEnd){
			setSelectionRange(input, selectionStart, selectionStart + 	replaceString.length);
		}else{
			setSelectionRange(input, selectionStart + replaceString.length, selectionStart + replaceString.length);
		}
	} else if (document.selection) {
		var range = document.selection.createRange();

		if (range.parentElement() == input) {
			var isCollapsed = range.text == '';
			range.text = replaceString;

			 if (!isCollapsed)  {
				range.moveStart('character', -replaceString.length);
				range.select();
			}
		}
	}
}

function catchTab(item,e){
	if(navigator.userAgent.match("Gecko")){
		c=e.which;
	}else{
		c=e.keyCode;
	}
	if(c==9){
		replaceSelection(item,"     ");
		setTimeout("getObjById('"+item.id+"').focus();",0);
		return false;
	}
}

function onContactsSubmit(event) {
	try {
		if (checkContactsForm()) {
			$('contacts_submit_btn').disabled = true;
			$('contacts_err').innerHTML = "<span class=\"err\">Attendi...</span>";
		} else {
			new Event(event).stop();
			return false;
		}
		
		return true;
	} catch (e) { }
}

function checkContactsForm() {
	var subject = $('contacts_subject').value;
	var msg = $('contacts_msg').value;
	var email = $('contacts_email').value;
	
	if (!subject.length) {
		alert("Errore: oggetto non inserito.");
		return false;
	} else if (!msg.length) {
		alert("Errore: messaggio non inserito.");
		return false;
	} else if (!email.length) {
		alert("Errore: devi specificare l'e-mail sulla quale vuoi ricevere la nostra risposta.");
		return false;
	}
	
	return true;
}

// flash minimum requirements
var flashMaj = 8;
var flashMin = 0;
var flashRev = 22;

function writeFlashNag() {
	window.addEvent("domready", function () {
		if ( !detectFlashVer(flashMaj, flashMin, flashRev) ) {
			$('flash_nag').setStyle("display", "block");
		} else {
			$('flash_nag').setStyle("display", "none");
		}
	});
}

function noFlashMp3() {
	window.addEvent("domready", function () {
		if ( !detectFlashVer(flashMaj, flashMin, flashRev) ) {
			$('audio_img_div').setStyle("visibility", "hidden");
			$('mp3_noflash').setStyle("visibility", "visible");
		}
	});
}

function segnalaAbuso(type, id) {
	if (confirm("Vuoi segnalare questa pagina allo staff di Monotonia.it?")) {
		if (document.location.href.substr(7, 7) == 'ragazze') {
			var url = "/report_abuse.php";
		} else {
			var url = "/ragazze/report_abuse.php";
		}
		var rand = (Math.round((Math.random()*99999)+1));
		var query_string = "type="+ type +"&id="+ id +"&r="+ rand;

		report_abuse_req = new XHR({
			method: 'get',
			onSuccess: function () { 
				//var content = report_abuse_req.response.text;
				alert("La pagina è stata segnalata allo staff di Monotonia.it\n\nGrazie per la collaborazione.");
			}
		});
		report_abuse_req.send(url, query_string);
	}
}

function faq_init() {
	window.addEvent("domready", function () {
		var accordion = new Accordion('.question', '.answer', {
			opacity: false,
			onActive: function(toggler, element){
				toggler.setStyle('text-decoration', 'none');
				toggler.setStyle('cursor', 'default');
				toggler.setStyle('color', '#dd89d3');
			},

			onBackground: function(toggler, element){
				toggler.setStyle('text-decoration', 'underline');
				toggler.setStyle('cursor', 'pointer');
				toggler.setStyle('color', '#008cee');
			}
		}, $('faq'));
	});
}

function slideShow_init() {
	window.addEvent("domready", function () {
		var so = new SWFObject("http://monotonia.it/swf/monoslideshow.swf", "SOmonoSlideshow", "200", "260", "8", "#ffffff");
		var rand = (Math.round((Math.random()*99999)+1));
		so.addVariable("dataFile", "http://monotonia.it/slideshow/monoslideshow.xml?"+ rand);
		so.addVariable("showLogo", "false");
		so.addVariable("showVersionInfo", "false");
		so.write("monoSlideshow");
	});
}

function homeMenu_init() {
	window.addEvent("domready", function() {
		var szNormal = 170, szSmall = 137, szFull = 236;

		var kwicks = $$("#home_menu .kwick");
		var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.quadOut});
		kwicks.each(function(kwick, i) {
			kwick.addEvent("mouseenter", function(event) {
				var o = {};
				o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
				kwicks.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("width").toInt();
						if(w != szSmall) o[j] = {width: [w, szSmall]};
					}
				});
				fx.start(o);
			});
		});

		$("home_menu").addEvent("mouseleave", function(event) {
			var o = {};
			kwicks.each(function(kwick, i) {
				o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
			});
			fx.start(o);
		})
	});
}

function urlencode( str ) {                            
    var ret = str;
    
    ret = ret.toString();
    ret = encodeURIComponent(ret);
    ret = ret.replace(/%20/g, '+');
 
    return ret;
}
//-->
