var timerId = 0; timerId = setInterval(function () { photo_ad_hns(); }, 100); function photo_ad_hns(type){ var element_start = "#header"; var element_div = "#articlebody"; //var element_div = "#article"; var element = "#article_content"; var element_img = "#article_content img"; min_ad_wid = "233"; ad_close_width = "20"; margin_ad_hei = "70"; big_ad_wid = "468"; big_ad_hei = "60"; tiny_ad_wid = "234"; tiny_ad_hei = "60"; big_ad_url = "http://ad.ad4989.co.kr/cgi-bin/PelicanC.dll?impr?pageid=00PT&out=iframe"; tiny_ad_url = "http://ad.ad4989.co.kr/cgi-bin/PelicanC.dll?impr?pageid=00PS&out=iframe"; jQuery(element_start).each(function(index) { start_offset = jQuery(this).offset(); start_offset_top = start_offset.top; start_offset_left = start_offset.left; }); jQuery(element_div).each(function(index) { div_wid = jQuery(this).width(); div_hei = jQuery(this).height(); div_offset = jQuery(this).offset(); div_offset_top = div_offset.top; div_offset_left = div_offset.left; }); jQuery(element).each(function(index) { wid = jQuery(this).width(); hei = jQuery(this).height(); offset = jQuery(this).offset(); offset_top = offset.top; offset_left = offset.left; }); clearInterval(timerId); jQuery(element_img).each(function(index) { if(index == 0) { photo_wid = jQuery(this).width(); photo_hei = jQuery(this).height(); photo_offset = jQuery(this).offset(); photo_offset_top = photo_offset.top; photo_offset_left = photo_offset.left; if(photo_wid > big_ad_wid) { ad_wid = big_ad_wid; ad_hei = big_ad_hei; ad_url = big_ad_url; } else { ad_wid = tiny_ad_wid; ad_hei = tiny_ad_hei; ad_url = tiny_ad_url; } if(div_offset_top > 500){ ad_pos_diff = 230; } else if(div_offset_top < 500 && div_offset_top >= 400){ ad_pos_diff = 190; } else if(div_offset_top < 400 && div_offset_top >= 300){ ad_pos_diff = 60; } else if(div_offset_top < 300 ){ ad_pos_diff = 20; } position_top = (start_offset_top + div_offset_top ) + photo_hei - ad_hei - 10 - ad_pos_diff; position_left = (photo_offset_left - start_offset_left)+ photo_wid - ad_wid - (photo_wid-ad_wid)/2; close_top = position_top; close_left = position_left + parseInt(ad_wid) - 10; if(photo_wid > min_ad_wid){ jQuery("
").appendTo(element); jQuery("