(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(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
 *
 */
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
        }
        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 {
        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]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

// date
(function(){$.fn.date=function(){
	var days=["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"];
	var months=['enero','febrero','marzo','abril','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre'];
	var date=new Date();
	return this.text(days[date.getDay()]+', '+date.getDate()+' '+months[date.getMonth()]+' de '+date.getFullYear());
};})(jQuery);

/*var openMyModal = function(source){};
openMyModal('http://deseloper.org/examples/modal-simple/modal.html');*/

function setUpTabs(){
	//$('#news h3.todas, #news h3.marcas, #news h3.corp, #news h3.invsoc, #news h3.searchb').find("a").bind("click", tabOptionsClick);
	//$('#news h3.searchb a').bind("click", function(){ if($('#news .tab-search').is(":hidden")){$('#news .tab-search').slideDown();}else{$('#news .tab-search').slideUp();$(this).removeClass("selected");} });
}

function tabOptionsClick(e){ 
	$this = $(this);
	$this.parent().parent().parent().find("h3 a").removeClass("selected");
	$this.addClass("selected");
	if($('#news .tab-search').is(":hidden")==false && $this.parent().is('.searchb')==false)$('#news .tab-search').slideUp();
	return false;
}


var MultiForms = {
	settings : {main: "#multiForms", trigger:"#multiformsTrigger", containers: ".multiformsContainer", prefix:"#mForm"},
	setUp : function(){
		$(this.settings.trigger).change(function(){
			MultiForms.chooseForm($(this).val());
		});
		MultiForms.chooseForm($(this.settings.trigger).val());
	},
	chooseForm : function(id){
		if(id>-1){
			$(this.settings.prefix+id).css("display", "block").siblings().css("display", "none");
		}
	}
}

function file_name_only(str) {
	var slash = '/'
	if (str.match(/\\/)) {
		  slash = '\\';
	}
	sURL = str.substring(str.lastIndexOf(slash) + 1, str.length);
	return sURL;
}

$(document).ready(function(){
	if($('body').is('.adultonly')){
		if($.cookie('chopp_filter_opened')!="true"){
			var oldHref = file_name_only(window.location.href);
			window.location.href='proteccion.html#'+oldHref;
		}
	}
});

