function gd(el){
	return document.getElementById(el);
}

function help_msg(el,tx)  {
	gd(el).innerHTML = tx;
}

function t(el){
	gd(el).style.display = gd(el).style.display != 'none'?'none':'';
}

function wopen(wdt,hgt,durl){
	var left = (screen.availWidth/2) - (wdt/2);
	var top = (screen.availHeight/2) - (hgt/2);
	var dwin = window.open(durl,'Insert','width='+wdt+',height='+hgt+', left='+left+', top='+top);
	dwin.focus();
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function openWebRadio(){
	wopen(220,300,'/webradio.php')
}

function getCookie(c_name){
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1){
	    c_start=c_start + c_name.length+1;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    }
	  }
	return "";
}

var cur_comp_img = 0;
var tm = false;

function ng_movex(objid, tox) {
	

	
	ob = gd(objid);
	fx = ob.offsetLeft;
	
	dx = Math.floor(Math.abs(tox-fx)*0.40);
	
	if (dx < 1 && fx != tox) dx = 1;
	
	newleft = (tox > fx) ? fx + dx : fx - dx;
	ob.style.left = newleft + 'px';
	if (fx == tox) {
		clearInterval(tm);
	}

}


function ng_slide(objid, mx){
	clearInterval(tm);
	tm = setInterval("ng_movex('"+objid+"',"+mx+");",15);
}

function open_gallery(art_id){
	
	cover = document.createElement('div');
	cover.id = 'gallery_lock';
	with (cover.style){
		
		position = 'absolute';
		float = 'left';
		zIndex = 98;
		left = '0px';
		top = '0px';
		right = '0px';
		bottom = '0px';
		backgroundColor = '#000000';
		filter = 'alpha(opacity=50)';
		opacity = (0.7);
    MozOpacity = (0.7);
    KhtmlOpacity = (0.7);
	}
	document.body.appendChild(cover);
	cover.onmousedown = function(){
		close_gallery();
	}
	
	g = document.createElement('div');
	g.id = 'g_gallery';
	g.className = 'adv_gallery_container'
	with (g.style){
		
		position = 'absolute';
		float = 'left';
		zIndex = 99;
		left = '50%';
		top = '50%';
		width = '600px';
		height = '540px';
		backgroundColor = '#000000';
		margin = '-270px 0 0 -300px';
		overflow = 'hidden';
	}
	
	document.body.appendChild(g);
	g.innerHTML = '<iframe scrollbar="no" frameborder="0" style="width:600px;height:540px;overflow:hidden" src="/ajaxgallery.php?c='+art_id+'"></iframe>';
}

function close_gallery(){
	if (gd('gallery_lock'))
		gd('gallery_lock').parentNode.removeChild(gd('gallery_lock'));
	if (gd('g_gallery'))
		gd('g_gallery').parentNode.removeChild(gd('g_gallery'));
}

function imgStar(act) {
	
	document.star_1.src='/images/star_red_graybg.jpg';
	if (act>1) {document.star_2.src='/images/star_red_graybg.jpg';}
	if (act>2) {document.star_3.src='/images/star_red_graybg.jpg';}
	if (act>3) {document.star_4.src='/images/star_red_graybg.jpg';}
	if (act>4) {document.star_5.src='/images/star_red_graybg.jpg';}
}

function imgStarnull() {
	document.star_1.src='/images/star_gray_graybg.jpg';
	document.star_2.src='/images/star_gray_graybg.jpg';
	document.star_3.src='/images/star_gray_graybg.jpg';
	document.star_4.src='/images/star_gray_graybg.jpg';
	document.star_5.src='/images/star_gray_graybg.jpg';
}


function adv_ng_show(srcobj, imgpath){
	gd('adv_gallery_full').src = imgpath;
	gd('adv_gallery_full').title = srcobj.title;
}

function adv_ng_move(direction){
	var sc = gd('adv_gallery_scr');
	allimages = sc.getElementsByTagName('img');
	imagecount = allimages.length;
	sc.style.width = (120 * imagecount) + 'px';
	if (direction == 'left'){
		nx = sc.offsetLeft + 600;
	} else {
		nx = sc.offsetLeft - 600;
	}
	if (nx > 0) nx = 0;
	if (nx < 600-imagecount*120) nx = 600-imagecount*120;

	if (allimages.length <= 25){
		ng_slide('adv_gallery_scr', nx);
	} else {
		sc.style.left = nx + 'px';
	}
	return false;
}

function get_aff(){

	if (gd('afm') && gd('aff_sign_1') && gd('aff_sign_2') && gd('aff_date') && gd('aff_percent')){
		i = gd('aff_sign_1').value+'.';
		i += gd('aff_sign_2').value+'.';
		i += gd('aff_date').value;
		gd('afm').style.display = 'block';
		gd('aff_percent').innerHTML = '<img style="margin-top:2px;" alt="" src="/images/loading.gif" />';
		aff_timer = setTimeout('xget(\'affinita='+i+'\',\'aff_percent\')',2000);
		return false;
	}
}

function get_asdf(){
	if (gd('asdf') && gd('zodiac_birth_day') && gd('zodiac_today')){
		i = gd('zodiac_birth_day').value+'.';
		i += gd('zodiac_today').value;
		gd('asdf').style.display = 'block';
		xget('asdf='+i,'asdf');	
		//gd('aff_percent').innerHTML = '<img style="margin-top:2px;" alt="" src="/images/loading.gif" />';
		//aff_timer = setTimeout('xget(\'affinita='+i+'\',\'aff_percent\')',2000);
		return false;
	}
}

function set_bgim(obj,imgpath){
	obj.style.backgroundImage = 'url('+imgpath+')';
}

function ng_move(direction){
	var sc = gd('compact_gallery_scr');
	allimages = sc.getElementsByTagName('img');
	imagecount = allimages.length;
	sc.style.width = (352 * imagecount) + 'px';
	if (direction == 'left'){
		if (cur_comp_img > 0){
			//sc.style.left = (sc.offsetLeft + 352) + 'px';
			cur_comp_img = cur_comp_img -1;
		} else {
			cur_comp_img = imagecount -1;
		}
	} else {
		
		if (cur_comp_img < imagecount-1){
			//sc.style.left = (sc.offsetLeft - 352) + 'px';
			cur_comp_img = cur_comp_img+1;		
		} else {
			cur_comp_img = 0;
		}
	}
	gd('compact_gallery_dida').innerHTML = allimages[cur_comp_img].title;
	ng_slide('compact_gallery_scr', -352*cur_comp_img);
}

function open_npo(npo_link){
	npo = window.open(npo_link,'newsmemory','left=0,top=0,height='+screen.availWidth+',width='+screen.availWidth+',resizable=yes');
	return false;
	/*npo.moveTo(0,0);
	npo.resizeTo(screen.availWidth,screen.availHeight);*/
}

function open_feedback_form(){
	if (gd('feedback_form') && gd('feedback_button')){
		gd('feedback_form').style.display = 'block';
		gd('feedback_form').style.top = '0px';
		gd('feedback_button').style.display = 'none';
		gd('feedback_message').focus();
		gd('feedback_spamtest').value = '20135';
	}
}

function close_feedback_form(){
	if (gd('feedback_form') && gd('feedback_button')){
		gd('feedback_form').style.display = 'none';
		gd('feedback_form').style.top = '-240px';
		gd('feedback_button').style.display = 'block';
	}
}

function window_size() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  } else {
  	return false;
	}
  return [myWidth,myHeight];

}

function hasbanner(obj){
	if (obj){
		if (obj.innerHTML.indexOf('.jpg') >= 0 || obj.innerHTML.indexOf('.swf') >= 0 || obj.innerHTML.indexOf('.gif') >= 0 || obj.innerHTML.indexOf('.png') >= 0 || obj.innerHTML.indexOf('<iframe') >= 0){
			return true;	
		}
	}
	return false;
}

function adapt_skyscraper(agent){

	if(gd('pub_skyscraper') && gd('header_menu_bar')){
		
		if (hasbanner(gd('pub_skyscraper'))){
			gd('pub_skyscraper').style.top = fpos(gd('header_menu_bar'))[1] + 'px';
			//gd('pub_skyscraper').style.left = (fpos(gd('header_menu_bar'))[0]+gd('header_menu_bar').offsetWidth+16) + 'px';
			gd('pub_skyscraper').style.left = 990 + 'px';
			
			if (agent == 'ipad')
				return;
			if (getCookie('hide_skyscraper'))
				return false;
				
			size = window_size();
			if (size){
				rpos = fpos(gd('pub_skyscraper'))[0]+gd('pub_skyscraper').offsetWidth;
				if (rpos > size[0] && size[0] > 800){
					gd('pub_skyscraper').style.left = (size[0] - (gd('pub_skyscraper').offsetWidth) - 16) + 'px';
					if (gd('skyscraper_hide')){
						gd('skyscraper_hide').style.display = 'block';
						gd('skyscraper_hide').style.left =(size[0] - (gd('pub_skyscraper').offsetWidth) - 28) + 'px'; 
						gd('skyscraper_hide').style.top = fpos(gd('pub_skyscraper'))[1] + 'px';
					}
				} else {
					if (gd('skyscraper_hide')){
						gd('skyscraper_hide').style.display = 'none';
					}
				}
			}
		}
	}	
}

function hide_skyscraper(){
	if (gd('pub_skyscraper') && gd('skyscraper_hide')){
		gd('skyscraper_hide').style.display = 'none';
		
		// Normale
		//gd('pub_skyscraper').style.left = (fpos(gd('header_menu_bar'))[0]+gd('header_menu_bar').offsetWidth+16) + 'px';
		
		// Slide
		movexy('pub_skyscraper', (fpos(gd('header_menu_bar'))[0]+gd('header_menu_bar').offsetWidth+16), fpos(gd('header_menu_bar'))[1]);
		setCookie('hide_skyscraper',1,1);
	}
	
}

function objmove(objid, tox, toy) {
	
	ob = gd(objid);
	fx = fpos(ob)[0];
	fy = fpos(ob)[1];
	
	dx = Math.floor(Math.abs(tox-fx)*0.30);
	dy = Math.floor(Math.abs(toy-fy)*0.30);
	
	if (dx < 1 && fx != tox) dx = 1;
	if (dy < 1 && fy != toy) dy = 1;
	
	newleft = (tox > fx) ? fx + dx : fx - dx;
	newtop = (toy > fy) ? fy + dy : fy - dy;
	
	ob.style.left = newleft + 'px';
	ob.style.top = newtop + 'px';
	
	if (fx == tox && fy == toy) {
		clearInterval(tm);
	}

}


function movexy(objid, mx, my){
	clearInterval(tm);
	tm = setInterval("objmove('"+objid+"',"+mx+","+my+");",15);
}

function send_feedback(){
	if (gd('feedback_message') && gd('feedback_spamtest')){
		
		if (gd('feedback_message').value.length < 20){
			alert('Si prega di inserire almeno 20 caratteri di testo');
			gd('feedback_message').focus();
			return false;
		}
		
		if (gd('feedback_spamtest').value == '20135'){
			gd('feedback_spamtest').value = '85113';
		} else {
			return false;
		}
		
		alert('Messaggio inviato. Grazie!');
		gd('feedback_form').submit();
	}
}



function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function fpos(obj) {
	if (obj){
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
			return [curleft,curtop];
		}
	}
	return false;
}

function check_email(eml){
	re = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;
	return (re.test(eml)) ? true : false;
}

function send_to_friend(art_id){
	if (art_id != '' && gd('mail_address')){
		if(check_email(gd('mail_address').value)){
			// indirizzi in blacklist NONSPEDIRE 
			if (gd('mail_address').value=='monica.midali@gmail.com') {
				gd('float_xbox_mail').style.display = 'none';
			}
			else {
				xget('sendto=' + gd('mail_address').value + '&article=' + art_id , 'float_xbox_mail');
			}
		} else {
			alert("Si prega di inserire un indirizzo email valido");
		}
	}
}

function detectBrowser(){
	var appVer   = navigator.appVersion.toLowerCase();
	var agt      = navigator.userAgent.toLowerCase();
	var bName    = navigator.appName;
	var iePos    = agt.indexOf('msie');
	var operaPos = agt.indexOf('opera');
	var ns6Pos   = agt.indexOf('netscape6');
	var geckoPos = agt.indexOf('gecko');
	var rvPos    = agt.indexOf('rv:')
	
	var version = parseFloat(appVer);
	if (iePos!=-1 && operaPos==-1)
	  version = parseFloat(agt.substring(iePos+5,agt.indexOf  (';',iePos)));
	else if (operaPos!=-1) {
	  version = parseFloat(agt.substring(operaPos+5,agt.indexOf('[',operaPos)));
	  bName= "Opera";
	}
	else if (ns6Pos !=-1)
	  version = parseFloat(agt.substring(ns6Pos+10));
	else if (geckoPos !=-1 && rvPos !=-1) {
	   version = agt.substring(rvPos+3,agt.indexOf(')',rvPos));
	   bName= "Mozilla";
	}
	return bName;
}

function togglesize(objid, defsize, deflineheight){
	if (gd(objid)){
		var currentSize = gd(objid).style.fontSize.replace("px","");
		if (currentSize && currentSize != defsize){
			gd(objid).style.fontSize = defsize + 'px';
			gd(objid).style.lineHeight = deflineheight + 'px';
		} else {
			gd(objid).style.fontSize = defsize + 2 + 'px';
			gd(objid).style.lineHeight = deflineheight + 3 + 'px';
		}
		with (gd('tools_size').style) {
			if (backgroundColor != 'rgb(128, 0, 0)' && backgroundColor.toLowerCase() != '#800000'){
				backgroundColor = '#800000';
			} else {
				backgroundColor = '';
			}
		}
	}
}

function toggleall(id,nome,quanti) {
	var i=0;
	var ii = 0;
	for (i=1;i<=quanti;i++)
	{
		ii++;
		var nn = nome + ii;
		var el = document.getElementById(nn);
		el.style.display = 'none';
	}
	
	var el = document.getElementById(id);
	if (el.style.display == 'none')	{
		el.style.display = 'block';
	}	else {
		el.style.display = 'none';
	}
} 

function print_content(content_id){
	if (content_id && gd('print_preview')){
		gd('print_preview').src = '/print.php?q=' + content_id + '';
	}
}
 
function tabshow(ident,tabid){
	if (gd(tabid) && ident){
		var divs = document.getElementsByTagName("div");
		for(i=0; i < divs.length; i++){
			if (divs[i].id.substr(0,ident.length) == ident){
				divs[i].style.display = 'none';
			}
		}
		gd(tabid).style.display = '';
	}
}

show_menu = function(menu_id){
	opener_id = menu_id.substr(6,menu_id.length-6);
	if (gd(opener_id) && gd(menu_id)){
		gd(opener_id).style.backgroundColor = '#900000';
		if (gd(menu_id).style.display != 'block'){
			with (gd(menu_id).style){
				zIndex = 99;
				left = fpos(gd(opener_id))[0] + 'px';
				top = (fpos(gd(opener_id))[1] + gd(opener_id).offsetHeight) + 'px';
				display = 'block';
				if (gd(menu_id).parentNode){
					el_right = fpos(gd(menu_id))[0] + gd(menu_id).offsetWidth;
					container_right = fpos(gd(menu_id).parentNode)[0] + gd(menu_id).parentNode.offsetWidth;
					if (el_right > container_right){
						left = (fpos(gd(opener_id))[0] - (gd(menu_id).offsetWidth - gd(opener_id).offsetWidth)) + 'px';
					}
				}
			}
		}
	}
}

hide_menu = function(menu_id){
	opener_id = menu_id.substr(6,menu_id.length-6);
	if (gd(menu_id) && gd(menu_id)){
		gd(menu_id).style.display = 'none';
		gd(opener_id).style.backgroundColor = '';
	}
}

function xget(x_params,target_id) {
	/*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
	window.XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP') }
	@end @*/
	
	if (x_params){
		var x_url = '/xrequest.php?'+x_params;	
		this.req = new XMLHttpRequest();
		req.open('GET', x_url, true);
		if (target_id && gd(target_id)){
			req.onreadystatechange = function (aEvt) {
				if (req.readyState == 4) {
					if(req.status == 200) {
						gd(target_id).innerHTML = req.responseText;
					}
				}
			}
		}
		req.send(null);
	}
}

function fbs_click(){
	u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function bookmarklink(url,btitle){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,btitle);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(btitle,url,"");
  } else {
    alert("per aggiungere questa pagina ai preferiti\npremere CTRL-D (Netscape) o CTRL-T (Opera)");
  }
}

function loadMainMenu(){
	
	// caricamento di tutti i menu a tendina presenti in pagina
	// ma non di quelli già elaborati
	
	var a_all = document.getElementsByTagName("a");
	for(var i=0; i < a_all.length; i++){
		if (a_all[i].id.substr(0,5) == 'menu_'){
			if (!a_all[i].onmouseover && !gd('float_'+a_all[i].id).onmouseover){
				a_all[i].onmouseover = function(evt){ show_menu('float_'+this.id) }	
				a_all[i].onmouseout = function(evt){ hide_menu('float_'+this.id) }	
				gd('float_'+a_all[i].id).onmouseover = function(evt){ show_menu(this.id) }	
				gd('float_'+a_all[i].id).onmouseout = function(evt){ hide_menu(this.id) }	
			}
		}
	}	
	
}

var vfut;

function valid_username(uname){
	if(uname.match(/[^a-zA-Z0-9\s-_]/g)) {
		return false;
	} else {
		return true;
	}
}

function vfu(uname){
	if (gd('username_verify_status')){

		xget('username_verify=' + uname, 'username_verify_status');

	}
}

function verify_username(uname, orig_name){
	
	if (vfut){
		clearTimeout(vfut);
	}
	
	if (gd('nus')){
		
		gd('nus').style.backgroundPosition = 'right center';
		gd('nus').style.backgroundRepeat = 'no-repeat';
		gd('nus').style.backgroundImage = '';
		
		if (uname == orig_name){
			gd('username_verify_status').innerHTML = '';
			return false;	
		}
		
		if(uname.length < 3){
			gd('username_verify_status').innerHTML = 'Nome utente troppo corto';
			gd('nus').style.backgroundImage = 'url(/images/warning.gif)';
			return false;
		}
		
		if(uname.length > 24){
			gd('username_verify_status').innerHTML = 'Nome utente troppo lungo';
			gd('nus').style.backgroundImage = 'url(/images/warning.gif)';
			return false;
		}
		
		
		
		if (!valid_username(uname)){
			gd('username_verify_status').innerHTML = 'Sono ammessi solo numeri, lettere e spazi';
			gd('nus').style.backgroundImage = 'url(/images/warning.gif)';
			return false;
		}
		
		var loading_img = '<img src="/images/loading.gif" />';
		if (gd('username_verify_status').innerHTML != loading_img){
			gd('username_verify_status').innerHTML = loading_img;
		}
	}

	vfut = setTimeout('vfu(\''+uname+'\')', 1000);

}


function verify_password(ufield, abo){
	if (gd('np1') && gd('np2') && gd('pass_verify_status1') && gd('pass_verify_status2')){
		
		gd('np1').style.backgroundPosition = 'right center';
		gd('np1').style.backgroundRepeat = 'no-repeat';
		gd('np1').style.backgroundImage = '';
		gd('pass_verify_status1').innerHTML = '';	
		gd('np2').style.backgroundPosition = 'right center';
		gd('np2').style.backgroundRepeat = 'no-repeat';
		gd('np2').style.backgroundImage = '';
		gd('pass_verify_status2').innerHTML = '';	
		
		
		if (gd('np1').value.length == 0 ){	
			return false;			
		}
		if (gd('np1').value.length < 8){
			gd('pass_verify_status1').innerHTML = 'Password troppo corta';
			gd('np1').style.backgroundImage = 'url(/images/warning.gif)';
			return false;
		}
		
		if (gd('np1').value == abo){
			gd('pass_verify_status1').innerHTML = 'La password non pu&ograve; essere il No.abbonato';
			gd('np1').style.backgroundImage = 'url(/images/warning.gif)';
			return false;
		}
		gd('np1').style.backgroundImage = 'url(/images/ok.png)';
		gd('pass_verify_status1').innerHTML = '';		

		if (gd('np1').value.length == 0 && gd('np2').value.length == 0){
			gd('pass_verify_status2').innerHTML = '';
			return false;
		}
		if (gd('np2').value != gd('np1').value){
			gd('pass_verify_status2').innerHTML = 'Password differente dalla prima';
			gd('np2').style.backgroundImage = 'url(/images/warning.gif)';
			return false;
		}
		gd('np2').style.backgroundImage = 'url(/images/ok.png)';
		gd('pass_verify_status2').innerHTML = '';	
		
	}
}

function verify_email(mfield, em){
	if (mfield && gd('email_verify_status')){
		
		if (mfield.value == em){
			mfield.style.backgroundImage = '';
			gd('email_verify_status').innerHTML = '';
			return false;
		}
		
		mfield.style.backgroundPosition = 'right center';
		mfield.style.backgroundRepeat = 'no-repeat';
		
		if (mfield.value != ''){
			if (!check_email(mfield.value)){
				gd('email_verify_status').innerHTML = 'Email non valido';
				mfield.style.backgroundImage = 'url(/images/warning.gif)';
			} else {
				gd('email_verify_status').innerHTML = '';
				mfield.style.backgroundImage = 'url(/images/ok.png)';
			}
		} else {
			gd('email_verify_status').innerHTML = '';
			mfield.style.backgroundImage = 'url(/images/warning.gif)';
		}
			
	}
}

/*window.onresize = function(){
	adapt_skyscraper();
}*/

window.onload = function(){

	try {
  	document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
	
	// caricamento dei menu
	loadMainMenu();
	
	
	/*var input_all = document.getElementsByTagName("input");
	for(var i=0; i < input_all.length; i++){
		if (input_all[i].title != ''){
			
		}
	}	*/
	
	// Social tools testata
	if(gd('social_tool')){
		var toolbuttons	= gd('social_tool').getElementsByTagName('a');
		for (var i = 0; i < toolbuttons.length; i++){
			gd(toolbuttons[i].id).style.background = 'url(/images/'+toolbuttons[i].id+'.png) no-repeat';
			gd(toolbuttons[i].id).onmouseover = function(){this.style.background = 'url(/images/'+this.id+'_hover.png) no-repeat';}
			gd(toolbuttons[i].id).onmouseout = function(){this.style.background = 'url(/images/'+this.id+'.png) no-repeat';}
		}
	}
	// ------------
	
	var img_all = document.getElementsByTagName("img");
	for(var i=0; i < img_all.length; i++){
		if (img_all[i].id.substr(0,5) == 'xbox_'){
			if (gd('float_'+img_all[i].id)){
				img_all[i].onclick = function(evt){ 
					if (gd('float_'+this.id) && gd('float_'+this.id).style.display != 'block'){
						show_menu('float_'+this.id);
					} else {
						hide_menu('float_'+this.id);
					}
				}	
			}
		}
	}	
	
	if (gd('gallery_thumbs') && gd('gallery_right') && gd('gallery_left') && gd('content_details_gallery')){
	
		var gx = gd('gallery_thumbs').offsetLeft;
		var gy = gd('gallery_thumbs').offsetTop;
		var gw = gd('gallery_thumbs').offsetWidth;
		var gv = 52;
		
		var imgs = gd('gallery_thumbs').getElementsByTagName('img');
		var imglen = imgs.length;

		maxleft = 0 - ((imglen*gv) - (6*gv));
		
		moveLeft = function(){
			if (gd('gallery_thumbs').offsetLeft<gx){
				gd('gallery_thumbs').style.left = gd('gallery_thumbs').offsetLeft+gv+"px";
				gd('gallery_thumbs').style.width = gd('gallery_thumbs').offsetWidth-gv+"px";
			}
		}
		
		moveRight = function() {
			if (gd('gallery_thumbs').offsetLeft > maxleft) {
				gd('gallery_thumbs').style.left = gd('gallery_thumbs').offsetLeft-gv+"px";
				gd('gallery_thumbs').style.width = gd('gallery_thumbs').offsetWidth+gv+"px";
			}
		}
		
		gd('gallery_left').onmouseout = function(evt) { this.src = '/images/arrow_left.gif'; return false; }		
		gd('gallery_left').onclick = function(evt) { moveLeft(); return false; }
		gd('gallery_left').ondblclick = function(evt) {	moveLeft();	return false;	}
		gd('gallery_left').onmouseover = function(evt) { this.src = '/images/arrow_left_hover.gif'; return false; }
		
		gd('gallery_right').onmouseout = function(evt) { this.src = '/images/arrow_right.gif'; return false; }
		gd('gallery_right').onclick = function(evt) {	moveRight(); return false; }
		gd('gallery_right').ondblclick = function(evt) { moveRight();	return false;	}
		gd('gallery_right').onmouseover = function(evt) { this.src = '/images/arrow_right_hover.gif'; return false; }	
			
	}
	
	
	if (gd('hover_box') && gd('image_full')){
		
		// Lore: 20090417 Anti trascinamento delle foto
		gd('image_full').onmousedown = function(evt){
			return false;
		}
		// Lore: 20090417 Anti tasto destro sulle foto
		gd('image_full').oncontextmenu = function(evt){
			return false;
		}
		
		gd('hover_box').onmousemove = function(evt){
			gd('image_full').onmousemove;
		}
		gd('hover_box').onmouseover = function(evt){
			gd('image_full').onmousemove;
		}
		gd('image_full').onmouseover = function(evt){
			//gd('hover_box').style.display = 'block';
			gd('image_full').onmousemove;
		}
		gd('image_full').onmouseout = function(evt){
			gd('hover_box').style.display = 'none';
		}
		gd('image_full').onmousemove = function(evt){

			gd('hover_box').style.display = 'block';
			var e = (evt) ? evt : window.event;
    	var scx = f_scrollLeft();
			var scy = f_scrollTop();
    	cx = (e.pageX) ? e.pageX : (e.clientX + scx);
    	cy = (e.pageY) ? e.pageY : (e.clientY + scy);	
    	
    	cx = cx + 12;
    	cy = cy + 12;
    	   	
    	if ((cx+12+gd('hover_box').offsetWidth) >= (gd('image_full').offsetWidth + fpos(gd('image_full'))[0])){
    		cx = (fpos(gd('image_full'))[0] + gd('image_full').offsetWidth) - gd('hover_box').offsetWidth - 10;
    	}
    	
    	gd('hover_box').style.left = cx + 'px';
    	gd('hover_box').style.top = cy + 'px';
    	
    	
		}
	}
	
	if (gd('ac')){
		gd('ac').style.display = 'none';
	}
	
	if (gd('sign_1')){
		for (var i = 0; i < 12;i++){
			elsign = i+1;
			elsign = 'sign_'+elsign;
			if (gd(elsign)){
				//elname = ;
				gd(elsign).onmouseover = function (evt){
					if (this.style.color != 'rgb(208, 208, 208)' && this.style.color.toLowerCase() != '#d0d0d0'){
						set_bgim(this,'/images/zodiac/hover/'+this.title+'_hover.jpg');
						this.style.color='#C00000';
					}
				}
				gd(elsign).onmouseout = function (evt){
					if (this.style.color != 'rgb(208, 208, 208)' && this.style.color.toLowerCase() != '#d0d0d0'){				
						set_bgim(this,'/images/zodiac/normal/'+this.title+'_normal.jpg');
						this.style.color='#808080';
					}
				}
				gd(elsign).onmousedown = function (evt){
					for (var q = 0; q < 12;q++){
						set_bgim(gd('sign_'+(q+1)),'/images/zodiac/normal/'+signs(q)+'_normal.jpg');
						gd('sign_'+(q+1)).style.color='#808080';
					}
					set_bgim(this,'/images/zodiac/selected/'+this.title+'_selected.jpg');
					this.style.color='#D0D0D0';
					//tabshow('zodiacfull_','zodiacfull_'+(i+1));
					return false;
				}
			}	
		}
	}

}

