/*RESERVAS*/
reservas = function (n,lang)
{
	this.calendari
	this.idioma = lang
	this.nom = n
	
//$('#reservas,#reservas_int').css("display","none")
}

reservas.prototype.close = function ()
{
	$('#reservas,#reservas_int,#reservas_later_info').css("display","none")
	
	if(jQuery.browser.mozilla!=true) $("html").css("overflow-x","visible")
	$("#reservas").css("height","300");
}
reservas.prototype.open = function ()
{
	stats("popup/reservas/");
	
	this.calendari = new calendari(this.idioma);
	
	
	if(jQuery.browser.mozilla!=true) $("html").css("overflow-x","hidden")

	$("#reservas").css("width",$(window).width());
	$("#reservas").css("height",$(document).height());
	
	
	var inheight = self.innerHeight
	var inwidth = self.innerWidth
	
	if(!self.innerHeight) {
		inheight = document.body.clientHeight
		inwidth = document.body.clientWidth
	}
	$("#reservas_int").css("top","90px")
	$("#reservas_int").css("left", (inwidth-$("#reservas_int").width())/2 )
	
	$("#reservas_later_info").css("left", (inwidth-$("#reservas_later_info").width())/2 )
	$("#reservas_later_info").css("top","160px")
	
	$('#reservas,#reservas_int,#reservas_later_info').fadeIn("slow");
}
reservas.prototype.nextMonth = function ()
{
	this.calendari.nextMonth();
}
reservas.prototype.prevMonth = function ()
{
	this.calendari.prevMonth();
}
reservas.prototype.selectDay = function (dia)
{
	this.calendari.actiu = new Date();
	this.calendari.actiu.setFullYear(this.calendari.actual.getFullYear(),this.calendari.actual.getMonth(),dia);
	this.calendari.actual.setDate(dia)

	this.calendari.write();
}
reservas.prototype.selectMonth = function (mes,any)
{
	var curDay = this.calendari.actual.getDate();
	
	if(this.calendari.maxMes(mes,any)>=this.calendari.actual.getDate())
	{
		this.calendari.actual.setFullYear(any,mes,this.calendari.actual.getDate())
	}
	else
	{
		this.calendari.actual.setFullYear(any,mes,1)
	}	
	
	this.calendari.dies = this.calendari.makeMes(this.calendari.actual.getMonth(),this.calendari.actual.getFullYear());
	this.calendari.write();
}
calendari = function (idioma)
{
	$("#dia").bind("change",function(){
		res.selectDay( $(this).val() );
	})
	
	$("#mesos").bind("change",function(){
		
		var month = $(this).val().split("|")[0]
		var year = $(this).val().split("|")[1]
		
		res.selectMonth(month,year);
	})
	
	this.actual = new Date();
	this.actual.setDate(this.actual.getDate());
	this.idioma = idioma
	
	if(this.idioma=="es")
		this.textMesos = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre')
	else 
		this.textMesos = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
	
	this.dies = this.makeMes(this.actual.getMonth(),this.actual.getFullYear());
	
	
	this.write();
	
}
calendari.prototype.nextMonth = function ()
{
	if(this.maxMes(this.actual.getFullYear(),this.actual.getMonth()+1)>=this.actual.getDate())
	{
		this.actual.setFullYear(this.actual.getFullYear(),this.actual.getMonth()+1,this.actual.getDate())
	}
	else
	{
		this.actual.setFullYear(this.actual.getFullYear(),this.actual.getMonth()+1,1)
	}
	
	this.dies = this.makeMes(this.actual.getMonth(),this.actual.getFullYear());
	
	this.write();	
}
calendari.prototype.prevMonth = function ()
{
	cur_date = new Date();
	if(cur_date.getMonth()==this.actual.getMonth() && cur_date.getFullYear()==this.actual.getFullYear()) return false;
	
	if(this.maxMes(this.actual.getFullYear(),this.actual.getMonth()-1)>=this.actual.getDate())
	{
		this.actual.setFullYear(this.actual.getFullYear(),this.actual.getMonth()-1,this.actual.getDate())
	}
	else
	{
		this.actual.setFullYear(this.actual.getFullYear(),this.actual.getMonth()-1,1)
	}
	
	this.dies = this.makeMes(this.actual.getMonth(),this.actual.getFullYear());
	
	this.write();	
}
calendari.prototype.write = function ()
{

	$("#tbcal > tbody > tr > td").removeClass("act")
	$("#tbcal > tbody > tr > td").html("")
	
	var sem = 0
	var semdia = 0
	
	var avui = new Date();
	
	$("#mesos_info").html(this.textMesos[this.actual.getMonth()] +" "+ this.actual.getFullYear() );
	
	this.writeSelect();
	
	avui = new Date();
	avui.setDate(avui.getDate());
	for(i=0;i<this.dies.length;i++)
	{
		if(this.actual.getDate()==this.dies[i])
		{
			html = this.addCero(this.dies[i])
			$("#s"+sem+">td:eq("+semdia+")").addClass("act")
			
		}
		else if(this.actual.getMonth()==avui.getMonth() && this.actual.getFullYear()<=avui.getFullYear() && this.dies[i]<=avui.getDate())
		{
			html = this.addCero(this.dies[i]);
		} else 
			html = '<a>'+this.addCero(this.dies[i])+'</a>';
		
		
		$("#s"+sem+">td:eq("+semdia+")").html( html );
		
		$("#s"+sem+">td:eq("+semdia+")> a").bind("click", function(){
			res.selectDay( $(this).html() );
		})
		
		if(semdia==6)
		{
			semdia=0
			sem++;
		} else semdia++;
	}
	
	if(this.idioma=="es")
		$("#dies").html("<td>L</td><td>M</td><td>M</td><td>J</td><td>V</td><td>S</td><td>D</td>");
	else 
		$("#dies").html("<td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td>");
}

calendari.prototype.writeSelect = function ()
{
	$("#mesos > option").remove()
	
	offset_data = new Date();
	
	
	if(this.actual>offset_data) {
		//offset_data.setMonth(offset_data.getMonth()+12);
		
		var anys = this.actual.getFullYear()-offset_data.getFullYear()
		var mesos = this.actual.getMonth()-offset_data.getMonth()
		
		var offset = (anys*12)+mesos+12
		
	} else offset = 12
		
	temp_data = new Date();
	
	for(i=0;i<offset;i++)
	{
		if(this.actual.getMonth()==temp_data.getMonth() && temp_data.getFullYear()==this.actual.getFullYear()) selected = "selected='selected'"
		else selected = ""
		
		$("#mesos").append("<option "+selected+" value='"+temp_data.getMonth()+"|"+temp_data.getFullYear()+"'>"+this.textMesos[temp_data.getMonth()] +" "+ temp_data.getFullYear() +"</option>");
		
		temp_data.setMonth(temp_data.getMonth()+1);
	}
	
	$("#dia > option").remove()
	max_dies = this.maxMes(this.actual.getMonth(),this.actual.getFullYear())
	
	
	temp_data = new Date();
	if(this.actual.getMonth()==temp_data.getMonth() && this.actual.getFullYear()==temp_data.getFullYear()) initday = this.actual.getDate();
	else initday = 1
	
	for(i=initday;i<=max_dies;i++)
	{
		if(i==this.actual.getDate()) selected = "selected='selected'"
		else selected = ""
		
		$("#dia").append("<option "+selected+">"+i+"</option>");
	}
	
	
}	

calendari.prototype.makeMes = function (mm,yyyy)
{
	var init = this.diaMes(1,mm,yyyy);
	var max = this.maxMes(mm,yyyy);
	var mesos = new Array();
	
	
/*	if(this.idioma=="es") {
		mesos.push(' ');
	}
*/	for(i=0;i<init;i++)
	{
		mesos.push(' ');
	}
	for(i=0;i<max;i++)
	{
		mesos.push(i+1);
	}
	return mesos ;
}

calendari.prototype.maxMes = function (mm, yyyy)
{
	var mDia;
	if((mm == 3) || (mm == 5) || (mm == 8) || (mm == 10))
	{
		mDia = 30;
  	}
  	else
	{
  		mDia = 31
  		if(mm == 1){
   			if (yyyy/4 - parseInt(yyyy/4) != 0){
   				mDia = 28
   			}
		   	else{
   				mDia = 29
  			}
		}
	}
	return mDia;
	

}
calendari.prototype.diaMes = function (dd,mm, yyyy)
{
	//mm--;
	
	var data = new Date(yyyy,mm,dd);
	var re_day = data.getDay()
	if(this.idioma=="es")
	{
		if(re_day==0) return 6
		else return data.getDay()-1
	}
	else
	{
		return data.getDay()
	}
	
	
}
calendari.prototype.addCero = function (dd)
{
	if(dd==' ') return '';
	
	if(dd<10) return "0"+dd
	else return dd
}
/*END RESERVAS*/

/*COMMENTS*/
comments = function (n,t,i)
{
	this.nom = n
	this.id = i
	this.tipus = t
	this.toggle = false;
	
	this.lastView = 0
	this.pagination = new Array();
}

comments.prototype.init = function ()
{	
	if($(document).height()>950) $("#comments").css("height",$(document).height());
	
	
	$('#cmnt_n,#cmnt_f,#cmnt_c').focus(function () { $(this).css("border","1px solid #7d7d7d"); })
	
}

comments.prototype.effect = function ()
{
	if(this.toggle==true)
	{	
		$("#comments-int").css("display","none");
		if(jQuery.browser.msie==true && jQuery.browser.version=="6.0")
			$("#comments").css("width","39px");
		else
			$("#comments").animate({ width:"39px" }, "slow","swing" )
			
		this.toggle=false
	}
	else
	{
		//stats("popup/comments/");
		
		if(jQuery.browser.msie==true && jQuery.browser.version=="6.0")
		{
			$("#comments").css("width","356px");
			this.muestra_bar();
		}	
		else 
			$("#comments").animate({ width:"356px" }, "slow","swing",this.muestra_bar )
		
		this.toggle=true
	}	
	

}

comments.prototype.muestra_bar = function ()
{
	$("#comments-int").fadeIn("slow");
	com.list();
}

comments.prototype.validate = function ()
{
	var error=false;
	
	if($('#cmnt_n').val().length<1) { error=true; $('#cmnt_n').css("border","1px solid red") }
	else $('#cmnt_n').css("border","1px solid #7d7d7d");
	
	if($('#cmnt_f').val().length<1) { error=true; $('#cmnt_f').css("border","1px solid red") }
	else $('#cmnt_f').css("border","1px solid #7d7d7d");
	
	if($('#cmnt_c').val().length<1) { error=true; $('#cmnt_c').css("border","1px solid red") }
	else $('#cmnt_c').css("border","1px solid #7d7d7d");

	if(error==false) this.add();
}

comments.prototype.add = function ()
{
	var nom = $('#cmnt_n').val()
	var from = $('#cmnt_f').val()
	var text = $('#cmnt_c').val()
	
	//stats("popup/comments/addComment");
	
	$.post("comments/add/"+this.tipus+"/"+this.id, { "cmnt[n]":nom,"cmnt[f]":from,"cmnt[c]":text }, call_back_coment , "json");
	
}

comments.prototype.list = function ()
{	
	if(com.pagination[0]instanceof Array==true) com.next_pag(0)
	else if(!this.coments) {
	/*	$.getJSON("comments/index/"+this.tipus+"/"+this.id,
			function(data,textStatus){
		        com.coments = data;
				this.lastView = 0
				com.list();
			}
		);
	*/	
		$('#comments-int > p').remove();

		com.coments = coments_items
		this.lastView = 0
		
		com.list();
		
		return false;
	} 
	else 
	{
		if(com.coments==undefined) return false;
		var item = com.coments
		cur_page = 0
		for(i=0;i<item.length;i++)
		{
			
			$('#insert-com').before("<p id='cmnt"+i+"'>"+item[i].c+"<br /><span>"+item[i].n+"</span> <strong>- "+item[i].f+"</strong></p>");
			
			if(com.pagination[cur_page] instanceof Array==false) com.pagination[cur_page] = new Array();		
			com.pagination[cur_page].push(item[i])
			
			if($('#insert-com').position().top+320>$(window).height())
			{
				$('#comments-int > p').remove();
				cur_page++;		
			}
		}
		
		$('#comments-int > p').remove();
		com.next_pag(0)
	}	
}

comments.prototype.next_pag = function (pag)
{
	$('#comments-int > p').remove();
	
	if(this.pagination[pag]==undefined) return;
	var item = this.pagination[pag]
	for(i=0;i<item.length;i++)
	{
		$('#insert-com').before("<p style='display:none' id='cmnt"+i+"'>"+item[i].c+"<br /><span>"+item[i].n+"</span> <strong>- "+item[i].f+"</strong></p>");
	}
	
	var html_pagi = "";
	var pag_ant = pag-1
	var pag_sig = pag+1
	if(this.pagination[ pag_ant ] instanceof Array==true) html_pagi += '<a style="cursor:pointer; color:black;" onclick="com.next_pag('+ pag_ant +')">&laquo; Anterior</a> |'
	if(this.pagination[pag_sig] instanceof Array==true) html_pagi += '| <a style="cursor:pointer; color:black;" onclick="com.next_pag('+ pag_sig +')">Siguiente &raquo;</a>'
	
	$('#insert-com').before("<p style='display:none;'>"+html_pagi+"</p>");
	
	$('#comments-int > p').fadeIn("fast");
	$('html, body').animate({scrollTop:0}, 'fast'); 
	
	
}
function call_back_coment(data)
{	
	if(data.status=="ok")
	{
		$('#cmnt_n').val("");
		$('#cmnt_c').val("");
		$('#cmnt_f').val("");
		$('#msgs').fadeIn("slow")
	}
	//alert(data);
}
/*END COMMENTS*/

/*PNG FIX*/
(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[@src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[@src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);
/*END PNG*/

/*ACTIVE CONTNT*/
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

(function($){ 
    $.fn.extend({
	
		tPlayer: function(options) {  
	
		var defaults = {  
			version: '1.05',
			// class to select images to see not the first!
 			classImg: 'img.dnone',
 			autoMode: false,
			interval: 4000,
			stopOnInteraction: true
	  	}
	
		var options = $.extend(defaults, options);

		var cycle=function() {
			
			//console.log('Actual: '+options.actual)
			if(options.actual == options.images.length-1) next = 0;
			else next = options.actual+1;
			
			isAuto = true;
			options.butons[next].trigger("click");

		};
		
		var isAuto = false; // To know if event is triggeret from interval
		

    	return this.each(function() {  
  			obj = $(this);
			// The image
			var image = $('img:first',obj);
			
			
			options.actual = 0;
			options.images = [];
			$('img:first, ' + options.classImg, obj).each(function(){
				options.images[options.images.length] = this.src;
			})
			
			if(options.images.length == 1) {
				$('ul li', obj).toggle();
				return;
			}
				
			// li button
			var bt = $('ul li', obj);

			// Allways ofbutton namebuton(off.gif)
			tmp = $('img', bt).attr('src').split(".");
			options.btoff_src = tmp[tmp.length-2] + "off.gif";
			options.bton_src = tmp[tmp.length-2] + ".gif";
			
			// PT tho the showing image
			options.ptactual = $('img', bt)
			
			
			// add butons for each image
			for(i=0; i<options.images.length-1; i++){
				$('ul', obj).append( bt.clone() );
			}
			
			// array de botons
			options.butons = []
			
			// Add a index to compute array position...and swap btoff
			$('ul li a', obj).each( function(n) {  
				this.index = n;
				// array de botons
				options.butons[n] = $(this); 
				$(this).children('img').attr({src:options.btoff_src});
			} )
			// Activate bton
			options.ptactual.attr({src: options.bton_src });
			
			$('ul li a', obj).click(function() {

				var ell = $(this);
				options.ptactual.attr({src:options.btoff_src}) 
				ell.children('img').attr({src: options.bton_src})
				//options.actual = this.index;
				options.ptactual = ell.children('img')
				// index
				options.actual = this.index
				image.fadeOut(300, function() {  
					 image.attr({'src': options.images[options.actual]  });
					 image.fadeIn(300)
					//if(options.onshow) options.onshow()
					});
				
				// if automode, reset timer, perhaps stop?
				if(options.autoMode==true && isAuto==false) {
					window.clearInterval(options.inte);
					if(options.stopOnInteraction==false) options.inte = window.setInterval(cycle,options.interval);
				}
				
				isAuto=false;
				//if(options.onclick) options.onclick()
				return false;
			});
			
			// If automode, autoplay
			if(options.autoMode==true) {
				options.inte = window.setInterval(cycle,options.interval)
			}
			
			
    	});  
 	}
  	
    }); 
})(jQuery);
/*RND ACTIVE*/




/*
 * Date Format 1.2.3
 * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
 * MIT license
 *
 * Includes enhancements by Scott Trenda <scott.trenda.net>
 * and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */

var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};


abrePopup = function(quin) {
	leftX = (screen.availWidth-510)/2
	topY = (screen.availHeight-419)/2
	if(document.all) he = 428
	else he = 419
	brand = window.open(quin, 'nextWin', 'left='+leftX+',top='+topY+',width=508,height='+he+',toolbar=no,scrollbars=no,resizable=no,status=no').focus()
}

function checkDate(dd,mm,yy) {
	var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
	var yesterday = new Date(); 
	yesterday.setDate(yesterday.getDate()-1);
	if( dt <= yesterday ) return false;
	if (parseFloat(dd) != dt.getDate()) { return false; }
	if (parseFloat(mm)-1 != dt.getMonth()) { return false; }
	return dt;
}







