var itk_disclosure_badge_going_to_close = true
var itk_disclosure_badge_last_id = 0
var itk_disclosure_badge_close_timer
var itk_disclosure_badge = {

	show: function (id, type, slot_id){ 
		if(typeof(type) == "undefined"){ type = "ppp" }
		// Added by Eric 2/13/2008
        // slot id is used for finding the post so we can record
        // metrics for how many clicks and views the disclosure
        // badge received from each post. Default=0
        // slot_id gets passed into .create() which passes it to .display_html()
		if(typeof(slot_id) == "undefined"){ slot_id = 0 }
		clearInterval(itk_disclosure_badge_close_timer)
		if(itk_disclosure_badge_last_id != id && itk_disclosure_badge_last_id != 0 && itk.id('pppDiv')){
			itk.rc(document.body, itk.id('pppDiv'))
			itk_disclosure_badge_last_id = 0
			itk.png_img_id = 0
		}
		if(!itk.id('pppDiv')) itk_disclosure_badge.create(id, type, slot_id) 
	},

	create: function (id, which, slot_id){
		var a = itk.ce("div")
		var s = a.style
		a.setAttribute('id','pppDiv')
		if(itk_browser.browser == "Explorer"){
			a.onmouseover = function() { itk_disclosure_badge_going_to_close = false; clearInterval(itk_disclosure_badge_close_timer) }
			a.onmouseout = function() { itk_disclosure_badge_going_to_close = true; itk_disclosure_badge.hide(); }
		}else{
			a.setAttribute('onmouseover', 'itk_disclosure_badge_going_to_close=false;clearInterval(itk_disclosure_badge_close_timer)')
			a.setAttribute('onmouseout', 'itk_disclosure_badge_going_to_close=true;itk_disclosure_badge.hide();')
		}
		s.visibility = "visible"
		s.width = "447px"
		s.height = "308px"
		s.position = "absolute"
		s.left = (itk.mouse_x - 30) + "px"
		if(!ad_closed){
			s.top = (itk.get_pixels_from_top(itk.id("disclosure_bar_"+id)) - 330) + "px"
			a.innerHTML = itk_disclosure_badge.display_html(id, which, slot_id)
			itk.ac(document.body, a)
			itk_disclosure_badge_last_id = id
			if(itk_browser.browser == "Explorer") itk.restyle_images()
		}else{
			itk_disclosure_badge_last_id = 0
			itk.png_img_id = 0
		}
	},

	hide: function (){ itk_disclosure_badge_close_timer = setInterval("itk_disclosure_badge.do_hide()", 1000) },

	do_hide: function (){
		if(ad_closed && itk_disclosure_badge_going_to_close && itk.id('pppDiv')){
			itk.rc(document.body, itk.id('pppDiv'))
			itk_disclosure_badge_last_id = 0
			itk.png_img_id = 0
		}
		clearInterval(itk_disclosure_badge_close_timer)
	},

	display_html: function (this_id, which, slot_id){
		bbid = "/images/buglet_border/";
		img_path = (which == "ss") ? itk_ss_root : itk_ppp_root
		if(which == "ss"){ 
	        path = itk_ss_root+"/sponsored_posts/"+this_id+"/adbubble"+"?slot_id="+slot_id;
	    }else{
	        path = itk_ppp_root+"/buglet/ad/"+this_id;
	    }
	    ul_w = 13, ul_h = 12, bt_w = 454, bt_h = 12, ur_w = 13, ur_h = 12, bl_w = 13, bl_h = 264, ll_w = 13, ll_h = 14, bb_w = 378, bb_h = 14, lr_w = 13, lr_h = 14, obj_w = 454, obj_h = 264, vat = "valign='top'"
		side_image = (itk_browser.browser != "Explorer") ? "_for_ff" : ""
        objectStyle = (itk_browser.browser == "Explorer") ? " style='margin:0px;padding:0px;border:0px;overflow:hidden;'" : ""
		a = "<table cellpadding='0' cellspacing='0' border='0'><tr>"
		a += "	<td>"+itk.png(img_path+bbid+'border_ul.png',ul_w,ul_h,'ul')+"</td>"
		a += "	<td colspan='2' align='left'>"+itk.png(img_path+bbid+'border_top.png',bt_w,bt_h,'bt')+"</td>"
		a += "	<td>"+itk.png(img_path+bbid+'border_ur.png',ur_w,ur_h,'ur')+"</td>"
		a += "</tr><tr>"
		a += "	<td "+vat+">"+itk.png(img_path+bbid+'border_left_264.png',bl_w,bl_h,'bl')+"</td>"
		a += "	<td colspan='2' bgcolor='#ffffff' valign='top'><iframe width='"+obj_w+"' height='"+obj_h+"' frameborder='0' id='pppObject' src='"+path+"'></iframe></td>"
		a += "	<td "+vat+">"+itk.png(img_path+bbid+'border_right_264.png',bl_w,bl_h,'bh')+"</td>"
		a += "</tr><tr>"
		a += "	<td "+vat+">"+itk.png(img_path+bbid+'border_ll.png',ll_w,ll_h,'ll')+"</td>"
		a += "	<td "+vat+" align='left'>"+itk.png(img_path+bbid+'border_pointer.png', 76, 50, 'pointer')+"</td>"
		a += "	<td "+vat+" align='left'>"+itk.png(img_path+bbid+'border_bottom.png',bb_w,bb_h,'bb')+"</td>"
		a += "	<td "+vat+">"+itk.png(img_path+bbid+'border_lr.png',lr_w,lr_h,'lr')+"</td>"
		a += "</tr></table>"
		return a
	}

}

var itk_disclosure_badge_loaded = {}
