// JavaScript Document

function G(id){ return document.getElementById(id); }
var flag=0;
var Msg_loopNum = 5;
function showMsg(){
if (typeof(redmsg)!= 'undefined') {
if (!redmsg || redmsg.length < 1) { return; }
document.getElementById('mnum').innerHTML = redmsg;
}
else
{
if(Msg_loopNum > 0) {setTimeout(function(){showMsg();},100);Msg_loopNum--;}
}
}
function g(){var ls=location.search;if(ls.indexOf("q=")!=-1){try{var q=(ls.match(new RegExp("q=[^&$]*")).toString());document.f1.word.value=decodeURIComponent(q.substr(2));}catch(e){}}}
function s(o,p){if(document.f1.word.value.length>0){var oh=o.href;var wd=encodeURIComponent(document.f1.word.value);if(oh.indexOf("q=")!=-1){o.href=oh.replace(new RegExp("q=[^&$]*"),"q="+wd);}else{var s=p?"&":"?";o.href=o.href+s+"q="+wd};}}
function cutText(jsonText,ffOnly) {
if (ffOnly) { 
if (typeof(document.getElementsByTagName('body')[0].style.textOverflow)!='undefined' && typeof(window.opera)!='undefined') { return; }
}
for (var name in jsonText) {
var length=jsonText[name];
var elems=document.getElementsByName(name);
for (var i=elems.length-1; i>=0; i--) {
if (elems[i].scrollWidth>length) { elems[i].innerHTML+="..."; }
while (elems[i].scrollWidth>length) {
elems[i].innerHTML=elems[i].innerHTML.substr(0,elems[i].innerHTML.length-4)+"...";
}
}
}
}
function formatPic(jsonPic){ 
for (var name in jsonPic) {
var maxWidth=jsonPic[name].width;
var maxHeight=jsonPic[name].height;
var valign=jsonPic[name].valign;
var image=document.getElementsByName(name);
for(var i=0;i<image.length;i++)
{
if(image[i].width>0 && image[i].height>0){ 
var rate = (maxWidth/image[i].width < maxHeight/image[i].height)?maxWidth/image[i].width:maxHeight/image[i].height;
if(rate <= 1){      
image[i].width = image[i].width*rate;
if (valign==1) { image[i].style.marginTop = (maxHeight-image[i].height)/2 + "px"; }
}
} 
}
}
}
var sid=((new Date()).getTime()+"_"+Math.round(Math.random()*2147483637));
function sendPfScrollStat() { if(document.images){(new Image()).src='/js/blank.js?func=pfscroll&sid='+sid+'&t='+(new Date()).getTime();} }
