var ad_left = '-1';           // показывает со смещением по горизонтали 0 - слева
var ad_top = '0';            // показывает со смещением по вертикали 0 - сверху начало
var ad_width = '500';         // ширина блока
var ad_height = '-1';         // высота блока
var ad_show_direct = 'top';// left/right/top/bottom
var ad_acenter = true;        // центрировать блок
var ad_advert_num = '3';      // количество объявлений выводит 
var ad_take_advert_num = '6'; // количество объявлений в ротации
var ad_title_fontsize = '19'; // размер заголовка
var ad_desc_fontsize = '14';  // размер описания
var ad_text_align = 'left';   // текст выравнивает
var ad_background = '#000F5E';// цвет фона
var ad_textcolor = '#FFFFFF'; // цвет текста
var ad_delay = '17';           // задержка ротации
var ad_min_width = '366';     // картинка минимум по ширине
var ad_min_height= '300';     // картинка минимум по высоте

var klikAd={width:'400',height:'100',min_width:'400',min_height:'300',top:'0',left:'0',show_direct:'left',ad_acenter:false,advert_num:1,move_step:13,changeInterval:6000,setRotate:false,moveInterval:14,images:new Array(),main_id:'klikAd_main',container_id:'klikAd_container',title_id:'klikAd_title',desc_id:'klikAd_desc',dlr:'_',posNum:0,imgNum:0,background:'#000000',title_font_size:'12',desc_font_size:'12',textcolor:'#ffffff',title_align:'center',desc_align:'center',setCss:function(){var link=document.createElement("link");link.media="screen";link.rel="stylesheet";link.type="text/css";link.href="http://polonim.com/diet/js/klikAd.css";document.getElementsByTagName("head")[0].appendChild(link)},setNextAd:function(){var pos=0;for(var i=1;i<=klikAd.advert_num;i++){klikAd.posNum=(klikAds[klikAd.posNum])?klikAd.posNum:0;pos=klikAd.posNum++;var adTitle=document.createElement("a");adTitle.target="_blank";adTitle.href=klikAds[pos][2];adTitle.style.fontSize=klikAd.title_font_size+"px";adTitle.style.color=klikAd.textcolor;adTitle.innerHTML=klikAds[pos][0];var adDesc=document.createElement("a");adDesc.target="_blank";adDesc.href=klikAds[pos][2];adDesc.style.fontSize=klikAd.desc_font_size+"px";adDesc.style.color=klikAd.textcolor;adDesc.innerHTML=klikAds[pos][1];document.getElementById(klikAd.title_id+klikAd.dlr+i).innerHTML='';document.getElementById(klikAd.title_id+klikAd.dlr+i).appendChild(adTitle);document.getElementById(klikAd.desc_id+klikAd.dlr+i).innerHTML='';document.getElementById(klikAd.desc_id+klikAd.dlr+i).appendChild(adDesc)}},setContainer:function(){var main=document.createElement("div");main.id=klikAd.main_id;main.style.height=klikAd.height+'px';main.style.background=klikAd.background;main.style.width=0;var container=document.createElement("div");container.id=klikAd.container_id;for(var i=1;i<=klikAd.advert_num;i++){var title=document.createElement("div");title.className=klikAd.title_id;title.style.textAlign=klikAd.title_align;title.style.fontSize=klikAd.desc_font_size+"px";title.id=klikAd.title_id+klikAd.dlr+i;var desc=document.createElement("div");desc.className=klikAd.desc_id;desc.style.textAlign=klikAd.desc_align;desc.style.fontSize=klikAd.desc_font_size+"px";desc.id=klikAd.desc_id+klikAd.dlr+i;container.appendChild(title);container.appendChild(desc);if(i!=klikAd.advert_num){var delimiter=document.createElement("hr");delimiter.className='klikAd_hr';container.appendChild(delimiter)}}main.appendChild(container);document.body.appendChild(main)},showAd:function(index){if(typeof index=='undefined')var index=klikAd.imgNum;if(!klikAd.setRotate){window.rotateTimer=window.setInterval(klikAd.setNextAd,klikAd.changeInterval);klikAd.setRotate=true}klikAd.adPosition(index);window.clearInterval(window.closeTimer);window.openTimer=window.setInterval(klikAd.iniAdWidth,klikAd.moveInterval);klikAd.imgNum=index},hideAd:function(){window.clearInterval(window.openTimer);window.closeTimer=window.setInterval(klikAd.decAdWidth,klikAd.moveInterval)},adPosition:function(index){var advert=document.getElementById(klikAd.main_id);if(!advert)return;var image=klikAd.images[index];var imgPos=klikAd.getAbsPosImg(image);var adLeft=klikAd.left;var adTop=klikAd.top;var pos_left=adLeft;var pos_top='0';if(klikAd.ad_acenter&&klikAd.show_direct!='right'&&klikAd.show_direct!='left'){pos_left=(image.width-parseInt(klikAd.width))/2}else{if(adLeft<0){var left=Math.abs(adLeft);pos_left='0';if(klikAd.show_direct=='right')pos_left=image.width-(parseInt(advert.style.width));else pos_left=image.width-parseInt(klikAd.width)-parseInt(left)+1}else{if((parseInt(klikAd.width)+parseInt(adLeft))>image.width){pos_left=image.width-parseInt(klikAd.width)}}}if(klikAd.ad_acenter&&klikAd.show_direct!='top'&&klikAd.show_direct!='bottom'){pos_top=(image.height-parseInt(klikAd.height))/2}else{if(adTop<0){var top=Math.abs(adTop);pos_top='0';if(klikAd.show_direct=='bottom')pos_top=image.height-(parseInt(advert.style.height));else pos_top=image.height-parseInt(klikAd.height)-parseInt(top)+1}else{pos_top=adTop;if((parseInt(klikAd.height)+parseInt(adTop))>image.height){pos_top=image.height-parseInt(klikAd.height)}}}if(klikAd.show_direct=="center"){pos_left=(image.width-parseInt(klikAd.width))/2;pos_top=(image.height-parseInt(klikAd.height))/2}advert.style.left=imgPos.x+parseInt(pos_left)+"px";advert.style.top=imgPos.y+parseInt(pos_top)+"px"},iniAdWidth:function(){var advert=document.getElementById(klikAd.main_id);var localStep=parseInt(klikAd.move_step);if(klikAd.show_direct=="left"||klikAd.show_direct=="right"){if(advert.clientWidth<klikAd.width){var curWidth=parseInt(advert.style.width);var newWidth=curWidth+localStep;if(newWidth>klikAd.width){localStep=localStep-(newWidth-klikAd.width);newWidth=klikAd.width}advert.style.width=newWidth+"px";if(klikAd.show_direct=="right"&&klikAd.left<0){advert.style.left=(parseInt(advert.style.left)-localStep)+"px"}}else{window.clearInterval(window.openTimer);advert.style.display="";advert.style.display="block";document.getElementById(klikAd.container_id).style.display="block"}}else if(klikAd.show_direct=="top"||klikAd.show_direct=="bottom"){if(advert.clientHeight<klikAd.height){var curHeight=parseInt(advert.style.height);var newHeight=curHeight+localStep;if(newHeight>klikAd.height){localStep=localStep-(newHeight-klikAd.height);newHeight=klikAd.height}advert.style.height=newHeight+"px";if(klikAd.show_direct=="bottom"&&klikAd.top<0){advert.style.top=(parseInt(advert.style.top)-localStep)+"px"}}else{window.clearInterval(window.openTimer);advert.style.display="";advert.style.display="block";document.getElementById(klikAd.container_id).style.display="block"}}else if(klikAd.show_direct=="center"){advert.style.width=klikAd.width+"px";document.getElementById(klikAd.container_id).style.display="block"}},decAdWidth:function(){document.getElementById(klikAd.container_id).style.display="none";window.clearInterval(window.ShowTimer);var advert=document.getElementById(klikAd.main_id);if(klikAd.show_direct=="left"||klikAd.show_direct=="right"){if(advert.clientWidth>0){var curWidth=parseInt(advert.style.width);var newWidth=curWidth-klikAd.move_step;newWidth=(newWidth>0)?newWidth:0;advert.style.width=newWidth+"px";if(klikAd.show_direct=="right"&&klikAd.left<0){advert.style.left=(parseInt(advert.style.left)+parseInt(klikAd.move_step))+"px"}}else{window.clearInterval(window.closeTimer)}}else if(klikAd.show_direct=="top"||klikAd.show_direct=="bottom"){if(advert.clientHeight>0){var curHeight=parseInt(advert.style.height);var newHeight=curHeight-klikAd.move_step;newHeight=(newHeight>0)?newHeight:0;advert.style.height=newHeight+"px";if(klikAd.show_direct=="bottom"&&klikAd.top<0){advert.style.top=(parseInt(advert.style.top)+parseInt(klikAd.move_step))+"px"}}else{window.clearInterval(window.closeTimer)}}else if(klikAd.show_direct=="center"){advert.style.width='0px';window.clearInterval(window.closeTimer)}},getAbsPosImg:function(img){var pos={x:0,y:0};pos.x=img.offsetLeft;pos.y=img.offsetTop;if(img.offsetParent){var tmp=klikAd.getAbsPosImg(img.offsetParent);pos.x+=tmp.x;pos.y+=tmp.y}return pos}};function klikAdStart(){if(typeof ad_width!="undefined")klikAd.width=ad_width;if(typeof ad_height!="undefined")klikAd.height=ad_height;if(typeof ad_top!="undefined")klikAd.top=ad_top;if(typeof ad_left!="undefined")klikAd.left=ad_left;if(typeof ad_show_direct!="undefined")klikAd.show_direct=ad_show_direct;if(typeof ad_acenter!="undefined")klikAd.ad_acenter=ad_acenter;if(typeof ad_advert_num!="undefined")klikAd.advert_num=ad_advert_num;if(typeof ad_background!="undefined")klikAd.background=ad_background;if(typeof ad_title_fontsize!="undefined")klikAd.title_font_size=ad_title_fontsize;if(typeof ad_desc_fontsize!="undefined")klikAd.desc_font_size=ad_desc_fontsize;if(typeof ad_textcolor!="undefined")klikAd.textcolor=ad_textcolor;if(typeof ad_min_width!="undefined")klikAd.min_width=ad_min_width;if(typeof ad_min_height!="undefined")klikAd.min_height=ad_min_height;if(typeof ad_delay!="undefined")klikAd.changeInterval=ad_delay*1000;if(typeof ad_text_align!="undefined"){klikAd.title_align=ad_text_align;klikAd.desc_align=ad_text_align}if(klikAd.height==-1){var kline=22;var kpad=20;var chTitleMax=0;var chDescMax=0;for(var i=0;i<klikAds.length;i++){if(chTitleMax<klikAds[i][0].length){chTitleMax=klikAds[i][0].length}if(chDescMax<klikAds[i][1].length){chDescMax=klikAds[i][1].length}}var title_font_size=parseInt(klikAd.title_font_size);var desc_font_size=parseInt(klikAd.desc_font_size);var w100=klikAd.width/100;var kfc=((title_font_size-8)/2.3)+((desc_font_size-8)/1.7);kline-=kfc+(1/w100*3.5);var titleLines=Math.ceil(chTitleMax/((kline-2)*w100));var descLines=Math.ceil(chDescMax/(kline*w100));var height=(titleLines*(title_font_size+3))+(descLines*(desc_font_size+3))+kpad;klikAd.height=parseInt(height*klikAd.advert_num)}klikAd.setCss();klikAd.setContainer();var images=document.getElementsByTagName('img');var count=images.length;var num=0;for(var i=0;i<count;i++){if((images[i].width>=klikAd.min_width)&&(images[i].height>=klikAd.min_height)){images[i].onmouseover=new Function('klikAd.showAd('+num+')');images[i].onmouseout=new Function('klikAd.hideAd()');klikAd.images.push(images[i]);num++}}var advert=document.getElementById(klikAd.main_id);advert.onmouseover=new Function('klikAd.showAd();');advert.onmouseout=new Function('klikAd.hideAd();');klikAd.setNextAd();if((klikAd.show_direct=="top"||klikAd.show_direct=="bottom")){advert.style.width=klikAd.width+"px";advert.style.height=0+"px"}}function metaKeywords(){metaCollection=document.getElementsByTagName('meta');for(i=0;i<metaCollection.length;i++){nameAttribute=metaCollection[i].name.search(/keywords/i);if(nameAttribute!=-1){return metaCollection[i].content}}return''}var adv_take=(typeof ad_take_advert_num=="undefined")?3:ad_take_advert_num;adv_take='&advs_num='+adv_take;var ad_take_meta=(typeof ad_take_meta=="undefined")?false:ad_take_meta;if(!ad_take_meta){var ad_keys=(typeof ad_keywords=="undefined")?'':'&keywords='+encodeURIComponent(ad_keywords)}else{var ad_keys='&keywords='+encodeURIComponent(metaKeywords())}var ad_clickURL=(typeof ad_click_url!="undefined")?'&click_url='+ad_click_url:'';document.write('<scr'+'ipt type="text/javascript" src="http://polonim.com/diet/js/getAds.php"></scr'+'ipt>');
