var itk_spon_intro 				= false
var itk_spon_open 				= false
var itk_spon_current_top 		= 33
var itk_spon_timer
var itk_spon_timer_secs 		= (itk_spon_preview) ? "" : 11
var itk_spon_data_title 		= ""
var itk_spon_data_image 		= ""
var itk_spon_data_copy 			= ""
var itk_spon_data_btn_name 		= ""
var itk_spon_data_link 			= ""
var itk_spon_data_blog 			= ""
var itk_spon_data_expires 		= ""
var itk_spon_data_footer		= ""
var itk_spon_data_view_type 	= "ini"
var itk_spon_data_id 			= 0
var itk_spon_data_opp_id        = 0
var itk_spon_data_booking_id    = 0
var itk_spon_data_opp_path      = ""
var itk_spon_data_spon_type      = 1
var itk_has_seen_sponsorship 	= (itk_spon_preview) ? false : itk_query.read("sponsorship_viewed")
var itk_site_has_sponsorship 	= false
var itk_spon_video_prepared     = false
var itk_spon_data_scrollable    = false
var itk_spon_data_position      = "top"
var itk_spon_custom_id          = 0
var itk_spon_custom_view        = "min"

var itk_sponsorships = {
	
	table: 		"sponsorship_information_"+itk_socialspark_blog_id,
	path: 		"",
	
	check_for_sponsorship: function (){
	    if(itk_spon_preview){
	        itk_sponsorships.show_preview()
	    }else{
	        this.path = itk_sponsorships.path_setup()
            itk_sponsorships.spon = itk_query.read(this.table)
		    itk_sponsorships.spon.length > 0 ? this.set_up_sponsorship() : itk_query.fetch(this.table, this.path)
		}
	},
	
	path_setup: function (){
		return itk_ss_root+"/blogs/"+itk_socialspark_blog_id+"/active_booking?url="+itk_cur_domain+"&permalink="+itk_socialspark_blog_id
	},
	
	show_preview: function(){
	    itk.browser_dimensions()
	    if(itk_spon_custom_id > 0){
	        this.draw_custom_sponsorship()
	    }else{
	        itk_has_seen_sponsorship = (itk_spon_data_spon_type == 1) ? false : true
    		itk_sponsorships.draw_divs()
    		itk_sponsorships.content_view()
	    }
	},
	
	set_up_sponsorship: function (){
	    if(itk_sponsorships.spon != "na"){
	    	if(itk_sponsorships.spon){
    			a = itk_sponsorships.spon.split("*~")
    			itk_spon_data_sponsored_by 	= unescape(a[0])
    			itk_spon_data_media_type 	= unescape(a[1]) //image, third_party_tags, video_embed_tag
    			itk_spon_data_media 		= unescape(a[2])
    			itk_spon_data_copy 			= unescape(a[3])
    			itk_spon_data_btn_name 		= unescape(a[4])
    			itk_spon_data_link			= unescape(a[5])
    			itk_spon_data_blog			= unescape(a[6])
    			itk_spon_data_expires		= unescape(a[7])
    			itk_spon_data_id	 		= unescape(a[8])
    			itk_spon_data_opp_id 		= unescape(a[9])
    			itk_spon_data_opp_path      = unescape(a[10])
    			itk_spon_data_booking_id    = unescape(a[11])
    			itk_spon_data_spon_type     = parseInt(unescape(a[12]))
    			itk_spon_custom_id          = parseInt(unescape(a[13]))
    		}else{
    			itk_sponsorships.save_sponsorship_data()
    		}
    		itk_query.flush(this.table)
    		itk_sponsorships.set_up_form()
		    itk.browser_dimensions()
		    itk.scrolling()
		    if(itk_spon_custom_id > 0){
    	        this.draw_custom_sponsorship()
    	        itk_sponsorships.set_up_view_image()
    	        itk_sponsorships.change_view_image("min")
    	        if(itk_browser.browser == "Explorer") window.attachEvent('onscroll', itk_sponsorships.ie_scroll)
    	    }else if(itk_spon_data_spon_type < 3){
    		    if(itk_spon_data_spon_type == 2) itk_has_seen_sponsorship = true
    		    itk_sponsorships.draw_divs()
    		    itk_sponsorships.set_up_view_image()
    		    itk_sponsorships.content_view()
    		    if(itk_browser.browser == "Explorer") window.attachEvent('onscroll', itk_sponsorships.ie_scroll)
		    }else if(itk_spon_data_spon_type == 3){
		        /*
		            itk_spon_data_media will contain the path to the banner ad image
		            itk_spon_data_copy will contain the top/bottom and scroll/stationary settings
		                               top/scroll, for example
		        */
		        // data_for_sponsorship        = itk_spon_data_copy.split("/")
		        //                 itk_spon_data_position      = data_for_sponsorship[0]
		        //                itk_spon_data_scrollable    = data_for_sponsorship[1]
		        //                itk_sponsorships.draw_leaderboard()
		        //                if(itk_browser.browser == "Explorer" && itk_spon_data_scrollable == "fixed"){
		        //                    window.attachEvent('onscroll', itk_sponsorships.ie_leaderboard_scroll)
		        //                }
		    }
	    }
	},

	content_setup: function (){
		sepratator = (itk_spon_data_link.split('?').length == 1) ? "?" : "&"
		itk_link =  itk_spon_data_link + sepratator + "view_type=" + itk_sponsorships.set_up_link()
		itk.id("itk_spon_title").innerHTML = "This blog is sponsored by <a href='" + itk_link + "' target='_blank' style='color: #ffffff;text-decoration: underline'>" + itk_sponsorships.set_up_sponsorship_title() + "</a>"
		if(itk_spon_data_media_type == "image"){
			itk.id("itk_spon_image").innerHTML = "<a href='" + itk_link + "' target='_blank'><img src='" + itk_ss_root + itk_spon_data_media + "' width='336' height='280' border='0' style='border:1px solid #666666'></a>"
		}else if(itk_spon_data_media_type == "video_embed_tag"){
			v = itk_spon_data_media
		    if(itk_spon_intro){
		        autoplay = v.match(/http:\/\/www\.youtube\.com\/v\/([\-]?\w+)/)[1]
		        myregexp = new RegExp(autoplay, "g")
		        v = v.replace(myregexp, autoplay+"&autoplay=1")
		    }
		    v = v.replace(/ wmode="transparent"/g, "")
		    v = v.replace(/width="425"/g, 'width="100%"')
		    v = v.replace(/height="355"/g, 'height="100%"')
		    itk.id("itk_spon_image").innerHTML = v
		}else{
			itk.id("itk_spon_image").innerHTML = itk_spon_data_media
		}
		itk_spon_data_copy = itk_spon_data_copy.replace(/\r\n/g, "<BR>")
		itk_sponsorship_to_socialspark_link = "<a href='"+itk_ss_root+"/advertisers/"+itk_spon_data_opp_path+"/sponsorships/"+itk_spon_data_opp_id+"?utm_source=SocialSpark%2BBugs&utm_medium=Blog%2BSponsorship&utm_campaign=Get%2BSponsored%2BLike%2BThis%2B-%2B"+itk_spon_data_opp_id+"' style='cursor:pointer;text-decoration:underline;color:orange'>"
		itk.id("itk_spon_content_text").innerHTML = itk_spon_data_copy
		itk.id("itk_spon_btn_text").innerHTML = "<a href='" + itk_link + "' style='color:#990000' target='_blank'>" + itk_spon_data_btn_name + "</a>"
		itk.id("itk_spon_bar_more_info").innerHTML = "Click here and <a href='"+itk_ss_root+"/signup?utm_source=SocialSpark%2BBugs&utm_medium=Blog%2BSponsorship&utm_campaign=Get%2BSponsored%2BLike%2BThis%2B-%2B"+itk_spon_data_opp_id+"' style='cursor:pointer;text-decoration:underline;color:orange'>join SocialSpark</a> for an opportunity to have " + itk_sponsorship_to_socialspark_link + itk_sponsorships.set_up_sponsorship_title() + " sponsor your Blog!</a>"
	},
	
	set_up_sponsorship_title: function(){
	    var a = itk_spon_data_sponsored_by
	    if(a.length > 31) a = itk_spon_data_sponsored_by.substring(0,28) + "..."
	    return a
	},
	
	set_up_link: function(){
	    var a
	    if(itk_spon_data_view_type == "ini"){
	        a = "initial"
	    }else if(itk_spon_data_view_type == "min"){
	        a = "minimized"
	    }else{
	        a = "maximized"
	    }
	    return a
	},
	
	content_view: function (){
		if(itk_has_seen_sponsorship){
		    if(!itk_spon_preview){
		        itk_sponsorships.submit_view("min")
		        itk_sponsorships.change_view_image("min")
		    }
		    this.close()
		}else{
		    if(!itk_spon_preview){
		        itk_sponsorships.submit_view("ini")
		        itk_sponsorships.change_view_image("ini")
			}
			itk_spon_intro = true
			itk_sponsorships.content_setup();
			if(itk_browser.browser != "Explorer") document.body.style.overflow = "hidden"
			itk.id("itk_spon_overlay").style.display = "block"
			a = itk.id("itk_spon_window").style
			a.top = ((itk.browser_height/2) - (390/2)) + "px"
			a.display = "block"
			itk.id("itk_spon_ad").style.top = (itk.i(a.top) + 1) + "px"
			itk.id("itk_spon_ad").style.display = "block"
			if(itk_spon_data_media_type != "video_embed_tag"){ 
				itk.id("itk_spon_countdown").style.display = "block"
				itk.id("itk_spon_countdown_bg").style.display = "block"
				itk.id("itk_spon_countdown").innerHTML = itk_spon_timer_secs
				if(!itk_spon_preview){
				    itk_spon_timer = setInterval("itk_sponsorships.timer_count()", 1000)
				}
			}
			if(!itk_spon_preview) itk_query.save("sponsorship_viewed","true", 7)
		}
	},
	
	timer_count: function (){
		if(itk_spon_timer_secs == 1){
			clearInterval(itk_spon_timer)
			itk_sponsorships.fade_out(1000)
		}
		itk_spon_timer_secs = itk_spon_timer_secs - 1
		itk.id("itk_spon_countdown").innerHTML = itk_spon_timer_secs
	},
	
	fade_out: function (mseconds){
	    var step = Math.round(mseconds / 100);
        var timer = 0;
        for(i = 80; i >= 0; i--) {
            setTimeout("itk_sponsorships.change_opacity(" + i + ")", (timer * step));
            timer++;
        }
	},
	
	change_opacity: function(opacity){
	    var fade_1 = document.getElementById("itk_spon_ad").style;
	    fade_1.opacity = (opacity / 100);
        fade_1.MozOpacity = (opacity / 100);
        fade_1.KhtmlOpacity = (opacity / 100);
        fade_1.filter = "alpha(opacity=" + opacity + ")";
        var fade_2 = document.getElementById("itk_spon_overlay").style;
        fade_2.opacity = (opacity / 100);
        fade_2.MozOpacity = (opacity / 100);
        fade_2.KhtmlOpacity = (opacity / 100);
        fade_2.filter = "alpha(opacity=" + opacity + ")";
        var fade_3 = document.getElementById("itk_spon_window").style;
        fade_3.opacity = (opacity / 100);
        fade_3.MozOpacity = (opacity / 100);
        fade_3.KhtmlOpacity = (opacity / 100);
        fade_3.filter = "alpha(opacity=" + opacity + ")";
        if(opacity==0) this.close()
	},
	
	rollup_sponsorship: function(mseconds, from, to, direction){
		var step = Math.round(mseconds / 100);
        var timer = 0.1;
        if(direction == "down"){
            for(i = from; i <= to; i++) {
                setTimeout("itk_sponsorships.roll_position(" + i + ", '" + direction + "')", (timer * step));
                timer++;
            }
            setTimeout("itk_sponsorships.fix_ad_height()", (timer * step))
        }else{
            setTimeout("itk_sponsorships.fix_ad_height()", (timer * step))
            for(i = from; i >= to; i--) {
                setTimeout("itk_sponsorships.roll_position(" + i + ", '" + direction + "')", (timer * step));
                timer++;
            }
        }
	},
	
	roll_position: function(top_val,direction){
	    itk.browser_dimensions()
	    itk.scrolling()
	    
	    var a = (itk_browser.browser != "Explorer") ? top_val : top_val + itk.offset_y
	    itk.id("itk_sponsorship_bar").style.top = a + "px"
	    itk.id("itk_spon_ad").style.top = a + "px"
	    
	    var b = (itk_browser.browser != "Explorer") ? itk.i(itk.browser_height - top_val) : itk.i((itk.browser_height + itk.offset_y) - top_val)
	    itk.id("itk_sponsorship_bar").style.height = b + "px"
		
	},
	
	fix_ad_height: function(){
	    itk.browser_dimensions()
	    itk.scrolling()
	    var a = (itk_spon_data_view_type == "min") ? itk_spon_current_top + "px" : (itk_spon_current_top - 36) + "px"
	    itk.id("itk_spon_ad").style.height = a
	    itk.id("itk_sponsorship_bar").style.height = a
	    if(itk_browser.browser == "Explorer") itk_sponsorships.ie_scroll()
	},
	
	close: function (){
	    itk_spon_data_view_type = "min"
		itk.browser_dimensions()
		itk.id("itk_spon_ad").style.display = "none"
		itk.id("itk_spon_close").style.display = "none"
		itk.id("itk_spon_logo").style.display = "none"
		itk.rc(document.body,itk.id("itk_spon_overlay"))
		itk.rc(document.body,itk.id("itk_spon_window"))
		itk.id("itk_sponsorship_bar").style.top = itk.browser_height + "px"
		itk.id("itk_spon_ad").style.top = itk.browser_height + "px"
		if (itk_browser.browser != "Explorer"){
		    itk.id("itk_spon_ad").style.opacity = 1
		    document.body.style.overflow = "auto"
	    }else{
	        itk.id("itk_spon_ad").style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
	    }
	    itk.id("itk_spon_image_bg").style.top = "53px"
        itk.id("itk_spon_image").style.top = "53px"
        itk.id("itk_spon_content").style.top = "53px"
        itk.id("itk_sponsorship_bar").style.display = "block"
	    itk.id("itk_spon_ad").style.height = "33px"
	    
	    itk.id("itk_spon_title").style.fontWeight = "normal"
	    itk.id("itk_spon_title").style.fontSize = "15px"
	    itk.id("itk_spon_title").style.top = "9px"
	    
	    itk.id("itk_spon_ad").style.display = "block"
	    itk.id("itk_spon_toggle").style.display = "block"
	    itk.id("itk_spon_powered").style.display = "block"
	    itk_spon_intro = false;
	    itk_sponsorships.content_setup();
	    itk_sponsorships.rollup_sponsorship(1500, itk.browser_height, (itk.browser_height - 33), "up")
	},
	
	close_initial_view: function(){
	    if(itk_spon_data_view_type == "ini"){
	        clearInterval(itk_spon_timer)
	        itk_sponsorships.fade_out(1000)
	    }else{
	        itk_sponsorships.close()
	    }
	},
	
	toggle_display: function (){
	    itk.browser_dimensions()
	    itk.scrolling()
	    itk_spon_btn = itk_spon_open ? "open" : "close"
	    itk_spon_current_top = itk_spon_open ? 33 : 374
	    if(itk_spon_data_view_type == "max"){
	        itk_spon_data_view_type = "min"
	        itk_sponsorships.rollup_sponsorship(200, itk.i(itk.id("itk_sponsorship_bar").style.top), (itk.browser_height - 33), "down")
	    }else{
	        itk_spon_data_view_type = "max"
	        if(!itk_spon_preview){
	            itk_sponsorships.submit_view("max")
	            itk_sponsorships.change_view_image("max")
	        }
	        itk_sponsorships.rollup_sponsorship(200, itk.i(itk.id("itk_sponsorship_bar").style.top), (itk.browser_height - 394), "up")
	    }
	    itk.id("itk_spon_toggle").innerHTML = itk.png(itk_ss_root+'/images/sponsorship/click_to_'+itk_spon_btn+'.png',78,18,'itk_spon_png_toggle_button')
	    itk.id('itk_image_'+itk.png_img_id).style.styleFloat = itk.id('itk_image_'+itk.png_img_id).style.cssFloat = "right"
	    itk.nm("itk_spon_png_toggle_button",0).style.cursor = "pointer"
	    if (itk_browser.browser != "Explorer"){
		    itk.nm("itk_spon_png_toggle_button",0).setAttribute("onclick", "itk_sponsorships.toggle_display()")
	    }else{
	        itk.nm("itk_spon_png_toggle_button",0).onclick = function() { itk_sponsorships.toggle_display() };
	    }
	    if(itk_browser.browser == "Explorer") itk.restyle_single_image("itk_spon_png_toggle_button")
		itk_sponsorships.content_setup()
		itk_spon_open = !itk_spon_open
		if(!itk_spon_video_prepared) itk_spon_video_prepared = true
	},
	
	position: function (){
		if(!itk_spon_intro){
		    div_left = (itk.i(itk.browser_width)/2)-273
			if(itk.id("itk_sponsorship_bar") && itk.id("itk_sponsorship_bar").style.display == "block"){
			    itk.scrolling()
				var a = itk.id("itk_sponsorship_bar").style
				var t = itk_spon_current_top
                // if(itk_spon_custom_id > 0){
                //     t = (itk_spon_custom_view == "min") ? (itk_spon_current_top + 96) : (itk_spon_current_top + 416)
                // }
				if(itk_browser.browser != "Explorer"){
				    a.top = (itk.i(itk.browser_height) - itk.i(t)) + "px"
    				a.position = "fixed"
				}else{
				    a.top = ((itk.i(itk.browser_height) - itk.i(t)) + itk.i(itk.offset_y)) + "px"
    				a.position = "absolute"
				}
				if(itk.id("itk_spon_title")) itk.id("itk_spon_title").style.left = div_left + "px"
			}
			if(itk.id("itk_spon_ad") && itk.id("itk_spon_ad").style.display == "block"){
				a = itk.id("itk_spon_ad").style
				a.top = (itk.i(itk.id("itk_sponsorship_bar").style.top) - 0) + "px"
				a.position = (itk_browser.browser != "Explorer") ? "fixed" : "absolute"
				itk.id("itk_spon_title").style.left = div_left + "px"
			}
		}
	},
	
	draw_divs: function (){
		a = ''
		a += '	<div id="itk_spon_window_container" style="margin:0 auto;position:relative;text-align:left;width:701px;height:390px;">';
		a += '		<div id="itk_spon_bg_ur" style="position:absolute;top:0px;left:698px;width:15px;height:53px;">'+itk.png(itk_ss_root+'/images/sponsorship/ur.png',15,53,'ur')+'</div>';
		a += '		<div id="itk_spon_bg_top" style="position:absolute;top:0px;left:15px;width:698px;height:53px;">'+itk.png(itk_ss_root+'/images/sponsorship/top.png',683,53,'top')+'</div>';
		a += '		<div id="itk_spon_bg_ul" style="position:absolute;top:0px;left:0px;width:15px;height:53px;">'+itk.png(itk_ss_root+'/images/sponsorship/ul.png',15,53,'ul')+'</div>';
		a += '		<div id="itk_spon_bg_left" style="position:absolute;top:53px;left:0px;width:15px;height:334px;">'+itk.png(itk_ss_root+'/images/sponsorship/left.png',15,334,'left')+'</div>';
		a += '		<div id="itk_spon_bg_middle" style="background:url('+itk_ss_root+'/images/sponsorship/bg.jpg) repeat-x;position:absolute;top:53px;left:15px;width:683px;height:354px;"></div>';
		a += '		<div id="itk_spon_bg_right" style="position:absolute;top:53px;left:698px;width:15px;height:325px;">'+itk.png(itk_ss_root+'/images/sponsorship/right.png',15,334,'right')+'</div>';
		a += '		<div id="itk_spon_bg_bottom" style="position:absolute;top:378px;left:15px;width:683px;height:9px;">'+itk.png(itk_ss_root+'/images/sponsorship/bottom.png',683,9,'bottom')+'</div>';
		a += '		<div id="itk_spon_countdown_bg" style="position:absolute;top:14px;left:19px;width:33px;height:35px;display:none;">'+itk.png(itk_ss_root+'/images/sponsorship/count_down_bg.png',33,35,'count_down_bg')+'</div>';
		a += '		<div id="itk_spon_countdown" style="position:absolute;top:18px;left:23px;width:25px;height:17px;font-family:verdana;font-size:12px;font-weight:bold;color:#ffffff;text-align:center;"></div>';
		a += '	</div>';
		b = itk.ce("div")
		s = b.style
		b.setAttribute('id','itk_spon_window');
		s.position = "absolute"
		s.width = "100%"
		s.height = "370px"
		s.top = "0px"
		s.left = "0px"
		s.textAlign = "center"
		s.display = "none"
		s.zIndex = "9001"
		document.body.insertBefore(b, document.body.firstChild);
		itk.id("itk_spon_window").innerHTML = a;
		
		a = ''
		a += '	<style>';
		a += '		#itk_spon_bar_more_info a:link {color: #ffffff;text-decoration: none;}';
		a += '		#itk_spon_bar_more_info a:visited {color: #ffffff;text-decoration: none;}';
		a += '		#itk_spon_bar_more_info a:hover {color: #ffffff;text-decoration: none;}';
		a += '		#itk_spon_bar_more_info a:focus {color: #ffffff;text-decoration: none;}';
		a += '		#itk_spon_bar_more_info a:active {color: #ffffff;text-decoration: none;}';
		a += '	</style>';
		if(itk_browser.browser == "Explorer"){
		    fade_img = itk.png(itk_ss_root+'/images/sponsorship/bar_background.png',3000,33,'background')
		}else{
		    fade_img = '<img name="background" src="'+itk_ss_root+'/images/sponsorship/bar_background.png" style="margin: 0px; padding: 0px; position: absolute; top: 0px; left: 0px;">'
		}
		a += '	<div id="itk_spon_bar_shading" style="position:absolute;top:0px;left:0px;height:33px;width:100%;overflow:hidden;">'+fade_img+'</div>';
		a += '	<div id="itk_spon_bar_transparent_bg" style="position:absolute;top:33px;left:0px;height:325px;width:100%;background-color:#ffffff;"></div>';
		a += '	<div id="itk_spon_bar_transparent_bottom_bg" style="position: absolute;top: 358px;left: 0px;height: 36px;width: 100%;opacity: .9;background-color: #000000;"></div>';
		a += '	<div id="itk_spon_bar_more_info" style="position:absolute;top:369px;left:0px;width:100%;height:30px;font-family:verdana;font-size:12px;color:#ffffff;text-align:center;"></div>';
		b = itk.ce("div");
		s = b.style
		b.setAttribute('id','itk_sponsorship_bar');
		s.display = "none";
		s.position = (itk_browser.browser != "Explorer") ? "fixed" : "absolute"
		s.overflow = "hidden";
		s.top = "0px";
		s.left = "0px";
		s.height = "33px";
		s.width = "100%";
		s.zIndex = "9000"
		document.body.insertBefore(b, document.body.firstChild);
		itk.id("itk_sponsorship_bar").innerHTML = a

		a = ''
		a += '	<div id="itk_spon_ad_container" style="margin:0 auto;position:relative;text-align:left;width:701px;height:390px;z-index:1010">';
		a += '		<style>'
		a += '			#itk_spon_ad_container a:link {color: #ffffff;text-decoration: none;}';
		a += '			#itk_spon_ad_container a:visited {color: #ffffff;text-decoration: none;}';
		a += '			#itk_spon_ad_container a:hover {color: #ffffff;text-decoration: none;}';
		a += '			#itk_spon_ad_container a:focus {color: #ffffff;text-decoration: none;}';
		a += '			#itk_spon_ad_container a:active {color: #ffffff;text-decoration: none;}';
		a += '		</style>'
		a += '		<div id="itk_spon_image_bg" style="position:absolute;top:73px;left:22px;width:336px;height:281px;background-color:#ffffff;"><iframe src="about:blank" width="336" height="281" frameborder="0"></iframe></div>';
		a += '		<div id="itk_spon_image" style="position:absolute;top:73px;left:28px;width:336px;height:281px;"></div>';
		a += '		<div id="itk_spon_content" style="position:absolute;top:73px;left:387px;width:294px;height:256px;overflow:auto;font-family:Arial,sans-serif;font-size:13px;color:#666666;text-align:left;">';
		a += '			<span id="itk_spon_content_text"></span>';
		a += '			<br /><br />';
		a += '			<table cellpadding="0" cellspacing="0" width="1" height="23" border="0">';
		a += '				<tr>';
		a += '					<td><img src="'+itk_ss_root+'/images/sponsorship/btn_left.jpg" width="5" height="23" style="padding: 0px; margin: 0px;"></td>';
		a += '					<td background="'+itk_ss_root+'/images/sponsorship/btn_bg.jpg" id="itk_spon_btn_text" style="font-family:verdana;font-weight:bold;font-size:10px;color:#990000;text-align:center;margin: 0px;padding: 0px 6px;"nowrap></td>';
		a += '					<td><img src="'+itk_ss_root+'/images/sponsorship/btn_right.jpg" width="5" height="23" style="padding: 0px; margin: 0px;"></td>';
		a += '				</tr>';
		a += '			</table>';
		a += '		</div>';
		a += '		<div id="itk_spon_logo" style="position:absolute;top:333px;left:598px;width:84px;height:24px;">'+itk.png(itk_ss_root+'/images/sponsorship/socialspark_logo.png',84,24,'socialspark_logo')+'</div>';
		click_action = (itk_spon_preview) ? "itk_sponsorships.close()" : "itk_sponsorships.close_initial_view()"
		a += '		<div id="itk_spon_close" style="position:absolute;top:18px;left:634px;width:54px;height:23px;cursor:pointer;z-index:1000;" onclick="itk_sponsorships.close_initial_view()">'+itk.png(itk_ss_root+'/images/sponsorship/close_button_off.png',54,23,'close_button_off')+'</div>';
		a += '	</div>';
		a += '	<div id="itk_spon_toggle" style="position:absolute;top:10px;left:16px;height:48px;width:98%;padding-right:18px;text-align:right;z-index:1011;display:none"></div>';
        div_left = (itk.i(itk.browser_width)/2)-273
        a += '	<div id="itk_spon_title" style="overflow:hidden;position:absolute;top:18px;left:'+div_left+'px;width:546px;height:30px;font-family:Tahoma,Verdana,Arial,sans-serif;font-weight:bold;font-size:18px;color:#ffffff;text-align:center;z-index:1012;"></div>';
        a += '	<div id="itk_spon_powered" style="position:absolute;top:6px;left:-2px;height:32px;width:100px;z-index:1013;display:none;"><a href="'+itk_ss_root+'?utm_source=SocialSpark%2BBugs&utm_medium=Blog%2BSponsorships&utm_campaign=Powered%2BBy%2BSocial%2BSpark">'+itk.png(itk_ss_root+'/images/sponsorship/powered_by_socialspark.png',157,27,'bar_logo')+'</a></div>';
        a += '	';
		b = itk.ce("div");
		s = b.style
		b.setAttribute('id','itk_spon_ad');
		s.display = "none"
		s.position = (itk_browser.browser != "Explorer") ? "fixed" : "absolute"
		s.width = "100%"
		s.height = "390px"
		s.top = "0px"
		s.left = "0px"
		s.textAlign = "center"
		s.overflow = "hidden"
		s.zIndex = "9012"
		document.body.insertBefore(b, document.body.firstChild);
		itk.id("itk_spon_ad").innerHTML = a;
		
		itk.id("itk_spon_toggle").innerHTML = itk.png(itk_ss_root+'/images/sponsorship/click_to_open.png',78,18,'itk_spon_png_toggle_button')
		itk.id('itk_image_'+itk.png_img_id).style.styleFloat = itk.id('itk_image_'+itk.png_img_id).style.cssFloat = "right"
		itk.nm("itk_spon_png_toggle_button",0).style.cursor = "pointer"
		if (itk_browser.browser != "Explorer"){
		    itk.nm("itk_spon_png_toggle_button",0).setAttribute("onclick", "itk_sponsorships.toggle_display()")
	    }else{
	        itk.nm("itk_spon_png_toggle_button",0).onclick = function() { itk_sponsorships.toggle_display() };
	    }
		
		a = itk.ce("div");
		s = a.style
		a.setAttribute('id','itk_spon_overlay');
		s.position = "absolute"
		s.width = itk.browser_width + "px"
		s.height = itk.browser_height + "px"
		s.top = "0px"
		s.left = "0px"
		s.zIndex = "9001"
		s.backgroundColor = "#000000"
		if (itk_browser.browser != "Explorer"){
		    s.opacity = ".8"
	    }else{
	        s.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=80)';
	    }
		s.display = "none"
		document.body.insertBefore(a, document.body.firstChild);
		if(itk_browser.browser == "Explorer") itk.restyle_images()
	},
	
	draw_leaderboard: function(){
	    // PUSH DOWN/UP THE CONTENT
	        if(itk_spon_data_position == "top" || (itk_spon_data_position == "bottom" && itk_spon_data_scrollable != "scrollable")){
	            b = itk.ce("div")
	            s = b.style
	            s.width = "100%"
	            s.height = "110px"
	            document.body.insertBefore(b, this.determine_insert())
	        }
	    // CREATE THE DIV THAT HOLDS THE BANNER AD
		    b = itk.ce("div")
		    b.setAttribute('id','itk_spon_window')
    		s = b.style
    		s.position = (itk_spon_data_scrollable == "scrollable") ? "absolute" : "fixed"
    		s.width = "100%"
    		s.height = "105px"
    		if(itk_spon_data_position == "top"){
    		    s.top = "0px"
		    }else if(itk_spon_data_position == "bottom" && itk_spon_data_scrollable != "scrollable"){
                s.top = (itk.browser_height - 110) + "px"
		    }
    		s.left = "0px"
    		s.textAlign = "center"
    		s.zIndex = "9001"
    		document.body.insertBefore(b, this.determine_insert())
		// DRAW THE BANNER AD
		    a = ''
    		a += '<div id="itk_spon_window_container" style="margin:0 auto;padding:10px;position:relative;text-align:left;width:780px;height:90px;">'
    		a += '<a href="'+itk_spon_data_link+'" target="_blank"><img src="'+itk_spon_data_media+'" border="0"></a>'
    		a += '<a href="#"><img src="" width="24" height="90" border="0"></a>'
    		a += '<a href="#"><img src="" width="24" height="90" border="0"></a>'
    		a += '</div>';
    		itk.id("itk_spon_window").innerHTML = a;
	},
	
	determine_insert: function(){
	    return (itk_spon_data_position == "top") ? document.body.firstChild : document.body.nextSibling
	},
	
	set_up_form: function (){
	    fn = "itk_sponsorship_form"
		f = itk.cf(fn, "itk_data_holder_iframe", itk_tracker_root + "/sponsorship_views/create")
		itk.cfi(f, "sponsorship_views[url]", escape(itk_cur_location))
		itk.cfi(f, "sponsorship_views[pvid]", itk_page_view_id)
		itk.cfi(f, "sponsorship_views[sponsorship_id]", itk_spon_data_opp_id)
		itk.cfi(f, "sponsorship_views[view_type]", "ini")
		itk.ac(itk.id("itk_data_holder"),f)
	},
	
	submit_view: function(val){
	    if(!itk_spon_preview){
	        itk.fv('', 'sponsorship_views[view_type]', val)
            itk.form_submit(itk_tracker_root + "/sponsorship_views/create")
        }
	},
	
	set_up_view_image: function(){
	    a = itk.ce("img");
		a.setAttribute('id','itk_sponsorship_view_image');
		a.setAttribute('width','1');
		a.setAttribute('height','1');
		a.setAttribute('src','');
		itk.ac(itk.id("itk_data_holder"),a)
	},
	
	change_view_image: function(view_type){
	    var vt = ""
	    switch(view_type){
        case "ini":
            vt = "initial"
            break
        case "min":
            vt = "minimized"
            break
        case "max":
            vt = "maximized"
            break
        }
	    src = itk_metrics_root
	    src += "/view/booking?"
	    src += "opportunity_id=" + itk_spon_data_opp_id
	    src += "&booking_id=" + itk_spon_data_booking_id
	    src += "&view_type=" + vt
	    itk.id("itk_sponsorship_view_image").setAttribute("src", src)
	},
	
	save_sponsorship_data: function (){
		var a = ""
		a += escape(itk_spon_data_sponsored_by) + "*~"
		a += escape(itk_spon_data_media_type) + "*~"
		a += escape(itk_spon_data_media) + "*~"
		a += escape(itk_spon_data_copy) + "*~"
		a += escape(itk_spon_data_btn_name) + "*~"
		a += escape(itk_spon_data_link) + "*~"
		a += escape(itk_spon_data_blog) + "*~"
		a += escape(itk_spon_data_expires) + "*~"
		a += escape(itk_spon_data_id) + "*~"
		a += escape(itk_spon_data_opp_id) + "*~"
		a += escape(itk_spon_data_opp_path) + "*~"
		a += escape(itk_spon_data_booking_id) + "*~"
		a += escape(itk_spon_data_spon_type) + "*~"
		a += escape(itk_spon_custom_id)
		itk_query.save(this.table, a, itk.tomorrow_at_midnight())
	},
	
	no_sponsorship: function (){
		itk_query.remove("sponsorship_viewed")
		itk_query.save(this.table, "na", 1)
	},
	
	bring_to_front: function (){
	    itk_new_zindex = itk.next_zindex()
	    if(itk.id("itk_spon_overlay")){
	        itk.id("itk_spon_overlay").style.zIndex         = itk_new_zindex + 1
        }
        if(itk.id("itk_spon_window")){    
			itk.id("itk_spon_window").style.zIndex          = itk_new_zindex + 2
	    }
		if(itk.id("itk_spon_ad")){
			itk.id("itk_spon_ad_container").style.zIndex    = itk_new_zindex + 3
			itk.id("itk_spon_toggle").style.zIndex          = itk_new_zindex + 4
			itk.id("itk_spon_title").style.zIndex           = itk_new_zindex + 5
			itk.id("itk_spon_powered").style.zIndex         = itk_new_zindex + 6
			itk.id("itk_spon_bar_more_info").style.zIndex   = itk_new_zindex + 7
			itk.id("itk_sponsorship_bar").style.zIndex      = itk_new_zindex + 8
			itk.id("itk_spon_ad").style.zIndex              = itk_new_zindex + 9
		}
	},
	
	ie_scroll: function (){
	    itk.scrolling()
	    itk.browser_dimensions()
	    if(itk_spon_custom_id > 0){
 		    var a = itk_spon_current_top
		}else{
		    var a = (itk_spon_data_view_type == "min") ? itk_spon_current_top : (itk_spon_current_top + 21)
		    var b = (itk_spon_data_view_type == "min") ? 33 : 338
		}
	    itk.id("itk_sponsorship_bar").style.top = ((itk.i(itk.browser_height) - itk.i(a)) + itk.i(itk.offset_y)) + "px"
	    var ad = itk.id("itk_spon_ad")
	    if(ad){
	        ad.style.top = (itk.i(itk.id("itk_sponsorship_bar").style.top) - 0) + "px"
    		ad.style.height = b + "px"
	    }
		
	},
	
	ie_leaderboard_scroll: function (){
	    itk.scrolling()
	    itk.browser_dimensions()
	    itk.id("itk_spon_window_container").style.top = ((itk.i(itk.browser_height) - 110) + itk.i(itk.offset_y)) + "px"
	},

	draw_custom_sponsorship: function(){
	    small_height = (itk_browser.browser != "Explorer") ? 130 : 128
	    large_height = (itk_browser.browser != "Explorer") ? 448 : 446
	    itk_spon_current_top = small_height
	    itk_spon_data_view_type = "min"
	    b           = itk.ce("div")
		s           = b.style
		s.position  = (itk_browser.browser != "Explorer") ? "fixed" : "absolute"
		s.width     = "100%"
		s.height    = "45px"
		s.top       = (itk.browser_height - small_height) + "px"
		s.left      = "0px"
		s.zIndex    = "9001"
		s.display   = "block"
		s.overflow  = "hidden"
		s.paddingTop = "85px"
		b.setAttribute('id','itk_sponsorship_bar')
		document.body.insertBefore(b, this.determine_insert())
	    itk.id("itk_sponsorship_bar").innerHTML = this.custom_html(large_height)
		itk.id("itk_spon_bar_more_info").innerHTML = this.custom_link()
	},
	
	expand_custom: function(sm, lr){
	    if(!itk_spon_preview) itk_sponsorships.change_view_image("max")
	    itk_spon_custom_view = "max"
	    itk_spon_data_view_type = "max"
	    itk_spon_current_top = lr
	    var img = itk_izearank_cache + "/images/custom_sponsorships/" + this.which_custom() + "/"
	    var div = itk.id("itk_sponsorship_bar").style
	    div.height = lr + "px"
	    if(itk_browser.browser != "Explorer"){
	        div.top = (itk.browser_height - lr) + "px"
        }else{
            div.top = ((itk.browser_height - lr) + itk.i(itk.offset_y)) + "px"
        }
	    itk.id("itk_spon_toggle_span").innerHTML = '<img src="'+img+'btn_click_to_close.png" alt="Click to Minimize" id="itk_spon_toggle" onclick="itk_sponsorships.condense_custom('+small_height+', '+large_height+')" />'
	},
	
	condense_custom: function(sm, lr){
	    if(!itk_spon_preview) itk_sponsorships.change_view_image("min")
	    itk_spon_custom_view = "min"
	    itk_spon_data_view_type = "min"
	    itk_spon_current_top = sm
	    var img = itk_izearank_cache + "/images/custom_sponsorships/" + this.which_custom() + "/"
	    var div = itk.id("itk_sponsorship_bar").style
	    div.height = "45px"
	    if(itk_browser.browser != "Explorer"){
	        div.top = (itk.browser_height - sm) + "px"
        }else{
            div.top = ((itk.browser_height - sm) + itk.i(itk.offset_y)) + "px"
        }
	    itk.id("itk_spon_toggle_span").innerHTML = '<img src="'+img+'btn_click_to_expand.png" alt="Click to Expand" id="itk_spon_toggle" onclick="itk_sponsorships.expand_custom('+small_height+', '+large_height+')" />'
	},
	
	custom_link: function(){
	    var a = ""
	        a += "Click here and "
	        a += "<a "
	        a += "  href='"+itk_ss_root+"/signup?utm_source=SocialSpark%2BBugs&utm_medium=Blog%2BSponsorship&utm_campaign=Get%2BSponsored%2BLike%2BThis%2B-%2B"+itk_spon_data_opp_id+"' "
	        a += "  style='cursor:pointer;text-decoration:underline;color:orange'"
	        a += ">join SocialSpark</a> for an opportunity to have "
	        a += "<a "
	        a += "  href='"+itk_ss_root+"/advertisers/"+itk_spon_data_opp_path+"/sponsorships/"+itk_spon_data_opp_id+"?utm_source=SocialSpark%2BBugs&utm_medium=Blog%2BSponsorship&utm_campaign=Get%2BSponsored%2BLike%2BThis%2B-%2B"+itk_spon_data_opp_id+"' "
	        a += "  style='cursor:pointer;text-decoration:underline;color:orange'"
	        a += ">" + itk_sponsorships.set_up_sponsorship_title() + " sponsor your Blog!</a>"
	    return a
	},
	
	custom_html: function(lr){
	    var id = itk_spon_custom_id
	    var img = itk_izearank_cache + "/images/custom_sponsorships/" + this.which_custom() + "/"
	    var img_custom = itk_izearank_cache + "/images/custom_sponsorships/" + itk_spon_custom_id + "/"
	    
	    var a = ''
	    if(this.which_custom() == "sears"){
	        a += '	#itk_custom_spon_bar { font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; border-top:1px solid #fff; text-align: left; background: url('+img+'bg_tile.jpg) repeat-x 0px 43px; width:100%; position:relative; top:2px; }'
            a += '	#itk_custom_spon_bar .itk_custom_top { height: 41px; background:#8b0e15 url('+img+'bg_top.jpg) repeat-x top center; position:relative; z-index:9015; }'
            a += '	#itk_custom_spon_bar .itk_custom_top h1 { text-indent:-9999px; background:url('+img+'logo_sears.png) no-repeat top left; width:158px; height:56px; margin-top:-21px; float:left; }'
            a += '	#itk_custom_spon_bar .itk_custom_top h3 { text-indent:-9999px; background:url('+img_custom+'top_text.png) no-repeat top left; width:445px; height:21px; float:left; margin:12px 0 0 0; }'
            a += '	#itk_custom_spon_bar .itk_custom_top p { float: right; margin-top:0; width:297px; }'
            a += '	#itk_custom_spon_bar .itk_custom_top img.itk_custom_photo { border:0; top:-89px; width:215px; height:180px; position:absolute; z-index:9023; }'
            a += '	#itk_custom_spon_bar .itk_custom_top img.itk_custom_logo { border:0; position:absolute; top:-85px; right:57px; width:94px; height:101px; z-index:9024; }'
            a += '	#itk_custom_spon_bar .itk_custom_top img#itk_spon_toggle { cursor: pointer; border:0; position:absolute; top:8px; right:10px; float:right; width:124px; height:25px; z-index:9025; }'
            a += '	#itk_custom_spon_bar .itk_custom_body { height:282px; z-index:9013; position:relative; border-top: 2px solid #051e05; clear:both; top:-11px; background: transparent url('+img+'bg_body.jpg) no-repeat center center; }'
            a += '	#itk_custom_spon_bar .itk_custom_top .itk_custom_wrapper { position:relative; }'
            a += '	#itk_custom_spon_bar .itk_custom_body .itk_custom_wrapper { position:relative; height: 281px; overflow:hidden; }'
            a += '	#itk_custom_spon_bar .itk_custom_body h2 { width:413px; height:72px; text-indent:-9999px; margin:30px 0 0 12px; background:url('+img+'body_text_'+this.custom_spon_gender(id)+'.png) no-repeat top left; }'
            a += '	#itk_custom_spon_bar .itk_custom_body h3 { width: 345px; height: 82px; text-indent: -9999px; margin: 10px 0 0 44px; background: url('+img+'body_text_grant_a_wish.png) no-repeat top left; }'
            a += '	p#itk_custom_photo_content { position:absolute; margin: 0; top:10px; right:0; float:right; width:400px; }'
            a += '	#itk_custom_spon_bar .itk_custom_body img.itk_custom_photo { border:0; width:350px; height:275px; float:right; margin-right:11px; }'
            a += '	#itk_custom_spon_bar .itk_custom_body img.itk_custom_floater { border:0; width:144px; height:110px; position:absolute; top:156px; }'
            a += '	#itk_custom_spon_bar .itk_custom_body ul { list-style-type: none; width: 398px; }'
            a += '	#itk_custom_spon_bar .itk_custom_body li { padding:0; margin-left:5px; width:50%; float: left; }'
            a += '	#itk_custom_spon_bar .itk_custom_body li.sears { padding:0; margin-left:5px; width:43%; float: left; }'
            a += '	#itk_custom_spon_bar .itk_custom_body li a { display:block; text-indent:-9999px; float: left; width: 100%; }'
            a += '	a#itk_custom_spon_visit_blog { height:31px; background:url('+img_custom+'btn_visit.png) no-repeat top right; }'
            a += '	a#itk_custom_spon_visit_advertiser { height:31px; background:url('+img+'btn_visit_sears.png) no-repeat top left; }'
            a += '	p#itk_custom_powered_by { position:absolute; bottom:15px; background: url('+img+'powered_by_socialspark.png) no-repeat bottom left; text-indent:-9999px; margin:0 0 0 103px; padding:0; width:335px; height: 23px; }'
            a += '	p#itk_custom_powered_by a { display:block; background:url('+img+'official_rules.png) no-repeat top right; height:100%; text-indent:-9999px; width:125px; position: absolute; right: 0; top: 7px; }'
            a += '	#itk_custom_spon_bar .itk_custom_wrapper { width: 875px; margin: 0 auto; }'
	    }else{
	        a += '	#itk_custom_spon_bar { text-align:left; font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; border-top:4px solid #fff; width:100%; position:relative;top:0; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_top { height: 41px; background:#527015 url('+img+'bg_top.jpg) repeat-y center center; position:relative; z-index:9015; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_top h1 { text-indent:-9999px; background:url('+img+'logo_kmart.png) no-repeat top left; width:70px; height:70px; margin-top:-35px; float:left; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_top h3 { text-indent:-9999px;background:url('+img_custom+'h3_text.png) no-repeat top center;width:453px; height:29px;float:left;margin:10px 0 0 3px; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_top p { float: right; margin-top:0; width:297px; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_top img.itk_custom_photo { right: 83px; border:0; top:-89px; width:214px; height:181px; position:absolute; z-index:9023; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_top img.itk_custom_logo { border:0; position:absolute; top:-85px; right:57px; width:94px; height:101px; z-index:9024; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_top img#itk_spon_toggle { cursor: pointer; border:0; position:absolute; top:8px; right:10px; float:right; width:124px; height:25px; z-index:9025; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_body {	height:286px;z-index:9013;position:relative;border-top: 2px solid #012704;clear:both;top:-11px;background:#004100 url('+img+'bg_body.jpg) repeat-y center center; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_top .itk_custom_wrapper { position:relative; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_body .itk_custom_wrapper { position:relative; height: 286px; overflow:hidden; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_body h2 { width:446px; height:94px;text-indent:-9999px;margin:30px 0 0 12px;background:url('+img+'body_text_'+this.custom_spon_gender(id)+'.png) no-repeat top left; }'
    	    a += '	p#itk_custom_photo_content { margin: 1em 0; position:relative; top:-217px; float:right; width:400px; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_body img.itk_custom_photo { border:0; width:345px; height:286px; float:right; margin-right:6px; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_body img.itk_custom_logo { border:0; width:112px; height:176px; position:absolute; top:82px; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_body ul { margin: 1em 0; list-style-type: none; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_body li { padding:0; margin-left:10px; width:322px; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_body li a { display:block; text-indent:-9999px; }'
    	    a += '	a#itk_custom_spon_visit_blog { height:44px; background:url('+img_custom+'btn_visit.png) no-repeat top right; margin:0 -2px 5px 0; }'
    	    a += '	a#itk_custom_spon_visit_advertiser { height:25px; background:url('+img+'btn_visit_kmart-com.png) no-repeat top right; }'
    	    a += '	p#itk_custom_powered_by { position:absolute; bottom:15px; background: url('+img+'powered_by_socialspark.png) no-repeat bottom left; text-indent:-9999px; margin:0; padding:0; width:372px; }'
    	    a += '	p#itk_custom_powered_by a { display:block; background:url('+img+'official_rules.png) no-repeat top right; height:100%; text-indent:-9999px; width:125px; float:right; }'
    	    a += '	#itk_custom_spon_bar .itk_custom_wrapper { width: 805px;margin: 0 auto; }'
	    }
    	
		var ss1 = document.createElement('style');
        var def = a
        ss1.setAttribute("type", "text/css");
        if (ss1.styleSheet) {   // IE
            ss1.styleSheet.cssText = def;
        } else {                // the world
            var tt1 = document.createTextNode(def);
            ss1.appendChild(tt1);
        }
        var hh1 = document.getElementsByTagName('head')[0];
        hh1.appendChild(ss1);

	    var a = ''
	    if(this.which_custom() == "sears"){
	        a += '<div id="itk_custom_spon_bar">'
            a += '	<div class="itk_custom_top">'
            a += '		<div class="itk_custom_wrapper">'
            a += '			<h1>Sears</h2>'
            a += '			<h3>We gave blogger ' + this.custom_spon_intro(id) + ' $500 to grant a wish</h3>'
            a += '			<p>'
            a += '				<img src="'+img_custom+'photo_sm.png" alt="' + this.custom_spon_intro(id) + '" class="itk_custom_photo" />'
            a += '				<span id="itk_spon_toggle_span"><img src="'+img+'btn_click_to_expand.png" alt="Click to Expand" id="itk_spon_toggle" onclick="itk_sponsorships.expand_custom('+small_height+', '+large_height+')" /></span>'
            a += '			</p>'
            a += '		</div>'
            a += '	</div>'
            a += '	<div class="itk_custom_body">'
            a += '		<div class="itk_custom_wrapper">'
            a += '			<h2>See what ' + this.custom_spon_gender(id) + ' bought and you might grab $500 too!*</h2>'
            a += '			<h3>Don\'t just give a gift, grant a wish!</h3>'
            a += '			<ul>'
            a += '				' + this.custom_spon_link(id)
            a += '				<li class="sears"><a href="' + this.custom_spon_sears_link(id) + '" target="_blank" id="itk_custom_spon_visit_advertiser">Visit Sears.com</a></li>'
            a += '			</ul>'
            a += '			<p id="itk_custom_photo_content">'
            a += '				<img src="'+img_custom+'photo_lrg.png" class="itk_custom_photo" alt="' + this.custom_spon_intro(id) + '" />'
            a += '				<img src="'+img+'gifts.png" alt="gifts" class="itk_custom_floater" />'
            a += '			</p>'
            a += '			<p id="itk_custom_powered_by">Powered by SocialSpark. <a href="http://blog.izea.com/dont-just-give-a-gift-grant-a-wish-contest-official-rules.html">*Click here for Official Rules.</a></p>'
            a += '		</div>'
            a += '	</div>'
            a += '  <div id="itk_spon_bar_more_info" style="background-color:#000000;width:100%;margin-top:-12px;padding-top:9px;height:30px;font-family:verdana;font-size:12px;color:#ffffff;text-align:center;">more info...</div>';
            a += '  <div style="display:none">' + this.custom_spon_tracking_pixel(id) + '</div>'
            a += '</div>'
	    }else{
    	    a += '<div id="itk_custom_spon_bar">'
            a += '	<div class="itk_custom_top">'
            a += '		<div class="itk_custom_wrapper">'
            a += '			<h1>KMart</h2>'
            a += '			<h3>We gave blogger ' + this.custom_spon_intro(id) + ' $500 to spend at KMart&hellip;</h3>'
            a += '			<p>'
            a += '				<img src="'+img_custom+'photo_sml.png" alt="Blogger Photo" class="itk_custom_photo" />'
            a += '				<img src="'+img+'bulb_sml.png" alt="KMart Bulb" class="itk_custom_logo" />'
            a += '				<span id="itk_spon_toggle_span"><img src="'+img+'btn_click_to_expand.png" alt="Click to Expand" id="itk_spon_toggle" onclick="itk_sponsorships.expand_custom('+small_height+', '+large_height+')" /></span>'
            a += '			</p>'
            a += '		</div>'
            a += '	</div>'
            a += '	<div class="itk_custom_body">'
            a += '		<div class="itk_custom_wrapper">'
            a += '			<h2>See what ' + this.custom_spon_gender(id) + ' bought and you might grab $500 too!*</h2>'
            a += '			<ul>'
            a += '				' + this.custom_spon_link(id)
            a += '				<li><a href="' + this.custom_spon_kmart_link(id) + '" target="_blank" id="itk_custom_spon_visit_advertiser">Visit KMart.com</a></li>'
            a += '			</ul>'
            a += '			<p id="itk_custom_photo_content">'
            a += '				<img src="'+img_custom+'photo_lrg.png" class="itk_custom_photo" alt="Blogger Photo" />'
            a += '				<img src="'+img+'bulb_lrg.png" alt="KMart Bulb" class="itk_custom_logo" />'
            a += '			</p>'
            a += '			<p id="itk_custom_powered_by">Powered by SocialSpark. <a href="http://blog.izea.com/holiday-hoopla-contest-official-rules.html?utm_source=Kmart&utm_medium=Blog%2BSponsorship&utm_campaign=Blogges%2BPromotion" target="_blank">*Click here for Official Rules.</a></p>'
            a += '		</div>'
            a += '	</div>'
            a += '  <div id="itk_spon_bar_more_info" style="background-color:#000000;width:100%;margin-top:-11px;padding-top:6px;height:30px;font-family:verdana;font-size:12px;color:#ffffff;text-align:center;">more info...</div>';
            a += '  <div style="display:none">' + this.custom_spon_tracking_pixel(id) + '</div>'
            a += '</div>'
        }
    	return a
	},
	
	custom_spon_gender: function(i){
	    if(i == 3 || i == 5 || i == 6 || i == 7 || i == 9 || i == 13) return "she"
	    if(i == 1 || i == 2 || i == 4 || i == 8 || i == 10 || i == 11 || i == 12 || i == 14) return "he"
	},
	
	custom_spon_intro: function(i){
	    // kmart
	    if(i == 1) a = 'Chris Brogan'
	    if(i == 2) a = 'Jeremy Schoemaker'
	    if(i == 3) a = 'Julia Roy'
	    if(i == 4) a = 'Loren Feldman'
	    if(i == 5) a = 'Michelle Madhok'
	    if(i == 6) a = 'Wendy Piersall'
	    if(i == 7) a = 'Chris Brogan'
	    // sears
	    if(i == 8) a = 'Steve Spalding'
	    if(i == 9) a = 'Liz Strauss'
	    if(i == 10) a = 'Joseph Jaffe'
	    if(i == 11) a = 'Chris Pirillo'
	    if(i == 12) a = 'Jim Kukral'
	    if(i == 13) a = 'Tamar Weinburg'
	    if(i == 14) a = 'Aaron Brazell'
	    return a
	},
	
	custom_spon_tracking_pixel: function(i){
	    if(i == 1) a = '<a href="http://ad.doubleclick.net/jump/N2465.SocialSpark/B3154018.28;sz=1x1"><img src="http://ad.doubleclick.net/ad/N2465.SocialSpark/B3154018.28;sz=1x1" border="0" width="1" height="1" alt="Click Here">'
	    if(i == 2) a = '<a href="http://ad.doubleclick.net/jump/N2465.SocialSpark/B3154018.31;sz=1x1"><img src="http://ad.doubleclick.net/ad/N2465.SocialSpark/B3154018.31;sz=1x1" border="0" width="1" height="1" alt="Click Here"></a>'
	    if(i == 3) a = '<a href="http://ad.doubleclick.net/jump/N2465.SocialSpark/B3154018.30;sz=1x1"><img src="http://ad.doubleclick.net/ad/N2465.SocialSpark/B3154018.30;sz=1x1" border="0" width="1" height="1" alt="Click Here"></a>'
	    if(i == 4) a = '<a href="http://ad.doubleclick.net/jump/N2465.SocialSpark/B3154018.29;sz=1x1"><img src="http://ad.doubleclick.net/ad/N2465.SocialSpark/B3154018.29;sz=1x1" border="0" width="1" height="1" alt="Click Here"></a>'
	    if(i == 5) a = '<a href="http://ad.doubleclick.net/jump/N2465.SocialSpark/B3154018.33;sz=1x1"><img src="http://ad.doubleclick.net/ad/N2465.SocialSpark/B3154018.33;sz=1x1" border="0" width="1" height="1" alt="Click Here"></a'
	    if(i == 6) a = '<a href="http://ad.doubleclick.net/jump/N2465.SocialSpark/B3154018.32;sz=1x1"><img src="http://ad.doubleclick.net/ad/N2465.SocialSpark/B3154018.32;sz=1x1" border="0" width="1" height="1" alt="Click Here"></a>'
	    if(i == 7) a = '<a href="http://ad.doubleclick.net/jump/N2465.SocialSpark/B3154018.28;sz=1x1"><img src="http://ad.doubleclick.net/ad/N2465.SocialSpark/B3154018.28;sz=1x1" border="0" width="1" height="1" alt="Click Here"></a>'
	    if(i == 8) a = '<IMG SRC="http://ad.doubleclick.net/imp;v1;f;210216328;0-0;0;32016100;1|1;28928014|28945893|1;;cs=t%3fhttp://ad.doubleclick.net/dot.gif?[timestamp]" width="1" height="1" />'
	    if(i == 9) a = '<IMG SRC="http://ad.doubleclick.net/imp;v1;f;210216328;0-0;0;32016102;1|1;28928014|28945893|1;;cs=z%3fhttp://ad.doubleclick.net/dot.gif?[timestamp]" width="1" height="1" />'
	    if(i == 10) a = '<IMG SRC="http://ad.doubleclick.net/imp;v1;f;210216328;0-0;0;32016106;1|1;28928014|28945893|1;;cs=l%3fhttp://ad.doubleclick.net/dot.gif?[timestamp]" width="1" height />'
	    if(i == 11) a = '<IMG SRC="http://ad.doubleclick.net/imp;v1;f;210216328;0-0;0;32016109;1|1;28928014|28945893|1;;cs=u%3fhttp://ad.doubleclick.net/dot.gif?[timestamp]" width="1" height="1" />'
	    if(i == 12) a = '<IMG SRC="http://ad.doubleclick.net/imp;v1;f;210216328;0-0;0;32016110;1|1;28928014|28945893|1;;cs=v%3fhttp://ad.doubleclick.net/dot.gif?[timestamp]" width="1" height="1" />'
	    if(i == 13) a = '<IMG SRC="http://ad.doubleclick.net/imp;v1;f;210216328;0-0;0;32016112;1|1;28928014|28945893|1;;cs=b%3fhttp://ad.doubleclick.net/dot.gif?[timestamp]" width="1" height="1" />'
	    if(i == 14) a = '<IMG SRC="http://ad.doubleclick.net/imp;v1;f;210216328;0-0;0;32016113;1|1;28928014|28945893|1;;cs=e%3fhttp://ad.doubleclick.net/dot.gif?[timestamp]" width="1" height="1" />'
	    return a
	},
	
	custom_spon_link: function(i){
	    if(i == 1) a = 'dadomatic'
	    if(i == 2) a = 'shoemoney'
	    if(i == 3) a = 'juliaroy'
	    if(i == 4) a = '1938media'
	    if(i == 5) a = 'shefinds'
	    if(i == 6) a = 'sparkplugging'
	    if(i == 7) a = 'dadomatic'
	    if(i == 8) a = "howtosplitanatom"
	    if(i == 9) a = 'successful-blog'
	    if(i == 10) a = 'jaffejuice'
	    if(i == 11) a = 'chris.pirillo'
	    if(i == 12) a = 'jimkukral'
	    if(i == 13) a = 'techipedia'
	    if(i == 14) a = 'technosailor'
	    return '<li><a href="' + this.custom_spon_tracking_link() + '" target="_blank" id="itk_custom_spon_visit_blog">Visit ' + a + '.com</a></li>'
	},

	custom_spon_kmart_link: function(i){
	    link = itk_spon_data_link.split("url=")
	    link = link[0] + "url=" + escape("http://ad.doubleclick.net/clk;209930921;31067753;g")
	    link += "&view_type=maximized"
	    return link
	},
	
	custom_spon_sears_link: function(i){
	    link = itk_spon_data_link.split("url=")
	    link = link[0] + "url=" + escape("http://ad.doubleclick.net/clk;208896739;30931331;o")
	    link += "&view_type=maximized"
	    return link
	},
	
	custom_spon_tracking_link: function(){
	    sepratator = (itk_spon_data_link.split('?').length == 1) ? "?" : "&"
    	return itk_spon_data_link + sepratator + "view_type=maximized"
	},
	
	which_custom: function(){
	    return (itk_spon_custom_id < 8) ? "kmart" : "sears"
	}

}

var itk_sponsorships_loaded = {}

window.addEventListener ? window.addEventListener("load", itk_sponsorships.bring_to_front, false) : window.attachEvent('onload', itk_sponsorships.bring_to_front)

