var title="";
var symbol="";
var ct=0;
var style="";
var isOpen=true;
var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));



function fSearchWeb(){
document.find.action="/hunt/webhunt.php";
document.find.submit();
}
function fFindSymbol(){
document.find.action="/stock/c.php";
document.find.submit();
}

function qs(el) {
	if (window.RegExp && window.encodeURIComponent) {
		var qe=encodeURIComponent(document.find.q.value);
		if (el.href.indexOf("q=")!=-1) {el.href=el.href.replace(new RegExp("q=[^&$]*"),"q="+qe);} 
		else {el.href+="&q="+qe;}}return 1;
	}

function ad_span(adName,spanName){
var ad=document.getElementById(adName);
if(ad){
ad.innerHTML=document.getElementById(spanName).innerHTML;
document.getElementById(spanName).innerHTML="";
}
}


function setPointer(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
} // end of the 'setPointer()' function


function setCheckboxes(the_form, do_check)
{
    var elts      = document.forms[the_form].elements['selected_tbl[]'];
    var elts_cnt  = elts.length;

    for (var i = 0; i < elts_cnt; i++) {
        elts[i].checked = do_check;
    } // end for

    return true;
} // end of the 'setCheckboxes()' function

function setSelectOptions(the_form, the_select, do_check)
{
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    } // end for

    return true;
} // end of the 'setSelectOptions()' function


function WriteDate()
{
var day="";
var month="";
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
mydate=new Date();
myweekday=mydate.getDay();
mymonth=mydate.getMonth()+1;
myday= mydate.getDate();
myyear= mydate.getYear();
year=(myyear > 200) ? myyear : 1900 + myyear;
if(myweekday == 0)
weekday=" 星期日 ";
else if(myweekday == 1)
weekday=" 星期一 ";
else if(myweekday == 2)
weekday=" 星期二 ";
else if(myweekday == 3)
weekday=" 星期三 ";
else if(myweekday == 4)
weekday=" 星期四 ";
else if(myweekday == 5)
weekday=" 星期五 ";
else if(myweekday == 6)
weekday=" 星期六 ";
document.getElementById('DateText').innerHTML=year+"年"+mymonth+"月"+myday+"日 "+weekday;
startTime();
}

function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
m=checkTime(m)
s=checkTime(s)
document.getElementById('TimeText').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',5000)
}

function checkTime(i)
{
if (i<10) 
  {i="0" + i}
  return i
}




var postminchars = parseInt('10');
var postmaxchars = parseInt('10000');
var disablepostctrl = parseInt('1');
var typerequired = parseInt('');
function checklength(theform) {
if (postmaxchars != 0) { message = "系统限制: "+postminchars+" 到 "+postmaxchars+" 字节"; }
else { message = ""; }
alert("\n当前长度: "+theform.message.value.length+" 字节\n\n"+message);
}

function validate(theform) {
if ( theform.message.value == "") {
alert("请完成内容。");
return false;
}

if (!disablepostctrl && ((postminchars != 0 && theform.message.value.length < postminchars) || (postmaxchars != 0 && theform.message.value.length > postmaxchars))) {
alert("您的帖子长度不符合要求。\n\n当前长度: "+theform.message.value.length+" 字节\n系统限制: "+postminchars+" 到 "+postmaxchars+" 字节");
return false;
}			
theform.topicsubmit.disabled = true;
return true;
}


function submit_bbs(){
if(validate(document.formpost)) {
	if(title=="") title=window.document.title;
document.formpost.fromurl.value=parent.location;
if(symbol.length<1||symbol.length>6){
document.formpost.fid.value="5";

document.formpost.typeid.value=13;
	document.formpost.selecttypeid.value=13;
document.getElementById('typeoptionURL').value=document.formpost.fromurl.value;
}
else{
document.formpost.symbol.value=symbol;
	document.formpost.fid.value="15";
document.formpost.typeid.value=10;
document.formpost.selecttypeid.value=10;
document.getElementById('typeoptionSymbol').value=symbol;
title=title+':'+document.formpost.message.value.substr(0,25)+'...';
}


document.formpost.subject.value=title;
//document.formpost.message.value=sfrom+document.formpost.message.value;




document.formpost.submit();
}
}

function thisopen(){
thisurl="/stock/viewpost.php?code="+symbol+"&url="+parent.location+"&title="+symbol+title;
window.open(thisurl);
}
function sendurl(){
window.open(thisurl);
}
function search_this(){
thisurl="/stock/webhunt.php?q="+title;
window.open(thisurl);
}
 function copyUrl(){
   var clipBoardContent=''; 
   clipBoardContent+=title;
   if(clipBoardContent=='')   clipBoardContent+=window.document.title;
   clipBoardContent+='\r\n'+parent.location;
   window.clipboardData.setData("Text",clipBoardContent);
   
  }




function E(id){return document.getElementById(id);}

function createXMLHttpRequest() {
	
    if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
    
    
}
    
    

function WriteLogin(){
var myname=GetCookie ("club_name");
if(myname==null)	
E("txtLogin").innerHTML ="欢迎您,游客,<a href=\"/home/do.php?ac=han66_login\"><b>请登录</b></a> - <a href=\"/home/cp.php\">个性化</a>";
else E("txtLogin").innerHTML ="欢迎您,<b>"+myname+"</b>  [<a href=\"/home/cp.php\">个性化</a> , <a href=\"/home/cp.php?ac=common&op=logout\">退出</a>]";
}


function HasLogin(){
//var myname=GetCookie ("club_name");
//if(myname==null) location.href='/club/logging.php?action=login&url='+parent.location;
}
function getCookieVal (offset) {  
var endstr = document.cookie.indexOf (";", offset);  
if (endstr == -1)    
endstr = document.cookie.length;  
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}

function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? ";path=/" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}


function AddCookie (name, value) {  
var cookie=GetCookie(name);
var carray=new Array;
if(cookie!=null) carray=cookie.split(',')
	if(carray.indexOf(value)>=0) return;
carray.push(value);
if(carray.length>20) carray.shift();

var exp = new Date(); 
exp.setTime (exp.getTime() +3600000 * 24 * 90); 
SetCookie(name,carray.join(','),exp); 


}

function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


	function getNames(obj,name,tij)
	{	
		var p = document.getElementById(obj);
		var plist = p.getElementsByTagName(tij);
		var rlist = new Array();
		for(i=0;i<plist.length;i++)
		{
			if(plist[i].getAttribute("name") == name)
			{
				rlist[rlist.length] = plist[i];
			}
		}
		return rlist;
	}

		function showTab(obj,name)
		{
			var p = obj.parentNode.getElementsByTagName("td");
			var p1 = getNames(name,"tab","div"); // document.getElementById(name).getElementsByTagName("div");
			for(i=0;i<p1.length;i++)
			{
				if(obj==p[i])
				{
					p[i].className = "taba f12";
					p1[i].className = "show";
				}
				else
				{
					p[i].className = "tabn f12";
					p1[i].className = "hide";
				}
			}
		}
		
function sf(){
	//if (top.location !=self.location) {top.location=self.location};document.f.q.focus();
	}
window.gbar={};(function(){;var h=window.gbar,a,g,f;function m(b,e,d){b.display=b.display=="block"?"none":"block";b.left=e+"px";b.top=d+"px"}h.tg=function(b){var e=0,d,c,i,j=0,k=window.navExtra;!g&&(g=document.getElementById("gbar"));!f&&(f=g.getElementsByTagName("div"));(b||window.event).cancelBubble=true;if(!a){a=document.createElement(Array.every||window.createPopup?"iframe":"div");a.frameBorder="0";a.id="gbi";a.scrolling="no";a.src="#";document.body.appendChild(a);if(k)for(var n in k){var l=document.createElement("div");l.appendChild(k[n]);l.className="gb2";g.appendChild(l)}document.onclick=h.close}for(;f[j];j++){c=f[j];i=c.className;if(i=="gb3"){d=c.offsetLeft;while(c=c.offsetParent)d+=c.offsetLeft;m(a.style,d,24)}else if(i=="gb2"){m(c.style,d+1,25+e);e+=20}}a.style.height=e+"px"};h.close=function(b){a&&a.style.display=="block"&&h.tg(b)};})();// -->

if(!Array.indexOf){
	    Array.prototype.indexOf = function(obj){
	        for(var i=0; i<this.length; i++){
	            if(this[i]==obj){
	                return i;
	            }
	        }
	        return -1;
	    }
	}		