//************name window if not named *************
var windowNames = "auction pics calendar schedule absent hotel";
var expr = new RegExp(window.name);
if((window.name == "" || !expr.test(windowNames)) && window.top==window){
  window.name="auction";
}
if(window.name == "auction"){
  mainWin = self;
}else{
  mainWin = window.opener;
}
//this solves a problem with IE 6 and the menu dropdowns acting funny if they are defined in the html
var contact = [["Join email List","/forms/mailList.shtml","Join our Auction notification mailing list"],["Directions","/directions.shtml","Directions to the hall"]];
var schedule = [["Calendar","/calendar","Full size version of our calendar"],["Directions","/directions.shtml","Directions to the hall"],["Accommodations","/lodging.shtml","A listing of local accommodations"]];
var services = [["About Us","/aboutus.shtml","About us"]];
var navArray = ["contact","schedule","services"];
var addSlideout = true;
var isMSIE = false;
//*************** set up the rollovers and load auction data **********
jQuery(document).ready(function(){
	setCurrentTab();
	//setTimeout("setCurrentTab()",5);
	//addLikeContainer();
	jQuery.each(jQuery.browser, function(i, val) {
		if(val && i=="msie"){//alert(document.styleSheets("mainStyle").rules[10].style.backgroundColor);
		    //addLikeContainer();
			if(jQuery.browser.version < 7){
			    jQuery("#subPage").load("/includes/upgrades.shtml",function(response, status, xhr){
		        jQuery("#upgrade").css('display', 'block');});
		        //jQuery("#masthead").css("background-image", "url(/images/blackGrad.gif)");
		        jQuery("#gaLogo img").attr('src', "/images/GALogo.gif");
				jQuery("#naaLogo img").attr('src', "/images/naa_logo-short.gif");
				jQuery("#nysaaLogo img").attr('src', "/images/nysaaLogo.gif");
		        jQuery("#navigation,#content,#footer").css("background-image", "url(/images/contentLeftSide.gif)");
		        jQuery("#navigationInner,#contentInner,#footerInner").css("background-image", "url(/images/contentRightSide.gif)");
		    }
		    jQuery("#universal-nav ul").css("padding-bottom","2px");
		    isMSIE = true;
			if(jQuery.browser.version > 6){
			    //jQuery("#subPage").load("/includes/upgrades.shtml",function(response, status, xhr){
		        //jQuery("#upgrade").css('display', 'block');})
			}
		 }
	});//close each
	//setTimeout("addAuctionsToTab(schedule,'schedule')",5);
	var waitTime = 5;
	for(var i=0; i <navArray.length; i++){
		var j = navArray[i];
		eval("setTimeout(\"addAuctionsToTab("+j+", '"+j+"');"+j+"=[];\","+waitTime+")");
		waitTime += 5;
	}
	setSharing();
//	setTimeout("setSharing()",3);
	//setTimeout("addAuctionsToTab(contact,'contact')",15);
	//setupNavDropDowns();
	loadFBscript();
	loadFutureAuctions();
	loadPastAuctions();
	//setSharing();
//    fixampfont();
//	loadFBscript();
	if(!isMSIE && window.top==window){
	  addLikeBox();
	  //addLikeBoxToTop()
	}
	if(typeof runExtraOnload != "undefined" && runExtraOnload){
	  extraOnload();
	}
  });//close ready
jQuery(document).ready(function(){
  if(isMSIE && window.top==window){ // needs to be in seperate document.ready or page will not load timing problem
//    setTimeout("addLikeBoxToTop()",300);
	//addLikeBoxToTop()
  }
});
function setCurrentTab(){
	if(typeof(currentTab) == "undefined" || currentTab == ""){
		currentTab = "home";
	}
	if(currentTab == "none"){
	  return;
	}
	selectTab(currentTab);
}

function setupNavDropDowns(id){
    var jquerykey = "";
	if(typeof(id) == "undefined" || id == ""){
	  jquerykey = "#universal-nav li.unav-has-child";
	}else{
	  jquerykey = "#universal-nav li.unav-has-child#"+id;
	}
	jQuery(jquerykey).each(function(){
	    var thisElement = jQuery(this);
	    var leftLoc = thisElement.positionAncestor("#top").left -1;
	    var width = thisElement.width()+ parseInt(thisElement.css('padding-left'))+ parseInt(thisElement.css('padding-right')) + 1;
	    if(thisElement.hasClass("rightEnd")){
	      width--;
	    }
	    var topLoc = thisElement.positionAncestor("#top").top + parseInt(thisElement.height())+ parseInt(thisElement.css('padding-top')) + parseInt(thisElement.css('padding-bottom'));

	    if(thisElement.hasClass("selected")){
	      topLoc -= 7;
	    }
		if(isMSIE){
		  leftLoc += 2;
		}
	    thisElement.children('div').css({'left' : leftLoc+'px'});
	    thisElement.children('div').css({'top' : topLoc+'px'});
	    thisElement.children('div').width(width);
	});
	jQuery(jquerykey).unbind('mouseenter').unbind('mouseleave');
	jQuery(jquerykey).hover( function() {jQuery(this).children('div').stop(true,true).slideDown('fast');jQuery(this).children('a').css({'color':'#000'});},function() {jQuery(this).children('div').stop(true,true).slideUp(100);jQuery(this).not('.selected').children('a').css({'color':'#333'});});
	if(isMSIE){
	  jQuery(jquerykey).hover( function() {if(jQuery(this).hasClass('selected')){jQuery(this).removeClass('selected');}},function() {if(jQuery(this).attr('id') == currentTab){jQuery(this).addClass('selected');jQuery(this).children('a').css('color','#000');}});
	}
}

function loadFutureAuctions(){
	localHost = location.hostname;
	host = "";
	url = "/services/auctions.php?reqType=futureAuctions";
	url = host+url;
	if(localHost != host){
		url += "&callback=?";
	}
	jQuery.getJSON(url, function(sData) {
	    addAuctionsToTab(sData,"schedule","top");
	});
}

function loadPastAuctions(){
	localHost = location.hostname;
	host = "";
	url = "/services/auctions.php?reqType=pastAuctions";
	url = host+url;
	if(localHost != host){
		url += "&callback=?";
	}
	jQuery.getJSON(url, function(sData) {
	    addAuctionsToTab(sData,"past");
	});
}

function addAuctionsToTab(data, id, where){
    if(typeof(where) == "undefined" || where == ""){
	  where = "bottom";
	}
	var tab = jQuery('#'+id);
	var listing = jQuery('#'+id+'-unav');
	var addListing = (listing.size()==0);
	var uList;
	if(addListing){
		listing = jQuery(document.createElement("div"));
		listing.addClass('unav-menu');
		listing.attr("id",id+'-unav');
        uList = jQuery(document.createElement("ul"));
        listing.append(uList);
		if(isMSIE){
			listing.css("margin-top","2px");
		}
	}else{
		uList = listing.children('ul');
	}
	if(where == "top"){
	  data = data.reverse();
	}
	for(var i=0;i<data.length;i++){
		var info = data[i];
		var text = info[0];
	    var url = info[1];
	    var title = info[2];
	    var item = jQuery(document.createElement("li"));
	    if(text == "---"){
			var hr = jQuery(document.createElement("hr"));
			item.append(hr);
	    }else{
	      var anchor = jQuery(document.createElement("a"));
		  if(url.search(/^(http:|https:)?\/\//) > -1){
		    anchor.attr('href',url);
		  }else{
		    if(url.indexOf('/online') == 0){  
	                anchor.attr('href',url);
	            }else{
	                anchor.attr('href','/goldfuss'+url);
	            }
	            //anchor.attr('href','http://w3.goldfuss-auction.com'+url);
	            //anchor.attr('href','/goldfuss'+url);
		  }
	      anchor.attr('title',title);
	      anchor.attr('target',"auction");
	      anchor.text(text);
	      item.append(anchor);
	    }
		if(typeof info[3] != "undefined" && typeof info[3] == "object"  && info[3].length > 0){
		  var newUI = createSubUI(info[3]);
		  newUI.data("setup",false);
		  item.append(newUI);
		  item.addClass("has-child");
		  item.hover(function(){
		      if(!newUI.data("setup")){
		        newUI.css("margin-left",(jQuery(this).width()-3)+"px");
			    newUI.find("a").each(function(){if(jQuery(this).attr("href").indexOf("javascript") == 0){jQuery(this).css("cursor","default");}});
			    newUI.data("setup",true);
			  }
			  newUI.css({visibility: "visible",display: "none"}).stop(true,true).show(200);},
			  function(){newUI.stop(true,true).hide(175);});
		}
		if(where == "top"){
		  uList.prepend(item);
		}else{
	      uList.append(item);
		}
	}
	if(addListing && data.length>0){
		tab.append(listing);
		tab.addClass('unav-has-child');
	}
	  setupNavDropDowns(id);
}

function createSubUI(data){
  var div = jQuery(document.createElement("div"));
  var list = jQuery(document.createElement("ul"));
	for(var i=0;i<data.length;i++){
		var info = data[i];
		var text = info[0];
	    var url = info[1];
	    var title = info[2];
	    var item = jQuery(document.createElement("li"));
	    if(text == "---"){
		    if(data.length > 3){
			  var hr = jQuery(document.createElement("hr"));
			  item.append(hr);
			}
	    }else{
	      var anchor = jQuery(document.createElement("a"));
	      anchor.attr('href',url);
	      anchor.attr('title',title);
	      anchor.attr('target',"auction");
	      anchor.text(text);
	      item.append(anchor);
	    }
		list.append(item);
	}
	div.append(list);
	div.addClass("unav-menu");
	return div;
}

function addParam(obj, key, value) {
    obj[key] = value;
}

function selectTab(id){
  jQuery('#'+id).addClass('selected');
}

function deselectTab(id){
  jQuery('#'+id).removeClass('selected');
}

function setSharing(){
	var pageUrl = escape(window.location.href);
	if(jQuery(".sharing").length > 0){
	  jQuery(".sharing").append(getTwitLink(pageUrl));
	  jQuery(".sharing").append(getFBlink(pageUrl,escape(document.title)));
	}
	if(jQuery(".sharingFBonly").length > 0){
	  jQuery(".sharingFBonly").append(getFBlink(pageUrl,escape(document.title)));
	}
	if(jQuery(".sharingTwtOnly").length > 0){
	  jQuery(".sharingTwtOnly").append(getTwitLink(pageUrl));
	}
}

function getFBlink(thisUrl, pageTitle){
    var FBHtml;
	if(isMSIE){
	  FBHtml = " <a href=\"http://www.facebook.com/sharer.php?u="+thisUrl+"&t="+pageTitle+"\" title=\"Add link to this page to Facebook\" target=\"_blank\">";
	  FBHtml += "<img src=\"/images/facebookIcon.png\" border=\"0\" width=\"16\" height=\"16\" />";
	  FBHtml += "</a>";
	}else{
	  FBHtml = " <span><fb:like href=\""+thisUrl+"\" class=\"fbcolor\" layout=\"button_count\" show_faces=\"false\" action=\"like\" colorscheme=\"light\" /></span>";
	}
	return FBHtml;
}

function getTwitLink(thisUrl){
	var twitHtml = " <a href=\"http://twitter.com/home?status=Check out "+thisUrl+"\" title=\"Add link to this page to Twitter\" target=\"_blank\" >";
	twitHtml += "<img src=\"/images/twitterIcon.png\" border=\"0\" width=\"16\" height=\"16\" />";
	twitHtml += "</a>";
	return twitHtml;
}

function fixampfont(){
    if(jQuery('#desc').length > 0){
      jQuery('#desc').html(jQuery('#desc').html().replace(/\&amp;/g,'<span class="amper">&amp;</span>'));
    }
	//if(jQuery('.auctionblock').length > 0){
    //  jQuery('.auctionblock').each(function(){jQuery(this).html(jQuery(this).html().replace(/\&amp;/g,'<span class="amper">&amp;</span>'))});
   // }
}
//************* cookie functions **************************
// Use this function to retrieve a cookie.
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
    if (dc.length > 0) {
    begin = dc.indexOf(cname);
        if (begin != -1) {
        begin += cname.length;
        end = dc.indexOf(";", begin);
            if (end == -1) end = dc.length;
            return unescape(dc.substring(begin, end));
        }
    }
return null;
}
//Use this function to save a cookie.
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) + "; path=/" +
((expires == null) ? "" : "; expires=" + expires.toGMTString());
}

// Use this function to delete a cookie.
function delCookie(name) {
document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}
function setChip(cookie, name, value) {
var dc = getCookie(cookie);
var cv = getChip(cookie, name);
var cn = name + '=';
    if (cv != null) {
    var start = dc.indexOf(cn);
        if (start != -1) {
        var end = dc.indexOf('|', start);
        setCookie(cookie, dc.substring(0, start) + cn + value + '|' + dc.substring(end + 1, dc.length), exp);
        }
    }
    else {
       if (dc != null) dc += cn + value + '|';
       else dc = cn + value + '|';
    setCookie(cookie, dc, exp);
    }
}

function getChip(cookie, name){
var cn = name + '=';
var dc = getCookie(cookie);
    if (dc != null) {
    var start = dc.indexOf(cn);
       if (start != -1) {
       start += cn.length;
       var end = dc.indexOf('|', start);
           if (end != -1) return unescape(dc.substring(start, end));
       }
   }
return null;
}

function delChip(cookie, name) {
var dc = getCookie(cookie);
var cv = getChip(name);
var cn = name + '=';
    if (cv != null) {
    var start = dc.indexOf(cn);
    var end = dc.indexOf('|', start);
    setCookie(cookie, dc.substring(0, start) + dc.substring(end + 1, dc.length), exp);
    }
}
//********* image display functions ****************************

function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;}
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;}
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;}
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function windowReturn(C){
	  if (window.name == "pics"){
	    if(C != null){this.close();}
	    else{
		window.opener.focus();
		this.blur();}
	  }
	  else{
	    window.history.back();
	  }
	}


function showPic(link){
	var url = link.href;
	var target = link.target;
	var pgwidth = pageWidth();
	var pgheight = f_clientHeight();
	var pgleft = (document.all)? window.screenLeft : window.screenX;
	var pgtop = (document.all)? window.screenTop : window.screenY;
//	var width = 650;
	var width = 695;
	//var width = 700;
	var height = 680;
	var winleft = Math.round(((pgwidth/2) - (width/2)) + pgleft);
	var wintop = Math.round((pgheight/2) - (height/2) + pgtop);
	var dotloc = url.lastIndexOf(".");
	var quesloc = url.lastIndexOf("?");
	if(quesloc < dotloc || quesloc < 0){
	    url += "?";
	}
	url += "&pu=true";
	var options = "status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=1, scrollbars=1, dependent=1, width="+width+", height="+height+", left="+winleft+", top="+wintop;
	if(target == null || target == "" || target == window.name){
		target = "pics";
	}
	//alert(pgleft + " x " + pgwidth+ " - "+winleft);
	var win = doOpen(url, target, options);
	return false;
}

function doOpen(url, name, options){
	  if(options.indexOf("top") < 0){
	    var opts = options.split(",");
		var optionsArray = new Array();
		for(i=0; i<opts.length;i++){
		  var temp = opts[i].split("=");
		  optionsArray[temp[0]] = temp[1];
		}
		//alert(optionsArray['height']+"  "+optionsArray['width']);
	    var winheight = jQuery(window).height();
        var winwidth = jQuery(document).width();
        var height = optionsArray['height'];
//      var width = jQuery(name).outerWidth();
	    var width = optionsArray['width'];
		optionsArray['top'] = winheight/2 - height/2;
		optionsArray['left'] = winwidth/2 - width/2;
		optionsArray['screenX'] = optionsArray['left'];
		optionsArray['screenY'] = optionsArray['top'];
	    //win.moveTo(winwidth/2 - width/2,winheight/2 - height/2);
		options = "";
		for(option in optionsArray){
		  if(option != ""){
		    options += option+"="+optionsArray[option]+",";
		  }
		}
		options = options.replace(/,$/,"");
//		alert(options)
	  }

    // attempt to open the popup
    win = window.open(url, name, options);
    if (win){
      // popup successfully created
      win.focus();
    }else if(name != "calendar" || getChip("goldLongTerm","noPopup") == null){
      // popup was not created.
	  if(document.body == null){
	    setTimeout("showPopupMessage(\""+url+"\", \""+name+"\", \""+options+"\")" ,1000);
      }else{
        showPopupMessage(url, name, options);
	  }
    }
    return win;
  }

function hidePopupMessage(msgId){
  var elmDiv = document.getElementById(msgId);
  if (elmDiv){
    elmDiv.parentNode.removeChild(elmDiv);
  }
}

  window.fbAsyncInit = function() {
    FB.init({appId: '121285354555424', status: true, cookie: true, xfbml: true});
  };

function loadFBscript(){
  var fb;
  if(jQuery('#fb-root').length == 0){
    fb = jQuery(document.createElement("div"));
    fb.attr('id',"fb-root");
	jQuery("body").append(fb);
  }else{
    fb = jQuery('#fb-root');
  }
  var js = jQuery(document.createElement('script'));
  js.attr('src','//connect.facebook.net/en_US/all.js');
  fb.append(js);
}

function rightSlideout(container, tab, content){
  //jQuery("#" + container).css("display","block");
  jQuery("#" + container).animate({"right": "-3"}, 600, function(){
    jQuery("#" + content).mouseleave(function(){
	  rightSlidein(container, tab, content);
	});
	jQuery("#" + tab).unbind("mouseenter");
	jQuery("#" + tab).unbind("click");
	jQuery("#" + tab).click(function (){rightSlidein(container, tab, content);})
  });
}

function rightSlidein(container, tab, content) {
  jQuery("#" + container).animate({"right": "-310"}, 500, function(){
	jQuery("#" + content).unbind("mouseleave");
	jQuery("#" + tab).unbind("click");
    jQuery("#" + tab).mouseenter(function(){rightSlideout(container, tab, content);});
	jQuery("#" + tab).click(function (){rightSlideout(container, tab, content);});
  });
}

function leftSlideout(container, tab, content){
  //jQuery("#" + container).css("display","block");
  jQuery("#" + container).animate({"left": "-3"}, 600, function(){
    jQuery("#" + content).mouseleave(function(){
	  leftSlidein(container, tab, content);
	});
	jQuery("#" + tab).unbind("mouseenter");
	jQuery("#" + tab).unbind("click");
	jQuery("#" + tab).click(function (){leftSlidein(container, tab, content);});
  });
}

function leftSlidein(container, tab, content) {
  jQuery("#" + container).animate({"left": "-310"}, 500, function(){
	jQuery("#" + content).unbind("mouseleave");
	jQuery("#" + tab).unbind("click");
    jQuery("#" + tab).mouseenter(function(){leftSlideout(container, tab, content);});
	jQuery("#" + tab).click(function (){leftSlideout(container, tab, content);});
  });
}

function addLikeBox(){
  if(addSlideout){
    var avalSpace = jQuery(window).height() - 110;
	var useHeight = (avalSpace <= 600)?(avalSpace-5):600;
    if(jQuery("#slideOut").length == 0){
      var so = jQuery(document.createElement("div"));
      so.attr("id","slideOut");
      var st = jQuery(document.createElement("div"));
      st.attr("id","sideTab");
      var sc = jQuery(document.createElement("div"));
      sc.attr("id","slideoutContent");
	  sc.css("height", useHeight+"px");
      sc.html('<fb:like-box profile_id="192524571493" width="300" height="'+useHeight+'" connections="10" stream="true" header="true"></fb:like-box>');
      so.append(st);
      so.append(sc);
	  so.css("display","block");
      jQuery("body").append(so);
    }
    jQuery("#sideTab").mouseenter(function(){
	  leftSlideout("slideOut", "sideTab", "slideoutContent");
	});

    if(jQuery("#slideOutB").length == 0){
      var sob = jQuery(document.createElement("div"));
      sob.attr("id","slideOutB");
      var stb = jQuery(document.createElement("div"));
      stb.attr("id","sideTabB");
      var scb = jQuery(document.createElement("div"));
      scb.attr("id","slideoutContentB");
	  //scb.css("height", useHeight+"px")
      scb.html('<fb:comments xid="192524571493" numposts="10" width="300"></fb:comments>');
      sob.append(stb);
      sob.append(scb);
	  sob.css("display","block");
      jQuery("body").append(sob);
    }
    jQuery("#sideTabB").mouseenter(function(){
	  leftSlideout("slideOutB", "sideTabB", "slideoutContentB");
	});
  }
}

function slideout(container, tab, content){
  jQuery("#" + container).animate({"left": "-330px"}, 550,function(){
     jQuery("#" + container).css("z-index","12");
	 jQuery("#" + container).animate({"left": "-15px"}, 550);//, function(){
	   jQuery("#" +  content).mouseleave(function(){slidein(container, tab, content);});
	   jQuery("#" + tab).unbind("mouseenter");
	   jQuery("#" + tab).click(function (){slidein(container, tab, content);});
	 //});
  });
}

function slidein(container, tab, content){
    jQuery("#" + container).animate({"left": "-330px"}, 550,function(){
     jQuery("#" + container).css("z-index","-1");
	 jQuery("#" + container).animate({"left": "-15px"}, 550);//, function(){
	   jQuery("#" + tab).mouseenter(function(){slideout(container, tab, content);});
	   jQuery("#" + content).unbind("mouseleave");
	   jQuery("#" + tab).unbind("click");
	 //});
  });
}

function addLikeBoxToTop(){
  if(addSlideout && jQuery("#likeContainer").length > 0){
    var avalSpace = jQuery(window).height() - 110;
//	var useHeight = (avalSpace <= 590)?(avalSpace-5):590;
	var useHeight = 590;
    var so = jQuery(document.createElement("div"));
    so.attr("id","slideOut2");
    var st = jQuery(document.createElement("div"));
//    st.attr("id","sideTab");
    st.attr("id","sideTabB");
    var sc = jQuery(document.createElement("div"));
    sc.attr("id","slideoutContent");
    sc.css("height", useHeight+"px");
    sc.html('<fb:like-box profile_id="192524571493" width="300" height="'+useHeight+'" connections="10" stream="true" header="true"></fb:like-box>');
    so.append(st);
    so.append(sc);
    jQuery("#likeContainer").append(so);

   // jQuery("#sideTab").mouseenter(function(){
    jQuery("#sideTabB").mouseenter(function(){
	  //slideout("slideOut2","sideTab","slideoutContent");
	  slideout("slideOut2","sideTabB","slideoutContent");
	});
/*
	var sob = jQuery(document.createElement("div"));
    sob.attr("id","slideOut2B");
    var stb = jQuery(document.createElement("div"));
    stb.attr("id","sideTab");
    var scb = jQuery(document.createElement("div"));
    scb.attr("id","slideoutContentB");
    scb.css("height","590px")
    scb.html('<fb:comments xid="192524571493" numposts="10" width="300"></fb:comments>');
    sob.append(stb);
    sob.append(scb);
    jQuery("#likeContainer").append(sob);

    jQuery("#sideTab").mouseenter(function(){
	  slideout("slideOut2B","sideTab","slideoutContentB");
	});*/
  }


}

function addLikeContainer(){
if(jQuery("#likeContainer").length == 0){
  var lc = jQuery(document.createElement("div"));
  lc.attr("id","likeContainer");
  lc.html(jQuery("#top").html());
  jQuery("#top").html(lc);
  }
}


function tempMessage(msg, closeWin){
    closeWin = (typeof closeWin == "undefined" || closeWin == "")? false: closeWin;
    if (!document.createElement){
	  return;
	}
    var tempElmDiv = jQuery(document.createElement('div'));

    var pgwidth = jQuery(window).width();;
	var xlocal = (document.all)? pgwidth - 121 : pgwidth - 136;
	tempElmDiv.attr("id","tempmessage");
//	tempElmDiv.css({'position' : 'fixed', 'left' : '5px','top':'100px','width': 'auto','color':'black','background-color':'white','font-weight':'normal','border':'solid #66a2d4 1px','font-size':'10pt','padding':'5px','z-index':'56'});
	tempElmDiv.css({'position' : 'fixed', 'left' :  xlocal+'px','top':'100px','width': 'auto','color':'black','background-color':'white','font-weight':'normal','border':'solid #66a2d4 1px','font-size':'10pt','padding':'5px','z-index':'56'});
	

	var html = msg;
	if(closeWin){
	  html += "<p align=\"center\"><a href=\"javascript:void(0)\" onclick=\"hidePopupMessage('tempmessage'); return false;\">Close this message<\/a></p>";
	}
     tempElmDiv.html(html);
     jQuery("body").append(tempElmDiv);
	 var winWidth = tempElmDiv.width();
	 if(winWidth < 103 || winWidth > 180){
	   winWidth = (document.all) ? 115 : 103;
	    tempElmDiv.css("width", winWidth +"px");
	 }
 }

function hidePopupMessage(msgId){
  var elmDiv = document.getElementById(msgId);
  if (elmDiv){
    elmDiv.parentNode.removeChild(elmDiv);
  }
}

  /**
   * Get the current coordinates of the first element in the set of matched
   * elements, relative to the closest positioned ancestor element that
   * matches the selector.
   * @param {Object} selector
   */
  jQuery.fn.positionAncestor = function(selector) {
      var left = 0;
      var top = 0;
      this.each(function(index, element) {
          // check if current element has an ancestor matching a selector
          // and that ancestor is positioned
          var $ancestor = jQuery(this).closest(selector);
          if ($ancestor.length && $ancestor.css("position") !== "static") {
              var $child = jQuery(this);
              var childMarginEdgeLeft = $child.offset().left - parseInt($child.css("marginLeft"), 10);
              var childMarginEdgeTop = $child.offset().top - parseInt($child.css("marginTop"), 10);
              var ancestorPaddingEdgeLeft = $ancestor.offset().left + parseInt($ancestor.css("borderLeftWidth"), 10);
              var ancestorPaddingEdgeTop = $ancestor.offset().top + parseInt($ancestor.css("borderTopWidth"), 10);
              left = childMarginEdgeLeft - ancestorPaddingEdgeLeft;
              top = childMarginEdgeTop - ancestorPaddingEdgeTop;
              // we have found the ancestor and computed the position
              // stop iterating
              return false;
          }
      });
      return {
          left:    left,
          top:    top
      }
};
