function getWindowSize(){
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth - 13;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	
	var data_returned = new Array ();
  	data_returned[0] = pageWidth;
  	data_returned[1] = pageHeight;
  	data_returned[2] = windowWidth;
  	data_returned[3] = windowHeight;
  	return data_returned;
}

function jsUrl(myUrl) {
	document.location.href = myUrl;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

var browserVersion;
var direction;
var scrolltimer;

function scrollStart(){
  if (document.layers) {	// netscape 4.0 and up
		browserVersion = eval(document.divASContainer.document.contentLayer);
	}
	else {
		if (document.getElementById) { // internet explorer 6.0 and netscape 6.0
			browserVersion= eval("document.getElementById('contentLayer').style");
		}
		else {	
			if (document.all) { // internet explorer 4.0 and up
				browserVersion = eval(document.all.contentLayer.style);
	      }
	   }
	}
}

function verScroll(dir, spd) {
	scrolltimer = null;
	direction = dir;
	speed = parseInt(spd);
	var x_pos;
	
	x_pos = parseInt(browserVersion.left);
	
	var x_wid = parseInt(document.getElementById('contentLayer').offsetWidth);
	var x_cont = parseInt(document.getElementById('divASContainer').offsetWidth);
	
	if (direction == "right" && x_pos > (x_cont - x_wid)){
		otstap = (x_pos - (speed));
	}
	else{
		if (direction == "right"){
			var asd = (x_wid + x_pos) - x_cont;
			if(asd <= 0) otstap = x_pos;
			else otstap = -speed;
		}
	} 	
	if (direction == "left" && x_pos < 0){
		otstap = (x_pos + (speed));
	} 
	else{
		if (direction == "left"){
			otstap = 0;
		} 
	}
	
	//browserVersion.left = parseInt(otstap) + 'px';
	
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") != -1){
		//scrolltimer = setTimeout("verScroll(direction,speed)", 16);
		//speed=100;
	}else{
		move(otstap, direction);
		//scrolltimer = setTimeout("verScroll(direction,speed)", 100);
	}
}

function stopScroll() {
	clearTimeout(scrolltimer);
}

function startAndStop(dir, spd) {
	clearTimeout(scrolltimer);
	verScroll(dir, spd);
}

function move(pos, dir){
	x_pos = browserVersion.left;
	
	if(dir == 'right') otstap = -1;
	else otstap = 1;
	
	if(x_pos == "") x_pos = otstap + 'px';	
	
	var text = x_pos;	
	text = text.replace('px', '');
	x_pos = text;
	
	var x_wid = parseInt(document.getElementById('contentLayer').offsetWidth);
	var x_cont = parseInt(document.getElementById('divASContainer').offsetWidth);
	
	if(dir == 'right'){
		if(x_pos > pos){
			 browserVersion.left = (x_pos - 3) + 'px';
			 setTimeout("move("+pos+", '"+dir+"')", 1);
		}
	}
	else{
		if(x_pos < pos && x_pos != -1){
			sc = 3;
			browserVersion.left = eval(sc + x_pos) + 'px';
			setTimeout("move("+pos+", '"+dir+"')", 1);
		}	
	}
}

function showHelp(width, height, title, url){
	size = getWindowSize(); 
			
	var left = (size[2] - width)/2;
	var top = (size[3] - height)/2;
			
	$('popupcontainer').style.display= 'block';
	$('popupcontainer').style.top = ( document.documentElement.scrollTop + 10 ) + "px";
	$('popupcontainer').style.left = left + 'px';			

	$('popupheader').style.width = (width - 26) + 'px';
	$('popupheader').style.height = (height - 26) + 'px';

	$('popuptitle').innerHTML = title;
	$('popupcontent').style.width = (width - 29) + 'px';
	$('popupcontent').style.height = (height - 53) + 'px';
			
	new Draggable('popupcontainer',{scroll:window,handle:'popupmove'});
	var myAjax = new Ajax.Updater( 'popupcontent', url, { method: 'get'} );
}
	
function hidePopUp(){
	$('popupcontainer').style.display= 'none';
	$('popupcontent').innerHTML = '';
}


function addToFav(type, id, element){
	if(idmember == 0){
		alert(must_login_fav);
	}
	else{
		if(element.className == "ico_fav_remove") element.className = "ico_fav";
		else element.className = "ico_fav_remove";
		
		obj = type+'_'+id+'_add_fav';		
		$(obj).style.visibility = "visible";
		$(obj).style.display = "block";
		//Effect.Appear(obj);
		setTimeout('hideAddFav("'+obj+'")', 3500); 
	
		var pars = 'add_to_fav=1&type='+type+'&id='+id;
				
		var myAjax = new Ajax.Request(site_url, { method: 'get', parameters: pars} );
	}
}

function hideAddFav(obj){
	Effect.Fade(obj);
}

function showhidePanelOption(id){
	obj = $(id).style;
	if(obj.display == 'none'){
		obj.display = 'block';
	}
	else{
		Effect.Squish(id);
	}
	
}

function submitdisable(myfield,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13){
		alert("Don't push Enter.\nPlease click on empty area..");
		return false;
	}
}

function rate(type, id, rate, div){
	var pars = 'rate='+type+'&value='+rate+'&id='+id;
		
	var myAjax = new Ajax.Updater(
		div, site_url, {method: 'get', parameters: pars}
	);
}

function approveVideo(id, value, div){
	var pars = 'approveVideo=yes&id='+id+'&value='+value;
		
	var myAjax = new Ajax.Updater(
		div, site_url, {method: 'get', parameters: pars}
	);
}

function approveAudio(id, value, div){
	var pars = 'approveAudio=yes&id='+id+'&value='+value;
		
	var myAjax = new Ajax.Updater(
		div, site_url, {method: 'get', parameters: pars}
	);
}

function approveVideoDetails(id, value, div){
	var pars = 'approveVideoDetails=yes&id='+id+'&value='+value;
		
	var myAjax = new Ajax.Updater(
		div, site_url, {method: 'get', parameters: pars}
	);
}

function approveAudioDetails(id, value, div){
	var pars = 'approveAudioDetails=yes&id='+id+'&value='+value;
		
	var myAjax = new Ajax.Updater(
		div, site_url, {method: 'get', parameters: pars}
	);
}

function showComments(type, id, div, page){
	var pars = 'comments='+type+'&id='+id+'&page='+page;
		
	var myAjax = new Ajax.Updater(
		div, site_url, {method: 'get', parameters: pars}
	);
}

function showCommentsVideo(type, id, div, page){
	var pars = 'display=1&comments='+type+'&id='+id+'&page='+page;
		
	var myAjax = new Ajax.Updater( div, site_url, {method: 'get', parameters: pars} );
}

function showCommentsTrailer(type, t, id, div, page){
	var pars = 'display=1&type='+t+'&comments='+type+'&id='+id+'&page='+page;
	
	var myAjax = new Ajax.Updater( div, site_url, {method: 'get', parameters: pars} );
}

function addComments(type, id, div){	
	
	var text = document.comment_form.comment.value;
	
	text = text.replace('?', '%3F');
	text = text.replace('#', '%23');
	text = text.replace('$', '%24');
	text = text.replace('&', '%26');
	text = text.replace('(', '%28');
	text = text.replace('(', '%29');
	text = text.replace('~', '%7E');
	text = text.replace('`', '%60');
	text = text.replace('=', '%3D');

	var pars = 'add=1&comments='+type+'&text='+text+'&id='+id;
	if(text.length > 5){
		$(div).innerHTML = '<img src="'+preload_img+'" alt="Loading" border="0" />';
		var myAjax = new Ajax.Updater( div, site_url, { method: 'get', parameters: pars });
	}
	else{
		alert("Comment must be least 5 words!");
	}
}

function addCommentsVideo(type, id, div){	
	
	var text = document.comment_form.comment.value;
	
	text = text.replace('?', '%3F');
	text = text.replace('#', '%23');
	text = text.replace('$', '%24');
	text = text.replace('&', '%26');
	text = text.replace('(', '%28');
	text = text.replace('(', '%29');
	text = text.replace('~', '%7E');
	text = text.replace('`', '%60');
	text = text.replace('=', '%3D');

	var pars = 'display=1&add=1&comments='+type+'&text='+text+'&id='+id;
	if(text.length > 5){
		$(div).innerHTML = '<img src="'+preload_img+'" alt="Loading" border="0" />';
		var myAjax = new Ajax.Updater( div, site_url, { method: 'get', parameters: pars });
	}
	else{
		alert("Comment must be least 5 words!");
	}
}

function addCommentsTrailer(type, id, div){	
	
	var text = document.comment_form.comment.value;
	
	text = text.replace('?', '%3F');
	text = text.replace('#', '%23');
	text = text.replace('$', '%24');
	text = text.replace('&', '%26');
	text = text.replace('(', '%28');
	text = text.replace('(', '%29');
	text = text.replace('~', '%7E');
	text = text.replace('`', '%60');
	text = text.replace('=', '%3D');

	var pars = 'add=1&comments='+type+'&text='+text+'&id='+id;
	if(text.length > 5){
		$(div).innerHTML = '<img src="'+preload_img+'" alt="Loading" border="0" />';
		var myAjax = new Ajax.Updater( div, site_url, { method: 'get', parameters: pars });
	}
	else{
		alert("Comment must be least 5 words!");
	}
}

function deleteComments(type, id, div){	
	var answer = confirm("Delete?");		
	if (answer){			
		var pars = 'deletecomments='+type+'&id='+id;
		
		$(div).innerHTML = '<img src="'+preload_img+'" alt="Loading" border="0" />';
		var myAjax = new Ajax.Updater( div, site_url, { method: 'get', parameters: pars });		
	}
}

function rateInfo(text){
	$('rate_info').innerHTML = text;
}

function rateInfoHide(){
	$('rate_info').innerHTML = '&nbsp;';
}

function showInfo(){	
	$("info_box").style.display = "block";
	$("info_box").className = "overlay_dialog_info";
	
	$('info_box_content').innerHTML = '<center><br /><br /><br /><br />'+loading_text+'<br /><img src="'+preload_img+'" alt="Loading..." border="0" /></center>';
}

var hide_player = 'no';

function editInfo(url, handle_text, other_opt){
	showInfo();
	size = getWindowSize(); 
	scroll(0,0);
	if(other_opt == "hide_player"){
		$('player').style.display = 'none';
		hide_player = 'yes';
	}
	
	$("buffer").style.display = "block";
	$("buffer").style.width = (size[0] - 20) + 'px';
	$("buffer").style.height = size[1] + 'px';
	
	$("info_box").style.height = "500px";
	$("info_box").style.width = "550px";
	$('info_box').style.top = "10px";
	$("info_box_handle").style.width = "530px";
	$("info_box_handle_text").innerHTML = handle_text;
	$("info_box").style.left = ((size[2] / 2) - 265) + "px";
	
	new Draggable('info_box', { scroll:window, handle:'info_box_handle'});
	
	var new_url = site_url + url;
	var myAjax = new Ajax.Updater('info_box_content', new_url, {method: 'get'});
}

function closeBuffer(id){
	$("buffer").style.display = "none";
	$(id).style.display = "none";
	
	if(hide_player == 'yes'){
		hide_player = 'no';
		$('player').style.display = 'block';
	}
}

function baddata(action, id){
	$("baddata").innerHTML = '<form name="bad" method="post" action="'+action+'"><font color="black">Reason:</font><font size="-1"><a href="javascript:;" onClick="returnbaddatainfo('+id+')">(Close)</a></font><br><textarea name="bad_reason" cols="20" rows="3"></textarea><br><input type="button" class="submitbtn" value="Send" onclick="return checkempty();"></font><input type="hidden" name="url" value="'+action+'" /></form>';
}

function returnbaddatainfo(id){
	$('baddata').innerHTML = '<input type="button" value="Bad data" onclick="baddata(\'?baddata=music&id='+id+'\')" class="submitbtn">';
}

function checkempty(){
	if (document.bad.bad_reason.value == "") {
		alert('Please enter reason!');
		return false;
	}
	else SendBadData();
}

function SendBadData(){
    var text = document.bad.bad_reason.value; 
	var url = document.bad.url.value; 	

    text = text.replace('?', '%3F');
	text = text.replace('#', '%23');
	text = text.replace('$', '%24');
	text = text.replace('&', '%26');
	text = text.replace('(', '%28');
	text = text.replace('(', '%29');
	text = text.replace('~', '%7E');
	text = text.replace('`', '%60');
	text = text.replace('=', '%3D');
	gourl = site_url + url + '&text='+text; 
	var myAjax = new Ajax.Request( gourl, { method: 'get'});
	
	$("baddata").innerHTML = '<input type="button" style="height: 32px;" value="Bad data" disabled />';

}	

function addToFav2(type, id, favorite){
	if(idmember == 0){
		alert(must_login_fav);
	}
	else{
		if(favorite == 0){
			var fav = 1;
			var fav_text = 'remove';
		}
		else{
			var fav = 0;
			var fav_text = 'In favorites';
		}
		
		$('add_to_fav').innerHTML = '<input type="button" value="'+fav_text+'" onclick="addToFav2(\''+type+'\', '+id+', '+fav+')" class="submitbtn">';	
		var pars = 'add_to_fav=1&type='+type+'&id='+id;
				
		var myAjax = new Ajax.Request(site_url, { method: 'get', parameters: pars} );
	}
}

function addToPlaylist(type, id, playlist){
	if(idmember == 0){
		alert(must_login_fav);
	}
	else{
		if(playlist == 0){
			var playlist = 1;
			var playlist_text = 'Delete PlayList';
		}
		else{
			var playlist = 0;
			var playlist_text = 'Add to PlayList';
		}
		
		$('add_to_playlist').innerHTML = '<input type="button" value="'+playlist_text+'" onclick="addToPlaylist(\''+type+'\', '+id+', '+fav+')" class="submitbtn">';	
		var pars = 'add_to_playlist=1&type='+type+'&id='+id;
				
		var myAjax = new Ajax.Request(site_url, { method: 'get', parameters: pars} );
	}
}

function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function changeGrid(type){
	if(type != list_grid){
		if(type == 'list'){
			$('view_list').innerHTML = '<img src="'+site_img+'list_list_ontab.gif" />';
			$('view_grid').innerHTML = '<img src="'+site_img+'list_grid.gif" />';
		}
		else{
			$('view_list').innerHTML = '<img src="'+site_img+'list_list.gif" />';
			$('view_grid').innerHTML = '<img src="'+site_img+'list_grid_ontab.gif" />';
		}
		createCookie("vbox_list_type", type, 365);
		list_grid = type;
		
		showCatalogType(info_type);
	}
}

function getListType(){
	var type = readCookie("vbox_list_type");
	if(type) returned = type;
	else returned = 'grid';
	
	if(returned == 'list'){
		$('view_list').innerHTML = '<img src="'+site_img+'list_list_ontab.gif" />';
		$('view_grid').innerHTML = '<img src="'+site_img+'list_grid.gif" />';
	}
	else{
		$('view_list').innerHTML = '<img src="'+site_img+'list_list.gif" />';
		$('view_grid').innerHTML = '<img src="'+site_img+'list_grid_ontab.gif" />';
	}
	
	return returned;
}


function showHide(id){
	var obj = $(id).style;
	if(obj.display == "block") obj.display = "none";
	else obj.display = "block";
}

function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

var id_tooltip = null; 
var id_main = null;
var tip_width = 0;
var tip_height = 0;
var tip_top_orig = 0;
var tip_left_orig = 0;

var tip_cureent_width = 0;
var tip_cureent_height = 0;
var tip_cureent_top = 0;
var tip_cureent_left = 0;

var tip_time_size_width = 0;
var tip_time_size_height = 0;
var tip_time_size_top = 0;
var tip_time_size_left = 0;

var tip_resize_time = 10;

var current_mouse_y = 0;

if (typeof document.attachEvent!='undefined') document.attachEvent('onmousemove',moveMouse);
else document.addEventListener('mousemove',moveMouse,false);

function showIt(id, width, height, tooltip_type){
	id_tooltip = id+'_tooltip';
	id_main = id+'_main';
	$(id_main).style.zIndex = '9998';
	if($(id_tooltip).style.display != 'block'){
		var size = getWindowSize();
		var ScrollTop = document.body.scrollTop;
		if (ScrollTop == 0){
    		if (window.pageYOffset) ScrollTop = window.pageYOffset;
    		else ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
		
		//$('buffer_body').innerHTML = current_mouse_y + ';' + ScrollTop + ';' + size[3];
		$(id_tooltip).style.display = 'block';
		
		//var is_valid = current_mouse_y - ScrollTop;
		//if(is_valid - 120 >0) var valid = "da";
		//else var valid = "ne";
		//$('buffer_tooltip').innerHTML = valid;
		
		// Calculate absolute position
		tip_left_orig = '-'+((width - 100) / 2);		
		tip_top_orig = '-'+(height / 10);
		
		tip_width = width;
		tip_height = height;
	
		//Start resize function
		tip_current_width = (width/2);
		tip_current_height = (height/2);
		tip_current_top = (tip_top_orig / 2);
		tip_current_left = (tip_left_orig / 2);
		
		$(id_tooltip).style.width = (width/2)+'px';
		$(id_tooltip).style.height = (height/2)+'px';
		$(id_tooltip).style.top = (tip_top_orig / 2)+'px';
		$(id_tooltip).style.left = (tip_left_orig / 2)+'px';  
		
		tip_time_size_width = ((tip_width - tip_current_width) / tip_resize_time);
		tip_time_size_height = ((tip_height - tip_current_height) / tip_resize_time);
		tip_time_size_top = ((tip_top_orig - tip_current_top) / tip_resize_time);
		tip_time_size_left = ((tip_left_orig - tip_current_left) / tip_resize_time);
		
		//$('buffer_body').innerHTML = tip_top_orig + ' --- '+tip_left_orig;
		
		s = $(id_tooltip).hasChildNodes();
		if(s){
			for( var x = 0; x < $(id_tooltip).childNodes.length; x++ ) {
				if($(id_tooltip).childNodes[x].nodeType == 1){
	  				random = randomString();
	  				$(id_tooltip).childNodes[x].id = id_tooltip+'_'+random;	  			
  				}
			} 
		}
		
		$(id_tooltip).innerHTML = '<center id="'+id_tooltip+'_preload_111"><br /><br /><br /><img src="'+preload_img2+'" id="'+id_tooltip+'_preload_img" /><br /><br />'+loading_text+'</center>';				
		resizeTip('max', id, tooltip_type);
	}
}

function loadTipContentAndParseId(id, type){
	var pars = 'tooltip=' + type + '&id=' + id;
	var myAjax = new Ajax.Updater( id_tooltip, site_url, { method: 'get', parameters: pars});
}


function resizeTip(type, id, tooltip_type){
	if(type == 'max'){
		if(tip_width > tip_current_width){
			tip_current_width = tip_current_width + tip_time_size_width;
			tip_current_height = tip_current_height + tip_time_size_height;
			tip_current_top = tip_current_top + tip_time_size_top;
			tip_current_left = tip_current_left + tip_time_size_left;
	
			$(id_tooltip).style.width = tip_current_width+'px';
			$(id_tooltip).style.height = tip_current_height+'px';
			$(id_tooltip).style.top = tip_current_top+'px';
			$(id_tooltip).style.left = tip_current_left+'px';  
			setTimeout('resizeTip("max", "'+id+'", "'+tooltip_type+'")', 1);
		}
		else{
			loadTipContentAndParseId(id, tooltip_type);
		}
	}
	else{	
		if(id_tooltip != null){
			$(id_main).style.zIndex = '1';
			hideAddFav($(id_tooltip));
			id_tooltip = null; 
			tip_width = 0;
			tip_height = 0;
			tip_top_orig = 0;
			tip_left_orig = 0;
			tip_cureent_width = 0;
			tip_cureent_height = 0;
			tip_cureent_top = 0;
			tip_cureent_left = 0;
			tip_time_size_width = 0;
			tip_time_size_height = 0;
			tip_time_size_top = 0;
			tip_time_size_left = 0;
		}
	}
}

function hideIt(type, m){
	  
	if(id_tooltip != null){
		var tooltip_id = $(id_tooltip).style.display;
		if((tooltip_id == 'none' && type == 'object')){
			$(id_tooltip).style.display = 'none';
		}
		
		if((tooltip_id == 'block' && type == 'tooltip_content')){			
			resizeTip('min');				
		}
	}
}

var tooltip = Class.create();
tooltip.prototype = {
  initialize:function(element, delay, callback, width, height, type){
		this.element = element;
		this.delay = delay;
		this.timer = null;
		this.callback = callback;
		this.width = width;
		this.height = height;
		this.type = type;
		
		if(id_tooltip != null){
			$(id_tooltip).style.display = 'none';
		}
		
		this.registerObserver();
	},
	
	registerObserver: function(){
		Event.observe(this.element, 'mouseover', this.onTimeoutEvent.bind(this));
		Event.observe(this.element, 'mouseout', this.hideEvent.bind(this));
	},
	
	doCallback: function() {
    	this.callback(this.element, this.width, this.height, this.type);
	},
	
	onTimeoutEvent: function(){	
		clearTimeout(this.timer);
		this.timer = setTimeout(this.doCallback.bind(this), this.delay * 1000);
	},
	
	hideEvent: function(){
		clearTimeout(this.timer);
		hideIt('object');
	}
};


function moveMouse(e) {

	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;
	
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY){
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY){
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
		
	current_mouse_y = posy;
		
	if (id_tooltip != null) {
	   checkMove(targ);	   
	}
}

function checkMove(m){
	var obj = $(id_tooltip); 
	if(obj){
		s = $(id_tooltip).hasChildNodes();
		if(s && obj){
			for( var x = 0; x < obj.childNodes.length; x++ ) {
				if(obj.childNodes[x].nodeType == 1){
	  				id = m.id;	  			
					var where_is_a=id.indexOf(id_tooltip);
				
	  				if(where_is_a == -1){
						hideIt('tooltip_content');
					}
  				}
			} 
		}
	}	
}

function editorChoose(id, text, type){
	$('editor_choose').innerHTML = text;
	var url = site_url;
	var pars = 'editor_choose='+id+'&type='+type;
	var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars});
}

function cancelEdit(){
	$('buffer').style.display = 'none';
	$('info_box').style.display = 'none';
	if( $('player') ){
		$('player').style.display = 'block';
	}
	
}