var imgtime;
function checkupimg(){
	if(document.all.UserImg.value==""||imgtime==document.all.UserImg.value){
		setTimeout(checkupimg,300);
	}else{
		//alert("接收到url");
		document.all.face.options[0].text = "上传图像";
		document.all.face.options[0].value = document.all.UserImg.value;
		//alert("更新完毕");
		document.all.face.selectedIndex = 0;
		document.images['faceView'].src = document.all.UserImg.value;
		//alert("图像更新完毕");
	}
}
function OpenWin(imgdesc){ //Open window
document.all.UserImg.value="";
var url = "http://img1.soufun.com/upload/usercenter?" + imgdesc;
newwindow = window.open(url,"nw1","height=135,width=300,resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no");
if(!newwindow.opener)newwindow.opener=self;
}
function showjieshao(divname){
				if(divname == 'jieshao1'){
					document.getElementById('jieshao1').style.display = 'block';
					document.getElementById('jieshao2').style.display = 'none';
				}
				else if(divname == 'jieshao2'){
					document.getElementById('jieshao1').style.display = 'none';
					document.getElementById('jieshao2').style.display = 'block';
				}
			}
function MM_openBrWindow(theURL,winName,features,w_height,w_width) { //v2.0
	var t = 0, l = 0;
	t = screen.height; l = screen.width;
	
	t = t - w_height; l = l - w_width;
	t = t/2; l = l /2
	//window.open(theURL,winName,features);
	features =features+"top= " + t + "px,height=" + w_height + "px,left=" + l + "px,width=" + w_width + "px" ;
	window.open(theURL,winName,features);
}

function ParentOfRefresh()
{
	if(null!=window.parent)
	{
		window.parent.location.assign(window.parent.location);	
	}
	else
	{}
}

function OpenOfRefresh()
{
	if(null!=window.opener)
	{
		try{				
			window.opener.location.href=window.opener.location.href;	
		}
		catch(e){
			return;
		}
	}
	else{
	window.location = window.location.href;
	}
}

function CloseWindow() 
{
	var ua = navigator.userAgent;
	var IEversion = parseFloat(ua.substring(ua.indexOf("MSIE ")+5, ua.indexOf(";",ua.indexOf("MSIE "))));
	if(IEversion< 5.5) {
		var str = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">';
		str += '<param name="Command" value="Close"></object>';
		document.body.insertAdjacentHTML("beforeEnd", str);
		document.all.noTipClose.Click();
	}
	else {
		window.opener =null;
		window.close();
	}
}

//change check all status by checked status in DataGrid
function CheckOneGridItem(outckbid, gridid, gridckbid) 
{
	var temp = null;
	
	temp = document.getElementById(gridid);
	if(null == temp)	return;
	var gridlength = temp.rows.length;
	
	var checkedall = false;
	for (var i = 0; i < 4; i ++) {
		temp = document.getElementById(gridid + "_" + "_ctl" + i + "_" + gridckbid);
		if(null == temp)	continue;
		checkedall = true;	break;
	}
	
	for (var i = -3; i < gridlength; i ++) {
		temp = document.getElementById(gridid + "_" + "_ctl" + (i+3) + "_" + gridckbid);
		if(null == temp)	continue;
		if(temp.checked)	continue;
		else {
			checkedall = false;
			break;
		}
	}
	for (var i = 0; i < 4; i ++) 
	{
		var name=gridid + ":" + "_ctl" + i + ":" + outckbid
		temp = document.getElementById(name);
		if(null == temp)
		{
			continue;
		}
		else
		{
			break;
		}
	}
	
	if(null == temp)	return;
	temp.checked = checkedall;
}


//全选或全部不选
function CheckAll_GridItem(outckbid) 
{
	
	var frm=document.Form1;
	for (var i=0;i<frm.elements.length;i++)
	{
		var e=frm.elements[i];
		if ((e.name != outckbid) && (e.type=='checkbox'))
		{
			e.checked=frm[outckbid].checked;
		}
	}
}
function CheckAll_GridItemLower(outckbid) 
{
	
	var frm=document.form1;
	for (var i=0;i<frm.elements.length;i++)
	{
		var e=frm.elements[i];
		if ((e.name != outckbid) && (e.type=='checkbox'))
		{
			e.checked=frm[outckbid].checked;
		}
	}
}
function hL(E)
{
	while (E.tagName!="TR")
	{E=E.parentElement;}
	E.className="H";
}

function dL(E)
{
	while (E.tagName!="TR")
	{E=E.parentElement;}
	E.className="";
}
//check all or not items in DataGrid
function CheckAllGridItem(outckbid, gridid, gridckbid) 
{
	var temp = null;
	
	temp = document.getElementById(gridid);
	if(null == temp)	return;
	var gridlength = temp.rows.length;
	var star_index
	var canchecked = false;
	for (var i = 0; i < 4; i ++) {
		temp = document.getElementById(gridid + "_" + "_ctl" + i + "_" + gridckbid);
		if(null == temp)
		{
			continue;
		}
		else
		{
			canchecked = true;
			star_index=i;
			break;
		}
	}
	
	for (var i = 0; i < 4; i ++) 
	{
		var name=gridid + ":" + "_ctl" + i + ":" + outckbid
		temp = document.getElementById(name);
		if(null == temp)
		{
			continue;
		}
		else
		{
			break;
		}
	}
			
	if(null == temp)	return;

	if(!canchecked)
	{
		temp.checked = false;
	}
	var checkedall = temp.checked;
	
	for (var i = -3; i < gridlength+star_index; i ++) {
		temp = document.getElementById(gridid + "_" + "_ctl" + (i+3) + "_" + gridckbid);
		if(null == temp)	continue;
		temp.checked = checkedall;
	}
}
function openwindow(url)
{
	window.open(url,"","width=600,height=400,toolbar=no,location=no,directories=no,status=no,resizable=no","")
}
function $(_sId){
	return document.getElementById(_sId);
}
function exist(s){return $(s)!=null;}
function hideList(_sId,_sStr,_iBegin,_iEnd)
{
	for(var i = _iBegin; i <= _iEnd; i++)
	{
		if(exist(_sId + i))
		{		
			$(_sId + i).style.display = _sStr;
		}
	}
}
function hide(_sId)
{
	$(_sId).style.display = $(_sId).style.display == "none" ? "" : "none";
}
function copyToClipBoard(txt) { 
     if(window.clipboardData) { 
             window.clipboardData.clearData(); 
             window.clipboardData.setData("Text", txt); 
     } else if(navigator.userAgent.indexOf("Opera") != -1) { 
          window.location = txt; 
     } else if (window.netscape) { 
          try { 
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
          } catch (e) { 
               alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'"); 
          } 
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); 
          if (!clip) 
               return; 
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); 
          if (!trans) 
               return; 
          trans.addDataFlavor('text/unicode'); 
          var str = new Object(); 
          var len = new Object(); 
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 
          var copytext = txt; 
          str.data = copytext; 
          trans.setTransferData("text/unicode",str,copytext.length*2); 
          var clipid = Components.interfaces.nsIClipboard; 
          if (!clip) 
               return false; 
          clip.setData(trans,null,clipid.kGlobalClipboard); 
     } 
  alert("复制成功！") ;
} 
function resizeM(el)
{

 if(el.runtimeStyle)
 {
	el.runtimeStyle.behavior="none";
 }

 var tempM = new Image();
 tempM.src = el.src ;
 tempM.el = el;
 tempM.onload = resizeMonLoad;
 tempM.doload = resizeMonLoad;
 if(el.fileSize && (el.fileSize>0)){; tempM.doload();};
}


function resizeMonLoad()
{
     var el = this.el;
	 var maxW = 400;
	 var maxH = 400;
	 el.style.visibility="visible";

	 if(this.width>=this.height)
	 {
		  if(this.width >= maxW)
		  {; 
			  var r = maxW / this.width;
			  el.style.height = (this.height * r ) + "px";
			  el.style.width = maxW + "px";
		  }
	 }else
	 {
		if(this.height >= maxH)
		{
			var r = maxH / this.height;
			el.style.width = (this.width * r )+ "px";
			el.style.height = maxH + "px";
		}
	 }

	 if(this.width < maxW)
	 {
         el.style.width = this.width + "px";
	 }

	  if(this.height < maxH)
	 {
         el.style.height = this.height + "px";
	 }



}

function replace(szMain,szBeforereplace,szAfterreplace) 
{ 
	strMain=new String(szMain) 
	arrMain=strMain.split(szBeforereplace) 
	var szReturn 
	szReturn=''; 
	for(var i=0;i<arrMain.length-1;i++) 
	{ 
	szReturn=szReturn+arrMain[i]+szAfterreplace; 
	} 
	return szReturn+arrMain[arrMain.length-1]; 
} 
function EnterKeyPress(nextid) { 
	var KeyCode = window.event.keyCode;  
	if(KeyCode == 13)
	{
		//FocusThisControl(nextid);
		document.getElementById(nextid).click();
	}
}
function DisplayView(obj){obj.style.display = obj.style.display?'':'none';}
function openWindow(_sUrl, _sWidth, _sHeight, _sTitle, _sScroll){var oEdit = new dialog();oEdit.init();oEdit.set('title', _sTitle ? _sTitle : "系统提示信息" );oEdit.set('width', _sWidth);oEdit.set('height', _sHeight);oEdit.open(_sUrl, _sScroll ? 'no' : 'yes');}


//移动

function ScrollRight(id)
{
	var element = document.getElementById(id);
	element.style.left = document.body.clientWidth - element.offsetWidth -30;
	window.setTimeout('ScrollRight("' + id + '")',Scroll(id));
}

function Scroll(suspend)
{
	centerMenu = false;	 // < 这个设置是在下面显示还是在上面显示 true 下面 false 上面 >
	menuBorder = 50; // < 这个设置上面显示时距离文档顶部的高度, 最小值为 minimum >
	timeCheck  = 250;	 
	timeUpdate = 15; 
	divUpdate  = 15;	 
	minimum    = 10;	 
	addHeight  = -4;

	menu = document.getElementById(suspend);
	winTop = document.body.scrollTop;
	winHeight = document.body.clientHeight + addHeight;
	menuTop	= menu.offsetTop;
	menuHeight = menu.offsetHeight;
	menuNew	= (centerMenu) ? Math.round (winTop + (winHeight - menuHeight) / 1) : winTop + menuBorder;
	if(menuNew < minimum)
	{
		menuNew = minimum;
	}
	if(menuTop != menuNew)
	{
		if((menuTop + menuHeight) < winTop || menuTop > (winTop + winHeight))
		{
			menu.style.top = (menuTop < menuNew) ? (winTop - menuHeight) : (winTop + winHeight);
		}
		else
		{
			menu.style.top = (menu, menuTop + Math.round((menuNew - menuTop) / divUpdate) + (menuTop < menuNew ? 1 : -1));
		}
     }
	 return (menu.offsetTop == menuNew)? timeCheck:timeUpdate;
}

function post(result){	
	var order="";		
	var ck=new HttpCookie("video");
	var value=new String();
	if(ck.values.hasKeys()){
		var keys=ck.values.allKeys();
		var pn=null;
		var keysLen=keys.length;
		for(var i=0;i<keysLen;i++){
			var curKey=keys[i];
			value=ck.values.get(curKey);
			if(value){
				var varry=value.split(",");
				pn=parent.document.getElementById(curKey);				
				var sn=null;
				if(pn){
					for(var j=0;j<varry.length;j++){					
					sn=parent.document.getElementById(varry[j]);
						if(sn){
							if(varry[j]=="mycalendar")
							{
								order=order+"DVMain_3_11,";
							}
							else
							{
								order=order+varry[j]+",";
							}									
						}
					}
				}
			}
		}
	}				 
	document.getElementById('issave').value=result;		
	document.getElementById('order').value=order;		
	if(result==false){	
		var name="video";
		var coo = '';
		expire = "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
		document.cookie = name + "=DVMain_3=" + coo + expire + ";path=/";
		parent.window.location.href=parent.window.location.href;
	}
	else if(order=='')
	{
		parent.window.location.href=parent.window.location.href;
	}
	else
	{		
		
		//document.all("stencilForm").submit();2010/04/26_Update
		document.getElementById('stencilForm').submit();
    }
}
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 '';
}
function GetCookieVal(offset)
{
	//获得Cookie解码后的值
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return document.cookie.substring(offset, endstr);
}	
function raloadusername(txtname){
	var remmeb= GetCookie("rememberName");	
	remmeb=unescape(remmeb); 	
	if(remmeb!=""){
		document.getElementById(txtname).value=remmeb;		
	}
}
//=====================2010/05/19_Add=================

function checklogin(strusername,strpassword)
{ 
 
	if ((document.getElementById(strusername).value == "") || IsTrue(document.getElementById(strusername)))
	{ 
		alert("请填写您的用户名！");
		document.getElementById(strusername).focus();
		return false; }
		else { document.forms['login'].username.value = document.getElementById(strusername).value; }
	if ((document.getElementById(strpassword).value == "") || IsTrue(document.getElementById(strpassword)))
	{ 
		alert("请填写您的登陆密码！");
		document.getElementById(strpassword).focus();
		return false; }
		else { document.forms['login'].password.value = document.getElementById(strpassword).value; }							
	document.forms['login'].submit();
}					
function IsTrue(obj)
{
	if((obj.value.indexOf ('%') != -1)||(obj.value.indexOf ('^') != -1)||(obj.value.indexOf ("'") != -1)||(obj.value.indexOf ("<") != -1)||(obj.value.indexOf (">") != -1)||(obj.value.indexOf ("=") != -1)||(obj.value.indexOf (",") != -1)||(obj.value.indexOf ("\"") != -1))
	{return true;}
	else
	{return false;}
}	
//=====================Jenny 20100621添加=================
function Go()
                {
                    var keyword = document.getElementById('keyword').value;
                    var url = 'http://search.soufun.com/blog/';
	                if (keyword !="") 
	                {	                    
	                    var searchtype = document.getElementById('searchtype').value
	                    if (searchtype == '博主') {
	                        url = 'http://search.soufun.com/blog/search02.jsp?q=' + escape(document.getElementById('keyword').value) + '&cat=1';
	                    }
	                    else if (searchtype == '博客全文') {
	                        url = 'http://search.soufun.com/blog/search.jsp?q=' + escape(document.getElementById('keyword').value) + '&fld=all';
	                    }
	                    else if (searchtype == '圈子') {
	                        url = 'http://search.soufun.com/blog/search03.jsp?q=' + escape(document.getElementById('keyword').value);
	                    }
	                    else if (searchtype == '群博客') {
	                        url = 'http://search.soufun.com/blog/search02.jsp?q=' + escape(document.getElementById('keyword').value) + '&cat=2';
	                    }
	                }
	                window.open(url); //打开新窗口	                
	            }

function CoLeeSelect(thisObj) {
    var thisinput = thisObj.getElementsByTagName("input");
    var thisul = thisObj.getElementsByTagName("ul");
    var thisli = thisul[0].getElementsByTagName("li");
    if (thisObj.id != "CoLeeSelect") {
        thisObj.id = "CoLeeSelect";
        thisObj.focus();
        thisul[0].style.display = "";
        for (var i = 0; i < thisli.length; i++) {
            thisli[i].onmouseover = function() {
                for (var j = 0; j < thisli.length; j++) {
                    thisli[j].className = "";
                }
                this.className = "on";
            }
            thisli[i].onclick = function() {                
                thisinput[0].value = this.innerHTML.replace(/[ ]/g,"");
            }
        }
    } else {
        ObjBlur();
    }
    thisObj.onblur = ObjBlur;
    function ObjBlur() {
        thisObj.id = "";
        thisul[0].style.display = "none";
        thisObj.blur();
    }
        }	           
function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
function getpromotionlist(divName, typename, colname, styletype) {

    jQuery.ajax({
        url: "/blogweb/getdata/getnewsinfo.aspx",
        data: 'typename=' + escape(typename) + '&colname=' + colname + "&styletype=" + styletype + "&" + Math.random(),
        type: 'GET',
        success: function(result) {
            jQuery("[name='" + divName + "']").html(result);            
        },
        //error
        error: function() {
            //nothing
        }
    });
}
function getsoufuntop() {
    jQuery.ajax({
        url: "/blogweb/getdata/getsoufuntop.aspx",
        data: 'ran=' + Math.random(),
        type: 'GET',
        success: function(result) {
            document.getElementById("soufuntop").innerHTML = result;
            if (jQuery("[name='newstypelist352']").size() > 0) {
                getpromotionlist('newstypelist352', '热门博主', 'newstypelist', '1');
            }
            if (jQuery("[name='promotioninfo4']").size() > 0) {
                getpromotionlist('promotioninfo4', '推广位4', 'promotionlist','2');
            }
        },
        //error
        error: function() {
            //nothing
        }
    });
}
function userquit() {
    document.forms['quit'].submit();
}
