function fixToolTipColor(){
	$('.ui-tooltip-pointer-down-inner').each(function(){
		var bWidth = $('.ui-tooltip-pointer-down-inner').css('borderTopWidth');
		var bColor = $(this).parents('.ui-slider-tooltip').css('backgroundColor')
		$(this).css('border-top', bWidth+' solid '+bColor);
	});	
}

$(document).ready(function() {

	$('.capmain, .scapmain').corner('4px');
	$('.div-corner, .side-body').corner('6px');

	$("a.login[href=#login]").live("click", function(event) { 
		$('div.login').corner('6px').css({opacity:0.9}).animate({opacity:'toggle',height: 'toggle'},1000);
	});

	$('.shoutboxpost').corner('10px');
	$('.shoutboxname').corner('5px');
	$('.shoutboxdate').corner('3px');
	$('.menu li a').corner('6px');	
	$('.button').corner('6px');
	$(".tip").simpletooltip();
	$('.admin-body, .forum-corner, .forum_thread, .forum_post, .no-desc, .admin-main-panel-contener-bg, .poll_options').corner('6px');
	$('textarea.resizable:not(.processed)').TextAreaResizer();
	$('.hide').animate({opacity:0.01},4500).hide(800);
	$('.admin-message').corner('6px').fadeIn(800).animate({opacity:0.01},4500).hide(800);
	$('#bbcode_smileys_list_shout_message').corner('4px').css({opacity:0.7});
	$('.error, .valid, .status').corner('6px').hide(1).fadeIn(1000);
	$('#render').corner('4px').css({opacity:0.4});

	$('#shoutbox').jScrollPane();
	$('.sb_post, .shoutbox').corner('6px');
	$('.shoutboxdate').css({opacity:0.5});
	$('.shoutboxdate:hover').css({opacity:1});
	$(".trigger").click(function(){
		var shout_id = (this.id);
		$("#toggle_" + shout_id).animate({opacity:0},1).animate({"width": "toggle"},1000).animate({opacity:0.7},1000);
	});

    $('.story-small img').each(function() {
        var maxWidth = 400;
        var maxHeight = 400;
        var ratio = 0;
        var width = $(this).width();
        var height = $(this).height();
 
        if(width > maxWidth){
            ratio = maxWidth / width;
            $(this).css("width", maxWidth);
            $(this).css("height", height * ratio);
            height = height * ratio;
        }

        if(height > maxHeight){
            ratio = maxHeight / height;
            $(this).css("height", maxHeight);
            $(this).css("width", width * ratio);
            width = width * ratio;
        }
    });

	$('#user_itemposts').selectToUISlider().next();
	$('#user_itemthread').selectToUISlider().next();
	$('#user_itemnews').selectToUISlider().next();
	$('#user_itemarticles').selectToUISlider().next();
	$('#user_itemmessages').selectToUISlider().next();
	$('#user_itemshouts').selectToUISlider().next();
	$('#user_itemweblinks').selectToUISlider().next();
	fixToolTipColor();
});






// thread_rating_include.php
function datosServidor() {
};
datosServidor.prototype.iniciar = function() {
	try {
		// Mozilla / Safari
		this._xh = new XMLHttpRequest();
	} catch (e) {
		// Explorer
		var _ieModelos = new Array(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
		);
		var success = false;
		for (var i=0;i < _ieModelos.length && !success; i++) {
			try {
				this._xh = new ActiveXObject(_ieModelos[i]);
				success = true;
			} catch (e) {
			// Implementar manejo de excepciones
			}
		}
		if ( !success ) {
			// Implementar manejo de excepciones, mientras alerta.
			return false;
		}
		return true;
	}
}
datosServidor.prototype.ocupado = function() {
	estadoActual = this._xh.readyState;
	return (estadoActual && (estadoActual < 4));
}
datosServidor.prototype.procesa = function() {
	if (this._xh.readyState == 4 && this._xh.status == 200) {
		this.procesado = true;
	}
}
datosServidor.prototype.enviar = function(urlget,datos) {
	if (!this._xh) {
		this.iniciar();
	}
	if (!this.ocupado()) {
		this._xh.open("GET",urlget,false);
		this._xh.send(datos);
		if (this._xh.readyState == 4 && this._xh.status == 200) {
			return this._xh.responseText;
		}
		
	}
	return false;
}
function _gr(reqseccion,divcont) {
	remotos = new datosServidor;
	nt = remotos.enviar(reqseccion,"");
	document.getElementById(divcont).innerHTML = nt;
}
var urlBase = "functions/thread_rating_include.php?";
function rateimg(rating,thread)  {
		remotos = new datosServidor;
		nt = remotos.enviar('functions/thread_rating_include.php?rating='+rating+'&thread='+thread);
		rating = rating * 18;
		document.getElementById('current-rating').style.width = rating+'px';
}

function blockError(){return true;}
window.onerror = blockError;

