#####################################################################################################
#Rollover macro for moinmoin
#
#Developer: Carlos Zager
#Email:czager@corvus.com.ve
#Date:Mon May 12 13:25:44 VET 2008
#Revision:0.1
#
#This macro is intended to be used as a way to attach an image reference with a rollover to a page
#
#Syntax: [[Rollover(url1,url2,width,height,link)]]
#
#@url1:URL of the base image to be used
#@url2:URL of the roll image to be used
#@width:Width of the biggest image
#@height:Height of the biggest image
#@link:URL where the  rollover should point to
#####################################################################################################

import random,os

def execute(macro,args):
	args=args.split(',')
	orig=args[0]
	origp=os.path.dirname(orig)
	origi=os.path.basename(orig)
	roll=args[1]
	rollp=os.path.dirname(roll)
	rolli=os.path.basename(roll)
	width=args[2]
	height=args[3]
	link=args[4]
	n=random.randint(0,10000)
	name='img%d'%n
	return macro.formatter.rawHTML("<style type='text/css'>.%s{display:block;width:%spx;height:%spx;background:url(%s?action=AttachFile&do=get&target=%s) no-repeat;} .%s:hover{background:url(%s?action=AttachFile&do=get&target=%s) no-repeat;}</style><a href='%s' class='%s'></a>"%(name,width,height,origp,origi,name,rollp,rolli,link,name))
