$(document).ready(function() {

var h_bro=document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight;						
var w_bro=document.body.scrollWidth > document.body.offsetWidth ? document.body.scrollWidth : document.body.offsetWidth;
/*moment list*/
$(".moment_list img").hover(
		function(){$(this).addClass("border_red");},
		function(){$(this).removeClass("border_red");}
);
$(".add_something").click (function(){
var position_m=$(this).parent().parent().position();									 
			$(".pop_box").css({
				left:position_m.left,
				top:position_m.top,
				display:"block"
			});	
});
//alert(window.innerWidth);
//alert($(this).width());alert((window.innerWidth-$(this).width())/2);	
$(".add_something_1").click (function(){
//alert(window.innerWidth);
//alert(window.innerHeight);
//alert(screen.width);
//alert(screen.height);
//alert($(document).height());whole html height
alert(document.documentElement.clientWidth);
alert(document.documentElement.clientHeight);
var position_m_left=((document.documentElement.clientWidth-$(this).width())/2);
var position_m_top=((document.documentElement.clientHeight-$(this).height())/2);

			$("#pop1").css({
				left:position_m_left,
				top:position_m_top,
				display:"block"
			});	
});

$(".add_something_2").click (function(){
var position_m=$("#pop1").position();				
			$(".pop_box").css({
				display:"none"
			});	
			$("#pop2").css({
				left:position_m.left,
				top:position_m.top,
				display:"block"
			});	
});
$(".add_something_3").click (function(){
var position_m=$(this).parent().position();				
			$(".pop_box").css({
				left:position_m.left,
				top:position_m.top,
				display:"block"
			});	
});
/*mail box pop box*/
$(".unread").click(function(){
var position_m=$(this).position();									 
			$(".pop_box").css({
				left:position_m.left+50,
				top:position_m.top,
				display:"block"
			});	
		});
/*date pop box*/
$(".date_pop").click(function(){
		$("#pop1").css({
				left:$(this).offset().left+"px",
				top:$(this).offset().top+"px",
				display:"block"
			});	
});

$(".dynamix_add_button").click(function(){
$(".dynamic_add_content").show();
equal_height($(".dynamic_add_content").height());
return false;
});
/*make the height of the left and right in same line at the btm*/
//equal_height();
/*for top nav*/
$(".top_menu li").hover(
function(){$(this).addClass("sfhover");},
function(){$(this).removeClass("sfhover")});

$("#cont_menu td").hover(
function(){$(this).addClass("cont_menu_hover");},
function(){$(this).removeClass("cont_menu_hover")});

$(".tab_list li").hover(
function(){$(this).addClass("sfhover");},
function(){$(this).removeClass("sfhover")});

$(".left_menu a").hover(
function(){$(this).addClass("left_menu_sfhover");},
function(){$(this).removeClass("left_menu_sfhover")});

$('.tab .tab_list:not(.non-js) li a').click(function() {
		
		$(this).parent().parent().find("li").removeClass("current").end();
		$(this).parent().addClass("current");
		$(this).parent().parent().siblings(".tab_content").removeClass("current_content");
		var id_this=$(this).attr("href")
		$('div' + id_this).addClass("current_content");
		return false;
	
});

});

function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

function equal_height(dynamic_add){
	/*make the height of the content in same
equalHeight($(".main_right"));
equalHeight($(".main_left"));
equalHeight($(".main_content_border"));*/
if (dynamic_add==undefined){dynamic_add=0;}
var lhh=$("#left_side_2").height();
var l_home=$("#left_side_home").height();
var chh=$(".main_left").height();
var rhh=$(".main_right").height();
var r_bhh=$(".banner_text").height();

var banner_h=$("#main_banner").height();
if(banner_h==null){banner_h=$("main_banner_home").height;}
if(chh==null){chh=$("#main_content_border").height();}
if(chh==null){chh=$("#main_content_border_2").height();}
lhh=lhh-284;
if ((lhh>chh)&&(lhh>rhh)) var hh=lhh;
else if ((rhh>chh)&&(rhh>lhh))var hh=rhh;
else var hh=chh;
//add for dynamic content addimg
if (hh>1000){
	hh=hh+dynamic_add;
	}

/*if(chh==null){$("#footer").css("margin-top","0px");}
if (($.browser.msie)&&( $.browser.version==6.0 ))
{$("#left_side_2").height(hh+274);
$(".main_right").height(hh);
$(".main_left").height(hh);}
else {}*/
/**/
if (r_bhh!=null){
$("#left_side_2").height(hh+285);
$(".main_right").height(hh-r_bhh+285);
$(".main_left").height(hh);}
else if (banner_h!=null){
$("#left_side_2").height(hh+285);
$(".main_right").height(hh+1);
$(".main_left").height(hh);
$("#main_content_border").height(hh);
$("#left_side_home").height(hh);}
else {
$("#left_side_2").height(hh+285);
$(".main_right").height(hh+285);
$(".main_left").height(hh+284);
$("#main_content_border").height(hh+284);
$("#main_content_border_2").height(hh+284);
}
dynamic_add=0;
	}
	
/*get the position of the e*/	
function getTop(e){
var ffset=e.offsetTop;
if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
return offset;
}
function getLeft(e){
var ffset=e.offsetLeft;
if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
return offset;
}