/**
 * So depricated. 
 */

$(document).ready(function(){

	doc = function(){
        if (self.innerHeight) {
            doc.pageYOffset = self.pageYOffset;
            doc.pageXOffset = self.pageXOffset;
            doc.innerHeight = self.innerHeight;
            doc.innerWidth  = self.innerWidth;
        }
        else 
            if (document.documentElement &&
            document.documentElement.clientHeight) {
                doc.pageYOffset = document.documentElement.scrollTop;
                doc.pageXOffset = document.documentElement.scrollLeft;
                doc.innerHeight = document.documentElement.clientHeight;
                doc.innerWidth  = document.documentElement.clientWidth;
            }
            else 
                if (document.body) {
                    doc.pageYOffset = document.body.scrollTop;
                    doc.pageXOffset = document.body.scrollLeft;
                    doc.innerHeight = document.body.clientHeight;
                    doc.innerWidth  = document.body.clientWidth;
                }
        return doc;
    }
    
    var getMouseCoord = function(e){
        (!e) ? e = window.event : e = e;
        objDoc = new doc();
        (e.pageX) ? objDoc.pageX = e.pageX : objDoc.pageX = e.clientX +
        objDoc.scrollLeft;
        (e.pageY) ? objDoc.pageY = e.pageY : objDoc.pageY = e.clientY +
        objDoc.scrollTop;
        return [e.pageX, e.pageY];
    }
    
    $("#rating_player_tab").click(function(){
        $("#company").hide();
        $("#player").fadeIn("slow");
        $("#rating_player_tab").attr("class", "active");
        $("#rating_company_tab").attr("class", "inactive");
    });
    
    $("#rating_company_tab").click(function(){
        $("#player").hide();
        $("#company").fadeIn("slow");
        $("#rating_player_tab").attr("class", "inactive");
        $("#rating_company_tab").attr("class", "active");
    });
    
    
    
    $("#faq_quest > DIV").click(function(){
        var num = this.id.replace(/q/g, "");
        var col = $("#faq_quest > DIV").length;
        
        for (i = 1; i <= col; i++) {
            $("#a" + i).hide();
            $("#q" + i).css({fontWeight: "normal", borderLeft: "1px solid #ccc",  background: "#eee" });
        }
        $("#a" + num).show();
        $("#q" + num).css({fontWeight: "bold", borderLeft: "1px solid #fff", background: "#fff" });
        
    });
    
    
    $("#billboard_faq_quest > DIV").click(function(){
        var num = this.id.replace(/q/g, "");
        var col = $("#billboard_faq_quest > DIV").length;

        for (i = 1; i <= col; i++) {
            $("#a" + i).hide();
            $("#q" + i).css({fontWeight: "normal"});
        }
        $("#a" + num).show();
        $("#q" + num).css({fontWeight: "bold" });
        
    });
    
    
    
    $(".hint").mouseover(function(event){
        xPos = getMouseCoord(event)[0];
        yPos = getMouseCoord(event)[1];
        $("#" + this.id + "_pop").css({
            top: yPos + 10,
            left: xPos + 10
        });
        $("#" + this.id + "_pop").show();
        //	alert(xPos);
    });
    
    
    $(".hint").mouseout(function(){
        $("#" + this.id + "_pop").hide();
    });
    
    
    $('#faq').click(function(){
    	
	    	$('#billboard_text, #billboard_ribbon, #billboard_title, #billboard_heroes').toggle();    	
	    	$('#billboard_faq_quest, #billboard_faq_answer, #billboard_hero').toggle();
    	
    	
    });
    
    
});



function setPosition(a,b){
	
	var o = $(a).offset();
	var h = $('#header').offset();
		
		h = o.left - $('#wrapper').offset().left;
			
		$(b).css({left: h}).show();	
}			

function hideSelectors(){
		$("#realmlang").hide();	
}


$(document).ready(function(){
					
$('.combobox a.lang').click(function(){
						
	setPosition(this,"#realmlang");
						return false;
});


$('#content').mousemove(hideSelectors);


});
