var activo=1;var last=0; var last_act=0;

jQuery.cookie = function (key, value, options) {

    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);

        if (value === null) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};


$(document).ready(function() {   
	
	//menu desdobravel
	/*$(".nivel_1").click(function () {		
		var el=$(this).attr('id');	
		var el1="#sec_"+el;
		if (last!=el1)
		{
			$('#sec_'+el).toggle();	
			el3 = $('#sec_'+el).attr('id2');
			if( el3 == 'false')
			{	
				var href=$(this).attr('rel');
				document.location=href;
			}
		}		
		if (last!=0 && last!=el1 ) 
		{		
			$(last).toggle();		
			$(last_act).removeClass("nivel_1_act").addClass("nivel_1");
		}			
		last="#sec_"+el;
		last_act=this;
	});*/

	//comentarios
	$(".clike_img").click(function () 
	{			
		el=$(this).attr('id');				
		if ($.cookie(el)!="like")
		{		
			$.post("/", { modo: "ajax", acc: "like", id: el },function(data)
			{
					$("#cl_"+el).html(data);	
					$("#like_"+el).show();
			});	
			$.cookie(el, 'like', { expires: 10 });			
		}		
	});
	
	$("#submete_comentario").click(function () 
	{	
		
		$.post("/", { modo: "ajax", acc: "salva_comment", dados: $(this).parent().serialize() },function(data)
		{
					
					
		});			
		
	});

	
		
	if($.browser.msie && $.browser.version<"7.0")
	{
		$(function(){
			
			$("<div>")
				.css({
					'position': 'absolute',
					'top': '0px',
					'left': '0px',
					backgroundColor: 'black',
					'opacity': '0.7',
					'width': '100%',
					'height': $('body').height(),
					zIndex: 5000
				})
				.appendTo("body");
				
			$("<div style='color:#000;background: url(/layout_images/browser.jpg)'><div style='float:left;padding-top:200px;padding-left:150px;'><li><a href='http://www.microsoft.com/windows/internet-explorer/default.aspx' style='color:#000'>Internet Explorer 8<a/></li><li><a href='http://www.mozilla.com/en-US/firefox/ie.html'  style='color:#000'>Firefox<a/></li><li><a href='http://www.google.com/chrome'  style='color:#000'>Chrome<a/></li><li><a href='http://www.apple.com/safari/'  style='color:#000'>Safari<a/></li></span></div></div>")
				.css({
					backgroundColor: 'white',
					'top': '50%',
					'left': '50%',
					marginLeft: -300,
					marginTop: -200,
					width: 579,
					paddingRight: 10,
					paddingLeft: 10,
					paddingTop: 10,
					height: 379,
					'position': 'absolute',
					zIndex: 6000
				})
				.appendTo("body");
		});		
	}
	
	
	//prettyphoto
	$("a[rel^='lightbox']").prettyPhoto({             
		animationSpeed: 'normal',  
		padding: 40, 
		opacity: 0.85, 
		showTitle: false, 
		allowresize: true,
		counter_separator_label: '/', 
		theme: 'light_square' 
	}); 

});


	

function replaceText(text){
	while(text.lastIndexOf("&") > 0){
		text = text.replace('&', '[i-Stats]');
	}
	return text;
}

var web_referrer = replaceText(document.referrer);
istat = new Image(1,1);
istat.src = "/counter.php?sw="+screen.width+"&sc="+screen.colorDepth+"&referer="+web_referrer+"&page="+location.href;
	function addLoadEvent(func) {	
	  var oldonload = window.onload;	
	  if (typeof window.onload != 'function') {	
	    window.onload = func;	
	  } else {	
	    window.onload = function() {	
	      if (oldonload) {	
	        oldonload();	
	      }	
	      func();	
	    }	
	  }
}	  

