/**
 * Recopilación de funciones más utilizadas.
 * revision 22.09.2010
 *
 * Listado de funciones:
 *
 * runSWF:			Muestra en archivo de flash en la página
 * ventana:			Genera una ventana en popup con el ancho y alto dado
 * equalHeight:		Igualador de alturas para dos o más columnas
 * vAlign:			Alinea un objeto con respecto a su contenedor
 * fieldtag:		Marca de agua para los input
 * revisabuscador:	Revisa que el formulario de búsqueda tenga el texto a buscar
 * BrowserSelector:	Selecciona el CSS correcto para cada navegador
 * Limit: 			Limita los caracteres en textarea
 * jQuery Cookie:	Manejador de Cookies para la página
 * jQuery.ScrollTo:	Mueve un objeto desde la posición actual a otra posición
 * Lazy Load:		jQuery plugin para cargar imagenes en segundo plano o solo cuando se requiera mostrar
 * IE_PNG Fix:		Fix para IE6 con PNG transparentes
 * Geolocation:		Plugin que detecta tu coordenada (lat, lng)
 * Custom Radio:	Plugin que modifica visualmente el Checkbox y Radio button
 *
 *
 * Changelog:
 * @revision 22.09.2010
 *	added: jQuery Custom Radio-buttons and Checkbox - plugin que modifica los checkbox y radiobutton
 *
 * @revision 20.09.2010
 *	added: jQuery-Geolocation-Plugin - plugin para detectar la posición del usuario
 *
 * @revision 23.08.2010
 *	added: IEPNG FIX - fox para ie con PNG transparentes
 *
 * @revision 18.08.2010
 *	added: Lazy Load - jQuery plugin for lazy loading images
 *
 * @revision 22.06.2010
 *	fix: runSWF wmode opaque en IE
 *
 * @revision 08.06.2010
 *	added: Plugin jQuery.ScrollTo para mover un objeto desde una posición hacia otra. Utilizado en los pasadores
 *
 */



/**
 * jQuery Custom Radio-buttons and Checkbox; basically it's styling/theming for Checkbox and Radiobutton elements in forms
 * By Dharmavirsinh Jhala - dharmavir@gmail.com
 * Date of Release: 13th March 10
 * Version: 0.8
 *
 * Extraido desde: http://blogs.digitss.com/javascript/jquery-javascript/jquery-fancy-custom-radio-and-checkbox/
 * Modificado por Alexis Lesa para que los cambios se realizen con clases (22.09.2010)
 *
 * USAGE:
 *	$(document).ready(function(){
 *		$(":radio").behaveLikeCheckbox();
 *	}
 */
jQuery.fn.extend({
	dgStyle: function() {
		$.each($(this), function() {
			var elm	=	$(this).children().get(0);
			elmType = $(elm).attr("type");
			$(this).data('type',elmType);
			$(this).data('checked',$(elm).attr("checked"));
			$(this).dgClear();
		});
		$(this).mousedown(function() { $(this).dgEffect(); });
		$(this).mouseup(function() { $(this).dgHandle(); });	
	},
	dgClear: function() {
		if($(this).data("checked") == true) {
			$(this).addClass("selected");
		} else {
			$(this).removeClass("selected");
		}	
	},
	dgEffect: function() {
		if($(this).data("checked") == true) {
			$(this).addClass("selected");
		} else {
			$(this).removeClass("selected");
		}
	},
	dgHandle: function() {
		var elm	= $(this).children().get(0);
		if($(this).data("checked") == true) {
			$(elm).dgUncheck(this);
		} else {
			$(elm).dgCheck(this);
		}
		
		if($(this).data('type') == 'radio') {
			$.each($("input[name='"+$(elm).attr("name")+"']"),function() {
				if(elm!=this) {
					$(this).dgUncheck(-1);
				}
			});
		}
	},
	dgCheck: function(div) {
		$(this).attr("checked",true);
		$(div).data('checked',true).addClass("selected");
	},
	dgUncheck: function(div) {
		$(this).attr("checked",false);
		if(div != -1) {
			$(div).data('checked',false).removeClass("selected");
		} else {
			$(this).parent().data("checked",false).removeClass("selected");
		}
	}
});
 
/**
 * A jQuery-Geolocation-Plugin
 *
 * @author Thomas Michelbach <thomas@nomoresleep.net>
 * @copyright NoMoreSleep(tm) <http://developer.nomoresleep.net>
 * @version 0.1
 *
 * Ejemplo de uso
 * if(navigator.geolocation) {
 * 		gl = navigator.geolocation.getCurrentPosition( function(position) {
 *
 *			alert("Latitud:" + position.coords.latitude + " - Long:" + position.coords.longitude);
 *		
 *		}, function() {
 *		},{timeout:15000});
 * }
 *
 */

(function($){
	
	$.extend($.support,{
		geolocation:function(){
			return $.geolocation.support();
		}
	});

	$.geolocation = {        
		find:function(success, error, options){
			if($.geolocation.support()){
				options = $.extend({highAccuracy: false, track: false}, options);
				($.geolocation.object())[(options.track ? 'watchPosition' : 'getCurrentPosition')](function(location){
					success(location.coords);
				}, function(){
					error();
				}, {enableHighAccuracy: options.highAccuracy});		
			}else{
				error();				
			}
		},
		object:function(){
			return navigator.geolocation;
		},
		support:function(){
			return ($.geolocation.object()) ? true : false;
		}
	}
	
})(jQuery);

 
/**
 * ***********************************************************************
 * IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support
 * (c) 2008-2009 Angus Turnbull http://www.twinhelix.com
 *
 * This is licensed under the GNU LGPL, version 2.1 or later.
 * For details, see: http://creativecommons.org/licenses/LGPL/2.1/
 *
 * ***********************************************************************
 */
var IEPNGFix = window.IEPNGFix || {};

IEPNGFix.tileBG = function(elm, pngSrc, ready) {
	// Params: A reference to a DOM element, the PNG src file pathname, and a
	// hidden "ready-to-run" passed when called back after image preloading.

	var data = this.data[elm.uniqueID],
		elmW = Math.max(elm.clientWidth, elm.scrollWidth),
		elmH = Math.max(elm.clientHeight, elm.scrollHeight),
		bgX = elm.currentStyle.backgroundPositionX,
		bgY = elm.currentStyle.backgroundPositionY,
		bgR = elm.currentStyle.backgroundRepeat;

	// Cache of DIVs created per element, and image preloader/data.
	if (!data.tiles) {
		data.tiles = {
			elm: elm,
			src: '',
			cache: [],
			img: new Image(),
			old: {}
		};
	}
	var tiles = data.tiles,
		pngW = tiles.img.width,
		pngH = tiles.img.height;

	if (pngSrc) {
		if (!ready && pngSrc != tiles.src) {
			// New image? Preload it with a callback to detect dimensions.
			tiles.img.onload = function() {
				this.onload = null;
				IEPNGFix.tileBG(elm, pngSrc, 1);
			};
			return tiles.img.src = pngSrc;
		}
	} else {
		// No image?
		if (tiles.src) ready = 1;
		pngW = pngH = 0;
	}
	tiles.src = pngSrc;

	if (!ready && elmW == tiles.old.w && elmH == tiles.old.h &&
		bgX == tiles.old.x && bgY == tiles.old.y && bgR == tiles.old.r) {
		return;
	}

	// Convert English and percentage positions to pixels.
	var pos = {
			top: '0%',
			left: '0%',
			center: '50%',
			bottom: '100%',
			right: '100%'
		},
		x,
		y,
		pc;
	x = pos[bgX] || bgX;
	y = pos[bgY] || bgY;
	if (pc = x.match(/(\d+)%/)) {
		x = Math.round((elmW - pngW) * (parseInt(pc[1]) / 100));
	}
	if (pc = y.match(/(\d+)%/)) {
		y = Math.round((elmH - pngH) * (parseInt(pc[1]) / 100));
	}
	x = parseInt(x);
	y = parseInt(y);

	// Handle backgroundRepeat.
	var repeatX = { 'repeat': 1, 'repeat-x': 1 }[bgR],
		repeatY = { 'repeat': 1, 'repeat-y': 1 }[bgR];
	if (repeatX) {
		x %= pngW;
		if (x > 0) x -= pngW;
	}
	if (repeatY) {
		y %= pngH;
		if (y > 0) y -= pngH;
	}

	// Go!
	this.hook.enabled = 0;
	if (!({ relative: 1, absolute: 1 }[elm.currentStyle.position])) {
		elm.style.position = 'relative';
	}
	var count = 0,
		xPos,
		maxX = repeatX ? elmW : x + 0.1,
		yPos,
		maxY = repeatY ? elmH : y + 0.1,
		d,
		s,
		isNew;
	if (pngW && pngH) {
		for (xPos = x; xPos < maxX; xPos += pngW) {
			for (yPos = y; yPos < maxY; yPos += pngH) {
				isNew = 0;
				if (!tiles.cache[count]) {
					tiles.cache[count] = document.createElement('div');
					isNew = 1;
				}
				var clipR = Math.max(0, xPos + pngW > elmW ? elmW - xPos : pngW),
					clipB = Math.max(0, yPos + pngH > elmH ? elmH - yPos : pngH);
				d = tiles.cache[count];
				s = d.style;
				s.behavior = 'none';
				s.left = (xPos - parseInt(elm.currentStyle.paddingLeft)) + 'px';
				s.top = yPos + 'px';
				s.width = clipR + 'px';
				s.height = clipB + 'px';
				s.clip = 'rect(' +
					(yPos < 0 ? 0 - yPos : 0) + 'px,' +
					clipR + 'px,' +
					clipB + 'px,' +
					(xPos < 0 ? 0 - xPos : 0) + 'px)';
				s.display = 'block';
				if (isNew) {
					s.position = 'absolute';
					s.zIndex = -999;
					if (elm.firstChild) {
						elm.insertBefore(d, elm.firstChild);
					} else {
						elm.appendChild(d);
					}
				}
				this.fix(d, pngSrc, 0);
				count++;
			}
		}
	}
	while (count < tiles.cache.length) {
		this.fix(tiles.cache[count], '', 0);
		tiles.cache[count++].style.display = 'none';
	}

	this.hook.enabled = 1;

	// Cache so updates are infrequent.
	tiles.old = {
		w: elmW,
		h: elmH,
		x: bgX,
		y: bgY,
		r: bgR
	};
};

IEPNGFix.update = function() {
	// Update all PNG backgrounds.
	for (var i in IEPNGFix.data) {
		var t = IEPNGFix.data[i].tiles;
		if (t && t.elm && t.src) {
			IEPNGFix.tileBG(t.elm, t.src);
		}
	}
};
IEPNGFix.update.timer = 0;

if (window.attachEvent && !window.opera) {
	window.attachEvent('onresize', function() {
		clearTimeout(IEPNGFix.update.timer);
		IEPNGFix.update.timer = setTimeout(IEPNGFix.update, 100);
	});
}

/**
 * ***********************************************************************
 * Lazy Load - jQuery plugin for lazy loading images
 *
 * Copyright (c) 2007-2009 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *   http://www.appelsiini.net/projects/lazyload
 *
 * Version:  1.5.0
 *
 * ***********************************************************************
 */
(function($) {

    $.fn.lazyload = function(options) {
        var settings = {
            threshold    : 0,
            failurelimit : 0,
            event        : "scroll",
            effect       : "show",
            container    : window
        };
                
        if(options) {
            $.extend(settings, options);
        }

        /* Fire one scroll event per scroll. Not one scroll event per image. */
        var elements = this;
        if ("scroll" == settings.event) {
            $(settings.container).bind("scroll", function(event) {
                
                var counter = 0;
                elements.each(function() {
                    if ($.abovethetop(this, settings) ||
                        $.leftofbegin(this, settings)) {
                            /* Nothing. */
                    } else if (!$.belowthefold(this, settings) &&
                        !$.rightoffold(this, settings)) {
                            $(this).trigger("appear");
                    } else {
                        if (counter++ > settings.failurelimit) {
                            return false;
                        }
                    }
                });
                /* Remove image from array so it is not looped next time. */
                var temp = $.grep(elements, function(element) {
                    return !element.loaded;
                });
                elements = $(temp);
            });
        }
        
        this.each(function() {
            var self = this;
            
            /* Save original only if it is not defined in HTML. */
            if (undefined == $(self).attr("original")) {
                $(self).attr("original", $(self).attr("src"));     
            }

            if ("scroll" != settings.event || 
                    undefined == $(self).attr("src") || 
                    settings.placeholder == $(self).attr("src") || 
                    ($.abovethetop(self, settings) ||
                     $.leftofbegin(self, settings) || 
                     $.belowthefold(self, settings) || 
                     $.rightoffold(self, settings) )) {
                        
                if (settings.placeholder) {
                    $(self).attr("src", settings.placeholder);      
                } else {
                    $(self).removeAttr("src");
                }
                self.loaded = false;
            } else {
                self.loaded = true;
            }
            
            /* When appear is triggered load original image. */
            $(self).one("appear", function() {
                if (!this.loaded) {
                    $("<img />")
                        .bind("load", function() {
                            $(self)
                                .hide()
                                .attr("src", $(self).attr("original"))
                                [settings.effect](settings.effectspeed);
                            self.loaded = true;
                        })
                        .attr("src", $(self).attr("original"));
                };
            });

            /* When wanted event is triggered load original image */
            /* by triggering appear.                              */
            if ("scroll" != settings.event) {
                $(self).bind(settings.event, function(event) {
                    if (!self.loaded) {
                        $(self).trigger("appear");
                    }
                });
            }
        });
        
        /* Force initial check if images should appear. */
        $(settings.container).trigger(settings.event);
        
        return this;

    };

    /* Convenience methods in jQuery namespace.           */
    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */

    $.belowthefold = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).height() + $(window).scrollTop();
        } else {
            var fold = $(settings.container).offset().top + $(settings.container).height();
        }
        return fold <= $(element).offset().top - settings.threshold;
    };
    
    $.rightoffold = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).width() + $(window).scrollLeft();
        } else {
            var fold = $(settings.container).offset().left + $(settings.container).width();
        }
        return fold <= $(element).offset().left - settings.threshold;
    };
        
    $.abovethetop = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).scrollTop();
        } else {
            var fold = $(settings.container).offset().top;
        }
        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
    };
    
    $.leftofbegin = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).scrollLeft();
        } else {
            var fold = $(settings.container).offset().left;
        }
        return fold >= $(element).offset().left + settings.threshold + $(element).width();
    };
    /* Custom selectors for your convenience.   */
    /* Use as $("img:below-the-fold").something() */

    $.extend($.expr[':'], {
        "below-the-fold" : "$.belowthefold(a, {threshold : 0, container: window})",
        "above-the-fold" : "!$.belowthefold(a, {threshold : 0, container: window})",
        "right-of-fold"  : "$.rightoffold(a, {threshold : 0, container: window})",
        "left-of-fold"   : "!$.rightoffold(a, {threshold : 0, container: window})"
    });
    
})(jQuery);

  
/**
 * *********************************************************************** 
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 * *********************************************************************** 
 */
(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
  
  
/**
 * ***********************************************************************
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 *
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 * *********************************************************************** 
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
 
/**
 * *********************************************************************** 
 * Limita los caracteres en textarea
 *
 * Limit – Limit the number of characters in a textarea jQuery plugin
 * copyright: http://www.unwrongest.com/projects/limit/
 * 
 * elemento: elemento a realizar la comprobación del limite de caracteres
 * limite: cantidad máxima de caracteres a limitar
 * campo_testigo: elemento al cual se le va a cargar la cantidad de caracteres restantes
 *
 * Uso: $(elemento).limit(limite, campo_testigo);
 * Ejemplo: $('#myTextarea').limit('140','#charsLeft');
 * 
 * *********************************************************************** 
 */
 (function($){ 
     $.fn.extend({  
         limit: function(limit,element) {
			
			var interval, f;
			var self = $(this);
					
			$(this).focus(function(){
				interval = window.setInterval(substring,100);
			});
			
			$(this).blur(function(){
				clearInterval(interval);
				substring();
			});
			
			substringFunction = "function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}";
			if(typeof element != 'undefined')
				substringFunction += "if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}"
				
			substringFunction += "}";
			
			eval(substringFunction);
			
			
			
			substring();
			
        } 
    }); 
})(jQuery);
 
/**
 * ***********************************************************************
 * CSS Browser Selector v0.3.5 (Feb 05, 2010)
 * Rafael Lima (http://rafael.adm.br)
 * http://rafael.adm.br/css_browser_selector
 * License: http://creativecommons.org/licenses/by/2.5/
 * Contributors: http://rafael.adm.br/css_browser_selector#contributors
 * *********************************************************************** 
 */
function css_browser_selector(u){
	var ua = u.toLowerCase(), is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; 
	c = b.join(' ');
	h.className += ' '+c; return c;
}; 
css_browser_selector(navigator.userAgent);

/**
 * ***********************************************************************
 * Revisa que el formulario de búsqueda tenga el texto a buscar
 *
 * param form formulario donde se esta realizando la búsqueda
 * param tag (opcional) si el campo posee un texto de marca de agua, revisa que no tenga ese texto en el input
 *
 * *********************************************************************** 
 */
function revisabuscador(form, tag) {
	tag = (tag!="") ? tag : "";
	if (form.q.value == "" || form.q.value == tag) {
		alert("Debe ingresar un texto");
		form.q.focus();
		return false;
	} else {
		return true;
	}
}

/**
 * ***********************************************************************
 * Alinea verticalmente el objeto definido con respecto a su objeto contenedor.
 *
 * Debe referenciarse a cada objeto por vez para realizar una alienación vertical correcta.
 * @example $("#bloque").vAlign();
 *
 * En caso de que sean multiples objetos del mismo identificador (id o clase) se debe utilizar de la siguiente forma:
 * @example $(".bloque").each ( function() { $(this).vAlign(); });
 *
 * *********************************************************************** 
 */
(function ($) {
	$.fn.vAlign = function() {
		return this.each(function(i){
		var ah = $(this).height();
		var ph = $(this).parent().height();
		var mh = (ph - ah) / 2;
		$(this).css('margin-top', mh);
		});
	};
})(jQuery);

 
/**
 * ***********************************************************************
 * jQuery Fieldtag Plugin
 * Version 1.1
 * 2009-05-07 10:10:35
 * URL: http://ajaxcssblog.com/jquery/fieldtag-watermark-inputfields/
 * Description: jQuery Plugin to dynamically tag an inputfield, with a class and/or text
 * Author: Matthias Jäggli
 * Copyright: Copyright (c) 2009 Matthias Jäggli under dual MIT/GPL license.
 *
 * Changelog
 * 1.1
 * Support for proper clearing while submitting the form of tagged fields
 * 1.0
 * Initial release
 * *********************************************************************** 
 */
(function($){
	$.fn.fieldtag = function(options){
		var opt = $.extend({
				markedClass: "tagged",
				standardText: false
			}, options);
		$(this)
			.focus(function(){
				if(!this.changed){
					this.clear();
				}
			})
			.blur(function(){
				if(!this.changed){
					this.addTag();
				}
			})
			.keyup(function(){
				this.changed = ($(this).val()? true : false);
			})
			.each(function(){
				this.title = $(this).attr("title"); //strange IE6 Bug, sometimes
				if($(this).val() == $(this).attr("title")){
					this.changed = false;
				}
				this.clear = function(){
					if(!this.changed){
						$(this)
							.val("")
							.removeClass(opt.markedClass);						
					}
				}
				this.addTag = function(){
					$(this)
						.val(opt.standardText === false? this.title : opt.standardText )
						.addClass(opt.markedClass);
				}
				if(this.form){
					this.form.tagFieldsToClear = this.form.tagFieldsToClear || [];
					this.form.tagFieldsToClear.push(this);
 
					if(this.form.tagFieldsAreCleared){ return true; }
					this.form.tagFieldsAreCleared = true;
 
					$(this.form).submit(function(){
						$(this.tagFieldsToClear).each(function(){
							this.clear();
						});
					});	
				}
			})
			.keyup()
			.blur();
		return $(this);
	}
})(jQuery);


/**
 * ***********************************************************************
 * ***********************************************************************
 */
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if (thisHeight > tallest) {
			tallest = thisHeight;
			}
	});
	
	group.height(tallest);
}

/**
 * ***********************************************************************
 * ***********************************************************************
 */
function ventana(url,nombre,ancho,alto,scroll) {
newWindow = window.open(url,nombre,'resizable=yes,menubar=no,location=no,toolbar=no,status=no,scrollbars='+scroll+',directories=no,width='+ancho+',height='+alto+',left='+(screen.availWidth-ancho)/2+',top='+(screen.availHeight-alto)/2);
}

/**
 * ***********************************************************************
 * ***********************************************************************  
 */
function runSWF(archivo, ancho, alto, version, bgcolor, id, menu, FlashVars, quality, allowScriptAccess, FullScreen) { 
	// Seteo valores por defecto
	var transparent_ie = '';
	var transparent_ns = '';
	var bgcolor_ie = '';
	var bgcolor_ns = '';

	var version_data="6,0,0,0";
	var menu_data=false;
	var id_data="flashMovie";
	var quality_data="high";
	var allowScriptAccess_data="always";
	var allowfullscreen_data_ie = "";
	var allowfullscreen_data_ns = ""

	// Modificación, a todos le pongo transparente.
	mode = 'wmode="transparent"';
	mode_ie = '<param name="wmode" value="transparent">\n';
	
	if(version!=""){
		var version_data=version;
	}

	if(menu!=""){
		var menu_data=menu;
	}

	if(bgcolor!="" && bgcolor != null){
		var bgcolor_data = bgcolor;
		var bgcolor_ie = '<param name="bgcolor" value='+bgcolor_data+'>\n';
		var bgcolor_ns = 'bgcolor='+bgcolor_data;
		
		mode = 'wmode="opaque"';
		mode_ie = '<param name="wmode" value="opaque">\n';
	
	}

	if(id!=""){
		var id_data=id;
	}

	if(quality!=""){
		var quality_data=quality;
	}

	if(allowScriptAccess!=""){
		var allowScriptAccess_data=allowScriptAccess;
	}

	if (FullScreen != "") {
		var allowfullscreen_data_ie = '<param name="allowfullscreen" value=true>';
		var allowfullscreen_data_ns = ' allowfullscreen=true';
	}

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version= '+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
	document.write('<param name="movie" value='+archivo+'>\n');
	document.write('<param name= "allowScriptAccess" value= '+allowScriptAccess_data+'>\n');
	document.write('<param name="quality" value='+quality_data+'>\n');
	document.write('<param name="FlashVars" value='+FlashVars+'>\n');
	document.write(bgcolor_ie);
	document.write(transparent_ie);
	document.write(allowfullscreen_data_ie);
	document.write(mode_ie);

	document.write('<param name="menu" value='+menu_data+' >\n');
	document.write('<embed src='+archivo+' '+bgcolor_ns+' '+transparent_ns+' ' + mode + ' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+allowfullscreen_data_ns+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect=true name='+id_data+'></embed>');
	document.write('</object>\n');
}
