
function mynews(data){var c="";c+='<div id="paidoo_search">';c+='<strong>'+data.title+'</strong><br />';c+='<input type="text" id="key" onkeypress="chkkey(event)">';c+='<button onclick="paidoo_click()">ค้นหาข่าว</button>';c+='</div>';c+='<div id="paidoo_api_VerticalResult"></div>';c+='<div id="paidoo_credit">ค้นได้ทันที ที่มีข่าว โดย <a href="http://paidoo.net">Paidoo.net</a></div>';c+='</div>';c+='<div id="paidoo_preview_popup"></div>';paidoo_option=data;paidoo_sniffBrowsers();document.getElementById('paidoo_mynews').innerHTML=c;paidoo_setTitleHeight();if(data.width){document.getElementById('paidoo_mynews').style.width=data.width;}paidoo_search(data.search,data.limit,0);}function paidoo_search(s,limit,offset){var url='http://paidoo.net/newsapi.php?s='+s+'&limit='+limit+'&offset='+offset+'&web='+document.domain+'&key='+paidoo_option.key;var js=document.createElement("script");if(paidoo_option.section!='all'){url+='&section='+paidoo_option.section;}if(paidoo_option.source!='all'){url+='&source='+paidoo_option.source;}js.setAttribute("src",url);js.setAttribute("type","text/javascript");document.body.appendChild(js);}function newsCallback(data){document.getElementById("paidoo_api_VerticalResult").innerHTML=data.result;paidoo_newsdata=data.news;paidoo_newsheight=data.height;}function paidoo_click(){var key=document.getElementById("key").value;paidoo_search(key,paidoo_option.limit,0);}function chkkey(e){var keynum;if(window.event){keynum=e.keyCode;}else if(e.which){keynum=e.which;}if(keynum==13){paidoo_click();}}function findPopupY(HeadPosY){var lowest=getY("paidoo_mynews")+getHeight("paidoo_mynews");var popupHeight=getHeight("paidoo_preview_popup");if(HeadPosY+popupHeight>lowest){return lowest-popupHeight;}else{var adjust=(ie?1:0);return HeadPosY+adjust;}}function findPopupX(HeadPosX){if(paidoo_option.popup=='left'){var adjust=(ie?1:0);return HeadPosX-getWidth("paidoo_preview_popup")+adjust;}if(paidoo_option.popup=='right'){var adjust=(ie?1:0);return HeadPosX+getWidth("paidoo_mynews")-2+adjust;}}function paidoo_popup(id){var newsHeader=document.getElementById("paidoo_head"+id);var popup=document.getElementById("paidoo_preview_popup");newsHeader.className="paidoo_head_hover";paidoo_padding=newsHeader.style.paddingLeft;if(paidoo_newsdata[id]!=''&&paidoo_option.popup!='none'){popup.style.display="block";popup.innerHTML=paidoo_newsdata[id];popup.style.height=paidoo_newsheight[id];popup.style.top=findPopupY(getY("paidoo_head"+id));popup.style.left=findPopupX(getX("paidoo_head"+id));}}function paidoo_popdown(id){var newsHeader=document.getElementById("paidoo_head"+id);var popup=document.getElementById("paidoo_preview_popup");newsHeader.className="paidoo_head";popup.style.display="none";}function paidoo_setTitleHeight(){changecss('.paidoo_title','height','15px');changecss('.paidoo_title','overflow','hidden');changecss('.paidoo_title','position','absolute');}function paidoo_sniffBrowsers(){ns4=document.layers;op5=(navigator.userAgent.indexOf("Opera 5")!=-1)||(navigator.userAgent.indexOf("Opera/5")!=-1);op6=(navigator.userAgent.indexOf("Opera 6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1);var agt=navigator.userAgent.toLowerCase();mac=(agt.indexOf("mac")!=-1);ie=(agt.indexOf("msie")!=-1);mac_ie=mac&&ie;}function getX(elemID){var offsetTrail=document.getElementById(elemID);var offsetLeft=0;while(offsetTrail&&offsetTrail.style.position!='absolute'){offsetLeft+=offsetTrail.offsetLeft;offsetTrail=offsetTrail.offsetParent;}if(navigator.userAgent.indexOf('Mac')!=-1&&typeof document.body.leftMargin!='undefined'){offsetLeft+=document.body.leftMargin;}return offsetLeft;}function getY(elemID){var offsetTrail=document.getElementById(elemID);var offsetTop=0;while(offsetTrail&&offsetTrail.style.position!='absolute'){offsetTop+=offsetTrail.offsetTop;offsetTrail=offsetTrail.offsetParent;}if(navigator.userAgent.indexOf('Mac')!=-1&&typeof document.body.leftMargin!='undefined'){offsetTop+=document.body.topMargin;}return offsetTop;}function getHeight(Elem){if(ns4){var elem=getObjNN4(document,Elem);return elem.clip.height;}else{if(document.getElementById){var elem=document.getElementById(Elem);}else if(document.all){var elem=document.all[Elem];}if(op5){xPos=elem.style.pixelHeight;}else{xPos=elem.offsetHeight;}return xPos;}}function getWidth(Elem){if(ns4){var elem=getObjNN4(document,Elem);return elem.clip.width;}else{if(document.getElementById){var elem=document.getElementById(Elem);}else if(document.all){var elem=document.all[Elem];}if(op5){xPos=elem.style.pixelWidth;}else{xPos=elem.offsetWidth;}return xPos;}}function changecss(theClass,element,value){var cssRules;if(document.all){cssRules='rules';}else if(document.getElementById){cssRules='cssRules';}var added=false;for(var S=0;S<document.styleSheets.length;S++){for(var R=0;R<document.styleSheets[S][cssRules].length;R++){if(document.styleSheets[S][cssRules][R].selectorText==theClass){if(document.styleSheets[S][cssRules][R].style[element]){document.styleSheets[S][cssRules][R].style[element]=value;added=true;break;}}}if(!added){if(document.styleSheets[S].insertRule){document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);}else if(document.styleSheets[S].addRule){document.styleSheets[S].addRule(theClass,element+': '+value+';');}}}}
