// firebug degradiation
if (! ("console" in window) || !("firebug" in console)) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group"
                 , "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i <names.length; ++i) window.console[names[i]] = function() {};
}

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}



/*Navigation [by Hector]*/
var $nodeOver=null;
var $nodeOverTimeoutTime=500;/*miliseconds*/
var $nodeOverTimeout=null;
function nodeOverTimeout(){
	$("#navigation>li.selected>ul").slideUp("slow");
	$("#navigation>li.selected, #navigation>li.selected li.selected").removeClass('selected');
	$($nodeOver).parent().find("ul:first").slideDown("slow",nodeOverSlideReset);
	$($nodeOver).parent().addClass('selected');
}
function nodeOverSlideReset(){
	$('.menu-left, .content-page').equalizeCols();
	$('.left-col, .right-col, .left-col-landing, .right-col-landing').equalizeCols();
	$('.right-col, .right-col-landing, .right-advertisement, .list-banners').fill_height();
}
/*----------------------*/

function printme() {
	popUpWindow(window.location + '&print=true',0,0,850,700);
}
/*------------------------------------------------------------------------------
 Function: footnoteLinks()
 Author: Aaron Gustafson (aaron at easy-designs dot net)
 Creation Date: 8 May 2005
 Modified Date: 24 Feb 2009
 Version: 1.3
 Homepage: http://www.easy-designs.net/code/footnoteLinks/
 License: Creative Commons Attribution-ShareAlike 2.0 License
 http://creativecommons.org/licenses/by-sa/2.0/
 Note: This version has reduced functionality as it is a demo of
 the script's development
 ------------------------------------------------------------------------------*/
 function footnoteLinks(containerID) {
 if (!document.getElementById ||
 !document.getElementsByTagName ||
 !document.createElement) return false;
 if (!document.getElementById(containerID) ) return false;
 var $container = $("#"+containerID);

 var $h2 = $("<h2></h2>").addClass("printOnly").text("Links");
 var $coll = $("#"+containerID+" *");
 var $ol = $("<ol></ol>").addClass("printOnly");
 var $note = $("<sup></sup>").addClass("pringOnly");
 var myArr = [];
 var thisLink;
 var num = 1;
 $coll.each( function () { 
	if($(this).attr("href") || $(this).attr("cite")) {
		thisLink = $(this).attr('href') ? $(this).attr('href') : $(this).attr('cite');
		//console.debug("%s %b", thisLink, (thisLink.indexOf("http") == -1));
		if(thisLink.indexOf("http") == -1) {
			thisLink = "http://www.tctmd.com" + thisLink;
			//console.debug("%s", thisLink);
		}
		
		var $note = $("<sup></sup>").addClass("printOnly");
		var loc = $.inArray(thisLink, myArr)
		if(loc > 0){
			$note.text(loc+1).appendTo($(this));			 
		}
		else {
			$("<li></li>").text(thisLink).appendTo($ol);
			myArr.push(thisLink);
			$note.text(num).appendTo($(this));
			num++;
		}
	}
});
 
 $container.append($h2).append($ol);

 $("html").addClass("noted");
 return true;
}

 jQuery.noConflict();
/*tctmd Javascript*/
 jQuery(document).ready(function($){
    $('label.overlabel').overlabel();
    $('img[src$=".png"]').fixpng();
    $('div:first-child,tr:first-child, td:first-child, ul:first-child, li:first-child, span:first-child, a:first-child').addClass('first-child');
    $('div:last-child , tr:last-child , td:last-child, ul:last-child, li:last-child, span:last-child, a:last-child').addClass('last-child');
	$('span.first-child').filter(".last-child").removeClass("last-child");
	
    // for top nav update
    $(".nav-top #ctl00_ctl00_mainmenu_menuMiddle li:last, .nav-top #ctl00_mainmenu_menuMiddle li:last").addClass("last-child");

    $('#coe-list li:last a').each(function() {
        $(this).addClass('round-small-corner');
        $('<span></span>').addClass('corner bl').appendTo($(this));
        $('<span></span>').addClass('corner br').appendTo($(this));
    });

    // left menu fix 
    $("#navigation > li > a").not(".head").each(function(index, domEl) {
        $(domEl).addClass("head");
        $("<span></span>")
		.addClass("arrow")
		.appendTo($(domEl));
    });
	
	var aTagBreadcrumb = $("#breadcrumb li:eq(2) > a").attr("href");
	
	if(aTagBreadcrumb) {
		$("#navigation a.head").each( function() { 
			if($(this).attr("href") == aTagBreadcrumb) {
				$(this).parent().addClass("selected");
				return false;
			}
		});	
	}
	
	/*
http://tctmd.com/txlist.aspx?trid=1310&tid=2656
http://tctmd.com/txlist.aspx?trid=1310&tid=2656
*/
    $("[id$='TextBoxSearch']").each(function(index, dom) {
        $(dom).click(function(event) {
            $("[id$='ImageButton1']").removeAttr("disabled");
            if (event.keyCode == 13) {
                $("[id$='ImageButton1']").click();
            }
        });
    });
    $("[id$='ImageButton1']").each(function(index, dom) {
        $(dom).click(function(event) {
            var $target = event.target;

            var str = $("[id$='TextBoxSearch']").val();
            var len = $.trim(str);

            if (len == 0) {
                //console.debug("nothing in the box");
                if ($(this).attr("disabled") == "disabled")
                    $(this).removeAttr("disabled");
                WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$tctmdsearch1$ImageButton1", "", true, "", "", false, false));
                $(this).focus().click();
                //$("form").submit(stopSubmit);	
            }
        });
    }).attr("disabled", "disabled");


    $("#login :input").each(function(index, dom) {

        $(this).keydown(function(event) {
            //var $target = $(event.target);
            //console.debug("%s", $(this).val());
            if (event.keyCode == 13) {
                event.stopPropagation();
                event.preventDefault();
                //alert("keycode "+event.keyCode);

                $("form").submit(stopSubmit);
                //alert("which button is it");
                WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$TCTMDMembership1$cmdLogin", "", true, "", "", false, false));
                $("[id$='cmdLogin']").focus().trigger("click");

                return false;
            }

        }); //.attr("tabIndex", index+5);
    });
    var stopSubmit = function(event) {
        event.stopPropagation(); return false;
    };

    //    $("form").submit(stopSubmit);

    $('.line-rounded, .line-rounded-yellow, #breadcrumb').box_round('only-bottom');

	$("#breadcrumb li.last-child").each(function() {
		if($(this).text() == "") {
			$(this).prev(".first-child")
			.removeClass("first-child")
			.addClass("last-child")
			.end()
			.remove();
			
		}
	});

	/*  taxonomy fix */
	$("#taxonomy-list").each( function(){
		var text = $("h1.title-banner").html(); 
		if($.trim(text).length == 0 )  $("h1.title-banner").remove();
		/*
		var pageName = $("#breadcrumb li.last-child").text();
		var titleText = $("h2 span").text();
		titleText = titleText.replace(pageName,"<strong>"+pageName+"</strong>");
		$("h2 span").html(titleText);
	*/
	});


    $("#sponsors table").each(function(index, domEl) {
		
        var sponsorWidth = $("#sponsors").innerWidth() - 86;
		$(domEl).css({"width": sponsorWidth, "float": "left"}).removeAttr("width");
       
	    var $tds = $("td", $(domEl));
        var tdWidth = Math.floor(sponsorWidth / $tds.length);
//        console.debug("sponsors %d tds %d", sponsorWidth, tdWidth);
        $tds.each(function(index2, domEles) {
			if(index2 == 3)
				tdWidth -= 10;
            $(domEles).css("width", tdWidth);
        });
		
		$("#sponsors > span.last-child").css("width", sponsorWidth);
		$(domEl).fadeIn("fast");
        //$(domEl).width(sponsorWidth);
    });
	/*
	$('.tab-control').each(function(){

		$(this).find('.tab-content').not(':first-child').css({display:'none'});
		
		var tmpID = $(this).find('.tab-titles li:first-child').addClass('tab-title-selected').find('a').attr('title');
		$(tmpID).addClass('tab-content-selected');
		
			$(this).find('ul.tab-titles>li>a').mouseover(function(){
																  
					var tabContentID = $(this).attr('title');	
					$(this).parent().parent().find('li.tab-title-selected').removeClass('tab-title-selected');
					$(this).parent().addClass('tab-title-selected').parent().parent()
						.find('.tab-content-selected').removeClass('tab-content-selected')
						.hide();
					$(tabContentID).addClass('tab-content-selected')
						.show();
							vAnimationInProgress=false;
							
				return false;
			});
			
	});
	*/
	
    $(".events-banners ul").each(function(index, domEl) {
        var ulWidth = $(domEl).width();
        var $lis = $("li", $(domEl));
        var liWidth = Math.floor(ulWidth / $lis.length);
        $lis.each(function(domEles) {
            $lis.css("width", liWidth);
        });
    });

    $(".content-iconbar").parent().parent().parent().css("width", "100%");

    // gold member fix 
    $(".gold-file-options").parent().parent().parent().parent().css("width", "100%");

    $(".gold-options-subscribed").each(function() {
        $(this).prepend("<table><tr><td><h3>Gold Member Subscribed Media</h3></td><td><i>&nbsp;&nbsp;(Please disable all Pop-up Blockers in order to access TCTMD Gold content)</i><br><br></td></tr></table>");
    });


    $(".events").each(function(index, domEle) {
        var $secCol = $(domEle).prev();
        var $firstCol = $secCol.prev();
        //console.debug("%s %s", $secCol.attr("class"), $firstCol.attr("class"));
        $(".last-child", $secCol).removeAttr("style");
        $(".last-child", $firstCol).removeAttr("style");
        $secCol.css("height", "auto");
        $firstCol.css("height", "auto");
        $(".mainTbl").addClass("homepage");
    });

    $(".ektdmsiframe").removeAttr("height").height(600);
	
	$(".list-titles div").each( function() {
		var $li = $("li", $(this));
		$li.removeAttr("class").addClass($li.parent().attr("class"));
		$li.insertBefore($(this));
		$(this).remove();
	}); 
	
	$("#navigation a.head").each( function(){ 
		if($(this).height() > 31) $(this).addClass("longer");
	});

    /*Navigation [by Hector]*/
   /* Removed becuase uses taxonomy
   $("#navigation>li>a").mouseover(function() {
        $nodeOverTimeout = setTimeout("nodeOverTimeout()", $nodeOverTimeoutTime);
        $nodeOver = this;
        return false;
    });
    $("#navigation>li.selected li a").mouseover(function() {
        $(this).parent().find("ul:first").slideDown("slow", nodeOverSlideReset);
        $("#navigation>li.selected li.selected").removeClass('selected');
        $node = $(this).parent();
        while ($node.parent().attr('id') != 'navigation') {
            $node.addClass('selected');
            $node = $node.parent().parent();
        }
        $("#navigation>li.selected ul li:not(.selected) ul").removeAttr('style');
    });
    $("#navigation>li>a").mouseout(function() {
        if (this == $nodeOver) {
            clearInterval($nodeOverTimeout);
        }
    });
	*/
    /*----------------------*/
    // script for nav need expand
    //$("#navigation .head").each(function(domEl) {
    /*$("#navigation .head").mouseover( function(index, domEl) {
    //console.debug("%s", this.href);
    $("#navigation > .selected").removeClass("selected");
    $("#navigation > li .head + ul").removeAttr("style");
    var $par = $(this).parent();
				
    //console.debug("%o %s", $(this).next(), $(this).next()[0].tagName);
    if($(this).next().length == 1) {
    $par.addClass("selected");
    $(this).next().slideDown("slow", function() { });
    }
    else {
    $par.addClass("selected");
    }
    //$($(domEl) +" + ul", $par).slideDown("slow", function(){ $par.addClass("selected"); });
    //$(this).next().slideDown("slow"), function() { $par.addClass("selected"); });
    //$par.addClass("selected");
    //console.debug("number of uls", $("ul", $(domEl)).length);
    });*/
    //});

    //$('#navigation').accordion({clearStyle:true,alwaysOpen: true, active: true, active: "2"});
    /*
    $("#navigation").accordion({
    active: false,
    header: '.head',
    navigation: true,
    event: 'click',
    fillSpace: true,
    animated: 'easeslide'
    });
		
		$("#navigation").accordion("activate",1);
    */
    /*
    $(".lsecond").accordion({clearStyle: true,autoheight: true,alwaysOpen: false});
    $(".lsecond").accordion("activate", 1); 
    $(".lthird").accordion({clearStyle: true,autoheight: true,alwaysOpen: false});
    $(.lthird").accordion("activate", 1);
    */
    $(".registration fieldset").each(function() {
        var heading = $("legend", this).remove().text();
        $("<h2></h2>")
			.text(heading)
			.addClass("title-blue-soft")
			.prependTo(this);

    });

    
    $(".subscribe").each(function() {
        $("a", $(this)).attr("href", "/gold.aspx");

        $("object", this).css({ "position": "relative", "z-index": 1 });

        $("<a></a>")
			.attr("href", "/gold.aspx")
			.css({ "position": "absolute", "width": 282, "height": 59, "z-index": 100, "margin-top": -60 })
			.text("")
			.appendTo($(this));

        $("div", $(this)).click(function() {
            $("a", $(this)).attr("href", "/gold.aspx").click();
        });
        //console.log("did i get here");
    });

    $(".video-final").css("display", "block");

    /* cache display */
	if( $("a[class^='cache']").length > 0 ) {
	
		$("<div></div>")
		.attr("id", "cache")
		.appendTo("#aspnetForm");
		
		$("#cache").each( function () {
			$("<div></div>")
			.addClass("innerBox")
			.appendTo($(this));
	
			$(this).css({opacity: ".7", filter: "alpha(opacity=70);"});
			$("a[class^='cache']").addClass("actions").appendTo($("#cache .innerBox"));
		});
	}
	
	
	
	/*
    $(".registration #username :text").each( function(domEl) {
    $(domEl).focus(function (event) {
    var $target = $(event.target);
    console.debug("%s", $target);
    //$target.title = $("label[for='"+$target.id+"'] span.minchar").text().remove();
    //if(event.keyCode != 13 || event.key
    });
    });
    */
    //	$('.right-col, .left-col, .right-col-landing, .left-col-landing, .menu-left, .content-page').equalizeCols();
	$('.round-white-corner, .round-small-corner, .blue-rounded, .head').box_round('default');
    $('.round-white-corner, .round-small-corner, .gray-rounded, .head').box_round('default');
    $('.title-blue, .title-blue-soft, .title-blue-hibryd, .title-yellow').box_round('title');
    // $('.left-col, .right-col,.right-col-landing, .menu-left, .right-advertisement, .list-banners,  .menu-right, .first-col, .second-col, 	.feature-content , .content-page, .content-block').fill_height();//commented on 2/23/2009 to fix Advertizement column height
    //$('.left-col, .right-col').fill_height();
	
	$("#content-main table").tableSpace();
	$("#content-main font").fontSizer();
	
	/* print styles */
	//footnoteLinks("sContent");
	var pageName = new String(window.location);
	var params = pageName.toLowerCase();
	if( params.indexOf('?')!=-1 && params.indexOf('print') ){
		var searchParams = location.search;
		if(searchParams.indexOf("print=true") > -1 ) {
			$("#footer, #right-col.interior, #breadcrumb, #nav-main, #branding .date, #branding div, .content-iconbar table, .relatedContent, .commentActions, .corner").css("display", "none");
			$('body').css({background:"#fff",padding: "0px 10px", fontSize: "medium" });
			$("left-col.interior").css("width", "100%");
			$("#branding, .degrade-box").css("background", "#fff");
			$(".printOnly").css("display", "block");
			$("sup.printOnly").css("display", "inline");
			$("#ctl00_ctl00_ekcss_global").removeAttr("href");
			window.print();
		}
		
		/*
		var url = params.substring(0, params.indexOf('?'));	
		params = params.substring(params.indexOf('?')+1);		
		params = params.substring(params.indexOf('print'));
		params = params.split('&');
		if( params[0].indexOf('=')!=-1){
			var values = params[0].split('=');
			if( values[1]=='true'){
				
				var oLink = document.createElement('link');
				oLink.setAttribute('href','/common/css/print.css');
				oLink.setAttribute('rel','stylesheet');
				oLink.setAttribute('type','text/css');
				$('html head').append(oLink);
				$('body').css({background:"#fff",padding: "0px 10px" });
				$('#container').css({width:"auto",margin:"0px"});
				$('.main_bg_internal form').css('background','none');
				$('#logo_img').css('margin-top','10px')
							  .attr({ src:'/common/images/tupperware_brands_print_logo.gif', alt: "Tupperware Brands", title: "Tupperware Brands" });
				if(pageName.indexOf("qa.html") > -1) {
					$("#breadcrumb").css("display", "none");	
				}
				else {
					$('#breadcrumb').html("<strong>URL: </strong><span>" + url + "</span>");
				}
				$('#branding .right, .mainTbl tfoot, #content-title, .mainTbl #col-left, #content-title, .print-this-content').css("display", "none");
				$("#content-main, #breadcrumb").css("position", "static");
				$("#col-body").css("overflow", "visible");
				$(".left, .right, #col-content-wide").css("float", "none");
				$("#content-tbl #col-content-wide p").css({"display": "block"});
				
				window.print();
			}
		}
		*/
	}
	/*  start of code for iframe swap pdfs*/
	var timeOut = 7000;
	if($(".ektdmsiframe").length > 0) {
		var $iframe = $('.ektdmsiframe');
		$("#sContent-loading").width($iframe.width()).height($iframe.height())
		.css({"opacity": ".75", "position": "absolute"});
		
		var timer = setTimeout('jQuery("#sContent-loading").fadeOut("fast");', timeOut);

	}
	
	
	
	$(".content-block p + ul").css("padding-top", "0").prev().css("padding-bottom", "5px");
	
	/* poll */
	$("#poll input[type='submit']").addClass("btn-generic");
	$(".most-viewed").attr("id", "poll");
	$("#poll div[id*='Poll']").addClass("poll-Div");
	
	
	/*  socal */
	//alert("give me an alert " + $("#ctl00_ctl00_phMainMiddle_phLeftColumn_Friends1 ul li").length);
	/*
	if($("#ctl00_ctl00_phMainMiddle_phLeftColumn_Friends1 ul li").length == 0 ) {
		$("#ctl00_ctl00_phMainMiddle_phLeftColumn_Friends1").parents(".sub-section").remove();	
	}
	*/
	//$(".ekGroupListInnerTable a[id^='lnksorted']").parent().parent().css("display", "none");
	
	//console.debug("groups obj %o", $("#ctl00_ctl00_phMainMiddle_phLeftColumn_Friends1").clone());
	
	if(jQuery.trim($(".ekGroupListInnerTable .ekGroupListFooter").text()).length == 0) {
		$(".ekGroupListInnerTable .ekGroupListFooter").remove();
	}
	
	$("#left-col .ekGroupListInnerTable tr:odd").addClass("odd");
	$("#left-col .CommunitySearch_ResultTable tbody tr, #left-col .ekGroupListInnerTable tbody tr:gt(0),"+
		".ekFriendsInnerTable tr:gr(2)").live("mouseover",
		function(){
			$(this).addClass("hover");
	 	})
		.live("mouseout", function () { 
			$(this).removeClass("hover");
		}
	);
		
	$("body.iframe .tab-titles a").live("click", function(e) {
		$(this)
			.parents(".tab-titles")
			.find(".tab-title-selected")
			.removeClass("tab-title-selected");
		$(this)
			.parent()
			.addClass("tab-title-selected");
		
		$("#my-tctmd > div").hide("fast");
		var pageId = $(this).attr("id");
		//console.debug("pageId %s boolean %b", pageId, (pageId.indexOf("Friends") > -1));
		if(pageId.indexOf("Friends") > -1) {
			//console.debug("friends div %o", $("#my-tctmd > div[id$='Friends']"));
			$("#my-tctmd div[id$='Friends']").fadeIn("normal");	
		}
		else {
			//console.debug("friends div %o", $("#my-tctmd > div[id$='Search']"));
			$("#my-tctmd div[id$='Search']").fadeIn("fast");
		}
		return false;
	});
	
	/* // remove point
	var objFriends;
    var objSearch;
    
    objFriends = $("#ctl00_phBody_dvFriends");
    objSearch = $("#ctl00_phBody_dvSearch");
	container = $("#my-tctmd > div").hide();
	ul = $(".tab-titles > li").removeClass("tab-title-selected");
	
    if(toggleSwitch=='friends')
    {               
    	objFriends.fadeIn("fast");
		ul.find("#first-button").addClass("tab-title-selected");
    }
    else
   	{
        objSearch.fadeIn("fast");
		ul.find(".last-child").addClass("tab-title-selected");
      //   alert("Hellow" + objSearch.style.display);
    }
	*/

	$("body.iframe .EkTB_Button").parent().css("display", "none");
	$("body.iframe .ekFriendsInnerTable .ekFriendsFooter").parent().remove();
	$("body.iframe .ekFriendsInnerTable tr:gt(2):odd, .columnInnerWrapper .members .ekGroupMembersInnerTable tr:gt(1):odd").addClass("odd");
	
	
	if($("input[id$='hidCurrentUser']").length == 1){
		var hidUser = $("input[id$='hidCurrentUser']").val();
		
		$(".ContributionForm a[title='Avatar']").each(function() {
			var href = new String($(this).attr("href"));
			var hrefArr = href.split("?");
			var params = hrefArr[1].split("=");
			if(params[1] === hidUser){
				$(this).parents(".ekMessagePost").addClass("me").append("<div class='corner'></div>");
				//$(".me .corner").
			}
			
		});		
	}
	
	if($(".AddComment").length == 1) {
	var limit = $('.AddComment .ContributionText').attr("maxlength");
	$(".AddComment h6").append("<span class='counter'>2000 characters left</span>");
	//console.debug("limit %d textArea %o", limit, $('.AddComment .ContributionText'));
	$('.AddComment .ContributionText').each(function(){  
    	// get current number of characters 
			
			var length = limit- $(this).val().length;  
			 // get current number of words  
			
			 // update characters  
			$('.AddComment .counter').html( length + ' characters left');  
			// bind on key up event  
			 $(this).keyup(function(){  
				// get new length of characters  
				var new_length = limit - $(this).val().length;  
				 // get new length of words  
				  
				 // update  
				var $remaining =  $('.AddComment .counter');
				var ouputStr = new String();
				 
				if(new_length < 0) {
				 	$remaining.addClass("error");
					outputStr = Math.abs(new_length) + ' characters over';
				}
				else {
					$remaining.removeClass("error");
					outputStr = new_length + ' characters left';
				}
				
				$remaining.html(outputStr);
			 });  
		 }); 
	}
	// added to stylesheet because ie7 doesnt get remove 
	//$("#tctmdSideBarAccordian1 li.last-child").remove();
	
	$(".groupsTable > table").css("width", "100%");
	$(".groupsTable .ekGroupListInnerTable a[id^='lnksorted']").parent().parent().show();
	$(".groupsTable .ekGroupListInnerTable .ekGroupListFooter").attr("colspan", 4);
	$(".groupLinks").appendTo($(".groupsTable .ekGroupListInnerTable tr.first-child td").eq(1));
	//* rightCol socal fix 
	
	$("#right-col .list-summary .list-summary .ekGroupListInnerTable td.first-child.last-child").parent().remove();
	$("#right-col .list-summary .list-summary .ekGroupListInnerTable .ekGroupListListGroupMain").each(function(){
		var aTag = $(this).find("a");
		$(this).html(aTag).fadeIn("normal");
	});
	
	$("#blog #ecmFirst").parent().parent().remove();
	$("#blog .blog .blogArchive").attr("href", $(".bloglink[href*='?BlogId']").attr("href"));
	$(".bloglink[href*='?BlogId']").remove();
	
	if($(".bloglink[href*='javascript']").length > 0 ) {
		var blogLink = $(".bloglink[href*='javascript']");
		//console.debug("blogLink:", blogLink);
		blogLink.parent().parent().addClass("remove");
		$("#blog .blog").prepend(blogLink);
		$(".remove").remove();
	}
	
	if($(".members").length > 0) {
		var headerText = $(".columnInnerWrapper .members .ekGroupMembersHeaderSpan").text();
		var h4Html = $(".columnInnerWrapper .members h3");
		var newHtml = h4Html.html().replace(/Members/,headerText);
		h4Html.html(newHtml);
	}
	
	if($("#forums").length > 0){
		$("#forums .content tr.first-child td").eq(1).text("Discussions");
	}
	
	$(".groupLinks").appendTo($("#remove").parent());
	//$("#remove").parent().parent().prev().remove();
	/* ekFriendsTable removal Colleagues.asp
	if($(".ekFriendsInnerTable #remove").length == 1){
		$("#remove").parent().remove();	
	}
	*/
	
	
	var networkPath = "/socialnetwork/blogdetail.aspx"
	$(".blogRecentPosts a,.entry h3.entryTitle a").each(function() { 
		var href = $(this).attr("href");
		hrefArr = href.split("aspx");
		hrefArr[0] = networkPath;
		//console.debug("hrefArr %o", hrefArr);
		$(this).attr("href", hrefArr.join(""));
	});
	
	$("#userjobs .listing .info").each(function() {
		var text = $(this).text();
		//alert(text.indexOf("http:"));
		if(text.indexOf("http:") > -1){
			$(this).wrap("<a></a>");
			var $linkTag = $(this).parent();
			$linkTag.attr("href", text).attr("target", "_blank");
		}
	});
	//$("#my-tctmd #AddFolder").parent().remove();
	
	if($(".eksubscribelink").length > 0){
		var html = $(".eksubscribelink").html();
		html += " Subscribe";
		$(".eksubscribelink").html(html);
	}

	//alert("browser version " + parseInt(jQuery.browser.version) + "");
    if(parseInt(jQuery.browser.version) != 6 ) {
	
	$('.menu-left, .content-page').equalizeCols();
    $('.right-col, .left-col-landing, .right-col-landing').equalizeCols();
	$('.profile, .profile-right').equalizeCols();
//    $('.left-col, .right-col, .left-col-landing, .right-col-landing, .right-advertisement, .list-banners,  .menu-right, .first-col, .second-col, .feature-content , .content-block').fill_height();
	$('.left-col, .right-col').equalizeCols();
	$('.left-col, .right-col').fill_height();
		if($("#home").length > 0){
			$('.first-col, .second-col').css("height", "auto");
			$('.left-col, .right-col').fill_height();
		}
		
		if($(".live").length > 0){	
			$(".second-col").removeAttr("style").find(".bg-gray-color").removeAttr("style");
			$(".live .slides").css("height", "auto");
			$('.left-col, .right-col').removeAttr("style").equalizeCols();
		}
	}
	else {
		if($(".landing").length > 0){
			$(".landing").css("height", "auto");	
		}
	}
	
	
	if($.browser.msie) {
		$(".title-banner a").stackOrderIEFix();
	}

    EndRequestHandler();
    var colgSpan = document.getElementById("spColleagues");

    var invitationLoc = new String(location.search);
	//console.debug("searchLoc %s", searchLoc);
	if(invitationLoc.indexOf("invitation=true") > -1){
		//console.log("yes im a redirect, need to open a lightbox");
		//eraseCookie('redirect');		
		$("#spColleagues a.thickbox").click();
	}
});


//ctl00_TCTMDMembership1_pnlLogin
//ctl00_TCTMDMembership1_cmdLogin
//ctl00_TCTMDMembership1_TextboxUserName
//ctl00_TCTMDMembership1_TextboxPassword
//ctl00_tctmdsearch1_TextBoxSearch
//ctl00_tctmdsearch1_ImageButton1
//$('.left-col, .right-col, .left-col-landing, .right-col-landing, .right-advertisement, .list-banners,  .menu-right, .first-col, .second-col, .feature-content , .content-block').fill_height();

jQuery(window).load(function(){
 
  if(parseInt(jQuery.browser.version) != 6 ) {
	
	jQuery('.menu-left, .content-page').equalizeCols();
    jQuery('.right-col, .left-col-landing, .right-col-landing').equalizeCols();
	jQuery('.profile, .profile-right').equalizeCols();
 jQuery('.left-col, .right-col, .left-col-landing, .right-col-landing, .right-advertisement, .list-banners,  .menu-right, .first-col, .second-col, .feature-content , .content-block').fill_height();
	jQuery('.left-col, .right-col').equalizeCols();
	jQuery('.left-col, .right-col').fill_height();
	//console.debug("#home page?", jQuery("#home").length);
		if(jQuery("#home").length > 0){
			jQuery('div.first-col, div.second-col, div.right-col, #home, div.right-advertisement').removeAttr("style");
			
			//jQuery('.first-col, .second-col, .right-col, #home').equalizeCols();
			jQuery('div.right-advertisement').removeAttr("style")
			  .find("div.list-banners").removeAttr("style")
			  .find("div.list").removeAttr("style");
			 jQuery(".round-white-corner").removeAttr("style"); 
			 // console.debug("reset the right-advertisement %o right-col %o", jQuery('div.right-advertisement').css("height"), jQuery('div.right-col').css("height"));
			  if(jQuery('div.right-advertisement').css("height") != "auto"){
				  jQuery('div.right-advertisement').removeAttr("style").css("height", "auto");
				 // console.debug("2: reset right-advertisement %o right-col %o  #home %o", jQuery('div.right-advertisement').css("height"),jQuery('div.right-col').css("height"), jQuery('#home').css("height"));
			  }
			  
			jQuery('.right-col, #home').fill_height();
			//jQuery('div.right-advertisement').removeAttr("style");
		}
		
		if(jQuery(".live").length > 0){	
			jQuery(".second-col").removeAttr("style").find(".bg-gray-color").removeAttr("style");
			jQuery(".live .slides").css("height", "auto");
			jQuery('.left-col, .right-col').removeAttr("style").equalizeCols();
		}
	}
	else {
		if(jQuery(".landing").length > 0){
			jQuery(".landing").css("height", "auto");	
		}
	}
});
/* =jQuery Plugins*/
(function($) {
    /* = plug-in : overlabel */
    $.fn.overlabel = function(options) {
        var opts = $.extend({}, $.fn.overlabel.defaults, options);
        var selection = this.filter('label[for]').map(function() {
            var label = $(this);
            var id = label.attr('for');
            var field = $('#' + id);
            if (!field) return;
            var o = $.meta ? $.extend({}, opts, label.data()) : opts;
            label.addClass(o.label_class);
            var hide_label = function() { label.css(o.hide_css) };
            var show_label = function() { this.value || label.css(o.show_css) };
            $(field)
					.parent().addClass(o.wrapper_class).end()
					.focus(hide_label).blur(show_label).each(hide_label).each(show_label);
            return this;
        });
        return opts.filter ? selection : selection.end();
    };
    $.fn.overlabel.defaults = {
        label_class: 'overlabel-apply',
        wrapper_class: 'overlabel-wrapper',
        hide_css: { 'display': 'none' },
        show_css: { 'display': 'block' },
        filter: false
    };
    /* =plug-in : fix-png */
    $.fn.fixpng = function() {
        var hack = {
            isOldIE: $.browser.msie && $.browser.version < 7,
            filter: function(src) { return "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src='" + src + "');"; }
        };
        return this.each(function() {
            if (hack.isOldIE) {
                var $$ = $(this);
                if ($$.attr('src')) {
                    var span = document.createElement('span');
                    $(span).attr({
                        id: $$.attr('id'), className: $$.attr('class')
                    });
                    $(span).css({
                        display: 'inline-block', width: $$.width(), height: $$.height(), filter: hack.filter($$.attr('src')), float: $$.attr('align') == 'left' ? 'left' : ($$.attr('align') == 'right' ? 'right' : 'none')
                    });
                    this.outerHTML = span.outerHTML;
                }
            }
        });
    };
    /* =plug-in : equal-heights */
    
	$.fn.equalizeCols = function() {
        var height = 0,
			reset = $.browser.msie ? "1%" : "auto";

        return this
			.css("height", reset)
			.each(function() {
			    height = Math.max(height, $(this).outerHeight(true));
			})
			.css("height", height)
			.each(function() {
			    var h = $(this).outerHeight(true);
			    if (h > height) {
			        $(this).css("height", height - (h - height));
			    };
			});

    };

    /**/
    /*****ROUND WHITE***/
    $.fn.box_round = function(options) {
        var type = options ? options : 'default'; /*default, only-top, only-bottom*/
        return this.each(function() {
            if (type == 'default' || type == 'only-top') {
                var _tleft = document.createElement("span"); _tleft.className = "corner tl";
                $(this).prepend(_tleft);
            }
            if (type == 'default' || type == 'only-top') {
                var _tright = document.createElement("span"); _tright.className = "corner tr";
                $(this).prepend(_tright);
            }
            if (type == 'default' || type == 'only-bottom') {
                var _bleft = document.createElement("span"); _bleft.className = "corner bl";
                $(this).prepend(_bleft);
            }
            if (type == 'default' || type == 'only-bottom') {
                var _bright = document.createElement("span"); _bright.className = "corner br";
                $(this).prepend(_bright);
            }
            if (type == 'title' || type == 'title-left') {
                var _bleft = document.createElement("span"); _bleft.className = "left-title";
                $(this).prepend(_bleft);
            }
            if (type == 'title' || type == 'title-right') {
                var _bright = document.createElement("span"); _bright.className = "right-title";
                $(this).prepend(_bright);
            }
        });
    };

    /*fill height to container**/
    $.fn.fill_height = function() {
        return this.each(function() {
		//	console.debug("%s", $(this).attr("class"));
            var maxHeight = $(this).css("height", "auto").height();
            var sumChildrenHeights = 0;
            var children = $(this).children('div').not('.corner');
		//	console.debug("%o %d", children, children.length);
            for(var i = 0, len = children.length; i < len; i++) {
                sumChildrenHeights = sumChildrenHeights + $(children[i]).css("height", "auto").outerHeight(true);
            }
			 
            var $lastchild = $(children[children.length - 1]);
			if($lastchild) {
       //     console.debug("%o childHeight %d",$lastchild, sumChildrenHeights);
			$lastchild.height( ($lastchild.height() + (maxHeight - sumChildrenHeights)));
			}
        });
    };
    /*acordion menu left*/
	
	// internal table padding
	$.fn.tableSpace = function() {
		return this.each( function() {
		var padding = $(this).attr("cellpadding");
			var margin = $(this).attr("cellspacing");
			var $that = $(this);
			if(padding > 0) {
				var tdLen = $("td", $that).length
				$("td", $that).each( function() {
					$(this).css("padding", padding+"px");
		
				});
		
				//console.debug("padding %d len %d", padding, tdLen);
			}
		});	
	};
	
	// font size face color
	$.fn.fontSizer = function() {
		return this.each( function() {
			if($(this).attr("color")) {
				$(this).css('color', this.color);
			}
			if($(this).attr("face")) {
				$(this).css('font-family', this.face);
			}
			/*
			if($(this).attr("size")) {
				$(this).css('font-size', this.size);
			}
		*/
		
		});	
	};
	$.fn.stackOrderIEFix = function () {
		var zIndexNumber = 1000;
		return this.each(function () {
				$(this).css('zIndex', zIndexNumber);
				zIndexNumber -= (zIndexNumber <= 0) ? 0 : 10;
	   });
	}
	
})(jQuery);

 function keycheck(btntoclick)
 {   
	 var e = window.event;
 
 	if (e.keyCode == 13) 
    {
  
        var objbutton;        
        var objpoll; 
	    var objgo;
        objbutton = document.getElementById(btntoclick);              
        objpoll = document.getElementById('ctl00_ctl00_phMainMiddle_phLeftColumn_Poll_ekpoll');
        objgo = document.getElementById('ctl00$ctl00$phMainMiddle$phLeftColumn$Show1$ButtonRelatedContent');
    
	    if(objgo!=null)
		    objgo.disabled = true;                
        if(objpoll!=null)
            objpoll.disabled = true;                
        //WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$TCTMDMembership1$cmdLogin", "", true, "", "", false, false))
    }        
      
 }
 
 
 /////// function do dispaly commnets box on show.aspx
function showCommentsBox()
{

   var dvOuter = document.getElementById("left-col");
   dvOuter.style.height = (dvOuter.offsetHeight + 450 ) + 'px';
    document.getElementById("dvCommentsBlock").style.display='block';
  
    
}
function showViewComments()
{
   var dvOuter = document.getElementById("left-col");
   dvOuter.style.height = (dvOuter.offsetHeight + 450 ) + 'px';
   document.getElementById("dvViewComments").style.display='block';
   document.getElementById("dvCommentsBlock").style.display='none';
}

function updateGallery(){

		/* multimedia center */
		jQuery("#multimedia-images #tabs li").each(function(){ 
			var isSelected = jQuery(this).hasClass("selected");
			jQuery(this).hover(function() {
				 if(!isSelected)
					jQuery(this).addClass("selected");
			   },
		   function () {
				if(!isSelected)
					jQuery(this).removeClass("selected");
			  })
		});
		jQuery("#multimedia-images-xslt .imgBlock div").each(function() { 
					jQuery(this).css({"position": "relative", "width": "170px", "height": "100px", "float": "left"});
		}); 
		jQuery("#multimedia-images-xslt .imgBlock").live("click",function(event){
			event.preventDefault();
			event.stopPropagation();

			jQuery("a", jQuery(this)).trigger('click');
		});
}

function AjaxCallbackFix() {
    if (typeof EndRequestHandler == 'function') {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
    }
}

function EndRequestHandler()
{
    var loc = new String(window.location);

    if(jQuery.prettyPhoto) {
		jQuery("a[rel^='lightbox']").prettyPhoto();
	}

    if(loc.indexOf("multimedia_images.aspx") > -1) {
        updateGallery();
    }

}