// 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();

(function($) {
	$.extend({
		webMethod: function(url, method, data, callback, failback) {
			$.ajax({
				type: "POST",
				url: url + "/" + method,
				data: data ? $.toJSON(data) : null,
				contentType: "application/json; charset=utf-8",
				dataType: "json",
				cache: false,
				success:  function(d) { callback(d ? d.d : null); },
				error: function(x, r, t) {
					try
					{
						var r = $.evalJSON(x.response);

						alert(r.Message);
					} catch (e) {
						alert("There was a problem processing your request, please try again later.");
					}

					if (failback)
						failback();
				}
			});
		}
	});

	$(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) {
					if (event.keyCode == 13) {
						 event.stopPropagation();
						 event.preventDefault();

						 $("form").submit(stopSubmit);
						 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;
		 };

		 $('.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();
		 });

		 $("#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);

			  $tds.each(function(index2, domEles) {
					if (index2 == 3)
						 tdWidth -= 10;
					$(domEles).css("width", tdWidth);
			  });

			  $("#sponsors > span.last-child").css("width", sponsorWidth);
			  $(domEl).fadeIn("fast");
		 });

		 $(".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");
		 });

		 $(".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();
			  });
		 });

		 $(".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"));
			  });
		 }

		 //	$('.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');

		 $("#content-main table").tableSpace();
		 $("#content-main font").fontSizer();

		 /* print styles */
		 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();
			  }
		 }

		 $(".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");

		 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;
		 });
		 
		 $("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>");
			  $('.AddComment .ContributionText').each(function() {
					var length = limit - $(this).val().length;

					// update characters  
					$('.AddComment .counter').html(length + ' characters left');

					$(this).keyup(function() {
						 var new_length = limit - $(this).val().length;
						 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);
					});
			  });
		 }

		 $(".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']");
			  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());

		 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;
			  $(this).attr("href", hrefArr.join(""));
		 });

		 $("#userjobs .listing .info").each(function() {
			  var text = $(this).text();
			  if (text.indexOf("http:") > -1) {
					$(this).wrap("<a></a>");
					var $linkTag = $(this).parent();
					$linkTag.attr("href", text).attr("target", "_blank");
			  }
		 });

		 if ($(".eksubscribelink").length > 0) {
			  var html = $(".eksubscribelink").html();
			  html += " Subscribe";
			  $(".eksubscribelink").html(html);
		 }

		 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').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);

		 if (invitationLoc.indexOf("invitation=true") > -1) {
			  $("#spColleagues a.thickbox").click();
		 }
	});

	$(window).load(function() {
		 if (parseInt($.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) {
					$('div.first-col, div.second-col, div.right-col, #home, div.right-advertisement').removeAttr("style");

					$('div.right-advertisement').removeAttr("style").find("div.list-banners").removeAttr("style").find("div.list").removeAttr("style");

					$(".round-white-corner").removeAttr("style");

					if ($('div.right-advertisement').css("height") != "auto") {
						 $('div.right-advertisement').removeAttr("style").css("height", "auto");
					}

					$('.right-col, #home').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");
			  }
		 }
	});

	/* =jQuery Plugins*/
	/* = 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() {
			if ($(this).hasClass("no-fill-height")) return;

			//console.debug("%s", $(this).attr("class"));
			var maxHeight = $(this).css("height", "auto").height();
			//console.debug("%s maxHeight %d", $(this).attr("class"), maxHeight);
			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) {
					if ($lastchild.hasClass("mainContent"))
						$lastchild.css("height", "auto");
					else {
						//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");

					});
			}
		});
	};

	// 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);
			}
		});
	};

	$.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;
        var objSearch;
        objbutton = document.getElementById(btntoclick);
        objpoll = document.getElementById('ctl00_ctl00_phMainMiddle_phLeftColumn_Poll_ekpoll');
        objgo = document.getElementById('ctl00$ctl00$phMainMiddle$phLeftColumn$Show1$ButtonRelatedContent');
        objSearch = document.getElementById('ctl00_ctl00_tctmdsearch1_TextBoxSearch');
        if (objgo != null)
            objgo.disabled = true;
        if (objpoll != null)
            objpoll.disabled = true;
        if (objSearch != 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();
    }

}
function PerformSearch() {
    var e = window.event;

    if (e.keyCode == 13) {

        var objType;
        var objSearch;
        var objpoll;

        objType = document.getElementById('ctl00_ctl00_tctmdsearch1_DropDownListContentType');
        objSearch = document.getElementById('ctl00_ctl00_tctmdsearch1_TextBoxSearch');
        objpoll = document.getElementById('ctl00_ctl00_phMainMiddle_phLeftColumn_Poll_ekpoll');


        if (objSearch.value != '') {
            if (objpoll != null) {
                // objpoll.disabled = true;                               
                location.href = "/searchresults.aspx?sstring=" + objSearch.value + "&stype=" + objType.value;

            }


        }
    }
    //searchresults.aspx?sstring=" + Server.UrlEncode(this.TextBoxSearch.Text) + "&stype=" + Server.UrlEncode(this.DropDownListContentType.SelectedValue));
}

