function GetObj(objID)
{
	if(document.getElementById)
	{
		return eval('document.getElementById("' + objID + '")');
	}
	else
	{
		if(document.layers)
		{
			return eval("document.layers['" + objID + "']");
		}
		else
		{
			return eval('document.all.' + objID);
		}
	}
}

//添加到收藏夹
function AddFavorite(pUrl,pName)
{
	if(!pUrl) pUrl = 'http://www.qihoo.com';
	if(!pName) pName = '奇虎网';
		
	if(window.sidebar && "object" == typeof(window.sidebar) && "function" == typeof(window.sidebar.addPanel))
	{
		window.sidebar.addPanel(pName,pUrl,'');
	}
	else
	{
		if(document.all && "object" == typeof(window.external))
		{
			window.external.addFavorite(pName,pUrl);
		}
		else
		{
				return false;
		}
	}
	return true;
}

//设置成主页
function SetHomePage(sid,sUrl)
{
	if(!sUrl) sUrl = "http://www.qihoo.com/";
	if(!sid) return false;
	
	if("function" == typeof(sid.setHomePage))
	{
		sid.style.behavior='url(#default#homepage)';
		sid.setHomePage(sUrl);
	}
	else
	{
		return false;
	}
	return true;
}

//走马灯效果
function CreateZMD(strA,targ,strP)
{
	var strD = '<marquee' + strP + ' onmouseover="this.stop();" onmouseout="this.start();">';
	
	//传入的各项以“|”分隔
	var arrURL = new Array();
	if(targ == "")
	{
		targ = "<<<";
	}
	arrURL = strA.split("|");
	var lenght = arrURL.lenght;
	var strB = "";
	for(var i=0; i<lenght;i++)
	{
		strB += targ + "&nbsq;" + arrURL[i] + "&nbsq;";
	}
	
	var strC = strD + strB + "</marquee>";
	return strC;
}

//提取Url参数部分,返回数组
function RequestQueryString(strName)
{
	if(!strName) strName = '';
	
	var strHerf = window.location.href;
	var intPos = strHerf.indexOf('?');
	var strParm = strHerf.substr(intPos+1);
	
	var arrTmp = strParm.split('&');
	var lenght = arrTmp.length;
	var Res = new Array();
	for(var i=0;i<lenght;i++)
	{
		var arrTmp1 = arrTmp[i].split('=');
		Res[i] = new Array();
		Res[i]['key'] = arrTmp1[0];
		Res[i]['value'] = arrTmp1[1];//key->value
		if(strName != '')
		{
			if(Res[i]['key'].toUpperCase() == strName.toUpperCase())
			{
				return Res[i]['value'];
			}
			else
			{
				if(i == lenght-1)
				{
					return false;
				}
			}
		}
	}
	return Res;
}

//设置页面焦点，并描颜色
function SetFocus(eid,idHead,idColor,ifTop)
{
	if(idHead == "" || typeof(idHead) != 'string' || !idHead)
	{
		idHead = 'utitle_';
	}
	if(idColor == "" || typeof(idColor) != 'string' || !idColor)
	{
		idColor = 'red';
	}
	if(!ifTop || ifTop == "")
	{
		ifTop == 0;
	}
	eid = idHead + eid;
	
	var isscroll = true;
	
	if(ifTop == 1)
	{
		isscroll = false;
	}
	
	var obee = GetObj(eid);
	if(obee)
	{
		obee.style.color = idColor;
		if(isscroll)
		{
			obee.focus();
		}
	}
}

//返回GMT格式的时间
function getGMTDate(days,hours,minutes)
{
	var expDate = new Date();
	
	if(typeof(days) == "number" && typeof(hours) == "number" && typeof(minutes) == "number")
	{
		expDate.setDate(expDate.getDate() + parseInt(days));
		expDate.setHours(expDate.getHours() + parseInt(hours));
		expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
		
		return expDate.toGMTString(); 
	}
	else
	{
		return false;
	}
}

//提供随机数
function makeRandom(intMin,intMax)
{
	if(!intMin)return false;
	if(!intMax)
	{
		intMax = intMin;
		intMin = 0;
	}
	var s = 0;
	var intR = intMax - intMin;
	s = Math.floor(Math.random()*intR);
	s = s + intMin;
	return s;
}

function OpCheck(str,way)
{
	//验证：电子邮件，电话号码，手机号码，邮政编码,身份证号
	var strCert = "";
	switch(way)
	{
		case "email":
			strCert = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-z]{2,4}$/;
			break;
		case "telephone":
			strCert = /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9]/;
			break;
		case "moblie":
			strCert = /^[1][3|5][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/;
			break;
		case "postcode":
			strCert = /^[0-9][0-9][0-9][0-9][0-9][0-9]/;
			break;
		case "idcode":
			strCert = /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9x]/;
			break;
	}
	return strCert.test(str);
}

function tabscroll(name,n,m)
{
	for(i=1;i<=m;i++){
		document.getElementById(String(name) + String(i)).style.display="none";
		document.getElementById(String(name)+"_tab"+String(i)).bgColor="#F6F0E9";
	}
	document.getElementById(String(name) + String(n)).style.display="block";
	document.getElementById(String(name)+"_tab"+String(n)).bgColor="#FFFFFF";
}

function input_face(str, id_name)
{
	oCtrl = document.getElementById(id_name);
	if (oCtrl.createTextRange) {
		oCtrl.focus();
		document.selection.createRange().duplicate().text = str;
	} else {
		oCtrl.value += str;
	}
}

function face_mi(oImage)
{
	oImage.width -= 2;
	oImage.style.border = "1px solid #FFB3FF";
	oImage.style.backgroundColor = "#FFEEFF";
}

function face_mo(oImage)
{
	oImage.width += 2;
	oImage.style.border = "";
	oImage.style.backgroundColor = "";
}

function ShowHideFace(oLink)
{
	oFace = document.getElementById('face');
	if (oFace.style.display == 'block')
	{
		oFace.style.display = "none";
		oLink.innerHTML = "[点击此处显示表情]";
	} else {
		oFace.style.display = "block";
		oLink.innerHTML = "[隐藏表情]";
	}
}
function showLocSelect()
{
	var locdiv=GetObj("locListDiv");
	if(locdiv.style.display=="block"){
		locdiv.style.display="none";
		return;
	}
	locdiv.style.display="block";
	var locs=locdiv.getElementsByTagName("li");
	for(var i=0;i<locs.length;i++)
	{
		var theloc=locs[i];
			theloc.onmouseover=function(){
				this.style.backgroundColor="#A0AAC8"
			}
			theloc.onmouseout=function(){
				this.style.backgroundColor="#F2F6FB"
			}
			theloc.onmousedown=function(){
				var locstr=this.innerHTML;
				if (locstr.indexOf(" ")!=-1) locstr=locstr.substr(0,locstr.indexOf(" ")); //fixbug 在IE下多出一个空格
//if(locstr=="湖南") alert(locstr);
				setLocNews(locstr);
				hideLocSelect();
				var l=GetObj("locbar");
				if (!PageUI.isIe) locstr= locstr+ '&utf8=1';
				getHTML(locstr);
			}
	}
}
var _shoucang_windows_size = 'width=580,height=560,status=no,scrollbars=yes,resizable=yes,top=100,left=235';

function shoucang(book,type,title,pic,linkurl,songurl,filmurl,bturl,flashurl) {
    window.open("/my/quick_add.php?nowbook=" + book + "&type=" + type + "&title=" + title + "&pic=" + pic + "&linkurl=" + linkurl + "&songurl=" + songurl + "&filmurl=" + filmurl + "&bturl=" + bturl + "&flashurl=" + flashurl,'new',_shoucang_windows_size);  
}
function _shoucang(book,type,title,pic,linkurl,idname,IDValue) {
    window.open("/my/quick_add.php?nowbook=" + book + "&type=" + type + "&title=" + title + "&pic=" + pic + "&linkurl=" + linkurl + "&idname=" + idname + "&IDValue=" + IDValue,'new',_shoucang_windows_size);  
}
