function newtime(postunixtimestamp)
{
	//var jstimestamp = myDate((postunixtimestamp*1000));
	var now = new Date();
	var jsnowtimestamp = now.getTime();
	
	newtimeserver(postunixtimestamp,Math.floor(jsnowtimestamp/1000));
	
//	var vtime=	jsnowtimestamp-postunixtimestamp*1000;
//	
//	if( vtime>0 && vtime<30*24*3600*1000 )
//	{
//		var tonowtime = tonow(vtime);
//		document.writeln(tonowtime); 
//	}
//	else if( vtime<0 )
//	{
//		document.writeln("0分钟前"); 
//	}
//	else
//	{
//		var jstimestamp = myDate((postunixtimestamp*1000));
//		document.writeln(jstimestamp); 
//	}
}
function newtime(postunixtimestamp,servertime)
{
	newtimeserver(postunixtimestamp,servertime);
}
function newtimeserver(postunixtimestamp,servertime)
{
	var jsnowtimestamp = servertime;
	var vtime=	jsnowtimestamp-postunixtimestamp;
	if( vtime>0 && vtime<30*24*3600 )
	{
		var tonowtime = tonow(vtime*1000);
		document.writeln(tonowtime); 
	}
	else if( vtime<0 )
	{
		document.writeln("0分钟前"); 
	}
	else
	{
		var jstimestamp = myDate((postunixtimestamp*1000));
		document.writeln(jstimestamp); 
	}
}


function tonow(vtime)
{
	var days=Math.floor( vtime/(24*3600*1000) )
	var hours=Math.floor( ( vtime-days*24*3600*1000) /(3600*1000) )
	var minutes=Math.floor( ( vtime-days*24*3600*1000-hours*3600*1000 ) /(60*1000) )
	return (days?days+"天":"")+(hours?hours+"小时":"")+minutes+"分钟前";
}

function myDate(timestamp) {
	d = new Date(timestamp);
	//var jstimestamp = (d.getFullYear())+"-"+(d.getMonth()+1)+"-"+(d.getDate())+" "+(d.getHours())+":"+(d.getMinutes())+":"+(d.getSeconds());
	var jstimestamp = (d.getFullYear())+"-"+(d.getMonth()+1)+"-"+(d.getDate());
	return jstimestamp;
}

	//评星星
	
		function star_fchange(objname,fsetid,starnum){
			eval('$(\''+objname+'_star_vname\').innerHTML=fsetid');
			star_rchange(objname,-fsetid,starnum);}
		function star_dchange(objname,fsetid,starnum){
			eval('$(\''+objname+'_star_vname_nownum\').value=fsetid');
			eval('$(\''+objname+'_star_vname\').innerHTML=$(\''+objname+'_star_vname_nownum\').value');
			star_rchange(objname,fsetid,starnum);}
		function star_rchange(objname,fsetid,starnum){
			if(fsetid==-1001){
				eval('fsetid=Number($(\''+objname+'_star_vname_nownum\').value)');
			}
			scolor='#F98C02';
			if(fsetid<0){fsetid=-fsetid;scolor='#ff4400';}
			eval('$(\''+objname+'_star_vname\').innerHTML=fsetid');
			for(jjj=1;jjj<=starnum;jjj++){if(jjj>fsetid)
				{eval('$(\''+objname+'_star_num_'+jjj+'\').style.color="#cccccc"');}
			else{eval('$(\''+objname+'_star_num_'+jjj+'\').style.color="'+scolor+'"');}}
			if(starnum==5)
			{
				switch (fsetid)
				{
					case 1:
						eval('$(\''+objname+'_desp\').innerHTML="很差"');
						break;
					case 2:
						eval('$(\''+objname+'_desp\').innerHTML="较差"');
						break;
					case 3:
						eval('$(\''+objname+'_desp\').innerHTML="一般"');
						break;
					case 4:
						eval('$(\''+objname+'_desp\').innerHTML="较好"');
						break;
					case 5:
						eval('$(\''+objname+'_desp\').innerHTML="极好"');
						break;
					default:
						eval('$(\''+objname+'_desp\').innerHTML="--"');
						break;
				}
			}
		}
		
//更改 img obj 对象宽度
function picmaxwidth(obj,width,onclickthis)
{
	if (!obj) return ;
	if (!width) {
        width = obj.clientWidth * 0.9;
    }
    var s_height = obj.height;
    var s_width = obj.width;
    if( obj.width > width )
    {
    	obj.style.width = width + "px";
    	if(onclickthis)
    	{
    		obj.style.height = width/s_width*s_height + "px";
	    	obj.onclick = function() {window.open(this.src)};
	    	obj.style.cursor = "pointer";
	    	obj.alt = "点击查看原始尺寸";
    	}
    }
}


function selectautoselect(selectid,value)
{
	var selectobject=$(selectid);
	for(var i=0;i<selectobject.options.length;i++)
	if(selectobject.options[i].value==value)
		selectobject.options[i].selected=true;	
}




//ie 6 PNG
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (version < 7) && (document.body.filters))
    {
       for(var j=0; j<document.images.length; j++)
       {
          var img = document.images[j]
          var imgName = img.src.toUpperCase()
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
          {
             var imgID = (img.id) ? "id='" + img.id + "' " : ""
             var imgClass = (img.className) ? "class='" + img.className + "' " : ""
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
             var imgStyle = "display:inline-block;" + img.style.cssText
             if (img.align == "left") imgStyle = "float:left;" + imgStyle
             if (img.align == "right") imgStyle = "float:right;" + imgStyle
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
             var strNewHTML = "<span " + imgID + imgClass + imgTitle
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
             img.outerHTML = strNewHTML
             j = j-1
          }
       }
    }    
}

function definesitereport( ctype,id)
{
	lightboxcommand='Site Report';
	ScreenConvert();
	DialogShowCenter(200,100);
	
	if( ctype=="bewwwnote" || ctype=="ghreply" )
	{		
	     var url = "/operate/report/type/"+ctype+"/id/"+id+"/?"+(new Date()).getTime();;   
	     var myajax = new Ajax.Updater(   
	         {success: 'Space-DialogCover-Content'},    
	         url,   
	         {   
	             asynchronous:true,   
	             method: 'get',   
	             evalscripts:true,
	             onSuccess :reportend()
	         }
	     );
	}
	else
	{
		$('Space-DialogCover-Content').innerHTML = "未设置相应处理流程<br/>请使用其它方式联系我们!";
	}
	
}

function modmembermailsend(rid,type)
{
	tourl='/operate/replymailset/tabletype/ghmember/type/mailsend/id/'+rid+'/set/'+type+'/'+((new Date()).getTime());
	var myAjax = new Ajax.Request(
		tourl,
		{
			method: 'get',
			onComplete: operatesetback
		}
	);
		
}
function operatesetback(originalRequest)
{	//共用正常返回
	checkword = originalRequest.responseText;
	if(checkword=='1')
	{
		sitealertshort('<br/>已更新设置!');
	}			
}

function reportend()
{
	DialogShowResize(300,270);
}
function sitealertshort(innerhtml)
{
	sitealert(innerhtml,2500,200,100);
}
function sitealert(innerhtml,autodistime,width,height)
{
	lightboxcommand='Site Alert';
	ScreenConvert();
	DialogShowCenter(width,height);
	$('Space-DialogCover-Content').innerHTML = innerhtml;

	if (autodistime > 0) {
		setTimeout("DialogCloseCenter()",autodistime);
	}
}
